<style>
@import url('../assets/views/index.css');
</style>

<template>
    <div class="home-box" v-if="isPhone">
        <!-- <mallHead msg="" @forword='goUrl("2-1")' @siteCity="siteCity"/> -->
        <newHead @siteCity="siteCity" @GetCityId="GetCityId"/>
        <div :style='{"min-height":minHeight+"px"}'>
            <transition name="slide">
                <router-view v-if="CityId" :changeCity='changeCity'></router-view>
            </transition>
        </div>
        <foot />
    </div>
    <div v-else>
        <img width="100%;" src="../assets/img/Phone.jpg" alt="">
    </div>
</template>
<script>
import mallHead from '@/components/global/head.vue'
import newHead from '@/components/global/newHead.vue'
import foot from '@/components/global/foot.vue'
export default {
    components: {
        mallHead,
        foot,
        newHead,
    },
    data () {
        return {
            minHeight:0,
            changeCity:null,
            isPhone:false,
            CityId:false,
        }
    },watch: {  // 监听参数变化
        changeCity: {
            handler: function(val, oldVal) {
                // console.log(val+'watch')
                this.changeCity = val
            },
            deep: true
        },
    },
    mounted () {
        if (this.$route.name === 'index') {
            this.$router.push({path: 'Home'})
        }
        //this.loadSize()
        //this.goUrl('2-1')
        //this.minHeight=document.documentElement.clientHeight-171
        this.minHeight=document.documentElement.clientHeight-400

        console.log(this.minHeight)
        let userAgentInfo = navigator.userAgent;
        let Agents = ["Android", "iPhone",
                    "SymbianOS", "Windows Phone",
                    "iPad", "iPod"];
        this.isPhone = true;
        for (let v = 0; v < Agents.length; v++) {
            if (userAgentInfo.indexOf(Agents[v]) > 0) {
                this.isPhone = false;
                break;
            }
        }
        return this.isPhone;
    },
    methods: {
        GetCityId(val){
            this.CityId=true;
        },
        siteCity(key) {
            // console.log(key+'methods')
            this.changeCity = key;
        },
        goUrl(index) {
            console.log(index)
            let path=''
            if(index=='2-1'){
                path='/Home'
            }
            if(index=='3'){
                path='/TicketHome'
            }
            if (path != "") {
                this.$router.push({ path });
                
            }else{
                let query={}
                this.$router.push({
                    path:'/coding',
                    query
                });
            }
        }
    }

}
</script>
