CustomerCard.vue 8.17 KB
<template>
  <div>
    <div class="customer-box" v-for="(item, index) in customerData" :key="index">
      <div class="customer-title">
        <div class="customer-name text-hide">{{ item.customerName }}</div>
        <div class="customer-carnumber">{{ item.cars && item.cars.length > 0 && item.cars[0].carNumber }}</div>
      </div>
      <div class="customer-info">
        <div class="customer-info-left">
          <div class="customer-info-label">
            <div class="customer-info-name">车系:</div>
            <div class="customer-info-message customer-info-car text-hide">{{ item.cars && item.cars.length > 0 && item.cars[0].carSeries }}</div>
          </div>
          <div class="customer-info-label">
            <div class="customer-info-name">招揽结果:</div>
            <div class="customer-info-message">{{ item.followResultEcho }}</div>
          </div>
          <div class="customer-info-label">
            <div class="customer-info-name">企微营销:</div>
            <div class="customer-info-message">
              {{ item.receiveStatus == 1 ? '已领取' : item.checkStatus == 1 ? '已查看' : item.sendStatus == 1 ? '已送达' : item.sendStatus == 0 ? '未送达' : '' }}
            </div>
          </div>
        </div>
        <div class="customer-info-right">
          <div class="customer-info-label">
            <div class="customer-info-name">企微账号:</div>
            <div v-if="item.type">
              <span class="customer-info-message customer-info-wechatnick text-hide">{{ item.nickName }}</span>
              <span class="customer-info-message" :class="[item.type == 1 ? 'customer-info-wechat' : 'customer-info-qiwechat']">{{ item.type == 1 ? '@微信' : item.type == 2 ? '@企微' : '' }}</span>
            </div>
            <div class="customer-info-message" v-else>未添加</div>
          </div>
          <div class="customer-info-label">
            <div class="customer-info-name">招揽日期:</div>
            <div class="customer-info-message text-hide">{{ item.solicitTime }}</div>
          </div>
          <div class="customer-info-label">
            <div class="customer-info-name">更新日期:</div>
            <div class="customer-info-message text-hide">{{ item.updatedTime }}</div>
          </div>
        </div>
      </div>
      <div class="customer-marketing">
        <div class="sprite-icon icon-tel" @click="callCustomer(item)"></div>
        <div class="sprite-icon icon-fllow" @click="followCustomer(item, index)"></div>
        <div class="sprite-icon icon-message" @click="sendMessage(item)"></div>
        <div class="sprite-icon icon-sendwechat" @click="sendWechat(item)"></div>
      </div>
    </div>
    <!-- 电话营销弹窗 -->
    <!-- <van-action-sheet v-model:show="show" :actions="actions" @select="onSelect" cancel-text="取消" close-on-click-action @cancel="onCancel" /> -->
  </div>
</template>

<script>
import { Toast } from 'vant'
import { wxConfig } from '@/api'
import CustomerInfoPopup from './CustomerInfoPopup.vue'
import CustomerFollowPopup from './CustomerFollowPopup.vue'
import { ssoApi } from '@/api'
export default {
  components: { CustomerInfoPopup, CustomerFollowPopup },
  name: 'CustomerCard',
  props: {
    customerInfo: {
      type: Array,
      default: () => {
        return []
      }
    },
    groupId: {
      type: String,
      default: () => {
        return null
      }
    },
    groupName: {
      type: String,
      default: () => {
        return ''
      }
    }
  },
  watch: {
    customerInfo(n) {
      this.customerData = n
    }
  },
  data() {
    return {
      // 电话营销弹窗
      show: false,
      actions: [{ name: '呼叫' }, { name: '复制' }],
      chatParams: {
        externalUserIds: [],
        groupName: '',
        userIds: [],
        chatId: ''
      },
      phoneNumber: null,
      customerData: this.customerInfo,
      customerIndex: 0,
      workUserId: ''
    }
  },
  mounted() {
    this.initWx()
    this.getuserInfo()
  },
  methods: {
    // 初始化微信接口
    initWx() {
      window.$wx = wxConfig
      window.$wx.init(['setClipboardData', 'navigateToAddCustomer', 'openEnterpriseChat', 'makePhoneCall']).then(() => {})
    },
    getuserInfo() {
      ssoApi.getuserInfo().then(res => {
        this.workUserId = res.data.workUserId
      })
    },
    changeTab(index) {
      this.isShow = false
      if (index === 0) {
        this.isShow = true
      }
    },
    // 电话招揽
    callCustomer(val) {
      console.log(val)
      if (!val.phoneNumber) {
        Toast('系统尚未查询到该用户的电话号码')
        return
      }
      this.phoneNumber = val.phoneNumber
      // 打开电话营销弹窗
      // this.show = true
      this.$emit('showAction', { phoneNumber: this.phoneNumber })
    },
    // 选择电话营销方式
    onSelect(e) {
      // 呼叫
      if (e.name === '呼叫') {
        // window.location.href = 'tel://' + this.telNumber
        this.makePhoneCall(this.phoneNumber)
        return
      }
      // 复制
      this.setClipboardData(this.phoneNumber)
    },
    // 电话招揽弹窗关闭
    onCancel() {
      this.show = false
    },
    // 招揽跟进
    followCustomer(val, index) {
      this.$emit('showFollowPop', { customerIndex: index, followCustomerData: val })
    },
    // 客户详情
    sendMessage(val) {
      this.$emit('showInfoPop', { followCustomerData: val })
    },
    // 企微沟通
    sendWechat(val) {
      // 如果未添加企微客户
      if (!val.userId) {
        if (val.phoneNumber) {
          wx.setClipboardData({
            data: val.phoneNumber,
            success(res) {
              Toast('已复制手机号,请尝试通过用户手机号来添加好友')
            },
            fail(res) {}
          })
        } else {
          Toast('尚未添加好友,请尝试添加客户为好友')
        }
        // 如果没有手机号,跳转到添加好友页面
        setTimeout(() => {
          window.$wx.navigateToAddCustomer().then(res => {
            // console.log(res)
          })
        }, 1000)

        return
      }
      let seach = {
        userIds: [], // 参与会话的企业成员列表,格式为userid1;userid2;...,用分号隔开。
        externalUserIds: [val.userId], // 参与会话的外部联系人列表,格式为userId1;userId2;…,用分号隔开。
        groupName: '', // 会话名称。单聊时该参数传入空字符串""即可。
        chatId: ''
      }
      // console.log(seach, 'seach')
      wxConfig.openEnterpriseChat(seach).then(res => {
        // console.log(res)
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.customer-box {
  //   width: 100%;
  background: #ffffff;
  box-shadow: 0px 2px 10px 0px rgba(224, 224, 224, 0.8);
  border-radius: 4px;
  margin: 0 16px 12px 16px;
}

.customer-title {
  display: flex;
  justify-content: space-between;
  height: 39px;
}

.customer-name {
  width: calc(100% - 120px);
  font-size: 14px;
  font-family: PingFangSC-Medium, PingFang SC;
  font-weight: 500;
  color: #282829;
  line-height: 39px;
  padding-left: 12px;
}

.customer-carnumber {
  font-size: 12px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #999999;
  line-height: 39px;
  white-space: nowrap;
  padding-right: 12px;
}

.customer-info {
  display: flex;
  padding: 12px;
  border-bottom: 1px solid rgba(195, 195, 195, 0.3);
  border-top: 1px solid rgba(195, 195, 195, 0.3);
  &-left,
  &-right {
    width: 50%;
  }
  &-label {
    display: flex;
  }
  &-name {
    font-size: 12px;
    width: 40%;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #999999;
    line-height: 18px;
  }
  &-message {
    font-size: 12px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #333333;
    line-height: 18px;
  }
  &-wechatnick {
    display: inline-block;
    max-width: 58px;
  }
  &-car {
    max-width: 80px;
  }
  &-wechat {
    vertical-align: bottom;
    color: #2cca74;
  }
  &-qiwechat {
    vertical-align: bottom;
    color: #3975c6;
  }
}

.customer-marketing {
  display: flex;
  justify-content: space-around;
  padding: 11px 0;
}

.customer-info-qiwechat {
  vertical-align: bottom;
  // color: #2cca74;
}
</style>