<template>
  <view>
    <AreaWrapper v-if="!loading" :areaSpecialAreaList="areaSpecialAreaList" />
    <cl-tabbar :current="2"></cl-tabbar>
  </view>
</template>

<script>
import clTabbar from '@/components/cl-tabbar.vue'
import AreaWrapper from '@/components/area-wrapper/index.vue'
import { REGIEST, UPGRADE } from '@/util/specialAreaMap'
import { mapActions } from 'vuex'
export default {
  components: {
    'cl-tabbar': clTabbar,
    AreaWrapper,
  },
  computed: {},
  data() {
    return {
      areaSpecialAreaList: [],
      visible: false,
      loading: true,
    }
  },
  onLoad(options) {
    this.init()
  },
  onShow() {},
  onHide() {},
  beforeDestroy() {},
  methods: {
    ...mapActions(['getSpecialAreaAuth']),
    init() {
      uni.showLoading({
        title: '加载中...',
      })
      this.getSpecialAreaAuth()
        .then(specialAreaList => {
          if (specialAreaList.includes(REGIEST.menuKey)) {
            this.areaSpecialAreaList.push(REGIEST)
          }
          if (specialAreaList.includes(UPGRADE.menuKey)) {
            this.areaSpecialAreaList.push(UPGRADE)
          }
        })
        .finally(() => {
          this.loading = false
          this.$nextTick(() => {
            uni.hideLoading()
          })
        })
    },
  },
}
</script>
