renew.js
7.43 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
"use strict";
const common_vendor = require("../../../common/vendor.js");
const common_api = require("../../../common/api.js");
require("../../../common/request.js");
require("../../../config.js");
require("../../../common/login.js");
if (!Array) {
const _easycom_uni_popup_dialog2 = common_vendor.resolveComponent("uni-popup-dialog");
const _easycom_uni_popup2 = common_vendor.resolveComponent("uni-popup");
(_easycom_uni_popup_dialog2 + _easycom_uni_popup2)();
}
const _easycom_uni_popup_dialog = () => "../../../uni_modules/uni-popup/components/uni-popup-dialog/uni-popup-dialog.js";
const _easycom_uni_popup = () => "../../../uni_modules/uni-popup/components/uni-popup/uni-popup.js";
if (!Math) {
(_easycom_uni_popup_dialog + _easycom_uni_popup)();
}
const _sfc_main = {
__name: "renew",
setup(__props) {
const app = getApp();
const vTypeImg = common_vendor.ref("/static/v1.png");
const card = common_vendor.ref({});
const orderId = common_vendor.ref("");
const telNo = common_vendor.ref("");
const userName = common_vendor.ref("");
const alertPayOk = common_vendor.ref(null);
const isActive = common_vendor.ref(null);
const amount = common_vendor.ref(0);
const myAmount = common_vendor.ref(null);
const priceList = common_vendor.ref(["500", "1000", "2000", "3000", "5000", "10000"]);
const popNotice = common_vendor.ref(false);
const content = common_vendor.ref("");
common_vendor.onLoad(() => {
content.value = app.globalData.venue.rechargeNotice;
popNotice.value = true;
});
common_vendor.onShow(() => {
common_api.getOwnMemberInfo().then((res) => {
card.value = res.data;
if (card.value.isVip) {
telNo.value = card.value.info.memberTelno;
userName.value = card.value.info.memberName;
} else {
telNo.value = common_vendor.index.getStorageSync("currUser").realTelno;
userName.value = "";
}
});
});
function closepopNotice() {
popNotice.value = false;
}
function goPay() {
if (!telNo.value) {
common_vendor.index.showToast({
title: `请填写充值手机号`,
icon: "none"
});
return;
}
if (!userName.value) {
common_vendor.index.showToast({
title: `请填写姓名`,
icon: "none"
});
return;
}
if (myAmount.value) {
amount.value = myAmount.value;
}
if (amount.value == 0) {
common_vendor.index.showToast({
title: `请选择或填写充值金额`,
icon: "none"
});
return;
}
common_api.getMemberLevelTip(telNo.value, amount.value).then((res) => {
console.log(res);
if (res.data.name != card.value.vipInfo.name) {
if (res.data.discountPercent < card.value.vipInfo.discountPercent) {
var changeDis = "降级";
} else {
var changeDis = "升级";
}
common_vendor.index.showModal({
title: "温馨提示",
content: `充值成功后,您将${changeDis}为${res.data.name},新的会员折扣为${(100 - res.data.discountPercent) / 10}折`,
success: function(res2) {
if (res2.confirm) {
goRecharge();
} else if (res2.cancel) {
console.log("取消充值");
}
}
});
} else {
goRecharge();
}
});
}
function goRecharge() {
common_vendor.index.getStorageSync("currUser");
common_api.rechargeCard({
telNo: telNo.value,
amount: amount.value,
userName: userName.value
}).then((res) => {
wePay(res.data.weixinData);
orderId.value = res.data.orderId;
});
}
function wePay(configdata) {
console.log(configdata);
common_vendor.index.requestPayment({
"provider": "wxpay",
"appId": configdata.appId,
"nonceStr": configdata.nonceStr,
"package": configdata.packageValue,
// 随机字符串
"timeStamp": configdata.timeStamp,
// 时间戳(单位:秒)
"signType": configdata.signType,
// 签名,这里用的 MD5/RSA 签名
"paySign": configdata.paySign,
success(res) {
console.log(res);
common_api.maRechargeConfirm({
orderId: orderId.value,
successFlag: true
}).then((response) => {
console.log(response);
});
alertPayOk.value.open();
},
fail(e) {
console.log(e);
common_vendor.index.showToast({
title: "支付取消",
icon: "none"
});
common_api.maRechargeConfirm({
orderId: orderId.value,
successFlag: false
}).then((response) => {
console.log(response);
});
}
});
}
function goCardDetail() {
common_vendor.index.redirectTo({
url: `/pages/usercenter/mycard/mycard`
});
}
function changePrice(item, index) {
if (isActive.value == index) {
isActive.value = null;
amount.value = 0;
} else {
isActive.value = index;
amount.value = item;
}
myAmount.value = null;
}
function changeMyAmount(val) {
if (myAmount.value) {
isActive.value = -1;
}
}
return (_ctx, _cache) => {
return common_vendor.e({
a: telNo.value,
b: common_vendor.o(($event) => telNo.value = $event.detail.value),
c: userName.value,
d: common_vendor.o(($event) => userName.value = $event.detail.value),
e: common_vendor.f(priceList.value, (p, index, i0) => {
return {
a: common_vendor.t(p),
b: index,
c: common_vendor.n(isActive.value == index ? "active" : ""),
d: common_vendor.o(($event) => changePrice(p, index), index)
};
}),
f: common_vendor.o(changeMyAmount),
g: myAmount.value,
h: common_vendor.o(($event) => myAmount.value = $event.detail.value),
i: card.value.isVip
}, card.value.isVip ? {
j: vTypeImg.value,
k: common_vendor.t(card.value.vipInfo.name),
l: common_vendor.t(card.value.info.cardCode),
m: common_vendor.t(card.value.info.balance),
n: common_vendor.t((100 - card.value.info.discountPercent) / 10),
o: common_vendor.t(card.value.info.expirationTime)
} : {}, {
p: common_vendor.o((...args) => _ctx.payChange && _ctx.payChange(...args)),
q: card.value.isVip
}, card.value.isVip ? {
r: common_vendor.o(goPay)
} : {
s: common_vendor.o(goPay)
}, {
t: common_vendor.o(goCardDetail),
v: common_vendor.p({
type: "success",
confirmText: "查看会员卡",
content: "充值成功"
}),
w: common_vendor.sr(alertPayOk, "bfa1fab8-0", {
"k": "alertPayOk"
}),
x: common_vendor.p({
type: "dialog"
}),
y: popNotice.value
}, popNotice.value ? {
z: common_vendor.t(content.value),
A: common_vendor.o(closepopNotice)
} : {});
};
}
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-bfa1fab8"], ["__file", "/Users/yangyang/project/j-mini/Venue/pages/usercenter/mycard/renew.vue"]]);
wx.createPage(MiniProgramPage);