pay2.js
1.72 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
var t = getApp(), n = t.request,wx_paying=0;
module.exports = {
url: "/api/weshop/plus/create/plus/order",
pay: function(dd, succ,fail) {
if(wx_paying) return false;
wx_paying=1;
if(getApp().globalData.scene)
dd.scene=getApp().globalData.scene;
wx.showLoading();
var i = this;
n.post(this.url, {
data: dd,
success: function(t) {
wx.hideLoading();
if(t.data.code==0){
if(t.data.data=="升级成功"){
"function" == typeof succ && succ(1);
}else{
i.weixinPay(t.data.data, succ,fail);
}
}else{
"function" == typeof fail && fail();
}
return false;
},
fail: function() {
wx.hideLoading();
wx_paying=0;
"function" == typeof fail && fail();
},
failStatus: function() {
wx.hideLoading();
wx_paying=0;
"function" == typeof fail && fail();
}
});
},
weixinPay: function(n, succ,fail) {
if(!n) return false;
wx.requestPayment({
timeStamp: String(n.timeStamp),
nonceStr: n.nonceStr,
package: n.packageValue,
signType: n.signType,
paySign: n.paySign,
success: function(n) {
wx_paying=0;
"function" == typeof succ && succ();
},
fail: function(n) {
wx_paying=0;
"function" == typeof fail && fail();
}
});
}
};