yuminge-app/yun-min-program-plugin-master/packageA/member/extension/notPresent/notPresent.js

165 lines
3.4 KiB
JavaScript

// pages/member/notPresent/notPresent.js
var app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
language: '',
datas:[],
// more
page: 1, // 分页数,当前页数
isLoadMore: true, // 判断是否要加载更多的标志
total_page: 0, // 总页数
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
this._getData(); //获取数据
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
let language = wx.getStorageSync('langIndex');
this.setData({ 'language': language.en});
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
if (this.data.isLoadMore) {
this.getMoreData();
} else {
wx.showToast({
title: '没有更多数据',
icon: 'none'
});
}
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
},
//获取数据 预计佣金
_getData() {
let that = this;
let urlStr = app.getNetAddresss('plugin.commission.api.commission.get-commission-list');
urlStr += '&commission_type=4';
app._getNetWork({
url: urlStr,
success: function(resdata) {
var res = resdata.data;
if (res.result == 1) {
that.setData({
datas: res.data.data,
total_page: res.data.last_page,
isLoadMore: true,
page: res.data.current_page
});
if (!that.data.total_page) {
that.setData({
total_page: 0
});
}
}
},
fail: function(res) {
console.log(res.msg);
}
});
},
// 获取更多数据,加载更多
getMoreData() {
let that = this;
let json = {};
this.setData({
isLoadMore: false
});
if (this.data.page >= this.data.total_page) {
return;
} else {
let pages = this.data.page;
pages += 1;
this.setData({
page: pages
});
json.commission_type=4;
json.page = this.data.page;
let urlStr = app.getNetAddresss('plugin.commission.api.commission.get-commission-list');
app._getNetWork({
url: urlStr,
data: json,
success: (resdata) => {
that.setData({
isLoadMore: true
});
var res = resdata.data;
if (res.result == 1) {
var nextPageData = res.data.data;
let datas = [...that.data.datas, ...nextPageData];
that.setData({
datas,
isLoadMore: true,
page: res.data.current_page
});
// let datas = this.data.info
// this.setData({
// info: datas
// })
} else {
let p = this.data.page;
p -= 1;
that.setData({
page: p,
isLoadMore: false
});
wx.showToast({
icon: 'none',
title: res.msg,
duration: 1500
});
}
}
});
}
},
});