小程序插件支付功能页调用失败
已按照文档说明配置,还是报 callMiniProgramFunction:fail File not found
因为插件开发,涉及源小程序和插件两个部分,很难提供代码片段,核心内容如下:
小程序中 app.json 已配置 “functionalPages”: true
根目录下建立文件 functional-pages/request-payment.js 如下
exports.beforeRequestPayment = function (paymentArgs, callback) { wx.login({ success(data) { wx.request({ method: 'POST' , url: 'https://foo.com/api/login' , data: { code: data.code }, success: function (res) { wx.request({ method: 'POST' , url: 'https://foo.com/api/order' , data: paymentArgs, header: { Token: res.data.token }, success: function (res) { if (res.data.code == 0) { callback( null , res.data.data) } else { callback(res.data.message) } }, fail: function (res) { callback(res) }, }) }, fail: function (res) { callback(res) }, }) }, fail: function (res) { callback(res) }, }) } |
插件中
< functional-page-navigator version = "develop" name = "requestPayment" args = "{{ { fee: total, paymentArgs: paymentArgs } }}" bind:success = "paymentSuccess" bind:fail = "paymentFailed" > < button type = "primary" >微信支付</ button > </ functional-page-navigator > |