测试小程序微信支付demo报错

狂风中的少年 提交于 2019-12-02 05:08:04

测试小程序微信支付demo报错
代码片段如下:
Page({
data: {
requestUrl: ‘’
},

payNow: function () {
var that = this;
wx.request({
url: app.data.requestUrl + ‘weChatPay/doUnifiedOrder’,
header: {
“Content-Type”: “application/json;charset=UTF-8”
},
data: {
requestData: {
openId: app.globalData.openId
}
},
method: ‘POST’,
dataType: ‘json’,
responseType: ‘text’,
success: function (res) {
console.log(“服务端返回订单号”);
var c = res.data;
wx.requestPayment({
timeStamp: res.data.data.timeStamp,
nonceStr: res.data.data.nonceStr,
package: res.data.data.package,
signType: ‘MD5’,
paySign: res.data.data.paySign,
success(res) {
console.log(“统一下单接口成功”);
},
fail(res) {
console.log(“统一下单接口失败”);
}
});
},
fail: function (res) { },
complete: function (res) { },
});
},
})

报错信息如下:
thirdScriptError
Cannot read property ‘requestUrl’ of undefined; [Component] Event Handler Error @ pages/index/index#bound payNow
TypeError: Cannot read property ‘requestUrl’ of undefined

at ye.payNow (http://127.0.0.1:21510/appservice/pages/index/index.js:53:21)
at Object.r.safeCallback (WAService.js:1:1125173)
at WAService.js:1:1317978
at r (WAService.js:1:1249680)
at WAService.js:1:1249802
at WAService.js:1:420977
at n (http://127.0.0.1:21510/appservice/dev/asdebug.js:1:27894)
at e.exports. (http://127.0.0.1:21510/appservice/dev/asdebug.js:1:28236)
at http://127.0.0.1:21510/appservice/dev/asdebug.js:1:1846
at Array.forEach ()
请各位大佬帮忙看下,怎么解决,非常感谢!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!