ViewTabs.vue 8.31 KB
<template>
  <div class="tabs">
    <div class="tab pointer">
      <div
        class="tab-left box"
        @click="changeType('total')"
      >
        <div class="tab-total-box">
          <div class="total-title-box flex">
            <div class="title inline total">客户总数</div>
            <div class="title inline">昨日新增</div>
            <div class="title inline">上月到店</div>
          </div>
          <div class="total-number-box flex">
            <transition-number
              :num="pageData.total.totalNum"
              idKey="number-total"
            />
            <transition-number
              :num="pageData.total.incrNum"
              idKey="number-incr"
            />
            <transition-number
              :num="pageData.total.returnNum"
              idKey="number-return"
            />
          </div>
        </div>
      </div>
      <div class="tab-right box">
        <template v-for="(i,index) in tabs">
          <div
            :key="index"
            class="item flex"
            @click="changeType(i.key)"
          >
            <div class="item-title">{{i.title}}</div>
            <transition-number
              :num="pageData[i.key].totalNum"
              :idKey="`number-${i.key}`"
              class="item-total"
            />
            <div class="item-incr flex">
              上月
              <transition-number
                :num="pageData[i.key].incrNum"
                :idKey="`number-incr-${i.key}`"
                class="item-incr-numer"
              />
            </div>
          </div>
        </template>
      </div>
    </div>
    <div class="tabs-content box">
      <div class="tabs-title">客户增长趋势</div>
      <div class="tabs-content-chart flex">
        <div
          class="line"
          id="total-chart"
        ></div>
        <div class="table user-select pointer">
          <div class="table-head">
            <template v-for="(i,index) in tabHead">
              <div
                :class="['table-head-item flex',{'active':index == tabIndex}]"
                :key="index"
                @click="changeTab(index)"
              >
                {{i}}
              </div>
            </template>
          </div>
          <div class="table-body flex">
            <template v-for="(i,index) in tabIndex == 0 ? pageData[tabType].top : pageData[tabType].last">
              <div
                class="table-body-item flex"
                :key="index"
              >
                <div class="table-num flex">{{index + 1}}</div>
                <div class="table-key">
                  <marquee
                    :direction="directionTimer"
                    :delay="delayTimer"
                    :text="i.name"
                  />
                </div>
                <div class="table-value">{{i.num}}</div>
              </div>
            </template>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script type="text/ecmascript-6">
const tabs = [
  {
    title: '企微客户',
    key: 'wechat'
  },
  {
    title: '企微群数',
    key: 'wechatGroup'
  },
  {
    title: '小程序客户数',
    key: 'applet'
  },
  {
    title: '公众号客户数',
    key: 'publiccus'
  }
]
let tabHead = ['前5品牌', '后5品牌']
import { changeMixin } from '@/mixins'
import * as echarts from 'echarts'
export default {
  name: 'ViewTabs',
  mixins: [changeMixin],
  data () {
    return {
      tabs,
      tabHead,
      tabType: 'total',
      tabIndex: 0,
      delayTimer: 3000,
      directionTimer: 3000,
      pageData: {
        total: {},
        wechat: {},
        wechatGroup: {},
        applet: {},
        publiccus: {}
      }

    }
  },
  mounted () {

  },
  methods: {
    init (params) {
      console.log(params)
      this.getBrandOverallbase('total')
      this.getBrandOverallbase('wechat')
      this.getBrandOverallbase('wechatGroup')
      this.getBrandOverallbase('applet')
      this.getBrandOverallbase('publiccus')
      this.getBrandOveralltrend('total')
    },
    changeType (type) {
      console.log(type)
      this.tabType = type
      this.getBrandOveralltrend(type)
    },
    changeTab (index) {
      this.tabIndex = index
    },
    getBrandOverallbase (queryItem) {
      const params = {
        queryItem,
        queryTime: '2022-06-23',
        corporateGroupName: '集团1',
        queryType: 0
      }
      this.api.overview.getBrandOverallbase(params).then(({ code, data }) => {
        if (code == 0) {
          let [dataList] = data.dataList
          dataList.top = this.ObjectToArray(dataList.topList)
          dataList.last = this.ObjectToArray(dataList.lastList)
          this.pageData[queryItem] = dataList
        }
      })
    },
    ObjectToArray (obj) {
      let arr = []
      obj = JSON.parse(obj)
      Object.keys(obj).map(name => arr.push({ name, num: obj[name] }))
      return arr
    },
    getBrandOveralltrend (queryItem) {
      const params = {
        queryItem,
        querystartTime: '2022-05-23',
        queryendTime: '2022-06-23',
        corporateGroupName: '集团1',
        queryType: 0
      }
      this.api.overview.getBrandOverallbase(params).then(res => {
        console.log(`________________${queryItem}_______________________`, res)
      })
    }
  }
}
</script>

<style scoped lang="scss">
.tabs {
  margin-bottom: 0.6vh;
  .tab {
    height: 7.8vh;
    display: grid;
    grid-template-columns: 41.5% 57.5%;
    justify-content: space-between;
    margin-bottom: 0.5vh;

    .tab-total-box {
      height: 100%;
      padding-left: 8px;
      box-sizing: border-box;
      .total-title-box {
        .total {
          width: 40%;
        }
        > div {
          box-sizing: border-box;
          width: 30%;
          padding-left: 0;
        }
      }
      .total-number-box {
        #number-total {
          font-size: 24px;
          color: #eb6001;
          font-weight: 700;
          line-height: 3.7vh;
          width: 40%;
        }
        > div {
          width: 30%;
          font-size: 14px;
          color: #f5aa01;
        }
      }
    }
    &-right {
      display: grid;
      grid-template-columns: repeat(4, 25%);
      height: 100%;
      .item {
        padding: 0 8px;
        box-sizing: border-box;
        flex-direction: column;
        justify-content: space-between;
        align-items: flex-start;
        &-title {
          font-size: 12px;
          color: #e8e8e8;
          padding-top: 0.5vh;
        }
        &-total {
          font-size: 16px;
          color: #eb6001;
          font-weight: 700;
        }
        &-incr {
          font-size: 12px;
          color: #606266;
          padding-bottom: 0.5vh;
          &-numer {
            font-size: 10.5px;
            color: #e60115;
          }
        }
      }
    }
  }
  &-content {
    height: 24.4vh;
    box-sizing: border-box;
    padding: 1vh 8px;
    display: flex;
    flex-direction: column;
    .tabs-title {
      font-size: 12px;
      color: #e8e8e8;
    }
    &-chart {
      height: 20.2vh;
      margin-top: auto;
      justify-content: space-between;
      gap: 0 8px;
      .line {
        flex: 7;
        background: #022;
      }
      .table {
        flex: 3;
        background: #262525;
        &-head {
          display: grid;
          grid-template-columns: repeat(2, 50%);
          height: 2.4vh;
          &-item {
            height: 100%;
            font-size: 10px;
            background: #353535;
            color: rgba($color: #fff, $alpha: 0.7);
            justify-content: center;
            &:hover {
              opacity: 0.9;
            }
          }
          .active {
            background: #eb6001;
            color: #fff;
          }
        }
        &-body {
          height: calc(100% - 2.4vh);
          flex-direction: column;
          justify-content: space-between;
          &-item {
            line-height: 3.4vh;
            width: 100%;
            font-size: 10px;
            color: #ffffff;
            .table-num {
              width: 22px;
              justify-content: center;
              color: #606266;
            }
            .table-key {
              width: calc(100% - 96px);
            }
            .tab-value {
              width: 52px;
              margin-left: auto;
              padding-right: 4px;
            }
          }
        }
      }
      > div {
        height: 100%;
      }
    }
  }
}
</style>