<template>
<div>

    <common @asynCallBack="asynCallBack"></common>
    <top-header :pageTitle="pageTitle"  :routeName="routeName"  ></top-header>

    <div class="mui-content">
        <div class="mui-content-padded">
            <img src="~$project/assets/img/03.jpg" width="100%"/>
        </div>
    </div>
    <div class="fyy-footer">
      <div class="bindfyy-btn">
        <button type="submit" class="mui-btn mui-btn-pink"   @click="toPay()" v-text="paytext">开通服务</button>
      </div>
    </div>
    <loading :visible="isLoading"></loading>

</div>
</template>


<script>

    import * as API  from '@/apis/Master/live'
    import Common from '$project/components/Common.vue'
    import Loading from '$project/components/Loading.vue'
    import TopHeader from '$project/components/TopHeader.vue'
    import {
        mapGetters,
        mapMutations
    } from 'vuex'
    import {
        currentTimeStamp,
        parseUnixTime
    } from '$project/utils'
    export default {
        name: 'GuestFromInfo',
        components: {
            Common,
            Loading,
            TopHeader
        },
        data() {
            return {
                pageTitle: '产品介绍',
                routeName: "MasterLiveInfo",

                isLoading: false,
                 paytext: "点击购买",
                orderId: null,
                id: this.$route.query.id,

                detail: {
                    order: {},
                    info: null,
                    list: []
                },
            }
        },
        created() {
             //接收参数来实现返回的页面是哪一种
            if (this.$route.query.routeName) {
                this.routeName = this.$route.query.routeName;
            }
        },
        methods:  {

            toPay() {
                this.isLoading = true;

                API.submit({
                    "personId": this.person_data.id,
                    "payPersonId": this.person_data.id,
                }).then(data => {

                    var url = window.location.href.split("#")[0];
                    var param = JSON.stringify(data).replace("{", "").replace("}", "").replace(/\",\"/g, "&").replace(/,\"/g, "&").replace(
                        /:/g, "=").replace(/\":\"/g, "=").replace(/\"/g, "");
                    param = param.replace('=//', '://');
                    window.location = url + "?#/master/live/pay?" + param;

                }).catch(error => {
                    this.isLoading = false;
                    mui.toast(error);
                })


            },asynCallBack(){},
        },
        mounted() {

         },
        destroyed() {

        },
        computed: {
            ...mapGetters({
                openId: 'wx_openid',
                token: 'token',
                person_data: 'person_data',
                person_popedom: 'person_popedom',
            })
        }
    }
</script>

<style scoped src="$project/assets/css/pension.css"></style>
<style scoped src="$project/assets/css/xpwyfyy.css"></style>
<style src="$project/assets/css/iconfont.css"></style>
<style>
</style>
