apply.vue 7.64 KB
<template>
  <div class="apply-wrap">
    <template v-if="count">
      <van-pull-refresh class="content" v-model="refreshing" @refresh="onRefresh">
        <van-list v-model="loading" :finished="finished" finished-text="已经到底啦" @load="onLoad">
          <template v-for="(i, index) in dataList">
            <div class="apply-item" :key="index">
              <div class="apply-item-head">
                <div class="title flex">
                  <div class="maxWidth">{{ i.merchantName }}</div>
                </div>
                <div class="type">主营: {{ i.carModel ? i.carModel : '--' }}</div>
              </div>
              <div class="apply-item-content">
                <div class="content-wrap flex">
                  <div class="title">申请场景</div>
                  <div class="info">{{ i.businessScenario ? i.businessScenario : '--' }}</div>
                </div>
                <div class="content-wrap flex-top">
                  <div class="title">申请活动</div>
                  <div class="info">{{ i.productItems ? i.productItems : '--' }}</div>
                </div>
                <div class="content-wrap flex">
                  <div class="title">申请时间</div>
                  <div class="info">{{ i.createdTime }}</div>
                </div>
                <div class="content-wrap flex">
                  <div class="title">申请人</div>
                  <div class="info linkman flex" @click="makePhone(i)">
                    <div style="max-width: 120px; overflow: hidden; white-space: nowrap">{{ i.contactName }}</div>
                    <span class="phone-num">{{ i.contactPhone }}</span>
                    <div class="sprite-icon icon-phone"></div>
                  </div>
                </div>
              </div>
              <div class="apply-item-footer flex">
                <div class="flex">
                  <template v-if="index == 0">
                    <van-popover v-model="showPopover" theme="dark" placement="top-start">
                      <div class="tip">点击可切换状态</div>
                      <template #reference>
                        <div :class="['sprite-icon', i.followType == 0 ? ' icon-remove' : ' icon-collect']" @click.stop="checkCollect(i)"></div>
                      </template>
                    </van-popover>
                  </template>
                  <div v-else :class="['sprite-icon', i.followType == 0 ? ' icon-remove' : ' icon-collect']" @click.stop="checkCollect(i)"></div>
                  <div :class="['follew-result', i.followType == 0 ? 'fail' : 'success']">{{ i.followType == 0 ? '未跟进' : '已跟进' }}</div>
                </div>
                <div class="record" @click.stop="popupShow(i)">访问记录</div>
              </div>
            </div>
          </template>
        </van-list>
      </van-pull-refresh>
    </template>
    <van-empty description="暂无数据" v-else />
    <popup-comp :show.sync="show" :list="detailList"></popup-comp>
  </div>
</template>
<script>
import { Toast } from 'vant'
import { businessApi } from '@/api'
import popupComp from './popupComp.vue'
export default {
  components: {
    popupComp
  },
  data() {
    return {
      dataList: [],
      detailList: [],
      loading: false,
      finished: false,
      refreshing: false,
      show: false,
      count: 1,
      pageNum: 0,
      pageSize: 20,
      showPopover: true,
      uuid: ''
    }
  },
  mounted() {
    this.uuid = this.getLocalStorage('dj_scrm_userInfo').uuid ? this.getLocalStorage('dj_scrm_userInfo').uuid : null
    setTimeout(() => {
      this.showPopover = false
    }, 3000)
  },
  methods: {
    makePhone(item) {
      this.makePhoneCall(item.contactPhone)
    },
    onLoad() {
      this.pageNum++
      this.loading = true
      const num = this.count / this.pageSize
      if (Number.isInteger(num)) {
        this.number = num
      } else {
        this.number = parseInt(num) + 1
      }
      if (this.dataList.length < this.count) {
        if (this.pageNum <= this.number) {
          this.activityRecord()
          this.loading = false
        }
      } else {
        this.loading = false
        this.finished = true
      }
    },
    activityRecord(isdiff) {
      this.loading = true
      const { pageNum, pageSize, uuid } = this
      businessApi.activityRecord({ pageNum, pageSize, userType: 2, uuid }).then(res => {
        if (res) {
          const dataList = res.data
          this.dataList = this.dataList.concat(dataList)
          this.count = res.count
          if(isdiff) Toast('刷新成功');
          if (this.dataList.length <= this.count) {
            if (this.count === 0) {
              this.finished = true
            } else {
              this.finished = false
            }
          }
          this.loading = false
        }
      })
    },
    onRefresh() {
      this.dataList = []
      this.pageNum = 1
      let isdiff = 1
      this.activityRecord(isdiff)
      if (this.refreshing) {
        this.content = this.dataList
        this.dataList = this.content
        this.refreshing = false
      }
      this.loading = false
    },
    popupShow(item) {
      let data = {
        activityId: item.activityId
      }
      this.detailList = []
      businessApi.getActivityRecord(data).then(res => {
        this.show = true
        this.detailList = res ? res : []
      })
    },
    checkCollect(item) {
      this.show = false
      let data = {
        activityId: item.activityId,
        followType: item.followType == 0 ? 1 : 0
      }
      businessApi.activityFollow(data).then(res => {
        if (res.code == 0) {
          this.dataList = []
          this.activityRecord()
          Toast('跟进状态修改成功')
        }
      })
    }
  }
}
</script>
<style lang='scss' scoped>
.apply-wrap {
  padding: 12px;
  .content {
    height: calc(100% - 80px);
    overflow: scroll;
  }
  .apply-item {
    box-sizing: border-box;
    background: #fff;
    box-shadow: 0 4px 8px 0 rgba(224, 224, 224, 0.5);
    margin-bottom: 12px;
    &-head {
      padding: 10px 16px 12px;
      border-bottom: 1px solid rgba(195, 195, 195, 0.3);
      .title {
        font-weight: 600;
        font-size: 16px;
        color: #333333;
        line-height: 24px;
      }
      .maxWidth {
        max-width: 350px;
        text-overflow: ellipsis;
        white-space: nowrap;
        overflow: hidden;
      }
      .type {
        font-weight: 400;
        font-size: 12px;
        color: #999999;
        line-height: 16px;
      }
    }
    &-content {
      padding: 12px 16px 10px;
      border-bottom: 1px solid rgba(195, 195, 195, 0.3);
      .content-wrap {
        margin-bottom: 8px;
        .title {
          font-weight: 400;
          font-size: 14px;
          color: #999999;
          width: 56px;
          text-align: left;
          white-space: nowrap;
        }

        .info {
          font-weight: 400;
          font-size: 14px;
          color: #333333;
          margin-left: 16px;
        }
        .linkman {
          height: 32px;
          background: #f5f7fa;
          border-radius: 4px;
          line-height: 32px;
          padding: 0 8px;
          box-sizing: border-box;
          .phone-num {
            color: #6e6e7a;
            margin: 0 6px 0 4px;
          }
        }
      }
    }
    &-footer {
      height: 48px;
      padding: 0 16px 0 12px;
      box-sizing: border-box;
      justify-content: space-between;
      font-size: 14px;
      .follew-result {
        color: #f0aa06;
      }
      .fail {
        color: #999999 !important;
      }
      .record {
        color: #3975c6;
        text-align: right;
      }
    }
    .icon-remove,
    .icon-collect {
      margin-right: 8px;
    }
  }
}
</style>