information.vue 3.77 KB
<template>
  <div
    class="layout"
    v-if="flag"
  >
    <div class="tips flex">请完善以下客户信息</div>
    <template v-if="customerList.length > 0">
      <scroll-view
        class="content"
        @ReachBottom="onReachBottom"
        ref="scrollView"
      >
        <template v-for="(item, index) in customerList">
          <div
            :key="index"
            class="item flex"
            @click="openUserProfile(item)"
          >
            <div class="avatar">
              <div class="sprite-icon icon-avatar">
                <img
                  :src="item.avatar"
                  alt=""
                  v-if="item.avatar"
                />
                <img
                  src="../../assets/images/user.png"
                  alt=""
                  v-else
                />
              </div>
            </div>
            <div class="info">
              <div class="phone flex name">{{ item.customerName }}</div>
              <div
                class="tags flex"
                v-if="item.labels.length > 0"
              >
                <template v-for="(i, ind) in item.labels.slice(0, 3)">
                  <div
                    :key="ind"
                    class="tag text-center"
                  >{{ i.labelValue }}</div>
                </template>
              </div>
            </div>
            <div class="sprite-icon icon-arrow"></div>
          </div>
        </template>
      </scroll-view>
    </template>
    <empty
      v-else
      description="暂无数据"
    />
  </div>
</template>

<script type='text/ecmascript-6'>
import { groupCustomer, wxConfig } from '@/api'
export default {
  name: '',
  data() {
    return {
      customerList: [],
      flag: false
    }
  },
  created() {
    this.init()
  },
  mounted() {
    wxConfig.init(['openUserProfile']).then(() => {})
  },
  methods: {
    onReachBottom() {
      this.$refs.scrollView.loading = false
      this.$refs.scrollView.finished = true
    },
    // 消息盒子-好友列表
    init() {
      this.showLoading()
      let { taskId } = this.getQuery()
      let search = {
        taskId: taskId || 'a00052d7f63843a0b09f2d9ec8557c3b',
        status: 0
      }
      groupCustomer.getCustomerList(search).then(res => {
        this.hideLoading()
        this.customerList = res || []
        this.flag = true
      })
    },
    //打开个人信息页
    openUserProfile({ userid }) {
      console.log(userid)
      // this.$router.push({
      //   name: 'customer.detail',
      //   query: {
      //     id: userid
      //   }
      // })
      let seach = {
        userid, //参与会话的企业成员列表,格式为userid1;userid2;...,用分号隔开。
        type: 2
      }
      wxConfig.openUserProfile(seach).then(res => {
        //   console.log(res)
      })
    }
  }
}
</script>

<style scoped lang='scss'>
@import '@/assets/css/customer.scss';
.layout {
  .content {
    height: calc(100vh - 40px);
    .item {
      min-height: 92px;
      height: auto;
      padding: 16px 16px 12px 16px;
      box-sizing: border-box;
      .name {
        // width: 50px;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
      }
      .tags {
        flex-wrap: wrap;
        .tag {
          padding: 0 12px;
          height: 28px;
          line-height: 28px;
          background: rgba(57, 117, 198, 0.15);
          border-radius: 14px;
          margin: 0 4px 4px 0;
          font-size: 14px;
          font-weight: 400;
          color: #3975c6;
          width: 64px;
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
          display: inline-block;
          text-align: center;
          &:last-child {
            margin-right: 0;
          }
        }
      }
    }
  }
}
</style>