ViewTabs.vue 6.51 KB
<template>
  <div class='tabs'>
    <div class='tab pointer'>
      <div class='tab-left box'>
        <div :class="{ 'tab-total-box': true }">
          <div class='total-title-box flex'>
            <div class='title inline total'>已开通门店
              <!--              <transition-number :num='dataOverView.openedStores' class='number-total' />-->
              <div class='number-total' v-if='dataOverView'>{{ toThousands(dataOverView.openedStores) }}</div>
            </div>
            <div
              :class="{'title':true,'inline':true, 'active': tabIndex == index}"
              v-for='(item,index) in tabTitleList'
              @click='clickItemTab(index,item)'
              :key='index'>{{ item.title }}
              <div class='flex' v-if='dataOverView'>
                <div class='transition-number'>{{ toThousands(dataOverView[item.type]) }}</div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class='tabs-content box'  v-loading='loading'>
      <div class='tabs-title title-icon'>
              <span>
                {{ linaBarTitle }}
              </span>
      </div>

      <line-bar  :isDatazoom='true' domId='viewTrendDomId' :lineTitle='linaBarTitle' :dataList='viewTrendList' boxHeight='190px'></line-bar>
    </div>
  </div>
</template>

<script type='text/ecmascript-6'>
import { changeMixin } from '@/mixins'

export default {
  name: 'ViewTabs',
  mixins: [changeMixin],
  data() {
    return {
      loading:false,
      tabHead: [],
      tabTitle: '客户总数',
      tabType: 'total',
      tabIndex: 0,
      delayTimer: 3000,
      directionTimer: 3000,
      pageData: {
        total: {},
        wechat: {},
        wechatGroup: {},
        applet: {},
        publiccus: {}
      },
      canvas: null,
      req: {},
      isGroup: true,
      updata: Date.now(),
      dataOverView: null,
      viewTrendList: null,
      linaBarTitle: '',
      tabType: '',
      tabTitleList: [
        { title: '访问量', type: 'views' },
        { title: '转发量', type: 'forward' },
        { title: '线索量', type: 'clue' },
        { title: '激活量', type: 'activation' }
      ]
    }
  },
  mounted() {
    this.init()
  },
  methods: {
    init() {
      this.getOverview()
      this.getviewTrend()
    },
    clickItemTab(index, item) {
      const { type, title } = item
      this.tabIndex = index
      this.getviewTrend(type, title)
    },
    getOverview() {
      // this.loading = true
      this.api.renewal.getOverview().then(res => {
        if (res.code == 0) {
          // this.loading = false
          this.dataOverView = res.data.dataList[0]
        }
      })
    },

    // 获取浏览量趋势
    getviewTrend(type = 'view', title = '访问量') {
      this.linaBarTitle = title
      if (type == 'views') type = 'view'
      let params = { queryItem: type }
      this.api.renewal.getviewTrend(params).then(res => {
        if (res.code == 0) {
          this.viewTrendList = res.data.dataList
        }
      })
    }
  }
}
</script>

<style scoped lang='scss'>
.tabs {
  //margin-bottom: 0.6vh;

  .tab {
    //height: 7.8vh;
    display: grid;
    margin-bottom: 3px;
    // overflow: hidden;
    .tab-total-box {
      height: 100%;
      padding-left: 8px;
      box-sizing: border-box;

      .total-title-box {
        .number-total {
          font-size: 24px;
          color: #eb6001;
          font-weight: 700;
          width: 40%;
        }

        .transition-number {
          font-size: 14px;
          color: #f5aa01;
        }

        .total {
          width: 30%;
        }

        > div {
          box-sizing: border-box;
          width: 20%;
          padding-left: 10px;
          //padding-right: 40px;
          height: 100%;
        }
      }

      .total-number-box {
        .number-total {
          font-size: 24px;
          color: #eb6001;
          font-weight: 700;
          //line-height: 3.7vh;
          width: 40%;
        }

        > div {
          width: 15%;
          font-size: 14px;
          color: #f5aa01;
        }
      }
    }


    .active {
      background: rgba(235, 96, 1, 0.1);
      box-sizing: border-box;
      border: 1px solid rgba(235, 96, 1, 0.8);
    }
  }

  &-content {
    //height: 24.4vh;
    height: 67%;
    overflow: hidden;
    box-sizing: border-box;
    padding: 1vh 8px;
    display: flex;
    flex-direction: column;
    //width: 70%;
    .tabs-title {
      font-size: 12px;
      color: #e8e8e8;

      &-info {
        font-size: 10px;
        color: #eb6001;
        line-height: 17px;
      }
    }

    //&-chart {
    //  height: 20.2vh;
    //  margin-top: auto;
    //  justify-content: space-between;
    //  gap: 0 8px;
    //
    //  .line {
    //    flex: 7;
    //    justify-content: center;
    //
    //    .canvas {
    //      width: 100%;
    //      height: 100%;
    //    }
    //
    //    .empty-img {
    //      max-width: 20vh;
    //      height: 9.5vh;
    //    }
    //  }
    //
    //  .table {
    //    flex: 3;
    //    background: #262525;
    //    position: relative;
    //
    //    .table-position {
    //      position: absolute;
    //      top: -20px;
    //      left: 50%;
    //      transform: translateX(-50%);
    //      color: #606266 !important;
    //    }
    //
    //    &-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);
    //
    //      &-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);
    //          //height: 3.6vh;
    //        }
    //
    //        .tab-value {
    //          width: 52px;
    //          margin-left: auto;
    //          padding-right: 4px;
    //        }
    //      }
    //    }
    //  }
    //
    //  > div {
    //    height: 100%;
    //  }
    //}
  }
}

</style>