<template name="basics">
    <view>
        <cu-custom class="home-custom" bgColor=".bg-sancolor"
                   bgImage="https://ahwgh.oss-cn-hangzhou.aliyuncs.com/enterprise/6525f808df760.png" :isBack="true">
            <view slot="backText">返回</view>
            <block slot="content">第三方检测</block>
        </cu-custom>
        <scroll-view scroll-y class="page">
            <view class="nav-list" style="margin-top: 40upx;">
                <view hover-class="none" @tap="toNextPage" :data-path="item.path" class="nav-li"
                      :class="'bg-'+item.color"
                      :style="[{animation: 'show ' + ((index+1)*0.2+1) + 's 1'}]" v-for="(item,index) in elements"
                      :key="index">
                    <view class="nav-title">{{ item.title }}</view>
                    <view class="nav-name">{{ item.subTitle }}</view>

                </view>
            </view>
        </scroll-view>
    </view>
</template>

<script>

    export default {
        data() {
            return {
                elements: [
                    {
                        title: "监督抽查",
                        name: "layout",
                        color: "green",
                        subTitle: "监督",
                        path: "/pages/sample-check-list/index"
                    },
                    {
                        title: "例行监测",
                        name: "background",
                        color: "mauve",
                        subTitle: "例行",
                        path: "/pages/zf-task-list/taskList"
                    }
                ]
            };
        },
        onShow() {
            /**/
            const userInfo = uni.getStorageSync("userInfo");
            if ((userInfo.level !== "乡镇级" && userInfo.person_group !== "组长") && this.elements.length === 1) {
                this.elements.push({
                    title: "网格员审核",
                    name: "background",
                    color: "red",
                    subTitle: "Review",
                    path: "/pages/grid/view"
                });
            }
        },
        methods: {
            toNextPage(e) {
                // console.log();
                //判断有没有登录，没有登录直接跳到登录，登录了 跳到任务详情
                uni.navigateTo({
                    url: e.currentTarget.dataset.path
                });
            }
        }
    };
</script>