yuminge-app/yun-min-program-plugin-master/packageF/bonusPoolsIndex/bonusPoolsTeam/bonusPoolsTeam.js

165 lines
4.2 KiB
JavaScript

// packageF/bonusPoolsIndex/bonusPoolsTeam/bonusPoolsTeam.js
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
active: '0',
page: 1,
current_page: 1,
last_page: 1,
isLoadMore: true, //判断是否要加载更多的标志
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let language = wx.getStorageSync("langIndex");
this.setData({
language: language.en,
});
wx.setNavigationBarTitle({
title: '团队业绩值',
})
this.getData();
},
bindChange(e) {
this.setData({
active: e.detail.index
})
this.init();
this.getData();
},
init() {
this.setData({
page: 1,
current_page: 1,
last_page: 1,
isLoadMore: true
})
},
getData() {
let json = {
page: this.data.page,
team_type: this.data.active == 0 ? "1" : "2"
}
let urlStr = app.getNetAddresss("plugin.xzhh-bonus-pool.frontend.controllers.team.index");
app._getNetWork({
url: urlStr,
data: json,
success: (resdata) => {
let res = resdata.data
if (res.result == 1) {
this.setData({
info: res.data.nums,
list: res.data.list.data,
current_page: res.data.list.current_page,
last_page: res.data.list.last_page
})
} else {
wx.showToast({
icon: 'none',
title: res.msg,
duration: 1500
});
}
},
fail: function (res) {
console.log(res);
}
});
},
getMore() {
this.data.isLoadMore = false; // 防止多次请求分页数据
if (this.data.current_page >= this.data.last_page) {
return;
} else {
let json = {
team_type: this.data.active == 0 ? "1" : "2",
page: this.data.page + 1
}
let urlStr = app.getNetAddresss("plugin.xzhh-bonus-pool.frontend.controllers.team.index");
app._getNetWork({
url: urlStr,
data: json,
success: (resdata) => {
this.data.isLoadMore = true;
let res = resdata.data
if (res.result == 1) {
this.setData({
page: this.data.page + 1,
list: this.data.list.concat(res.data.list.data),
current_page: res.data.list.current_page,
last_page: res.data.list.last_page
})
} else {
wx.showToast({
icon: 'none',
title: res.msg,
duration: 1500
});
}
},
fail: function (res) {
this.data.isLoadMore = true;
console.log(res);
}
});
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
if (this.data.isLoadMore) {
this.getMore();
}
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})