前端代码
weChatPay() {
uni.request({
url: 'http://www.xxx.com/wechat/wxapporder',
data: {
id},
dataType: 'json',
method: 'POST'
}).then(response => {
let pay = response[1].data.pay
console.log('app微信支付数据包', JSON.stringify(pay))
const params = JSON.stringify({
appid: pay.appid,
partnerid: pay.partnerid,
prepayid: pay.prepayid,
package: pay.package,
noncestr: pay.noncestr,
timestamp: pay.timestamp + '',
sign: pay.sign
})
uni.requestPayment({
provider: 'wxpay',
orderInfo: params,
success: function(res) {
uni.showModal({
title: '提示',
content: '支付成功',
showCancel: false,
success: res => {
v.isSuccess = true;
},
});
console.log('success:' + JSON.stringify(res));
},
fail: function(err) {
uni.showModal({
title: '支付失败',
content: JSON