clueDetail.js 4.85 KB
// packageStoreAssistant/packageActivity/pages/clueDetail/clueDetail.js
import ActivityApi from '~/api/activityApi/index'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    show: false,
    checkedValue: 0,
    followType: [{
      value: 0,
      label: '真实事故'
    }, {
      value: 1,
      label: '非真实事故'
    }, {
      value: 2,
      label: '无法处理'
    }],
    infoList: [{
      label: '客户姓名',
      value: 'customerName'
    }, {
      label: '客户电话',
      value: 'customerPhone'
    }, {
      label: '车牌号',
      value: 'licensePlate'
    }, {
      label: '设备SN',
      value: 'sn'
    }],
    followList: [{
      label: '回访结果',
      value: 'followResult'
    }, {
      label: '回访时间',
      value: 'followTime'
    }, {
      label: '备注',
      value: 'followRemark'
    }, ]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },
  onRoute(options) {
    const {
      id,
      tabIndex
    } = options
    console.log(options)
    this.setData({
      id,
      tabIndex
    })
    this.getDetail(id);
  },
  showPopup() {
    this.setData({
      show: true
    })
  },
  radioChange(e) {
    this.setData({
      checkedValue: e.detail.value
    })
  },
  bindTextAreaBlur: function (e) {
    this.setData({
      followRemark: e.detail.value
    })
  },
  comfirm() {
    const {
      id,
      followRemark,
      checkedValue
    } = this.data
    ActivityApi.followByStaff({
      id,
      followRemark,
      followResult: checkedValue
    }).then(res => {
      wx.$router.back(prev => {
        prev.selectComponent('#page-0').selectComponent('#clue').getList(true)
      })
    })
  },
  cancel() {
    this.setData({
      show: false
    })
  },
  getDetail(id) {
    ActivityApi.clueDetail({
      id
    }).then(res => {
      const {
        mediaDetailList = [], carAddressList = []
      } = res
      res.fileUrl = mediaDetailList.find(i => i.mediaType == 'VIDEO').fileUrl
      res.collisionTime = new Date(res.collisionTime).format("yyyy-MM-dd hh:mm:ss")
      res.collisionTimeStr = res.collisionTime.substring(11)
      res.followTime = new Date(res.followTime).format("yyyy-MM-dd hh:mm:ss")
      const {
        followType
      } = this.data
      res.followResult = followType.find(i => i.value == res.followResult)?.label
      const lineList = {
        x: carAddressList.map(i => i.time),
        y: carAddressList.map(i => i.sp)
      }
      let start, end, pl
      if (carAddressList && carAddressList.length) {
        pl = [{
          latitude: carAddressList[0].y,
          longitude: carAddressList[0].x
        }, {
          latitude: res.latitude,
          longitude: res.longitude
        }, {
          latitude: carAddressList[carAddressList.length - 1].y,
          longitude: carAddressList[carAddressList.length - 1].x
        }]
        start = {
          id: 1,
          width: '25',
          height: '25',
          callout: {
            content: '起点',
            color: '#494C4D',
            display: 'ALWAYS',
            padding: 4,
            borderRadius: 8
          },
          iconPath: './images/i2.png',
          latitude: carAddressList[0].y,
          longitude: carAddressList[0].x
        }
        end = {
          id: 2,
          width: '25',
          height: '25',
          callout: {
            content: '终点',
            color: '#494C4D',
            display: 'ALWAYS',
            padding: 4,
            borderRadius: 8
          },
          iconPath: './images/i3.png',
          latitude: carAddressList[carAddressList.length - 1].y,
          longitude: carAddressList[carAddressList.length - 1].x
        }
      }
      const markers = [{
        id: 8,
        width: '25',
        height: '25',
        callout: {
          color: '#494C4D',
          content: '碰撞点',
          display: 'ALWAYS',
          padding: 4,
          borderRadius: 8
        },
        iconPath: './images/i1.png',
        latitude: res.latitude,
        longitude: res.longitude
      }, start, end]
      const polyline = [{
        points: pl,
        color: '#58c16c',
        width: 6,
        borderColor: '#2f693c',
        borderWidth: 1
      }]
      this.setData({
        info: res,
        lineList,
        polyline,
        markers
      })
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})