openEmbeddedMiniProgram会调用两次接口
当主程序调用drpay0后子程序需要调起支付,在支付还没有调起时,返回主程序提示支付已取消,第二次调用drpay时,就会有两次微信支付被调起 /* 支付 */
drPay(params, title = "支付", callback) {
let id = '' /* 支付小程序的appid */
wx.openEmbeddedMiniProgram({
appId: id,
path: 'pages/drpay',
extraData: {
'params': encodeURIComponent(JSON.stringify(params)),
'title': '支付'
},
envVersion: config.envVersion, // develop(开发版),trial(体验版),release(正式版)
success: res => {
wx.setStorageSync('drPayStatus', true);
callback(true);
},
fail: err => {
callback(false);
}
});
},
/* 获取支付返回的页面参数 */
getAppParams(options) {
if (wx.getStorageSync('drPayStatus')) {
wx.setStorageSync('drPayStatus', false);
wx.hideLoading();
if (options.referrerInfo && options.referrerInfo.extraData && options.referrerInfo.extraData.params) {
let extraData = JSON.parse(decodeURIComponent(options.referrerInfo.extraData.params))
this.modal('操作提示', extraData.tips, false, () => {
if (extraData.order_type == 1) return wx.navigateBack();
if (extraData.url) return this.redirectTo(extraData.url);
})
} else {
this.modal('操作提示', '支付已取消', false, () => {
wx.navigateBack()
})
}
}
}