vue AliPay

作者: 郭先森啊 | 来源:发表于2020-08-10 14:07 被阅读0次

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、支付成功后 返回页面的地址需要后端设置

相关文章

网友评论

    本文标题:vue AliPay

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