<template>
    <div>
        <header class="comhead incomhead">
            <!-- <a class="searchbtn" href="javascript:void(0);">
                <img src="@/assets/images/icon/search01.png" alt />
            </a> -->
            <h2>
                <span @click="OnCategoryClick()">{{now.TITLE}}</span>
            </h2>
        </header>
        <div class="comheadbg"></div>

        <!--身高 弹出层-->
        <aside class="winbox subjectupbox" :style="{display:showWin?'block':'none'}">
            <div class="winclick" @click="OnCategoryClick()"></div>
            <div class="subjectup">
                <a class="" @click="OnItemClick(item)" :class="item.ID==now.ID?'sel':''" v-for="item in lsCategory" :key="item.ID">{{item.TITLE}}</a>
            </div>
        </aside>
    </div>
</template>
<script>
export default {
    data(){
        return {
            lsCategory:[],
            showWin:false,
            now:{
                TITLE:'',
                ID:''
            }
        }
    },
    mounted(){
        this.ComOnLoad()
    },
    methods:{
        ComOnLoad(){
            var that=this;
            that.$ajax.post({
                url:'/api/webapi/home/categoryGetList',
                success:(_res)=>{
                    that.lsCategory=_res.lsCategory;
                 
                    var nowid=window.localStorage.getItem('jtk_category_id') || '';
                    for(var i=0;i<_res.lsCategory.length;i++) {
                        if(_res.lsCategory[i].ID==nowid) {
                            that.now={
                                ID:nowid,
                                TITLE:_res.lsCategory[i].TITLE
                            }
                            break;
                        }
                    }
                }
            })
        },
        OnCategoryClick(){
            this.showWin=!this.showWin;
        },
        OnItemClick(_item) {
            window.localStorage.setItem('jtk_category_id',_item.ID);
            this.showWin=false;
            this.now=_item;
            this.$emit('OnCategoryChange',_item)
        }
    }
}
</script>