lookCustomer.vue 7.15 KB
<template>
  <div class="customer-container" v-if="flag">
    <div class="customer-container-head">
      <div class="font-16 color54 line-24 title text-hide">{{ groupName }}</div>
      <div class="search-head flex">
        <van-dropdown-menu active-color="#3369B1">
          <van-dropdown-item v-model="searchType" :options="seachArray" @change="selectType" />
        </van-dropdown-menu>
        <search :keyword="keyWord" placeholder="请输入关键字" @search="searchkeyWord"></search>
      </div>
      <drop-down :selectOption1="statusList" :selectOption2="resultList" :currentValue1="status" :currentValue2="result" @changeFirst="changeFirst" @changeSecond="selectSecondChange"></drop-down>
    </div>
    <scroll-view class="content" @ReachBottom="onReachBottom" ref="scrollView">
      <customer-card v-if="customerInfo.length > 0" :customerInfo="customerInfo" @showFollowPop="showFollowPop" @showInfoPop="showInfoPop" @showAction="showAction"></customer-card>
      <empty v-else></empty>
    </scroll-view>
    <!-- 跟进弹窗 -->
    <customer-follow-popup ref="customerFollowRef" :info="followCustomerData" @changeIndexEvent="changeIndexEvent"></customer-follow-popup>
    <!-- 客户信息弹窗 -->
    <customer-info-popup ref="customerInfoRef"></customer-info-popup>
    <van-action-sheet v-model:show="show" :actions="actions" @select="onSelect" cancel-text="取消" close-on-click-action @cancel="onCancel" />
  </div>
</template>
<script>
import { mapState } from 'vuex'
import { solicitApi } from '@/api'
import { Notify } from 'vant'
export default {
  data() {
    return {
      // 电话营销弹窗
      show: false,
      actions: [{ name: '呼叫' }, { name: '复制' }],
      phoneNumber: '',
      flag: false,
      keyWord: '',
      status: 0,
      result: 0,
      searchType: 0,
      seachArray: [
        { text: '客户姓名', value: 0 },
        { text: '车牌号', value: 1 },
        { text: '车架号', value: 2 },
        { text: '手机号码', value: 3 }
      ],
      customerInfo: [],
      statusList: [
        { text: '全部状态', value: 0 },
        { text: '已跟进', value: 1 },
        { text: '未跟进', value: 2 }
      ],
      resultList: [{ text: '全部结果', value: 0 }],
      followCustomerData: {},
      customerIndex: 0
    }
  },
  computed: {
    ...mapState({
      followResultList: state => state.solicit.followResultList,
      staffId: state => state.solicit.staffId,
      activityId: state => state.solicit.activityId
    })
  },
  created() {
    this.groupId = this.getQuery().groupId
    this.groupName = this.getQuery().groupName ? this.getQuery().groupName : ''
  },
  mounted() {
    this.initOption()
    this.showLoading()
    this.getSendCustomerList()
  },
  methods: {
    // 初始化微信接口
    initWx() {
      window.$wx = wxConfig
      window.$wx.init(['setClipboardData', 'navigateToAddCustomer', 'openEnterpriseChat', 'makePhoneCall']).then(() => {})
    },
    // 电话招揽弹窗关闭
    onCancel() {
      this.show = false
    },
    // 选择电话营销方式
    onSelect(e) {
      // 呼叫
      if (e.name === '呼叫') {
        // window.location.href = 'tel://' + this.telNumber
        this.makePhoneCall(this.phoneNumber)
        return
      }
      // 复制
      this.setClipboardData(this.phoneNumber)
    },
    showFollowPop(data) {
      this.$refs.customerFollowRef.init()
      this.customerIndex = data.customerIndex
      this.followCustomerData = data.followCustomerData
    },
    showInfoPop(data) {
      this.$refs.customerInfoRef.getCustomerDetail(data.followCustomerData)
    },
    showAction(data) {
      this.show = true
      this.phoneNumber = data.phoneNumber
    },
    changeIndexEvent() {
      let params = {
        customerId: this.followCustomerData.actCutId
      }
      solicitApi.getCustomerDetail(params).then(({ code, data, message }) => {
        if (code == 0) {
          data.solicitTime = data.solicitTime ? data.solicitTime.slice(0, 11) : data.solicitTime
          data.updatedTime = data.updatedTime ? data.updatedTime.slice(0, 11) : data.updatedTime
          this.customerInfo[this.customerIndex] = data
          if (data.followFlag == 2) {
            this.customerInfo.splice(this.customerIndex, 1)
          } else {
            this.$set(this.customerInfo, this.customerIndex, data)
          }
        } else {
          Notify(message)
        }
      })
    },
    // 获取送达客户信息
    getSendCustomerList(index) {
      this.hideLoading()
      let params = {
        keyWord: this.keyWord,
        type: this.searchType + 1,
        customerGroupType: 2,
        id: this.activityId,
        staffId: this.staffId,
        groupId: this.groupId,
        followFlag: this.status == 0 ? 10 : this.status == 2 ? 0 : this.status //0未跟进、1已跟进
      }
      if (this.status != 2) {
        params.followResult = this.result != 0 ? this.result : ''
      }
      solicitApi.getCustomerList(params).then(({ code, data, message }) => {
        if (code == 0) {
          data.map(item => {
            item.solicitTime = item.solicitTime ? item.solicitTime.slice(0, 11) : item.solicitTime
            item.updatedTime = item.updatedTime ? item.updatedTime.slice(0, 11) : item.updatedTime
          })
          this.customerInfo = data
        } else {
          Notify(message)
        }
        this.flag = true
      })
    },
    onReachBottom() {
      this.$refs.scrollView.loading = false
      this.$refs.scrollView.finished = true
    },
    searchkeyWord(e) {
      this.keyWord = e
      if (this.searchType != 0 && this.keyWord.length <= 2 && this.keyWord != '') {
        return
      }

      this.getSendCustomerList()
    },
    selectType() {
      this.keyWord = ''
    },
    changeFirst(index) {
      this.status = index
      this.result = 0
      this.getSendCustomerList()
    },
    selectSecondChange(index) {
      this.result = index
      this.getSendCustomerList()
    },
    initOption() {
      this.followResultList.forEach(item => {
        this.resultList.push({
          text: item.dictLabel,
          value: item.dictValue
        })
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.customer-container {
  &-head {
    height: 142px;
    background: #fff;
    margin-bottom: 12px;
    .search-head {
      padding: 0 16px;
      height: 50px;
      box-sizing: border-box;
      border-bottom: 1px solid rgba(216, 216, 216, 0.3);
      /deep/.van-dropdown-menu__bar {
        box-shadow: 0 0 0 #fff;
        font-weight: 400;
        margin-right: 13px;
      }
      /deep/ .van-dropdown-menu__title {
        font-size: 14px !important;
        color: #333333 !important;
      }
      /deep/ .van-search {
        width: 250px;
        padding: 0;
      }
      /deep/ .van-dropdown-item__content {
        width: 160px;
        background: #ffffff;
        border-radius: 8px;
        margin: 4px 0 0 8px;
        /deep/ .van-cell__title {
          text-align: center;
        }
        /deep/ .van-cell__value {
          display: none;
          width: 0;
        }
      }
    }
    .title {
      padding: 10px 16px;
    }
  }
  .content {
    height: calc(100vh - 154px);
    /deep/ .van-list {
      background: #f7f7f7;
    }
  }
}
</style>