// 微信支付
pay:function(){
wx.request({
url: , //后端接口
data:{
openid: openid,//传用户openid给后端
id: //传订单ID给后端
},
header: {
'Content-Type': 'application/x-www-form-urlencoded'
},
method: 'POST',
success: function (res) {
console.log("返回数据!!!!!!",res);
console.log('调起支付');
wx.requestPayment({
'timeStamp': res.data.timeStamp,
'nonceStr': res.data.nonceStr,
'package': res.data.package,
'signType': 'MD5',
'paySign': res.data.paySign,
'success': function (res) {
console.log('success');
wx.showToast({
title: '支付成功',
icon: 'success',
duration: 3000
});
},
'fail': function (res) {
// console.log(res);
console.log('用户支付扣款失败', res)
},
'complete': function (res) {
console.log('complete');
}
});
},
fail: function (res) {
console.log(res.data)
}
});
},
微信小程序调取微信支付
于 2022-12-13 14:09:11 首次发布