获取参数(固定写法,后端让你怎么写你就怎么写)
wx.config({
debug: false,
appId: '{$signPackage["appId"]}',
timestamp: '<?php echo $signPackage["timestamp"];?>',
nonceStr: '<?php echo $signPackage["nonceStr"];?>',
signature: '<?php echo $signPackage["signature"];?>',
jsApiList: ['chooseWXPay']
});
进行跳转事件
wx.ready(function () {
//跳转
wx.chooseWXPay({
timestamp: res.data.timeStamp,
nonceStr: res.data.nonceStr,
package: res.data.package,
signType: res.data.signType,
paySign: res.data.paySign,
success: function () {
//支付成功
$.toast("订单支付成功", "text");
window.location.href = '?s=/weixin/SkincaseNew/yaoqinghan'
},
cancel: function () {
//支付取消
window.location.href = '?s=/weixin/SkincaseNew/yaoqinghan'
}
})
});
wx.error(function (res) {
//支付失败
console.log(res)
});