pay.js
3.95 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
var t = getApp(), n = t.request,wx_paying=0;
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) {
if(wx_paying) return false;
wx_paying=1;
var i = this;
var dd = {
parent_sn: t,
store_id: sto,
type: 2,
};
if (type == 1) dd.type = 1;
if(getApp().globalData.scene)
dd.scene=getApp().globalData.scene;
console.log(dd,'支付场景');
wx.showLoading();
n.post(this.url, {
data: dd,
success: function(t) {
wx.hideLoading();
if(t.data.code==0){
i.weixinPay(t.data.data, e, a);
}else{
getApp().confirmBox(t.data.msg);
setTimeout(function(){
wx.redirectTo({
url: "/pages/user/order_list/order_list",
});
},1000)
wx_paying=0;
}
return false;
},
fail: function() {
wx.hideLoading();
wx_paying=0;
"function" == typeof a && a();
},
failStatus: function() {
wx.hideLoading();
wx_paying=0;
"function" == typeof a && a();
}
});
},
weixinPay: function(n, e, a) {
if(!n) return false;
getApp().globalData.no_clear=1;
//有的话用最新的支付方式
if(n.orderInfo) {
wx.requestOrderPayment({
timeStamp: String(n.timeStamp),
nonceStr: n.nonceStr,
package: n.packageValue,
signType: n.signType,
paySign: n.paySign,
orderInfo: n.orderInfo, // 需要新增的 订单 信息
success (n) {
wx_paying=0;
t.showSuccess("支付成功!", e);
},
fail (n) {
wx_paying=0;
if(!n.errMsg ) {
getApp().showWarning("支付失败");
"function" == typeof fail && fail();
return false;
}
console.log(n), "requestOrderPayment:fail" == n.errMsg ? t.showWarning("支付失败") : "requestOrderPayment:fail cancel" == n.errMsg ? t.showWarning("您已取消支付") :
t.confirmBox("支付失败:" + n.errMsg.substr("requestOrderPayment:fail ".length)),
"function" == typeof a && a();
}
})
}else{
wx.requestPayment({
timeStamp: String(n.timeStamp),
nonceStr: n.nonceStr,
package: n.packageValue,
signType: n.signType,
paySign: n.paySign,
success: function (n) {
wx_paying=0;
console.log(n), t.showSuccess("支付成功!", e);
},
fail: function (n) {
wx_paying=0;
console.log(n), "requestPayment:fail" == n.errMsg ? t.showWarning("支付失败") : "requestPayment:fail cancel" == n.errMsg ? t.showWarning("您已取消支付") :
t.confirmBox("支付失败:" + n.errMsg.substr("requestPayment:fail ".length)),
"function" == typeof a && a();
}
});
}
}
};