orderPromptPop.js 2.12 KB
// components/orderPromptPop/orderPromptPop.js
Component({

  /**
   * 组件的属性列表
   */
  properties: {
    show: {
      type: Boolean
    },
    popupSlotStyle: {
      type: String,
      value: 'height: calc(100% - var(--fontSize120));'
    },
    height: {
      type: String,
      value: 'var(--fontSize500)'
    },
    includesChildHeight: {
      type: String,
      value: 'var(--fontSize980)'
    },
    sceneObj: {
      observer: function(v) {
        // 是否是扫码核销或再次下单,是的话不显示补录入口
        if (Object.keys(v)?.length) {
          let { payTypeList } = this.data
          let index = payTypeList?.findIndex(v => v.value == 5)
          if (index > -1) {
            payTypeList?.splice(index, 1)
            this.setData({
              payTypeList,
              includesChildHeight: 'var(--fontSize870)'
            })
          }
          this.setData({
            payTypeList
          })
        }
      }
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    infoData: {},
    payTypeList: [{
      label: '收款方为门店收款',
      value: '3'
    }, {
      label: '收款方为嘀加且属于对公转账收款',
      value: '4'
    }, {
      label: '收款方为嘀加二维码收款',
      value: '5',
      tips: '适用于已有交易收款流水需补录订单时'
    }, {
      label: '收款方为嘀加二维码收款',
      value: '6',
      tips: '适用于多笔订单一笔流水付款'
    }]
  },

  /**
   * 组件的方法列表
   */
  methods: {
    chooseParent(e) {
      let { type } = e.currentTarget.dataset
      this.setData({
        'infoData.payFlag': type
      })
    },
    chooseChild(e) {
      let { type } = e.currentTarget.dataset
      this.setData({
        'infoData.payType': type
      })
    },
    cancel() {
      this.triggerEvent('cancel')
    },
    confirm() {
      let { infoData } = this.data
      if (!infoData.payFlag || (infoData.payFlag == 2 && !infoData.payType)) {
        return wx.$util.showToast('请选择订单收款方式')
      }
      this.cancel()
      this.triggerEvent('confirm', infoData)
    }
  }
})