conquestCell.js 3.32 KB
// tabOperating/pages/index/components/conquestCell/conquestCell.js
import api from '../../../../api'
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    date: {
      type: String,
      observer: function (n) {
        console.log(n)
        this.getbusinessList(n)
        // if (n) this.getLetter()
      }
    }, // 查询日期
    hidden: {
      // 刷新列表
      type: Boolean,
      observer: function (n) {}
    }
    // date: String
  },

  /**
   * 组件的初始数据
   */
  data: {
    orderObj: {
      orderCount: 0,
      upgradeCount: 0,

      list: []
    },
    orderItem: [
      {
        label: '车架号',
        prop: 'standNo',
        required: true
      },
      {
        label: '抵用礼券',
        prop: 'couponName',
        required: true
      },
      {
        label: '领券时间',
        prop: 'couponPickUpDate',
        required: true
      },
      {
        label: '拒升理由',
        prop: 'refusalReason'
      },
      {
        label: '购买商品',
        prop: 'subOrders'
      }
      // {
      //   label: '支付方式',
      //   prop: 'payType'
      // }
      // {
      //   label: '',
      //   prop: ''
      // }
    ],
    payType: {
      0: '战败',
      1: '微信支付',
      2: '门店收款',
      3: 'POS机收款'
    }
  },

  /**
   * 组件的方法列表
   */
  methods: {
    refreshList() {
      let { date } = this.data
      this.getbusinessList(date)
    },
    getbusinessList(n) {
      wx.$util.showLoading('加载中...')
      let params = {
        installUpgradeBeginTimeStr: n + ' 00:00:00',
        installUpgradeEndTimeStr: n + ' 23:59:59'
      }
      api
        .listForBusinessView(params)
        .then(result => {
          wx.hideLoading()
          let { data, code } = result
          // console.log(result)
          if (code == '0') {
            // 处理时间戳
            data.list = data.list.map(item => {
              // console.log(wx.$util.tsFormatTime)
              item.couponPickUpDate = wx.$util.tsFormatTime(item.couponPickUpDate)
              item.installUpgradeTime = wx.$util.tsFormatTime(item.installUpgradeTime, 'h:m')
              return item
            })

            this.setData({
              orderObj: data,
              triggered: false
            })
          }
        })
        .catch(err => {
          console.log(err)
        })
      // console.log()
    },
    showSellBox(e) {
      let { orderObj } = this.data
      let { index } = e.currentTarget.dataset
      // console.log(index)
      let active = orderObj.list[index].active
      orderObj.list[index].active = active ? false : true
      this.setData({
        orderObj
      })
    }
  },
  /** 组件生命周期 */
  lifetimes: {
    // attached: function () {
    //   // 支付方式为微信
    //   console.log('attached')
    //   // console.log(this.data)
    //   // console.log(this)
    //     if (this.data.orderType == 1) {
    //       this.createWxQrcode()
    //     }
    //   }
    // },
    ready() {
      // console.log('ready')
      // console.log(this)
      // console.log(this.data)
      // let { date } = this.data
      // console.log(this.data)
      // console.log(date)
      // wx.$util.showLoading('加载中...')
      // setTimeout(() => {
      //   wx.$util.hideLoading()
      // }, 2000)
    }
  }
})