groupDetail.vue 6.58 KB
<template>
  <div class="group-customer-wrap">
    <div class="group-customer-vehicle">
      <div class="group-customer-vehicle-info">{{ groupBase && groupBase.groupName }}</div>
      <div class="group-customer-person-info">
        <div class="line-person-info text-14 flex">
          <div class="person-info-title">群主|</div>
          <div>{{ groupBase && groupBase.groupHostName }}</div>
        </div>
        <div class="line-person-info text-14 flex">
          <div class="person-info-title">创建时间|</div>
          <div>{{ groupBase && groupBase.createDate }}</div>
        </div>
      </div>
    </div>
    <div class="group-customer-members flex">
      <div class="group-customer-members-line">
        <div class="group-customer-members-line-text text-12 line-17">全部群成员</div>
        <div class="text-20">
          <span>{{ baseStatics && baseStatics.total }}</span>
          <span class="text-12">人</span>
        </div>
      </div>
      <div class="line"></div>
      <div class="group-customer-members-line">
        <div class="group-customer-members-line-text text-12 line-17">今日入群</div>
        <div class="text-20">
          <span>{{ baseStatics && baseStatics.addNum }}</span>
          <span class="text-12">人</span>
        </div>
      </div>
      <div class="line"></div>
      <div class="group-customer-members-line">
        <div class="group-customer-members-line-text text-12 line-17">今日退群</div>
        <div class="text-20">
          <span>{{ baseStatics && baseStatics.removeNum }}</span>
          <span class="text-12">人</span>
        </div>
      </div>
    </div>
    <tab-customer :list="['客户(' + custList.length + ')', '员工(' + staffList.length + ')']" @change="change" :index="tabIndex">
      <index ref="customerIndex" :index="tabIndex" :keyWord="keyWord" @searchkeyWord="searchkeyWord" :tableData="tabIndex == 0 ? custList : staffList"></index>
    </tab-customer>
  </div>
</template>
<script>
import index from '@/views/customer'
import { detailApi, wxConfig } from '@/api'
import { Dialog } from 'vant'
export default {
  components: { index },
  data() {
    return {
      tabIndex: 0,
      baseStatics: '', //群统计
      groupBase: '',
      // list: ['客户', '员工'],
      chatId: '',
      keyWord: '',
      custList: [],
      staffList: []
    }
  },
  mounted() {
    this.showLoading()
    let { id } = this.getQuery()
    console.log(id)
    // id = 'wr_pmOEQAAux1Gl8wPKIswjE49qP1mnQ'
    if (id) {
      this.chatId = id
      this.initData(id)
      this.hideLoading()
    } else {
      wxConfig.init(['getCurExternalChat']).then(() => {
        wxConfig
          .getCurExternalChat()
          .then(chatId => {
            console.log(chatId, 'chatId')
            this.chatId = chatId
            this.initData(chatId)
            this.hideLoading()
          })
          .catch(e => {
            this.hideLoading()
            Dialog.alert({
              title: '提示',
              message: '页面加载失败,请重试!',
              confirmButtonText: '知道了',
              confirmButtonColor: '#3975c6'
            }).then(() => {
              wx.closeWindow()
            })
          })
      })
    }
  },

  methods: {
    initData(id) {
      this.getCustomerBaseDetail(id) //群基本信息
      this.getCustomerBaseDetailStatics(id) //统计接口
      this.getCustomerCustList() //群客户列表
      this.getCustomerStaffList() //群员工列表
    },
    //群基本信息
    getCustomerBaseDetail(chatId) {
      let obj = {
        chatId,
        pageSize: 10,
        pageNum: 1
      }
      detailApi.getCustomerBaseDetail(obj).then(res => {
        if (res) {
          let reg = /(\d{4})\/(\d{1,2})\/(\d{1,2})/
          res.createDate = res.createDate.replace(reg, '$1-$2-$3')
          this.groupBase = res
        }
      })
    },
    //统计接口
    getCustomerBaseDetailStatics(chatId) {
      let obj = {
        chatId,
        pageSize: 10,
        pageNum: 1
      }
      detailApi.getCustomerBaseDetailStatics(obj).then(res => {
        if (res) {
          this.baseStatics = res
        }
      })
    },
    //群客户列表
    getCustomerCustList() {
      let obj = {
        chatId: this.chatId,
        pageSize: 20,
        pageNum: 1,
        keyword: this.keyWord
      }
      detailApi.getCustomerCustList(obj).then(res => {
        if (res) {
          console.log(res, 'res')
          this.custList = res
        }
      })
    },
    //群员工列表
    getCustomerStaffList() {
      let obj = {
        chatId: this.chatId,
        pageSize: 20,
        pageNum: 2,
        customerName: this.keyWord
      }
      detailApi.getCustomerStaffList(obj).then(res => {
        if (res) {
          this.staffList = res
          // this.$refs.customerIndex.staffList = res
        }
      })
    },
    change(index) {
      this.keyWord = ''
      this.tabIndex = index
      if (this.tabIndex == 0) this.getCustomerCustList() //群客户列表
      if (this.tabIndex == 1) this.getCustomerStaffList() //群员工列表
    },
    searchkeyWord(e) {
      this.keyWord = e
      if (this.tabIndex == 0) this.getCustomerCustList() //群客户列表
      if (this.tabIndex == 1) this.getCustomerStaffList() //群员工列表
    }
  }
}
</script>
<style lang="scss" scoped>
.group-customer-wrap {
  margin: 10px 16px;
  box-sizing: border-box;
  overflow: hidden;
  .group-customer-vehicle {
    width: 100%;
    height: auto;
    background: #ffffff;
    box-shadow: 0px 4px 8px 0px rgba(224, 224, 224, 0.5);
    border-radius: 4px;
    padding: 10px;
    box-sizing: border-box;
    &-info {
      font-size: 16px;
      font-weight: 600;
      color: #333333;
      padding: 10px 0 20px 10px;
      border-bottom: 1px solid rgba(0, 0, 0, 0.1);
      word-break: break-all;
    }
    .group-customer-person-info {
      margin: 9px 0 10px 10px;
      .line-person-info {
        margin-bottom: 7px;
        .person-info-title {
          width: 80px;
          text-align: right;
          margin-right: 6px;
          color: #999999;
        }
      }
    }
  }
  .group-customer-members {
    width: 100%;
    height: 93px;
    border-radius: 4px;
    margin: 10px 0;
    padding: 20px 30px;
    box-sizing: border-box;
    justify-content: space-between;
    background: linear-gradient(127deg, #3975c6 0%, rgba(57, 117, 198, 0.99) 98%, #3975c6 100%);
    .line {
      width: 2px;
      height: 40px;
      background: #fff;
    }
    &-line {
      display: flex;
      width: auto;
      flex-direction: column;
      align-items: center;
      &-text {
        margin-bottom: 8px;
      }
    }
  }
}
</style>