美文网首页
vue AliPay

vue AliPay

作者: 郭先森啊 | 来源:发表于2021-09-06 10:19 被阅读0次
关注公众号【Miles】查看更多技术文档

相关链接:https://t.1yb.co/DeZ6

1、确认接口返回值 赋给 this.$router.replace({path: '/aliPay', query: {data: resp.data.data.data}}); 跳转aliPay支付页面

/ /确认支付

Pay(){

  toPay({ }).then( resp =>{

    if (resp.data.code == 0) {

      this.$router.replace({path: '/aliPay', query: {data: resp.data.data.data}});

    }

  })

}

2、唤起支付宝页面 单独页面 aliPay(index.vue)

<template>

<div v-html="html"></div>

</template>

<script>

export default {

    data() {

        return {

            html: ''

        }

    },

    methods: {

        fetchVideoPay() {

            this.html = this.$route.query.data;

            this.$nextTick(() => {

                document.forms[0].submit()   //渲染支付宝支付页面

            })

        }

    },

    mounted() {

        this.fetchVideoPay()

    }

}

</script>

3、支付成功后 返回页面的地址需要后端设置

方案2:

发起支付请求 返回结果直接赋值在下方代码

document.querySelector('body').innerHTML = resp.data.data //查找到当前页面的body,将后台返回的form替换掉他的内容

document.forms[0].submit()

方案3:https://www.cnblogs.com/darkerxi/p/10725243.html

方案4:https://www.jianshu.com/p/201dab4d9659

相关文章

网友评论

      本文标题:vue AliPay

      本文链接:https://www.haomeiwen.com/subject/podewltx.html