<template>
    <Cn-page :loading="loading" noPadding>
        <view slot="body">
            <view class="index">
                <!-- 运维 -->
                <YunWei v-if="userInfo.authorities === 'operation_manager'" />
                <!-- 专职 -->
                <ZhuanZhi v-if="userInfo.authorities === 'market_user'" />
                <!-- 工程 -->
                <GongCheng v-if="userInfo.authorities === 'engineering_user'" />
                <!-- 主用户 -->
                <ZhuYongHu v-if="userInfo.authorities === 'app_vip_user'" />
                <YouKe v-if="userInfo.authorities === 'tourist'"> </YouKe>
                <Device ref="device" :store="store" />
            </view>
        </view>
    </Cn-page>
</template>
<script>
import YunWei from './comp/indexYunWei.vue'
import GongCheng from './comp/indexGongCheng.vue'
import ZhuYongHu from './comp/indexZhuYongHu.vue'
import ZhuanZhi from './comp/indexZhuanZhi.vue'
import YouKe from './comp/indexYouKe.vue'
import Device from './comp/device.vue'
import list from '../../common/js/list'

export default {
    mixins: [list],
    components: {
        YunWei,
        GongCheng,
        ZhuYongHu,
        ZhuanZhi,
        YouKe,
        Device,
    },
    data() {
        return {
            loading: false,
            userInfo: {},
        }
    },
    methods: {
        send() {
            uni.createPushMessage({
                title: '灿能',
                content: '灿能推送',
                success: function (res) {
                    console.log('推送成功')
                },
                fail: function (res) {
                    console.log('推送失败')
                },
            })
        },
        loadingChange(e) {
            this.loading = e
        },
    },
    onLoad() {
        this.store = this.DataSource('/cs-device-boot/EquipmentDelivery/queryEquipmentByProject')
    },
    onShow() {
        this.userInfo = uni.getStorageSync(this.$cacheKey.userInfo)
        if (
            this.userInfo.authorities === 'app_vip_user' ||
            this.userInfo.authorities == 5 ||
            this.userInfo.authorities === 'tourist'
        ) {
            uni.setTabBarBadge({
                index: 1,
                text: '6',
            })
        }
        this.$refs.device && this.$refs.device.init()
    },
}
</script>
<style lang="scss">
.index {
    padding: 34rpx 0 0;
}

/deep/ .uni-card {
    background: $uni-theme-white;
}
</style>
