[更新]
This commit is contained in:
96
pages/coupon/coupon.js
Normal file
96
pages/coupon/coupon.js
Normal file
@@ -0,0 +1,96 @@
|
||||
// pages/coupon/coupon.js
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
couponArr : '',
|
||||
coupons : [],
|
||||
count : '',
|
||||
couponLabel : [
|
||||
{ title : "未使用", used: 0 },
|
||||
{ title : "已使用", used: 1 },
|
||||
{ title : "已过期", used: 2 }
|
||||
],
|
||||
stateType : '0', //卡券状态
|
||||
barHeight : getApp().globalData.statusBarHeight,
|
||||
type : ''
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad (options) {
|
||||
this.setData({
|
||||
type : options.type
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* tabs
|
||||
*/
|
||||
orderTab(e){
|
||||
if(this.data.stateType != e.currentTarget.dataset.state){
|
||||
this.setData({
|
||||
stateType: e.currentTarget.dataset.state
|
||||
})
|
||||
|
||||
// 获取卡权益
|
||||
this.couponInfo()
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow () {
|
||||
// 获取列表
|
||||
this.couponInfo();
|
||||
},
|
||||
|
||||
/**
|
||||
* 卡券列表
|
||||
*/
|
||||
couponInfo() {
|
||||
wx.$api.user.coupon(this.data.stateType).then(res=>{
|
||||
this.setData({
|
||||
count : res.data.count,
|
||||
coupons : res.data.list
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 去使用卡券
|
||||
*/
|
||||
// applyTap(e) {
|
||||
// let id = e.currentTarget.dataset.id
|
||||
// wx.navigateTo({
|
||||
// url: '/pages/couponDetails/couponDetails?id=' + id
|
||||
// })
|
||||
// },
|
||||
|
||||
/**
|
||||
* 查看优惠券分组
|
||||
*/
|
||||
couponTap(e) {
|
||||
let id = e.currentTarget.dataset.id,
|
||||
status = e.currentTarget.dataset.status
|
||||
wx.navigateTo({
|
||||
url: '/pages/couponArr/couponArr?id=' + id + '&status=' + status
|
||||
})
|
||||
},
|
||||
|
||||
publicTap() {
|
||||
if(this.data.type == 'couponPublic'){
|
||||
wx.switchTab({
|
||||
url: '/pages/user/user'
|
||||
})
|
||||
}else {
|
||||
wx.navigateBack({
|
||||
delta: 1
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user