open.js
2.71 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
import { equityApi } from '~/api/api'
import { defaultMerchantId } from '~/utils/request/environment'
Page({
/**
* 页面的初始数据
*/
data: {
isOpen: false,
openingStatus: false
},
// 获取门店会员卡信息
getMemberCardData() {
const merchantId = wx.$storage.get('srcm_shopmall_merchant_id')
let newMerchantId = merchantId || defaultMerchantId
let para = {
merchantId: newMerchantId
}
equityApi.memberCard(para).then(res => {
this.setData({
memberInfo: res
})
wx.$Track.setTrack(
{
memberInfo: res
},
6
)
})
},
// 获取用户会员信息
toCheckMember() {
equityApi.checkOpenMember().then(res => {
if (res.code == 0 && res.data.cardNo) {
wx.$storage.set('isVIP', true)
this.setData({
openingStatus: false
})
if (this.data.pageForm) {
if (this.data.pageForm == 'oil') {
wx.$storage.set('refresh_oil_oage', true)
}
wx.navigateBack({
delta: 1
})
return
}
const index = 1-wx.$util.judgeMerchantForXubao()
wx.$router.reLaunch(`/pages/tab/shopMall/index?tabIndex=${index}`)
}
})
},
// 去购买会员
async openMemberFn() {
let sid = wx.$util.getSessionId()
if (!sid) {
this.setData({
showLogin: true
})
return
}
const { memberInfo } = this.data
const merchantId = wx.$storage.get("srcm_shopmall_merchant_id");
wx.$api.showLoading()
let para = {
equityClassId: memberInfo.equityClassId,
orderCode: memberInfo.orderCode,
orderSource: 3,
merchantId
}
wx.$Track.setTrack(
{
...para,
type: '购买权益卡'
},
7
)
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.navigateTo({
url: '/packageShopmall/packageEquity/pages/agreement/index'
})
},
toActive() {
wx.navigateTo({
url: '/packageShopmall/packageEquity/pages/active/active'
})
}
})