144 lines
3.0 KiB
JavaScript
144 lines
3.0 KiB
JavaScript
// packageE/regionalAwards/regionalAwards.js
|
|
var app = getApp();
|
|
Page({
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
listData: [],
|
|
statistics: {},
|
|
info: {},
|
|
location: {},
|
|
isLoadMore: true,
|
|
total_page: 0,
|
|
page: 1,
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
this.getData();
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
if (this.data.isLoadMore) {
|
|
this._getMoreData();
|
|
} else {
|
|
console.log("没有更多数据");
|
|
}
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {},
|
|
gotoAwardsRecord(evt) {
|
|
let id = evt.currentTarget.dataset.id;
|
|
wx.navigateTo({
|
|
url:
|
|
"/packageE/regionalAwards/regionalAwardsRecord/regionalAwardsRecord?id=" +
|
|
id,
|
|
});
|
|
},
|
|
|
|
_getMoreData() {
|
|
let that = this;
|
|
if (this.data.page >= this.data.total_page) {
|
|
return;
|
|
} else {
|
|
let urlStr = app.getNetAddresss(
|
|
"plugin.regional-reward.Frontend.controllers.quota.index"
|
|
);
|
|
this.data.page++;
|
|
app._postNetWork({
|
|
url: urlStr,
|
|
data: {
|
|
page: this.data.page,
|
|
},
|
|
success: (resdata) => {
|
|
let res = resdata.data;
|
|
if (res.result != 1) return;
|
|
if (res.data.list.current_page >= res.data.getRecord.last_page) {
|
|
that.setData({
|
|
isLoadMore: false,
|
|
});
|
|
}
|
|
let listData = this.data.listData;
|
|
listData.push(...res.data.getRecord.data);
|
|
this.setData({ listData });
|
|
},
|
|
fail: function (res) {
|
|
console.log(res.msg);
|
|
},
|
|
});
|
|
}
|
|
},
|
|
getData() {
|
|
let that = this;
|
|
let urlStr = app.getNetAddresss(
|
|
"plugin.regional-reward.Frontend.controllers.quota.index"
|
|
);
|
|
app._postNetWork({
|
|
url: urlStr,
|
|
success: (resdata) => {
|
|
let res = resdata.data;
|
|
if (res.result != 1) return this.tips(res.msg);
|
|
|
|
this.data.total_page = res.data.list.last_page || 0;
|
|
if (res.data.list.current_page >= res.data.list.last_page) {
|
|
that.setData({
|
|
isLoadMore: false,
|
|
});
|
|
}
|
|
this.setData({
|
|
location: res.data.location,
|
|
statistics: res.data.statistics,
|
|
info: res.data.info,
|
|
listData: res.data.list.data,
|
|
});
|
|
},
|
|
fail: function (res) {
|
|
console.log(res.msg);
|
|
},
|
|
});
|
|
},
|
|
|
|
tips(msg) {
|
|
wx.showToast({
|
|
title: msg,
|
|
icon: "none",
|
|
duration: 2000,
|
|
});
|
|
return false;
|
|
},
|
|
});
|