open.js
2.5 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
const defaultMerchantId = ''
Page({
/**
* 页面的初始数据
*/
data: {
isOpen: false,
openingStatus: false,
IMGURKBASE: 'equity/version/1_0_0/',
},
// 获取门店会员卡信息
getMemberCardData() {
const {
merchantId
} = wx.p.storage.get('merchant_info')
let newMerchantId = merchantId || defaultMerchantId
let para = {
merchantId: newMerchantId
}
wx.p.api.equityApi.memberCard(para).then(res => {
this.setData({
memberInfo: res
})
// wx.$Track.setTrack(
// {
// memberInfo: res
// },
// 6
// )
})
},
// 获取用户会员信息
toCheckMember() {
wx.p.api.equityApi.checkOpenMember().then(res => {
if (res.code == 0 && res.data.cardNo) {
wx.p.storage.set('isVIP', true)
this.setData({
openingStatus: false
})
if (this.data.pageForm) {
if (this.data.pageForm == 'oil') {
wx.p.storage.set('refresh_oil_oage', true)
}
wx.p.router.back()
return
}
wx.p.router.switchTab('/pages/tab/equity/index')
}
})
},
// 去购买会员
async openMemberFn() {
const loginStatus = await wx.p.router.intercept()
const { merchantId } = wx.p.storage.get('merchant_info')
if (loginStatus) return
const {
memberInfo
} = this.data
wx.p.wxApi.showLoading()
let para = {
equityClassId: memberInfo.equityClassId,
orderCode: memberInfo.orderCode,
orderSource: 3,
merchantId
}
// wx.$Track.setTrack(
// {
// ...para,
// type: '购买权益卡'
// },
// 7
// )
wx.p.api.equityApi.buyMemberCard(para).then(res => {
wx.hideLoading()
this.handlePay(res)
})
},
// 处理购买参数拉起支付
handlePay(payData) {
const {
timeStamp,
nonceStr,
packages,
signType,
paySign
} = payData
let self = this
wx.requestPayment({
timeStamp: timeStamp,
nonceStr: nonceStr,
package: packages,
signType: signType,
paySign: paySign,
success() {
setTimeout(() => {
self.toCheckMember()
}, 1500)
this.setData({
openingStatus: true
})
},
fail() {}
})
},
onLoad: function (options) {
this.getMemberCardData()
this.data.pageForm = options.page
},
toLook() {
wx.p.router.go('/packageEquity/pages/agreement/index')
},
})