如何在A页面调用wx.scanCode拿到参数发起异步请求后直接跳转至B页面而不返回A再跳转至B?
API:scanCode
基础库:2.4.4
微信版本号:7.0.4
问题:在A页面呼起扫一扫,在扫一扫的成功回调里发起异步请求,请求的成功回调里navigateTo B页面。总是在调起扫一扫后重回A页面而后才跳转B页面,如何直接跳至B页面?
代码:
jumpPay: function (e) { wx.scanCode({ success(res) { let str = res.result let q={} str.replace(/([^?&=]+)=([^&]+)/g,(_,k,v)=>q[k]=v); // q; // str = str.match(/qrcode=(\S*)/)[1]; console.log( '扫一扫获得的res' ,q) if (q.qrcode){ const getScanQuery = {qr_code:q.qrcode} PayStore.getQueryScanInfo(getScanQuery).then( function (res) { // 发起异步请求 if (0==res.data.retcode){ let query = {...res.data,...getScanQuery} query = JSON.stringify(query) wx.navigateTo({ url: '/pages/pay/payInput?query=' +query }); } else { console.log( '接口回参错误' )
} }). catch ( (error) => { console.log(error) }) } else { console.log( '未获取到qrcode' ) } }, fail(){ console.log( '扫一扫调用失败' ) } }) }, |