record.vue 3.33 KB
<template>
  <div class="record-container" v-if="flag">
    <scroll-view class="content" @ReachBottom="onReachBottom" ref="scrollView">
      <template v-if="recordList.length > 0">
        <div class="record-container-content">
          <!-- <div class="font-16 color-3 fw5 line-22 m-l-4">2021-12-31</div> -->
          <template v-for="(item, index) in recordList">
            <div class="record-container-content-item" :key="index">
              <div class="portrait">
                <img :src="item.avatar" alt="" v-if="item.avatar" />
                <img v-else src="../../assets/images/user.png" />
              </div>
              <div class="m-t-4 font-14 line-22">
                <div class="color-3 customerName text-hide">{{ item.customerName }}</div>
                <div class="color6 m-t-4">
                  {{ item.operationType == 1 ? '浏览了' : item.operationType == 2 ? '领取优惠券' : '下单购买' }}
                  <span class="color-3 m-l-4">{{ item.goodsName }}</span>
                </div>
                <div class="font-12 color9 m-t-4" v-if="item.operationType == 3">订单编号:{{ item.orderCode }}</div>
              </div>
              <div class="font-12 color9 time">{{ item.operationDate }}</div>
            </div>
          </template>
        </div>
      </template>
      <template v-else>
        <empty description="暂无数据" />
      </template>
    </scroll-view>
  </div>
</template>
<script>
import { groupCustomer } from '@/api'
import { Notify } from 'vant'
import { util } from '../../utils'
import { mapActions } from 'vuex'
export default {
  data() {
    return {
      flag: false,
      recordList: [],
      page: {
        pageNum: 1,
        pageSize: 10
      }
    }
  },
  mounted() {
    this.showLoading()
    this.getcustomerRecordList()
  },
  methods: {
     ...mapActions({
      navigation: 'navigation'
    }),
    //重新登录
    reLogin() {
      /**登录过期 重新登录 */
      util.clearSessionId()
      this.navigation()
    },
    getcustomerRecordList() {
      let list = this.recordList
      groupCustomer.getcustomerRecordList({ ...this.page }).then(({ code, data, message }) => {
        this.hideLoading()
        if (code == 0) {
          this.recordList = [...list, ...data.list]
          if (this.page.pageNum > 1) this.$refs.scrollView.loading = false
          if (data.list == 0 && this.flag) {
            this.$refs.scrollView.finished = true
          }
        } else if(code == 21) {
          this.reLogin()
        }else{
          Notify(message)
        }
        this.flag = true
      })
    },
    onReachBottom() {
      this.page.pageNum++
      this.getcustomerRecordList()
    }
  }
}
</script>
<style lang="scss" scoped>
.record-container {
  padding: 0 12px;
  /deep/ .van-list {
    background: #f7f7f7;
    height: 100%;
    .van-empty {
      height: 100%;
    }
  }
  &-content-item {
    background: #ffffff;
    border-radius: 6px;
    margin: 8px 0;
    padding: 8px 12px 12px 12px;
    display: flex;
    position: relative;
    .customerName {
      max-width: 160px;
    }
    .portrait {
      width: 40px;
      height: 40px;
      margin-right: 6px;
      img {
        width: 100%;
        border-radius: 50%;
      }
    }
    .time {
      position: absolute;
      top: 14px;
      right: 12px;
      line-height: 18px;
    }
  }
}
</style>