<template>
  <view class="content">
    <u-cell-group>
      <u-cell v-for="(item,index) in baseList" :key="index" isLink :url="item.url">
        <view slot="title">{{ item.title }}</view>
        <view slot="value">
          <u-badge :value="item.NUM"></u-badge></view>
      </u-cell>
    </u-cell-group>
  </view>
</template>

<script>
import {
  getHotWorkRedPoint,
} from "../../../api";

export default {
  data() {
    return {
      baseList: []
    }
  },

  computed: {
    userInfo() {
      return this.$store.getters.getUserInfo
    }
  },
  onShow(event) {
    this.baseList = [
      {
        title: '（港股）安全监督部初审',
        url: '/pages/super-hot/supervision-department/list',
        NUM: 0
      },
      {
        title: '（港股）安委会办公室审批',
        url: '/pages/super-hot/security-committee/list',
        NUM: 0
      },
      {
        title: '（港股安委办主任）安全总监签发',
        url: '/pages/super-hot/safety-director/list',
        NUM: 0
      },
    ]
    this.getRedPoint()
  },
  methods: {

    async getRedPoint() {
      let resData = await getHotWorkRedPoint({USER_ID: this.userInfo.USER_ID});
      if (resData.varList != null && resData.varList.length > 0) {
        for (var i = 0; i < resData.varList.length; i++) {
          if (resData.varList[i].STATE == '35') {
            this.$set(this.baseList[0], 'NUM', resData.varList[i].NUM)
          } else if (resData.varList[i].STATE == '36') {
            this.$set(this.baseList[1], 'NUM', resData.varList[i].NUM)
          } else if (resData.varList[i].STATE == '37') {
            this.$set(this.baseList[2], 'NUM', resData.varList[i].NUM)
          }
        }
      }
    },
    fnNavigator(e) {
      uni.$u.route({
        url: this.baseList[e].url
      })
    }
  },
}
</script>

<style scoped>

</style>
