StoreApply.js 2.27 KB
// packageMine/pages/serviceManage/components/StoreApply/StoreApply.js
import { IMG_URL } from '~/utils/constantData'
import mineServiceApi from '~/api/mineApi/mineService'
import { getNowMonth } from '~/utils/format'
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    // 1-服务中心(园区店) 2-客户(4s店)
    merchantType: {
      type: Number,
      value: 1
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    IMG_URL,
    bgUrl: `${IMG_URL}/personal/empty_tran.png`,
    serviceList: [],
    total: -1,
    pageCof: {
      currentPage: 1,
      pageSize: 10
    },
    isAsk: false,
    reviewStatusObj: {
      1: {
        label: '审核中',
        color: '#3666FE'
      },
      2: {
        label: '已通过',
        color: '#21AB60'
      },
      3: {
        label: '已驳回',
        color: '#F36261'
      }
    }
  },

  lifetimes: {
    attached() {
      this.handleSearch()
    }
  },

  /**
   * 组件的方法列表
   */
  methods: {
    handleSearch() {
      this.setData({
        ['pageCof.currentPage']: 1,
        total: -1
      })
      this.getList(true)
    },

    scrollonReachBottom() {
      this.getList()
    },

    getList(isReset = false) {
      let { serviceList, pageCof, total, isAsk, merchantType } = this.data
      let _this = this
      if (total == serviceList.length || isAsk) {
        return true
      }
      let params = {
        ...pageCof,
        merchantType: merchantType
      }
      this.setData({
        isAsk: true
      })
      mineServiceApi.getReviewList(params).then(res => {
        let { list, total } = res.data
        const dateFormat = merchantType == 1 ? 'yyyy-MM-dd hh:mm:ss' : 'yyyy-MM-dd'
        list.forEach(item => {
          item.createdDate = item.createdDate ? new Date(item.createdDate).format(dateFormat).replace(/-/g, '.') : ''
        })
        this.setData({
          serviceList: pageCof.currentPage == 1 ? (list || []) : serviceList.concat(list),
          ['pageCof.currentPage']: pageCof.currentPage + 1,
          triggered: false,
          total
        })
        if (isReset) {
          this.setData({
            scrollTop: 0
          })
        }
      }).finally(function () {
        _this.setData({
          isAsk: false
        })
      })
    },

  }
})