191 lines
4.0 KiB
JavaScript
191 lines
4.0 KiB
JavaScript
// packageI/dealer_task_reward/dealerTaskRewardIndex/dealerTaskRewardIndex.js
|
|
const app = getApp();
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
active:0,
|
|
active1:0,
|
|
|
|
details:{},
|
|
|
|
page: 1, //分页数,当前页数
|
|
isLoadMore: true, //判断是否要加载更多的标志
|
|
total_page: 0, //总页数
|
|
listData: [],
|
|
|
|
wait_amount:0,
|
|
settle_amount:0
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
this.getDetails();
|
|
this.getListData();
|
|
},
|
|
|
|
getDetails() {
|
|
let urlStr = app.getNetAddresss('plugin.dealer-task-reward.frontend.controllers.page.index');
|
|
app._postNetWork({
|
|
url: urlStr,
|
|
success: (resdata) => {
|
|
let res = resdata.data;
|
|
if(res.result != 1) return app.tips(res.msg);
|
|
wx.setNavigationBarTitle({
|
|
title: res.data.plugin_name,
|
|
});
|
|
this.setData({
|
|
details:res.data,
|
|
goods_list:res.data.goods_list
|
|
});
|
|
},
|
|
fail: function (res) {
|
|
console.log(res.msg);
|
|
}
|
|
});
|
|
},
|
|
|
|
swichTabTItem(e){
|
|
this.setData({
|
|
active:e.detail.index
|
|
});
|
|
},
|
|
|
|
switchTabStatus(e){
|
|
this.setData({
|
|
active1:e.detail.index
|
|
});
|
|
this.getListData();
|
|
},
|
|
|
|
gotoRecord(evt){
|
|
let goods_id = evt.currentTarget.dataset.id;
|
|
wx.navigateTo({
|
|
url: `/packageI/dealer_task_reward/dealerTaskRewardRecord/dealerTaskRewardRecord?goods_id=${goods_id}&task_id=${this.data.details.task_id}`,
|
|
});
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
if (this.data.isLoadMore) {
|
|
this.getMoreData();
|
|
} else {
|
|
console.log('没有更多数据');
|
|
}
|
|
},
|
|
|
|
|
|
getListData(){
|
|
this.data.page = 1;
|
|
this.data.total_page = 0;
|
|
this.data.isLoadMore = true;
|
|
|
|
let urlStr = app.getNetAddresss("plugin.dealer-task-reward.frontend.controllers.reward.index");
|
|
let json={};
|
|
if(this.data.active1>0){
|
|
json.status = this.data.active1;
|
|
}
|
|
app._getNetWork({
|
|
url: urlStr,
|
|
data: json,
|
|
success: (resdata) => {
|
|
var res = resdata.data;
|
|
if (res.result != 1) return app.tips(res.msg);
|
|
|
|
this.setData({
|
|
isLoadMore: true,
|
|
total_page: res.data.reward_list.last_page,
|
|
listData: res.data.reward_list.data,
|
|
wait_amount:res.data.wait_amount,
|
|
settle_amount:res.data.settle_amount
|
|
});
|
|
if (!this.data.total_page) {
|
|
this.data.total_page = 0;
|
|
}
|
|
}
|
|
});
|
|
},
|
|
|
|
getMoreData(){
|
|
if(this.data.active!=1) return;
|
|
this.data.isLoadMore = false;
|
|
if (this.data.page >= this.data.total_page) {
|
|
return;
|
|
} else {
|
|
this.data.page++;
|
|
let json = {
|
|
page: this.data.page
|
|
};
|
|
if(this.data.tabsIndex!=3){
|
|
json.status = this.data.tabsIndex;
|
|
}
|
|
let urlStr = app.getNetAddresss("plugin.gratitude-reward.frontend.index.index");
|
|
app._getNetWork({
|
|
url: urlStr,
|
|
data:json,
|
|
success: (resdata) => {
|
|
var res = resdata.data;
|
|
|
|
if (res.result == 1) {
|
|
this.data.isLoadMore = true;
|
|
var myData = res.data.reward_list.data;
|
|
this.setData({
|
|
listData: this.data.listData.concat(myData)
|
|
});
|
|
} else {
|
|
this.data.isLoadMore = false;
|
|
this.data.page--;
|
|
}
|
|
}
|
|
});
|
|
}
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {
|
|
|
|
}
|
|
}); |