pay.js
2.18 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
var t = getApp(), n = t.request;
module.exports = {
url: "/api/weshop/order/pay/createOrder",
rechange: function(t, e, a) {
var i = this;
n.post(this.url, {
data: {
account: t
},
success: function(t) {
i.weixinPay(t.data.result, e, a);
},
fail: function() {
"function" == typeof a && a();
},
failStatus: function() {
"function" == typeof a && a();
}
});
},
pay: function(t, e, a,sto,type) {
var i = this;
var dd = {
parent_sn: t,
store_id: sto,
type: 2,
};
if (type == 1) dd.type = 1;
n.post(this.url, {
data: dd,
success: function(t) {
if(t.data.code==0){
i.weixinPay(t.data.data, e, a);
}else{
getApp().showWarning(t.data.msg);
setTimeout(function(){
wx.redirectTo({
url: "/pages/user/order_list/order_list",
});
},1000)
}
return false;
},
fail: function() {
"function" == typeof a && a();
},
failStatus: function() {
"function" == typeof a && a();
}
});
},
weixinPay: function(n, e, a) {
wx.requestPayment({
timeStamp: String(n.timeStamp),
nonceStr: n.nonceStr,
package: n.packageValue,
signType: n.signType,
paySign: n.paySign,
success: function(n) {
console.log(n), t.showSuccess("支付成功!", e);
},
fail: function(n) {
console.log(n), "requestPayment:fail" == n.errMsg ? t.showWarning("支付失败") : "requestPayment:fail cancel" == n.errMsg ? t.showWarning("您已取消支付") : t.showWarning("支付失败:" + n.errMsg.substr("requestPayment:fail ".length)),
"function" == typeof a && a();
}
});
}
};