forked from Levin000/TianguoguoXiaopu
-
Notifications
You must be signed in to change notification settings - Fork 79
/
Copy pathpay.js
executable file
·46 lines (45 loc) · 1.26 KB
/
pay.js
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
function wxpay(app, money, orderId, redirectUrl) {
let remark = "在线充值";
let nextAction = {};
if (orderId != 0) {
remark = "支付订单 :" + orderId;
nextAction = { type: 0, id: orderId };
}
wx.request({
url: 'https://api.it120.cc/' + app.globalData.subDomain + '/pay/wx/wxapp',
data: {
token: wx.getStorageSync('token'),
money:money,
remark:remark,
payName:"在线支付",
nextAction:nextAction
},
//method:'POST',
success: function(res){
if(res.data.code == 0){
// 发起支付
wx.requestPayment({
timeStamp:res.data.data.timeStamp,
nonceStr:res.data.data.nonceStr,
package:'prepay_id=' + res.data.data.prepayId,
signType:'MD5',
paySign:res.data.data.sign,
fail:function (aaa) {
wx.showToast({title: '支付失败:' + aaa})
},
success:function () {
wx.showToast({title: '支付成功'})
wx.redirectTo({
url: redirectUrl
});
}
})
} else {
wx.showToast({ title: '服务器忙' + res.data.code + res.data.msg})
}
}
})
}
module.exports = {
wxpay: wxpay
}