参考代码 (app支付和网页支付)

recharge: function () {

      if (this.data.rechargeMoneyType === '') {
        Toast('请选择充值类型')
      } else if (this.data.rechargePackageId === '') {
        Toast('请选择充值金额')
      } else if (this.data.rechargeWay === '') {
        Toast('请选择充值方式')
      } else {
        if (!this.disable) {
          return
        }
        this.disable = false
        rechargeService.recharge(this.data.isApp, this.data.rechargeMoneyType, this.data.rechargePackageId, this.data.rechargeWay, this.failCallback, this.successCallback).then(res => {
          if (res.code === 200) {
            this.confirmPlay(res.t, this.data.rechargeWay)
            const div = document.createElement('div')
            div.innerHTML = res.t.formStr
            document.body.appendChild(div)
            document.forms[0].submit()
          }
         // this.$router.go(-1)
        })
      }
    },
    confirmPlay: function (data, type) {
      var url = '/ecom/ecomapp#/RechargeRecord'
      var Url = url ? helpers.makeUrls(url) : ''
      if (this.data.isApp === 'isApp') {
        if (type === 10) {
          let code = '{"type" : 1 , "data" : {"paytype" : "0" , "orderstring" : "' + data.payString + '" , "timestamp" : "" , "sign" : "" , "package" : "" , "partnerid" : "" , "prepayid" : "" , "noncestr" : "" , "returnurl" : "' + Url + '"}}'
          confirm(code)
        }
         // this.$route.push('WithdrawRecord')
      }

    },



核心代码:

const div = document.createElement('div')//创建div
            div.innerHTML = res.t.formStr//将返回的form 放入div
            document.body.appendChild(div)
            document.forms[0].submit()

Logo

前往低代码交流专区

更多推荐