orderRatingPopup.js 2.5 KB
// import api from '../../api/api.js'
// import Util from '../../utils/util'
Component({
  options: {
    multipleSlots: true // 在组件定义时的选项中启用多slot支持
  },
  /*组件的属性列表*/
  properties: {
    title: {
      type: String,
      value: '标题'
    },
    // 弹窗内容
    content: {
      type: String,
      value: '内容'
    },
    // 弹窗取消按钮文字
    btn_no: {
      type: String,
      value: '取消'
    },
    // 弹窗确认按钮文字
    btn_ok: {
      type: String,
      value: '补录这笔订单'
    },
    //是否显示取消按钮
    isShowCancel: {
      type: Boolean,
      value: true
    },
    //是否显示右上角关闭按钮
    isShowClose: {
      type: Boolean,
      value: true
    },
    //应用于某些场景的button的open-type属性
    sureButtonType: {
      type: String,
      value: ''
    },
    //控制弹窗的显示
    flag: {
      type: Boolean,
      value: true
    },
    orderInfoSetting: {
      type: Object,
      value: {},
      observer: function (n) {
        console.log(n, 'orderInfoSetting')
        n && this.setOrderInfo(n)
      }
    }
  },
  /* 组件的初始数据 */
  data: {
    wrapAnimate: 'wrapAnimate',
    popupAnimate: 'popupAnimate',
    tags: [
      {
        name: '服务态度好',
        value: '1',
        checked: false
      },
      {
        name: '性价比高',
        value: '2',
        checked: false
      },
      {
        name: '价格便宜',
        value: '3',
        checked: false
      },
      {
        name: '一般',
        value: '4',
        checked: false
      }
    ],
    orderInfo: {}
  },
  lifetimes: {
    attached: function () {
      // 在组件实例进入页面节点树时执行
    },
    detached: function () {
      // 在组件实例被从页面节点树移除时执行
    }
  },
  /* 组件的方法列表 */
  methods: {
    setOrderInfo(orderInfo) {
      console.log(orderInfo, 'orderInfo')
      orderInfo.evaluation = orderInfo.evaluation.split(',')
      console.log(orderInfo.evaluation, 'orderInfo.evaluation')
      let { tags } = this.data
      tags.forEach((item, index) => {
        if (orderInfo.evaluation.includes(item.value)) {
          item.checked = true
        }
      })
      this.setData({
        orderInfo,
        tags
      })
    },
    /* 内部私有方法建议以下划线开头 triggerEvent 用于触发事件 */
    _close() {
      //触发取消回调
      this.triggerEvent('close')
    },
    _success() {}
  }
})