index.js
4.11 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
import MineApi from '~/api/mineApi/index'
const discountTypes = ['','满减券','折扣券','代金券','兑换券','购车代金券','商品折扣券','服务券']
Page({
data: {
coupons: [
{
label: '',
value: '',
tip: '',
sign: '',
type: ''
},
{
label: '优惠券名称',
value: '',
tip: '',
sign: '',
type: ''
},
{
label: '类型',
value: '',
tip: '',
sign: '',
type: ''
},
{
label: '有效期',
value: '',
tip: '',
sign: '',
type: ''
},
{
label: '',
value: '',
tip: '',
sign: '',
type: ''
},
{
label: '发放门店',
value: '',
tip: '',
sign: '',
type: ''
},
],
customer: [
{
label: '客户姓名',
value: ''
},
{
label: '手机号',
value: ''
},
{
label: '领取时间',
value: ''
},
],
discountType:0,
pageShow:false
},
onRoute(options) {
if(options.code){
const userStorage = wx.$storage.get('userInfo')
let para = {
verficationCode:options.code,
merchantId:userStorage.merchantId
}
this.query = para
wx.$api.showLoading()
MineApi.couponsDetailByScan(para).then(res => {
wx.hideLoading();
let {customer,coupons} = this.data
let {effectiveType,effectiveDays,effectiveStartTime,effectiveEndTime} = res
// 客户信息
customer[0].value = res.userName || ''
customer[1].value = res.phone || ''
customer[2].value = res.receiveStartTime?new Date(res.receiveStartTime).format('yyyy-MM-dd'):''
// 优惠券信息
coupons[1].value = res.couponName || ''
coupons[2].value = discountTypes[res.discountType] || ''
coupons[5].value =res.userCouponMerchantName || ''
// 有效期
let effectiveStr = ''
if(effectiveType==1){
effectiveStr = `${effectiveDays}天`
}else if(effectiveType==2){
effectiveStr = `${new Date(effectiveStartTime).format('yyyy/MM/dd')}~${new Date(effectiveEndTime).format('yyyy/MM/dd')}`
}else{
effectiveStr = '无有效期'
}
coupons[3].value = effectiveStr
if(res.discountType==7){
coupons[4].tip =`已核销${res.usedAmount || 0}次`
let str1 = ''
if(res.useType==0){
str1 = '不限次数'
}else if(res.useType ==1){
str1 = (res.effectiveType >2?'':'有效期内')+'可用'+`${res.useAllAmount}次`
}else{
str1 = '每隔'+`${res.useLimitDays}天`+'|'+`可用${res.useAmount}次`
}
coupons[4].value =`已核销${res.usedAmount || 0}次`
coupons[4].label =`使用限制`
coupons[1].label =`服务名称`
}
// 套餐
if(res.packageId){
coupons[0].label = '所属套餐'
coupons[0].value = res.packageName || ''
coupons[0].sign = res.receiveWay==6?'集团套餐':''
}
// 定向礼包
if(res.directionalGiftName){
coupons[0].label = '所属定向礼包'
coupons[0].value = res.directionalGiftName || ''
coupons[0].sign = res.merchantType==2?'集团':''
coupons[0].type = res.directionalGiftReceiveCondition?(res.directionalGiftReceiveWay==1?`手机号:${res.directionalGiftReceiveCondition}`:`车架号后6位:${res.directionalGiftReceiveCondition}`):'直接领取'
}
if(res.activityName){
coupons[0].label = '所属活动'
coupons[0].value = res.activityName
}
this.setData({
customer,
coupons,
discountType:res.discountType,
pageShow:true
})
})
}
},
toComfirm(){
wx.$api.showLoading('提交中')
MineApi.comfirmHx(this.query).then(res => {
wx.hideLoading();
wx.$router.go('/packageStoreAssistant/packageMine/pages/success/index')
})
},
})