168 lines
3.3 KiB
JavaScript
168 lines
3.3 KiB
JavaScript
// packageH/o2o/storeConsumeIncme/storeConsumeIncme.js
|
|
const app = getApp();
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
active: 0,
|
|
page: 1,
|
|
info: []
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
this.getdata();
|
|
},
|
|
onChange(e) {
|
|
console.log(e);
|
|
let ind = e.detail.index;
|
|
this.setData({
|
|
info: [],
|
|
active: ind,
|
|
page: 1,
|
|
current_page: 1,
|
|
last_page: 1
|
|
});
|
|
this.getdata();
|
|
},
|
|
goUse(e) {
|
|
let id = e.currentTarget.dataset.id;
|
|
wx.navigateTo({
|
|
url: '/packageH/o2o/storeConsumeIndex/storeConsumeIndex?id='+id,
|
|
});
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
if(this.data.current_page >= this.data.last_page){
|
|
console.log('没有更多');
|
|
return;
|
|
}else{
|
|
let pages = this.data.page + 1;
|
|
this.setData({
|
|
page : pages
|
|
});
|
|
this.getMoreData();
|
|
}
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {
|
|
|
|
},
|
|
getdata() {
|
|
wx.showLoading({
|
|
title: '加载中',
|
|
});
|
|
let that = this;
|
|
let urlStr = app.getNetAddresss('plugin.store-card.Frontend.Modules.Card.Controllers.records.index');
|
|
app._getNetWork({
|
|
url: urlStr,
|
|
data: {
|
|
state: that.data.active,
|
|
page: that.data.page
|
|
},
|
|
success: (resdata) => {
|
|
let res = resdata.data;
|
|
wx.hideLoading({
|
|
success: (res) => {},
|
|
});
|
|
if (res.result == 1) {
|
|
that.setData({
|
|
info: res.data.data,
|
|
current_page: res.data.current_page,
|
|
last_page: res.data.last_page
|
|
});
|
|
} else {
|
|
wx.showToast({
|
|
title: res.msg,
|
|
duration: 1000,
|
|
icon: 'none'
|
|
});
|
|
}
|
|
},
|
|
fail: function (res) {
|
|
console.log(res.msg);
|
|
}
|
|
});
|
|
},
|
|
getMoreData() {
|
|
wx.showLoading({
|
|
title: '加载中',
|
|
});
|
|
let that = this;
|
|
let urlStr = app.getNetAddresss('plugin.store-card.Frontend.Modules.Card.Controllers.records.index');
|
|
app._postNetWork({
|
|
url: urlStr,
|
|
data: {
|
|
state: that.data.active,
|
|
page: that.data.page
|
|
},
|
|
success: (resdata) => {
|
|
let res = resdata.data;
|
|
wx.hideLoading({
|
|
success: (res) => {},
|
|
});
|
|
if (res.result == 1) {
|
|
let nextData = res.data.data;
|
|
that.setData({
|
|
info: that.data.info.concat(nextData),
|
|
current_page: res.data.current_page,
|
|
last_page: res.data.last_page
|
|
});
|
|
} else {
|
|
wx.showToast({
|
|
title: res.msg,
|
|
duration: 1000,
|
|
icon: 'none'
|
|
});
|
|
}
|
|
},
|
|
fail: function (res) {
|
|
console.log(res.msg);
|
|
}
|
|
});
|
|
}
|
|
}); |