index.vue 4.13 KB
<template>
  <div class="layoutIndex">
    <tab class="tabber-wrap" :list="list" :index="tabIndex" @change="changeTab" v-if="initShow"></tab>
    <template v-if="flag">
      <scroll-view class="content" @ReachBottom="onReachBottom" ref="scrollView">
        <template v-if="clewList.length > 0">
          <template v-for="item in clewList">
            <div class="content-item" :key="item.id" @click="gotoDetail(item)">
              <div class="content-item-des text-space">
                <div class="content-item-name weight-6 text-16 color-3 line-22 text-hide">{{ item.name }}</div>
                <div class="content-item-phone text-12 color-9 line-17">{{ item.phone }}</div>
              </div>
              <div class="content-item-info">
                <span class="text-12 color-9 weight-4 line-17">
                  线索类型
                  <label>{{ item.type == 1 ? '客户意见' : item.type == 2 ? '卖车询价' : item.type == 3 ? '救援服务' : item.type == 4 ? '新车询价' : item.type == 5 ? '试驾预约' : '维保预约' }}</label>
                </span>
                <span class="text-12 color-9 weight-4 line-17">
                  创建时间
                  <label>{{ item.createdDate }}</label>
                </span>
              </div>
            </div>
          </template>
        </template>
        <template v-else>
          <empty description="暂无数据" />
        </template>
      </scroll-view>
    </template>
  </div>
</template>

<script type="text/ecmascript-6">
import { Notify } from 'vant'
import { clewApi } from '@/api'
export default {
  name: '',
  data() {
    return {
      flag: false,
      list: ['跟进中', '已完成'],
      tabIndex: 0,
      clewList: [],
      initShow: false,
      page: {
        pageNum: 1,
        pageSize: 10
      }
    }
  },
  props: {},
  watch: {},
  created() {
    this.getClueList()
  },
  mounted() {},
  methods: {
    gotoDetail(data) {
      this.$router.push({ name: 'clew.detail', query: { taskId: data.id } })
    },
    getClueList() {
      const status = this.tabIndex === 0 ? 1 : 2
      const params = {
        ...this.page,
        status
      }
      const clewList = this.clewList
      this.showLoading()
      clewApi.getClueList({ ...params }).then(({ code, data, message }) => {
        this.hideLoading()
        if (code === '0') {
          if (status === 1) {
            this.list = [`跟进中(${data.total})`, '已完成']
            this.initShow = true
          }
          this.flag = true
          if (data.list.length > 0) {
            this.clewList = [...clewList, ...data.list]
            this.page.pageNum > 1 ? (this.$refs.scrollView.loading = false) : ''
          } else {
            this.page.pageNum > 1 ? (this.$refs.scrollView.finished = true) : ''
            this.page.pageNum > 1 ? (this.$refs.scrollView.loading = false) : ''
          }
        } else {
          Notify(message)
        }
      })
    },
    changeTab(index) {
      this.flag = false
      this.clewList = []
      this.page.pageNum = 1
      this.tabIndex = index
      this.getClueList()
    },
    onReachBottom() {
      console.log('触底')
      this.page.pageNum = this.page.pageNum + 1
      this.getClueList()
    }
  }
}
</script>

<style scoped lang="scss">
.layoutIndex {
  height: 100vh;
  overflow: hidden;
  .content {
    height: calc(100vh - 82px);
    margin: 16px 15px;
    box-sizing: border-box;
    &-item {
      width: 100%;
      height: 118px;
      background: #ffffff;
      box-shadow: 0px 4px 8px 0px rgba(224, 224, 224, 0.5);
      border-radius: 4px;
      margin-bottom: 11px;
      &-des {
        height: 47px;
        border-bottom: 1px solid rgba(195, 195, 195, 0.3);
        // width:100%;
        padding: 16px 16px 9px 16px;
        box-sizing: border-box;
        .content-item-name{
          width: calc(100% - 100px);
        }
      }
      &-info {
        padding: 10px 16px 16px 16px;
        box-sizing: border-box;
        span {
          display: block;
          label {
            margin-left: 20px;
          }
        }
      }
      &-info :nth-child(1) {
        margin-bottom: 10px;
      }
    }
  }
}
</style>