zoukankan      html  css  js  c++  java
  • Vue 手机端支付宝支付

    <template>
        <div v-html="payHtml">{{payHtml}}</div>
    </template>
    
    <script>
        import {skl_postInitiateOrder} from "../../../serve/api";
        import Cookies from "js-cookie";
        import {Toast} from "vant";
    
        export default {
            name: "payHtml",
            data(){
                return{
                    payHtml: '',
                    addId:''
                }
            },
            mounted(){
                this.addId = this.$route.params.addr_id;
               // alert(this.addId);
                this.Pay();
            },
            methods:{
                async Pay(){
                    //alert("456");
                    let res = await skl_postInitiateOrder(接口参数);//skl_postInitiateOrder 接口方法
                    if(res.error == 0) {
                        let form = res.info;
                        this.payHtml = form;
                        this.$nextTick(() => {
                            document.getElementById('alipaysubmit').submit()
                           // document.forms["alipaysubmit"].submit();    //渲染支付宝支付页面
                        })
                    }
                    else {
                        //alert("2");
                        Toast({
                            message: "支付失败",
                            duration: 1000
                        });
                    }
                },
            },
            destroyed: function () {//离开时销毁
                console.log("我已经离开了!");
                //this.stopTimer();
                this.$router.push('/order/payresult');
            }
    
        }
    </script>
    

      

  • 相关阅读:
    信号
    序列化数据的两种方式
    ModelForm的使用
    分页模板
    Django中间件进行用户登陆验证
    Flask 笔记一
    pipenv 使用基本命令
    git本地文件 上传 远程仓库
    service "$service" status 返回的状态
    &>/dev/null 的作用
  • 原文地址:https://www.cnblogs.com/syeacfpl/p/13724818.html
Copyright © 2011-2022 走看看