前端代码
weChatPay() {
uni.request({
url: 'http://www.xxxx.com/wechat/wxmporder',
data: {
id},
dataType: 'json',
method: 'POST'
}).then(response => {
uni.requestPayment({
provider: 'wxpay',
timeStamp: pay.timeStamp + '',
nonceStr: pay.nonceStr,
package: pay.package,
signType: pay.signType,
paySign: pay.paySign,
success: function(res) {
uni.showModal({
title: '提示',
content: '支付成功',
showCancel: false,
success: res => {
},
});
console.log('success:' + JSON.stringify(res));
},
fail: function(err) {
console.log('fail:' + JSON.stringify(err));
}
});
})
}
后台代码
router.all('/wxmporder', async function (req, res, next) {
const appid = <