AI助手支持GPT4.0
调起微信支付jsapi后,不想支付了关闭支付页,页面被卡住了,怎么办?
pay() { if (!this.selIndArr.length) { Toast({ message: '请先选择要支付的订单!', duration: 1000, forbidClick: true }) return; } let orderNumArr = [] for (let i = 0; i < this.selIndArr.length; i++) { orderNumArr.push(this.list[this.selIndArr[i]].orderId) } Toast.loading({ mask: true, duration: 0, forbidClick: true, message: '发起支付中...' }); let params = { orderNos: orderNumArr.join() } this.$api.payOrder(params).then(res => { if (res.code == 10000) { Toast.clear(); let param = res.data.jsRequstParam this.onBridgeReady(param) if (typeof WeixinJSBridge == "undefined") { if (document.addEventListener) { document.addEventListener('WeixinJSBridgeReady', this.onBridgeReady(param), false); } else if (document.attachEvent) { document.attachEvent('WeixinJSBridgeReady', this.onBridgeReady(param)); document.attachEvent('onWeixinJSBridgeReady', this.onBridgeReady(param)); } } else { this.onBridgeReady(param) } } }) }, onBridgeReady(param) { let that = this; WeixinJSBridge.invoke( 'getBrandWCPayRequest', { "appId": param.appId, "timeStamp": param.timeStamp, "nonceStr": param.nonceStr, "package": param.pack, "signType": param.signType, "paySign": param.paySign }, function (res) { console.log('onBridgeReadyRes==', res); if (res.err_msg == "get_brand_wcpay_request:ok") { console.log('get_brand_wcpay_request:ok'); that.checkPay(param.outTradeNo, 0) } else if (res.err_msg == "get_brand_wcpay_request:cancel") { Toast('取消支付!'); } }); },
pay() { if (! this.selIndArr.length ){toast ({message: 'please select the order to be paid first! ', duration: 1000, forbidClick: true }) return; } let orderNumArr = [] for (let i = 0; i < this.selIndArr.length ; i++) { orderNumArr.push ( this.list [ this.selIndArr [i]].orderId) } Toast.loading ({mask: true, duration: 0, / / continuously display toast forbidclick: true, message: 'initiating payment...'}); let params = { orderNos: orderNumArr.join () } this.$ api.payOrder (params).then(res => { if ( res.code == 10000) { Toast.clear (); let param = res.data.jsRequstParam this.onBridgeReady (param) if (typeof WeixinJSBridge == "undefined") { if ( document.addEventListener ) { document.addEventListener ('WeixinJSBridgeReady', this.onBridgeReady (param), false); } else if ( document.attachEvent ) { document.attachEvent ('WeixinJSBridgeReady', this.onBridgeReady (param)); document.attachEvent ('onWeixinJSBridgeReady', this.onBridgeReady (param)); } } else { this.onBridgeReady (param) } } }) }, onBridgeReady(param) { let that = this; WeixinJSBridge.invoke ( 'getBrandWCPayRequest', { "appId": param.appId , / / the name of the official account is passed from merchant to timeStamp: param.timeStamp , / / timestamp, seconds since 1970 "noncestr": param.nonceStr , / / random string "package": param.pack , "signType": param.signType , / / wechat signature method: "paysign": param.paySign / / wechat signature}, function (RES) { console.log ('onBridgeReadyRes==', res); if ( res.err_ msg == "get_ brand_ wcpay_ request:ok ") { console.log ('get_ brand_ wcpay_ request:ok '; / / use the above method to judge the front-end return, and the wechat team solemnly prompts:// res.err_ MSG will return OK after the user pays successfully, but it is not guaranteed that it is absolutely reliable. So check whether the order is paid successfully that.checkPay ( param.outTradeNo , 0) } else if ( res.err_ msg == "get_ brand_ wcpay_ request:cancel ") {toast ('cancel payment! '); // window.history.back (-1); } }); },
为了帮助你更快的定位问题,请提供如下信息(有敏感信息可私信提供):
-请求的具体API接口(提供文档地址和请求的URL):
- 问题发生时间【必填】:
- 商户号【 必填】:
- 商户订单号【 必填】:
- 相关报错信息文案:
- 问题截图或视频:
-完整的请求和返回参数以及单号: