<template>
    <view class="second-class dir-left-nowrap">
        <view class="spring-board" v-if="switchBool">
            <view class="ollapse main-right" @click="switchBool = false">
                <image src="./image/ollapse.png" class="ollapse-icon"></image>
            </view>
            <view class="ollapse-view">
                <text class="item" v-for="(it, key) in list" :key="key"  :class="{'active': key === activeIndexTwo}" @click="setNav(it, key)">
                    {{it.name}}
                </text>
            </view>
        </view>
        <scroll-view scroll-x
                     v-if="!switchBool"
            class="left dir-left-nowrap main-center"
        >
            <view>
                <text class="item" v-for="(it, key) in list" :key="key" :class="{'active': key === activeIndexTwo}" @click="setNav(it, key)">
                    {{it.name}}
                </text>
            </view>
        </scroll-view>
        <view class="right" v-if="!switchBool" @click="switchBool = true">
            <image src="./image/expand.png" class="icon"></image>
        </view>
    </view>
</template>

<script>
    export default {
        name: "second-class",

        props: ['list', `activeIndexTwo`],

        data() {
            return {
                switchBool: false
            }
        },

        methods: {
            setNav(it, key) {
                this.$emit('setNav',it, key);
            }
        }
    }
</script>

<style scoped lang="scss">
    .second-class {
        position: relative;
        height: #{106upx};
        width: #{528upx};
        background-color: #ffffff;
    }
    .left {
        width: #{448upx};
        white-space: nowrap;
        vertical-align: center;
        background-color: #ffffff;
        line-height: #{106upx};
    }
    .right {
        width: #{80upx};
        height: #{106upx};
        position: relative;
        box-shadow: #{-1upx 0 5upx -5upx} rgba(0, 0, 0, .2);
    }
    .item {
        display: inline-block;
        font-size: #{24upx};
        height: #{54upx};
        line-height: #{54upx};
        padding: #{0 24upx};
        border: #{1upx} solid #cccccc;
        border-radius: #{34upx};
        margin-right: #{16upx};
    }
    .icon {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: #{56upx};
        height: #{56upx};
    }
    .ollapse {
        height: #{106upx};
        width: #{528upx};
        position: relative;
    }
    .ollapse-icon {
        position: absolute;
        top: 50%;
        right: #{12upx};
        width: #{56upx};
        height: #{56upx};
        transform: translateY(-50%);
    }
    .ollapse-view > text {
        margin-bottom: #{20upx};
    }
    .spring-board {
        position: absolute;
        top: 0;
        left: 0;
        width: #{528upx};
        z-index: 1000;
        background-color: #ffffff;
    }
    .active {
        color: #ff4544;
        border: #{1rpx} solid #ff4544;
    }
</style>