<template>
    <view class="container">
        <swiper class="swiper square-dot" indicator-color="#D7E3FD" indicator-active-color="#3874F6" :indicator-dots="true"
            :circular="true" duration="500">
            <swiper-item class="swiper-item" v-for="(it, i) in apps" :key="i">
                <navigator :url="item.path" open-type="navigate" class="app" v-for="item in it" :key="item.label">
                    <view class="icon" :style="{ backgroundColor: item.color }">
                        <text class="iconfont" :class="item.icon" style="font-size: 6.400vw;" />
                    </view>
                    <view class="label u-line-1">
                        {{ item.label }}
                    </view>
                </navigator>
            </swiper-item>
        </swiper>
    </view>
</template>

<script>
export default {
    name: 'workbench',
    data() {
        return {
            apps: []
        };
    },
    created() {
        this.rander();
    },
    methods: {
        rander() {
            const clist = ['#5487F7', '#F29C37', '#9A6FF8', '#5AB73F', '#5487F7']
            let authList = uni.getStorageSync('authList'),
                list = [{
                    label: "设备中心",
                    icon: "icon-xunjianzhongxin",
                    path: "/pages/facility/index?page=设备中心"
                }, {
                    label: "巡检中心",
                    icon: "icon-xunjianzhongxin"
                }, {
                    label: "告警中心",
                    icon: "icon-gaojingzhongxin",
                    path: "/pages/alerts/index"
                }, {
                    label: "取水系统",
                    icon: "icon-xunjianzhongxin"
                }, {
                    label: "雨洪系统",
                    icon: "icon-xunjianzhongxin"
                }, {
                    label: "工单",
                    icon: "icon-gongdan",
                    path: "/packageA/workOrder/index"
                }].filter(v => authList[v.label]),
                apps = [];
            for (let i = list.length / 5; i > 0; i--) {
                apps[apps.length] = list.splice(0, 5).map((v, i) => {
                    v.color = clist[i]
                    return v
                })
            };
            this.apps = apps;
        }
    }
}
</script>

<style lang="scss" scoped>
.container {
    width: 355px;
    margin: 0 auto;
    margin-top: 10px;
    background: #fff;
    border-radius: 4px;
    overflow: hidden;

    .swiper {
        height: 96px;

        .swiper-item {
            display: flex;
            margin-top: 5px;
            box-sizing: border-box;
            padding: 0 10px;

            .app {
                width: 68px;
                height: 69px;
                display: flex;
                flex-direction: column;
                align-items: center;
                padding: 5px 0;
                box-sizing: content-box;
                border-radius: 4px;

                .icon {
                    display: flex;
                    justify-content: center;
                    align-items: center;
                    width: 44px;
                    height: 44px;
                    border-radius: 4px;
                    color: #fff;
                }

                .label {
                    font-size: 12px;
                    color: #333333;
                    margin-top: 8px;
                    width: 60px;
                    text-align: center;
                }
            }
        }
    }
}
</style>
