<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>