claimsNote.js 2.58 KB

import { equityApi } from '~/api/api'
Page({
  data: {
    showPage: false,
    noteList: [],
    isCanFresh: false,
    status: {
      32: '待受理',
      40: '已失效',
      33: '待定损',
      35: '待定损', // 定损不通过展示为待定损
      34: '待服务', // 定损通过展示为待服务
      23: '已服务'
    },
    track_event_code: 'claimsNote_page'
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    wx.$api.showLoading('加载中...')
    if(options&&options.formPage=='apply'){
      wx.navigateTo({
        url: '/packageShopmall/packageEquity/pages/claimsNoteDetail/claimsNoteDetail?writeOffCode='+options.writeOffCode,
      });
      this.setData({isCanFresh:true,contractNo:options.contractNo})
      return
    }
    this.getList(options.contractNo)
  },
  onShow(){
    let {isCanFresh,contractNo} = this.data
    if(isCanFresh){
      this.getList(contractNo)
    }
  },
  toDetail(e){
    const {item} = e.currentTarget.dataset
    this.data.isCanFresh = true
    wx.navigateTo({
      url: `/packageShopmall/packageEquity/pages/claimsNoteDetail/claimsNoteDetail?writeOffCode=${item.writeOffCode}`,
    });
  },
  // 获取列表
  getList(contractNo){
    wx.$api.hideLoading()
    equityApi.claimsList({contractNo}).then(res=>{
      wx.hideLoading();
      if(res&&res.length){
        let tempArr = []
        res.forEach(el=>{
          // 32:待受理,40:已失效,33:待定损 34:定损通过 35:定损不通过 23:待核赔" 状态是其余值时,统一展示为已服务
          if (![32, 40, 33, 34, 35, 23].includes(el.status)) el.status = 23
          el.attachmentList?.forEach(ele=>{
            if(ele.firstClassifyName=='现场照片'){
              tempArr = ele.attachments
              el.images = tempArr
            }
          })
          let strlist = []
          el.serviceItemsList?.forEach(k=>{
            strlist.push(k.serviceItemName)
          })
          el.serviceItemsListStr = strlist.join(' ')
        })
      }
      this.setData({
        noteList: res || [],
        showPage: res.length?false:true,
        contractNo
      })
    })
  },
  toPreview(e) {
    const { item } = e.currentTarget.dataset
    wx.previewImage({
      current: item, // 当前显示图片的 http 链接
      urls: [item] // 需要预览的图片 http 链接列表
    })
  },
  // 打开地图
  openMap(e) {
   const target = e.currentTarget.dataset.item
    wx.openLocation({
      latitude: parseFloat(target.merchantLat),
      longitude: parseFloat(target.merchantLng),
      address: target.merchantAddress
    })
  }
})