Files
sykl-hy/pages/coupons/list/index.js

74 lines
1.6 KiB
JavaScript

/*
* 手太欠
* 愿这世界都如故事里一样 美好而动人~
*/
Page({
/**
* 页面的初始数据
*/
data: {
couponArr : [], //抵值券
page : {}, //下一页
lodingStats : false, //加载状态
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.setData({
couponId: options.couponid
})
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
// 获取我的抵值券
this.couponInfo();
},
// 我的抵值券
couponInfo(page){
wx.$api.user.couponList(this.data.couponId,{
page : page || 1
}).then(res => {
let listArr = this.data.couponArr,
newData = []
if(page == 1 || page == undefined) listArr = []
newData = listArr.concat(res.data.data)
this.setData({
couponArr : newData,
page : res.data.page,
lodingStats : false
})
wx.stopPullDownRefresh()
}).catch(err => {})
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
// 获取我的抵值券
this.couponInfo();
},
/**
* 上拉加载
*/
onReachBottom(){
this.setData({
lodingStats: true
})
let pageNumber = this.data.page.current
if(this.data.page.has_more){
pageNumber++
// 获取我的抵值券
this.couponInfo(pageNumber);
}
}
})