0
点赞
收藏
分享

微信扫一扫

Electron 与 外部浏览器 通讯,支付宝支付回调

爱薇Ivy趣闻 2022-03-11 阅读 92

Electron 客户端发起请求传参

 this.$axios.get(`/alipay/pc/bankSale/pay/${this.data.id}`).then((res) => {
          window.shell.openExternal(`${WEB_URL}/aliPayClient?htmlData=` + this.urlEncode(res))
          // this.$router.push({ path: '/aliPay', query: { htmlData: res } })
        })
   urlEncode(str) {
      var s = ''
      if (str.length == 0) {
        return ''
      }
      s = str.replace(/%/g, '%25')
      s = s.replace(/&/g, '%26')
      s = s.replace(/ /g, '%20')
      // s = s.replace(/\\+/g, '%2B')
      // s = s.replace(/\//g, '%2F')
      s = s.replace(/=/g, '%3D')
      s = s.replace(/#/g, '%23')
      return s
    },

web项目正常获取参数即可

<template>
  <!-- <div v-html="payGateWay">{{ payGateWay }}</div> -->
  <div>
    <div v-html="payGateWay"></div>
  </div>
</template>

<script>
export default {
  name: 'AliPay',
  auth: false,
  components: {},
  data() {
    return {
      payGateWay: '支付中请稍后',
    }
  },
  computed: {},
  mounted() {
    this.payGateWay = this.$route.query.htmlData
    console.log('object :>> ', this.payGateWay)
    this.$nextTick(() => {
      document.forms[0].submit()
      // console.log('document.forms[0] :>> ', document.forms)
    })
  },
  methods: {},
}
</script>

<style scoped lang="less"></style>
举报

相关推荐

0 条评论