<template>
    <div :class="iosX?'iosX':''">
        <div class="comfootbg"></div>
        <footer class="comfoot">
            <div class="tabfix w100">
                <nav>
                    <a v-for="item in list" :key="item.id" :class="{'sel':item.id==sel}" @click="GotoLink(item)">
                        <p>{{item.title}}</p>
                    </a>

                </nav>
            </div>
        </footer>
    </div>
</template>
<script>
export default {
    name:'Footer',
    data(){
        return {
            list:[
                {id:1,name:'home',title:'首页',link:'/'},
                {id:2,name:'cls',title:'课程',link:'/curriculum'},
                {id:3,name:'artisan',title:'匠人圈',link:'/qa'},
                {id:4,name:'user',title:'我的',link:'/user'},
            ],
            iosX:false
        }
    },
    props:{
        //选中
        sel:{
            type:Number,
            default:0
        }
    },
    mounted(){
        //iphoneX适配
        this.iosX=window.isIosX || false;
    },
    methods:{
        removeURLParameter(url, parameter,_hash) {
            var urlparts = url.split('?');
            if(urlparts.length >= 2) {
                //参数名前缀
                var prefix = encodeURIComponent(parameter) + '=';
                var pars = urlparts[1].split(/[&;]/g);
                //循环查找匹配参数
                for(var i = pars.length; i-- > 0;) {
                    if(pars[i].lastIndexOf(prefix, 0) !== -1) {
                        
                        //存在则删除
                        pars.splice(i, 1);
                    }
                }
                var result=urlparts[0] + (pars.length > 0 ? '?' + pars.join('&') : '');
                return result
            }
            return url;
        },
        GotoLink(_item){
            if(_item.link.length<=0 || _item.id==this.sel) {
                return;
            }
            this.$router.push(_item.link)
        }
    }
}
</script>