<!--
1.点击支付按钮触发payOrder
2.postJSON是封装的请求方法,参数subData是根据后端的来
3.api 是后端的支付接口返回订单相应的东西
4.触发微信的支付api
-->
payOrder(order_id,order_money){
let that=this;
let subData={
user_id:uni.getStorageSync('userInfo').user_id,
payment_mode:2,
money:order_money,
pay_type:1,
order_id:order_id
}
postJSON(api,subData,res=>{
if(res.data.status==1){
console.log('拿到支付参数:'+res.data.data.timeStamp)
console.log('拿到支付参数:'+res.data.data.nonceStr)
console.log('拿到支付参数:'+res.data.data.package)
console.log('拿到支付参数:'+res.data.data.paySign)
that.payApi(res.data.data.timeStamp,
res.data.data.nonceStr,
res.data.data.package,
res.data.data.paySign)
}else{
that.$toast(res.data.message,'none');
}
});
},
payApi(timeStamp,nonceStr,packages,paySign){
let that=this;
uni.requestPayment({
'timeStamp':timeStamp,
'nonceStr': nonceStr,
'package': packages,
'signType': 'MD5',
'paySign': paySign,
"success":function(res){
uni.redirectTo({
url: 'url',
})
},
"fail":function(err){
uni.showToast({
title: '支付失败',
icon: 'none'
})
uni.redirectTo({
url: 'url',
})
}
})
},
- 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