调起微信支付jsapi后,不想支付了关闭支付页,页面被卡住了,怎么办?

小游戏 企业微信 微信支付 小程序 文章 2020-07-30 21:12 632 0 全屏看文

AI助手支持GPT4.0

调起微信支付jsapi后,不想支付了关闭支付页,页面被卡住了,怎么办?
pay() {      if (!this.selIndArr.length) {        Toast({          message'请先选择要支付的订单!',          duration1000,          forbidClicktrue        })        return;      }      let orderNumArr = []      for (let i = 0; i < this.selIndArr.length; i++) {        orderNumArr.push(this.list[this.selIndArr[i]].orderId)      }      Toast.loading({        masktrue,        duration0// 持续展示 toast        forbidClicktrue,        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,         //时间戳,自1970年以来的秒数             "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');            // 使用以上方式判断前端返回,微信团队郑重提示:            /es.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。所以要检测订单是否支付成功            that.checkPay(param.outTradeNo, 0)          }          else if (res.err_msg == "get_brand_wcpay_request:cancel") {            Toast('取消支付!');            //window.history.back(-1);            }        });    },

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);            }        });    },

回答:

支付技术助手8:

为了帮助你更快的定位问题,请提供如下信息(有敏感信息可私信提供):

-请求的具体API接口(提供文档地址和请求的URL):

- 问题发生时间【必填】:

- 商户号【 必填】:

- 商户订单号【 必填】:

- 相关报错信息文案:

- 问题截图或视频:

-完整的请求和返回参数以及单号:

喵(^・ェ・^):蟹蟹,已解决,是我多调起了一次
北望沣渭:

支付不成功至少包括两种:`:cancel` 及 `:fail`,你仅捕获了一种,建议回调仅对`:ok`做严格判断,其他全部认为失败,就应该万事大吉了。

喵(^・ェ・^):蟹蟹,已解决,是我多调起了一次

-EOF-

AI助手支持GPT4.0