orderDetails.js 3.83 KB
// packageConversionPlus/pages/orderDetails/orderDetails.js
import util from '../../../utils/util.js'
import api from '../../restapi.js'
import filter from '../../../utils/filter'
Page(filter.identityFilter({

  /**
   * 页面的初始数据
   */
  data: {
    // 订单状态 1 待跟进, 2 不升级, 3 待支付,4 已支付,6 已评价 , 9 已撤销
    orderStatus:{
      1:{
        text:'待跟进',
        color:'#999'
      },
      2:{
        text:'不升级',
        color:'#EF4342'
      },
      3:{
        text:'待支付',
        color:'#FF9834'
      },
      4:{
        text:'已支付',
        color:'#07C160'
      },
      6:{
        text:'已评价',
        color:'#05BAA0'
      },
      9:{
        text:'已撤销',
        color:'#999'
      }
    },
    orderObj: [
      {
        label: '支付方式:',
        key: 'payType',
        enum: {
          '2': '门店收款',
          '3': 'POS机',
          '0': '不升级',
        }
      },
      {
        label: '订单总额:',
        key: 'totalPrice',
        color: '#FF6601'
      },
      {
        label: '订单编号(交易单号):',
        key: 'outTradeNo'
      },
      {
        label: '工单时间:',
        key: 'successDate'
      },
      
    ],
    customerInfoObj: [{
        label: '客户姓名:',
        key: 'customerName'
      },
      {
        label: '手机号:',
        key: 'customerPhone',
        btnName: '拨打电话',
        callBack: 'phoneCall',
      },
      {
        label: '车架号:',
        key: 'standNo',
      },
     
      {
        label: '客户来源:',
        key: 'merchantName'
      },
      {
        label: '销售顾问:',
        key: 'employeeName'
      },
      {
        label: '备注:',
        key: 'remark',
      },
    ]
  },
  previewImage(e) {
    let {
      url
    } = e.currentTarget.dataset
    wx.previewImage({
      urls: [url],
      current: url
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options)
    util.showLoading('加载中...')
    api.getDetailByOrderCode(options, res => {
      console.log(res)
      let {
        returnCode,
        data
      } = res
      if(returnCode == 0 && data){
        data.time = new Date(data.installUpgradeTime).format('yyyy-MM-dd hh:mm:ss')
        if(data.payOrder && data.payOrder.successDate ) data.payOrder.successDate = new Date(data.payOrder.successDate).format('yyyy-MM-dd hh:mm:ss')
        if (data.profitAllocatinList && data.profitAllocatinList.length > 0) {
          let shopProfitMoney = 0
          data.profitAllocatinList.map(i => {
            shopProfitMoney += i.shopProfitMoney
          })
          data.shopProfitMoney = `${shopProfitMoney}元`
        }
        let orderDetails = {
          ...data.comment,
          ...data.payOrder,
          ...data.customer,
          ...data
        }
        this.setData({
          orderDetails
        })
        util.hideLoading()
      }else{
        util.hideLoading()
        util.showToast('系统异常')
      }
    })
  },
  phoneCall(e) {
    let {
      value
    } = e.currentTarget.dataset
    wx.makePhoneCall({
      phoneNumber: value
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

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

  },

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

  },

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

  },

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

  },

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

  },
  onLogin(){},
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
}))