<template>
    <view class="main">
        <view class="heard">
            <image class="headerBg" src="/static/images/examine/bg.png"></image>
            <view class="content">
                <!--  顶部标题  -->
                <view class="top" :style="{height:menu.bottom+'px'}">
                    <view class="titleModule" :style="{height:(menu.bottom-menu.top)+'px'}">
                        <image class="img" src="https://eshangtech.com/ShopICO/ahyd-BID/commercial/navigation-left.svg"></image>
                        <text class="title">考评考核</text>
                    </view>
                </view>
                <!--  选择片区  -->
                <div class="picker">
                    <div class="selectService" @click="handleShowPopup">
                        <image class="img" src="/static/images/examine/fixed.svg"></image>
                        <view class="select">
                            <view class="selectContent">
                                <view class="name">皖中</view>
                                <p class="area">片区</p>
                                <image class="rightArrow" src="https://eshangtech.com/ShopICO/ahyd-BID/commercial/rightArrow.svg"></image>
                            </view>
                        </view>
                    </div>
                </div>
                <!--  选择月份  -->
                <view class="monthTabs">
                    <scroll-view class="big" :show-scrollbar="false" scroll-with-animation  scroll-x="true" enable-flex :scrollIntoView="current" >
                        <div :id="'item'+item.value" :class="selectMonth===item.value?'monthItem selectItem':'monthItem'" v-for="(item,index) in monthList" :key="index" @click="handleSelectMonth(item.value)">{{item.label}}</div>
                    </scroll-view>
                </view>
            </view>
        </view>

        <view class="content">
            <view class="tab">
                <view :class="selectTab===item.value?'tabItem selectItem':'tabItem'" v-for="(item,index) in tabList" :key="index" @click="handleChangeTab(item.value)">{{item.label}}</view>
            </view>

            <view class="serviceList">
                <view class="serviceItem">
                    <view class="itemTitle">
                        <text class="title">新桥服务区</text>
                        <text class="unit">月度</text>
                    </view>
                    <view class=""></view>
                </view>
            </view>
        </view>

        <uniPopup type="bottom" :round="true" :show="showPop" @hidePopup="hidePopup">
            <view class="popup">
                <view class="top">
                    <text class="popupTitle">选择片区</text>
                    <image class="close" src="/static/images/examine/close.svg"></image>
                </view>
                <view class="list">
                    <view class="item" v-for="(item,index) in areaList" :key="index">{{item.label}}<text class="unit">片区</text></view>
                </view>
            </view>
        </uniPopup>
    </view>
</template>
<script>
import uniPopup from '@/components/uni-popup'
export default {
    components:{
        uniPopup
    },
    data(){
        return {
            monthList:[{label:'1月',value:1},{label:'2月',value:2},{label:'3月',value:3},{label:'4月',value:4},{label:'5月',value:5},{label:'6月',value:6},{label:'7月',value:7},
                {label:'8月',value:8},{label:'9月',value:9},{label:'10月',value:10},{label:'11月',value:11},{label:'12月',value:12}],
            selectMonth:0,
            current:'',
            menu:{},
            statusBarHeight:'',
            showPop:false,
            areaList:[{label:'皖中',value:'皖中'},{label:'皖中',value:'皖中'},{label:'皖中',value:'皖中'}],// 片区列表
            tabList:[{label:'考核管理',value:1},{label:'日常巡检',value:2},{label:'晨会管理',value:3}],// tab选项卡
            selectTab:1,// 选中的tab选项卡
            serviceList:[],// 服务区列表
        }
    },
    onLoad(){
        //  获取手机参数对页面进行适配
        let systemInfo = uni.getSystemInfoSync()
        this.statusBarHeight = Number(systemInfo.statusBarHeight)
        this.menu = uni.getMenuButtonBoundingClientRect()
        console.log('this.menu',this.menu)
        const date = new Date()
        let month = date.getMonth() + 1
        this.monthList = this.monthList.filter(item=>item.value<=month)
    },
    onReady(){
        var _this = this;
        _this.getThisMonth()
    },
    methods:{
        // 拿到当前月份 用于页面一开始自动滚动到相对应的月份
        getThisMonth(){
            const date = new Date()
            const month = date.getMonth() + 1
            this.selectMonth = month
            this.current='item'+month
            console.log('this.current',this.current)
        },
        // 是否显示弹出框
        handleShowPopup(){
            this.showPop = true
        },
        // 弹出框点击蒙层关闭
        hidePopup(){
            this.showPop = false
        },
        // 点击月份改变选中月份
        handleSelectMonth(value){
            this.selectMonth = value
        },
        // 点击选项卡改变选项卡
        handleChangeTab(value){
            this.selectTab = value
        }
    }
}

</script>
<style scoped lang="scss">
@import '/static/public/font/stylesheet.css';

.main{
    width: 100%;
    .heard{
        width: 100%;
        height: 366px;
        position: relative;
        .content{
            width: 100%;
            height: 100%;
            position: absolute;
            box-sizing: border-box;
            padding: 0 16px;
            top: 0;left: 0;
            z-index: 2;
            .top{
                width: 100%;
                position: relative;
                .titleModule{
                    width: 100%;
                    bottom: 0;
                    position: absolute;
                    display: flex;
                    justify-content: center;
                    .img{
                        width: 24px;
                        height: 24px;
                        position: absolute;
                        left: 0px;
                    }
                    .title{
                        font-size: 18px;
                        font-family: PingFangSC-Medium, PingFang SC;
                        font-weight: 500;
                        color: #FFFFFF;
                        line-height: 28px;
                    }
                }
            }
            .picker{
                .selectService{
                    display: flex;
                    align-items: center;
                    .img{
                        width: 40px;
                        height: 40px;
                        z-index: 2;
                    }
                    .select{
                        height: 32px;
                        min-width: 110px;
                        background: #F8F8FA;
                        border-radius: 0 16px 16px 0;
                        transform: translateX(-20px);
                        box-sizing: border-box;
                        padding-left: 25px;
                        display: flex;
                        align-items: center;
                        position: relative;
                        .selectContent{
                            display: flex;
                            align-items: center;
                            .name{
                                font-size: 14px;
                                font-family: PingFangSC-Semibold, PingFang SC;
                                font-weight: 600;
                                color: #160002;
                            }
                            .area{
                                font-size: 12px;
                                font-family: PingFangSC-Regular, PingFang SC;
                                font-weight: 400;
                                color: #786B6C;
                                margin-left: 2px;
                            }
                            .rightArrow{
                                position: absolute;
                                right: 2px;
                                width: 24px;
                                height: 12px;
                            }
                        }

                    }
                }
            }
            .monthTabs{
                width: 100%;
                height: 32px;
                border-radius: 17px;
                box-sizing: border-box;
                border: 1px solid #BF99FE;
                background: linear-gradient(180deg, #8338FF 0%, #A976FF 100%);
                overflow: hidden;
                padding: 2px 0;
                margin-top: 16px;
                .big{
                    text-align: center;
                    white-space: nowrap;
                    .monthItem{
                        display: inline-block;
                        width: 55px;
                        height: 24px;
                        font-size: 14px;
                        font-family: PingFangSC-Semibold, PingFang SC;
                        font-weight: 600;
                        color: #B8C2FF;
                        line-height: 24px;
                        margin-right: 4px;
                        text-align: center;
                        border-radius: 12px;
                    }
                    .selectItem{
                        background: #fff;
                    }
                    .monthItem:first-child{
                        margin-left: 4px;
                    }
                }
            }
        }
        .headerBg{
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: 1;
        }
    }
    .content{
        width: 100%;
        height:200px;
        box-sizing: border-box;
        padding: 16px 16px 0;
        border-top-left-radius: 16px;
        border-top-right-radius: 16px;
        .tab{
            width: 100%;
            height: 38px;
            background: #F3F1F5;
            border-radius: 4px;
            box-sizing: border-box;
            padding: 4px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            .tabItem{
                width: 33%;
                height: 100%;
                font-size: 14px;
                font-family: PingFangSC-Regular, PingFang SC;
                font-weight: 400;
                color: #786B6C;
                text-align: center;
                line-height: 30px;
            }
            .selectItem{
                background: #fff;
                font-size: 14px;
                font-family: PingFangSC-Semibold, PingFang SC;
                font-weight: 600;
                color: #8441F3;
                border-radius: 4px;
            }
        }
        .serviceList{
            width: 100%;
            background: url("https://eshangtech.com/ShopICO/ahyd-BID/examine/serviceItemBg.svg")no-repeat;
            background-size: contain;
            .serviceItem{
                width: 100%;
                height: 270px;
                box-sizing: border-box;
                padding: 16px;
                border-radius: 8px;
                margin-top: 12px;
                .itemTitle{
                    display: flex;
                    align-items: center;
                    .title{
                        font-size: 18px;
                        font-family: AlimamaShuHeiTi;
                        color: #33077A;
                        line-height: 26px;
                    }
                    .unit{
                        font-size: 12px;
                        font-family: PingFangSC-Regular, PingFang SC;
                        font-weight: 400;
                        color: #3B48E3;
                        line-height: 12px;
                        padding: 3px 4px;
                        background: rgba(59, 72, 227, 0.1);
                        margin-left: 8px;
                        border-radius: 2px;
                    }
                }
            }
        }
    }
    .popup{
        width: 100%;
        height: 60vh;
        box-sizing: border-box;
        padding: 16px;
        .top{
            width: 100%;
            display: flex;
            align-items: center;
            justify-content: space-between;
            .popupTitle{
                font-size: 16px;
                font-family: PingFangSC-Semibold, PingFang SC;
                font-weight: 600;
                color: #160002;
                line-height: 22px;
            }
            .close{
                width: 20px;
                height: 20px;
            }
        }
        .list{
            width: 100%;
            margin-top: 12px;
            .item{
                width: 100%;
                font-size: 14px;
                font-family: PingFangSC-Semibold, PingFang SC;
                font-weight: 600;
                color: #160002;
                line-height: 20px;
                text-align: left;
                padding:12px 0;
                .unit{
                    font-size: 12px;
                    font-family: PingFangSC-Regular, PingFang SC;
                    font-weight: 400;
                    color: #786B6C;
                    line-height: 18px;
                }
            }
        }
    }
}
</style>
