UserTab.vue 4.28 KB
<template>
  <div class="user-tab">
    <StatisticsBox class="user" :list="userData"></StatisticsBox>
    <!-- <template v-for="(tab, index) in userData">
      <div :class="['tab-item', { active: selectIndex == index }]" :key="index" @click="getTrend(tab.view, tab.text)">
        <div class="tab-title">{{ tab.text }}</div>
        <div class="tab-count text-linear">{{ numAddSymbol(dataList[tab.value]) }}</div>
        <div class="tab-increase flex-between">
          <div class="increase-text">当年新增</div>
          <div class="increase-count">{{ numAddSymbol(dataList[tab.key]) }}</div>
        </div>
      </div>
    </template> -->
  </div>
</template>

<script>
const TEXT_VIEW = [
  {
    name: '用户数',
    valueName: 'totalnum',
    value: '15,351,2',
    bottomLabel: '当年新增',
    bottemName: 'increnum',
    bottomValue: '7,329,2'
  },
  {
    name: '企微客户数',
    valueName: 'totalwechatnum',
    value: '15,351,2',
    bottomLabel: '当年新增',
    bottemName: 'increwechatnum',
    bottomValue: '7,329,2'
  },
  {
    name: '企微群数',
    valueName: 'totalwechatgroupnum',
    value: '15,351,2',
    bottomLabel: '当年新增',
    bottemName: 'increwechatgroupnum',
    bottomValue: '7,329,2'
  },
  {
    name: '小程序',
    valueName: 'totalappletnum',
    value: '15,351,2',
    bottomLabel: '当年新增',
    bottemName: 'increappletnum',
    bottomValue: '7,329,2'
  },
  {
    name: '个微客户数',
    valueName: 'totalsinglewechantnum',
    value: '15,351,2',
    bottomLabel: '当年新增',
    bottemName: 'incresinglewechantnum',
    bottomValue: '7,329,2'
  }
]
export default {
  name: 'UserTab',
  data() {
    return {
      dataList: TEXT_VIEW,
      userData: TEXT_VIEW,
      selectIndex: 0
    }
  },
  async created() {
    await this.getoverview()
    this.getTrend('total', '用户数')
  },
  methods: {
    getoverview() {
      this.api.operational.getoverview().then(res => {
        if (res.code === '0') {
          const _data = res.data.dataList[0]
          this.dataList.forEach(item => {
            item.value = _data[item.valueName]
            item.bottomValue = _data[item.bottemName]
          })
        }
      })
    },

    getTrend(queryItem, name) {
      const selectIndex = TEXT_VIEW.findIndex(item => item.text === name)
      if (selectIndex > 2) return
      this.selectIndex = selectIndex
      const params = { req: { queryItem }}
      this.api.operational.getTrend(params).then(res => {
        console.log(res);
        if (res.code === '0') {
          const dataList = res.data.dataList
          const obj = {
            dataList,
            name
          }
          this.$bus.$emit('drawPrivateChart', obj)
        }
      })
    }
  }
}
</script>
<style scoped lang="scss">
.user-tab {
  width: 100%;
  height: 9.02vh;
  margin: 1.46vh 0 0.98vh 0;
  /deep/ {
    .statistics {
      height: 9.51vh;
      .statistics-name {
        margin-bottom: 0;
      }
      .statistics-bottom {
        margin-top: 0;
      }
    }
  }
  .tab-item {
    cursor: pointer;
    width: 9.65vw;
    height: 9.02vh;
    background: #0b0e31;
    margin-right: 0.28vw;
    padding: 0.28vh 0;
    box-sizing: border-box;
    &.active {
      border: 1px solid #6578ff;
      position: relative;
      &::after {
        content: '';
        position: absolute;
        bottom: -4px;
        left: 50%;
        height: 6px;
        width: 6px;
        margin-left: -3px;
        background: #0b0e31;
        border-bottom: 1px solid #6578ff;
        border-right: 1px solid #6578ff;
        transform: rotate(45deg);
      }
    }
    .tab-title {
      font-weight: 400;
      font-size: 12px;
      color: #e8e8e8;
      margin: 0 0.69vw;
      height: 2.07vh;
    }
    .tab-count {
      font-weight: 700;
      font-size: 22px;
      margin: 0 0.69vw;
      height: 3.8vh;
      line-height: 3.8vh;
    }
    .tab-increase {
      height: 2.44vh;
      border-top: 1px solid #171f60;
      padding: 0 0.69vw;
    }
    .increase-text {
      font-size: 9px;
      color: #dddddd;
    }
    .increase-count {
      font-weight: 700;
      font-size: 12px;
      color: #ffffff;
    }
  }
}
</style>