failed.js
4.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
// index.js
// 获取应用实例
import {
couponsApi
} from "../../../../api/api"
Page({
data: {
tabs: ['已使用', '已失效'],
curTabIndex: 0,
couponsList: [],
noData: false,
showGiftsModal: false,
giftsList: [],
haveCouponsList: []
},
jump(e) {
let {
item
} = e.currentTarget.dataset
let url = 'packageMine.order.detail'
wx.$router.go(url, item)
},
state(e) {
let {
key
} = e.currentTarget.dataset
let {
couponsList,
haveCouponsList
} = this.data
couponsList[key].checkCoupon = !couponsList[key].checkCoupon
if (!couponsList[key].checkCoupon) {
couponsList[key].userCouponList = haveCouponsList[key].slice(0, 4)
} else {
couponsList[key].userCouponList = haveCouponsList[key]
}
this.setData({
couponsList,
})
},
changeTab(e) {
this.data.haveCouponsList = []
this.setData({
curTabIndex: e.detail,
couponsList: []
})
this.getCouponsList(e.detail)
},
bottomToRefresh(e) {
let isBottom = e.detail.direction
if (isBottom == 'bottom') {
//刷新下一页
}
},
getCouponsList(index = 0) {
wx.$util.showLoading()
let {
couponType
} = this.data
let para = {}
if (couponType == 0) para.useMemberType = index + 1
couponsApi[couponType == 0 ? 'getCardData' :
index == 0 ? 'getVipUsedList' : 'getVipFailList'](para).then(res => {
wx.hideLoading()
let list = res.map(item => {
item.checkCoupon = false
item[couponType == 0 ? 'userCouponList' : 'list'].map(itm => {
if (couponType == 1) {
itm.id = itm.userCouponId
}
itm.receiveStartTime = new Date(itm.receiveStartTime).format('yyyy.MM.dd')
if (itm.effectiveType == 1) {
itm.receiveEndTime = new Date(itm.receiveEndTime).format('yyyy.MM.dd hh:mm:ss')
} else {
itm.receiveEndTime = new Date(itm.receiveEndTime).format('yyyy.MM.dd')
}
itm.discountIntensity = itm.discountIntensity / 100
return itm
})
this.data.haveCouponsList.push(index == 0 ? item.userCouponList : item.list)
return item
})
list = res.map(item => {
if (couponType == 0) {
if (item.userCouponList.length > 4) item.userCouponList = item.userCouponList.slice(0, 4)
} else {
item.couponAmount = item.list.length
if (item.list.length > 4) item.userCouponList = item.list.slice(0, 4)
else item.userCouponList = item.list
}
return item
})
this.setData({
couponsList: list,
noData: list.length ? false : true,
haveCouponsList: this.data.haveCouponsList
})
})
},
onLoad(options) {
wx.$router.getData(({
couponType,
giftsList
}) => {
this.setData({
couponType,
giftsList
})
wx.setNavigationBarTitle({
title: couponType == 0 ? '门店券' : '会员套餐'
})
})
this.getCouponsList()
},
// ***********定向礼包相关内容***********
clickClose() {
this.setData({
showGiftsModal: false
})
},
// 去使用
toUseGifts(e) {
let {
item
} = e.currentTarget.dataset
let temp = JSON.stringify(item)
let {
discountType,
// useChannel,
// id
} = item
let detailInfo = 1
if (discountType == 2 || discountType == 4) {
// wx.$router.go('packageMall.coupon', {
// userCouponId: id,
// useMemberType: item.useMemberType
// })
// 修改跳转方式
wx.navigateTo({
url: '/packageMall/pages/coupon/coupon?item=' + temp + '&detailInfo=' + detailInfo + '&useMemberType=' + item.useMemberType
})
return
}
/**线上商品代金券 */
if (discountType == 3 && useChannel == 1) {
if(item.useMemberType == 1) {
wx.$util.showToast('代金券已使用')
return
}
// wx.$router.go('packageMine.coupon.recommend', {
// couponInfo: item
// })
// 修改跳转方式
wx.navigateTo({
url: '/packageMine/pages/coupon/recommend/recommend?item=' + temp
})
return
}
wx.navigateTo({
url: '/packageMine/pages/coupon/detail/detail?item=' + temp
})
},
onHide() {}
})