Files
cardsystem/pages/couponArr/couponArr.js
2021-05-21 15:02:18 +08:00

78 lines
1.7 KiB
JavaScript

// pages/couponArr/couponArr.js
Page({
/**
* 页面的初始数据
*/
data: {
id : '',
status : '',
couponArr : '', //卡券组列表
page : 1, //分页
lodingStats : false //加载状态
},
/**
* 生命周期函数--监听页面加载
*/
onLoad (options) {
this.setData({
id : options.id,
status : options.status
})
// 获取卡券组列表
this.couponInfo();
},
/**
* 卡券组列表
*/
couponInfo(page) {
wx.$api.user.couponArr(this.data.id, this.data.status, page || '').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()
})
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
// 获取团购列表
this.couponInfo();
},
/**
* 上拉加载
*/
onReachBottom(){
this.setData({
lodingStats: true
})
let pageNumber = this.data.page.current
if(this.data.page.has_more){
pageNumber++
this.couponInfo(pageNumber)
}
}
/**
* 去使用卡券
*/
// applyTap(e) {
// let id = e.currentTarget.dataset.id
// wx.navigateTo({
// url: '/pages/couponDetails/couponDetails?id=' + id
// })
// }
})