微擎已将微信支付打包成函数,我们只需调用微擎函数,传入我们需要的参数即可
ordering.wxml
// 微信支付
weixinpay: function (outTradeNo, orderPrice, orderId, orderType) {
var that = this
app.util.request({
'url': 'entry/wxapp/pay', //调用wxapp.php中的doPagePay方法获取支付参数
data: {
outTradeNo: outTradeNo,
orderPrice: orderPrice
},
'cachetime': '0',
success(res) {
if (res.data && res.data.data && !res.data.errno) {
//发起支付
wx.requestPayment({
'timeStamp': res.data.data.timeStamp,
'nonceStr': res.data.data.nonceStr,
'package': res.data.data