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

小游戏 企业微信 微信支付 小程序 文章 2020-07-30 21:12 765 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


国内超级便宜服务器

摸鱼人热门新闻聚合

钻级赞助商 我要加入

开发者在线工具

第三方支付技术请加QQ群

相关文章
微信H5支付 系统繁忙请稍后再试?
kbone. ScrollView中 scroll-into-view小程序中无效?
为什么cocos creator发布的游戏在微信小游戏开发工具的真机调试下报4930错误?【已解决】
企业微信与微信静默登录不互通吗?微信公众号网页分享给企业微信,企业微信打开提示【请在微信中打开】。
微信登录,用来扫码授权的二维码有效期多久
随便看看
组件内为什么不能跳转页面? 613
超级链提示报错这个问题怎么解决啊?,没办法加链接,是已认证用户 607
wx.login这个API 为什么我不调用后端接口就可以拿到code? 879
只有小程序原始id和名称怎么找回小程序账号密码? 762
小程序/wxa/getwxacodeunlimit? 1973
更新了开发工具,上传代码pages/index/index.js, file not found? 1606
不同主体不同应用(公众号、小程序、企业微信等)下面用户的openid会不会一样? 1821
wx.login可以获取其他手机号的openId吗? 713
image无法在真机显示部分本地图片(getLocalImgData:fail get file)? 928
wx.request fail返回请求超时? 1434