add.vue 7.7 KB
<template>
  <div :class="['container-add', copywriting != '' ? `page-type-${tabIndex}` : '']">
    <tip :title="title"></tip>
    <template v-if="customerList.length > 0">
      <div class="customerList-add">
        <scroll-view class="content" @ReachBottom="onReachBottom" ref="scrollView">
          <div class="customer-add" v-for="(item, index) in customerList" :key="index">
            <div class="customer-add-portrait" v-if="tabIndex == 3">
              <img :src="item.avatar" alt="" v-if="item.avatar" />
              <img src="../../assets/images/user.png" alt="" v-else />
            </div>
            <div :class="{ 'customer-add-info': true, 'customer-add-all-info': tabIndex === 3 }">
              <div class="customer-add-info-number">{{ item.customerPhone }}</div>
              <div class="customer-add-info-name">{{ item.customerName }}</div>
            </div>
            <template v-if="item.status == 0">
              <div class="customer-add-friend flex">
                <div class="sprite-icon icon-customer-add" @click="addFriend(item)"></div>
                <div class="customer-add-friend-text">加好友</div>
              </div>
              <div class="line"></div>
              <div class="customer-add-friend flex" @click="callPhone(item.customerPhone)">
                <div class="sprite-icon icon-customer-phone"></div>
                <div class="customer-add-friend-text">拨打电话</div>
              </div>
            </template>
            <div class="customer-add-stay" v-else-if="item.status == 1">待通过</div>
            <div class="customer-add-pass" v-else-if="item.status == 2">已通过</div>
            <div class="buttomLine"></div>
          </div>
        </scroll-view>
      </div>
      <template v-if="tabIndex == 0 && copywriting != ''">
        <div class="copy-box">
          <div class="sprite-icon icon-customer-copy" @click="copy"></div>
          <div class="title">客户好友申请文案</div>
          <div>{{ copywriting }}</div>
        </div>
      </template>
    </template>
    <empty v-else description="暂无数据" />
  </div>
</template>
<script>
import { wxConfig } from '@/api'
import { groupCustomer } from '@/api'
export default {
  name: 'customerDetails',
  data() {
    return {
      check: true,
      customerList: [],
      taskId: this.$route.query.taskId ? this.$route.query.taskId : 'e0e1a10cf50f427bb6d35906cf3dbf21',
      copywriting: ''
    }
  },
  props: {
    tabIndex: {
      type: Number,
      default: 0
    }
  },
  created() {
    this.init()
  },

  computed: {
    title() {
      switch (this.tabIndex) {
        case 0:
          return `您共有${this.customerList.length}位客户待添加!`
        case 1:
          return `您共有${this.customerList.length}位客户待通过!`
        case 3:
          return `您共有${this.customerList.length}位客户!`
        default:
          return `您共有${this.customerList.length}位客户待添加!`
      }
    }
  },
  watch: {
    tabIndex: {
      handler(newVal) {
        this.init()
      }
    }
  },
  mounted() {
    this.initWx()
  },
  methods: {
    //初始化微信接口
    initWx() {
      window.$wx = wxConfig
      window.$wx.init(['navigateToAddCustomer', 'setClipboardData']).then(() => {})
    },
    init() {
      let search = {
        taskId: this.taskId,
        status: this.tabIndex == 3 ? '' : this.tabIndex
      }
      groupCustomer.getCustomerList(search).then(res => {
        this.customerList = res || []
      })
    },
    onReachBottom() {
      this.$refs.scrollView.loading = false
      this.$refs.scrollView.finished = true
    },
    //拨打电话
    callPhone(phone) {
      this.makePhoneCall(phone)
    },
    //加好友
    addFriend(data) {
      let obj = {
        customerId: data.customerId
      }
      groupCustomer.updateCustomerWork(obj).then(res => {})

      this.setClipboardData(data.customerPhone) //复制
      window.$wx.navigateToAddCustomer().then(res => {
        console.log(res)
      })
    },
    //文案拷贝
    copy() {
      this.setClipboardData(this.copywriting) //复制
    }
  }
}
</script>
<style lang="scss" scoped>
.container-add {
  width: 100%;
  .customerList-add {
    // background: #fff;
    .content {
      height: calc(100vh - 90px);
    }
    .customer-add {
      padding: 16px 16px;
      width: 375px;
      box-sizing: border-box;
      display: flex;
      align-items: center;
      position: relative;
      .customer-add-portrait {
        img {
          width: 44px;
          height: 44px;
        }
      }
      .customer-add-info {
        text-align: left;
        padding-right: 119px;
        .customer-add-info-number {
          font-size: 16px;
          font-weight: 600;
          color: #333333;
          line-height: 22px;
          margin-bottom: 6px;
          width: 110px;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
        }
        .customer-add-info-name {
          font-size: 14px;
          font-weight: 400;
          color: #333333;
          line-height: 20px;
          white-space: nowrap;
          width: 110px;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
        }
      }
      .customer-add-all-info {
        text-align: left;
        padding: 0 59px 0 16px !important;

        .customer-add-info-number {
          font-size: 16px;
          font-weight: 600;
          color: #333333;
          line-height: 22px;
          margin-bottom: 6px;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
          width: 110px;
        }
        .customer-add-info-name {
          font-size: 14px;
          font-weight: 400;
          color: #333333;
          line-height: 20px;
          white-space: nowrap;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
          width: 110px;
        }
      }
      .customer-add-friend {
        width: 36px;
        margin: 0 auto;
        flex-direction: column;
        .customer-add-friend-text {
          font-size: 12px;
          font-weight: 400;
          color: #666666;
          line-height: 17px;
          white-space: nowrap;
          margin-top: 7px;
        }
      }
      .line {
        margin: 0 13px 0 16px;
        width: 1px;
        height: 42px;
        background: rgba(0, 0, 0, 0.1);
      }
      .customer-add-stay {
        font-size: 12px;
        font-weight: 400;
        color: #3975c6;
        line-height: 17px;
        margin-left: 78px;
        white-space: nowrap;
      }
      .customer-add-pass {
        font-size: 12px;
        font-weight: 400;
        color: #666666;
        line-height: 17px;
        margin-left: 81px;
        white-space: nowrap;
      }
    }
  }
  .stickyfix {
    height: 130px;
    background: #ffffff;
    box-shadow: 0px 1px 0px 0px #e9e9e9;
    box-sizing: border-box;
    padding: 10px 16px;
    position: fixed;
    left: 0;
    bottom: 0;
    z-index: 99;
  }
  .copy-box {
    height: 130px;
    box-sizing: border-box;
    padding: 10px 16px;
    font-weight: 500;
    font-size: 14px;
    color: #333333;
    word-break: break-all;
    position: relative;
    background: #ffffff;
    box-shadow: 0px 1px 0px 0px #e9e9e9;
    .sprite-icon {
      position: absolute;
      top: 10px;
      right: 15px;
    }
    .title {
      margin-bottom: 16px;
    }
  }
  .buttomLine {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 375px !important;
    height: 1px;
    opacity: 0.3;
    background-color: #c3c3c3 !important;
  }
}
.page-type-0 {
  .content {
    height: calc(100vh - 220px) !important;
  }
}
</style>