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

162 lines
3.3 KiB
JavaScript

// pages/member/present/present.js
var app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
language: '',
datas: [],
// more
page: 1, // 分页数,当前页数
isLoadMore: true, // 判断是否要加载更多的标志
total_page: 0, // 总页数
types: '5'
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
if (options.type && options.type == 1) {
this.setData({
types: '6'
});
this._getData("6");
wx.setNavigationBarTitle({
title: '无效佣金'
});
} else {
this.setData({
types: '5'
});
this._getData("5"); //获取数据
wx.setNavigationBarTitle({
title: '已提现佣金'
});
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
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'
// })
// }
if (this.data.current_page >= this.data.total_page){
wx.showToast({
title: '没有更多数据',
icon: 'none'
});
}else{
this.getMoreData();
}
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
},
_getData(type) {
let that = this;
let urlStr = app.getNetAddresss('plugin.commission.api.commission.get-commission-list');
urlStr += '&commission_type=' + type;
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,
current_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 pages = this.data.page;
pages += 1;
this.setData({
page: pages
});
let urlStr = app.getNetAddresss('plugin.commission.api.commission.get-commission-list');
app._getNetWork({
url: urlStr,
data: {
page: that.data.page,
commission_type: that.data.types
},
success: function(resdata) {
var res = resdata.data;
if (res.result == 1) {
var nextPageData = res.data.data;
let datas = [...that.data.datas, ...nextPageData];
that.setData({
datas,
total_page: res.data.last_page,
current_page: res.data.current_page
});
}
},
fail: function(res) {
console.log(res.msg);
}
});
}
});