showPickerBg.js 1.02 KB
// component/showPikerBg/showPikerBg.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    title: String,
    index: { 
      type: Number
    },
    range: Array,
    rangeKey: {
      type: String
    },
    hasBottomLine: {
      type: Boolean,
      value: true
    },
    reasonIndex: {
      type: String,
      observer(newVal) {
        if (newVal) {
          this.setData({
            defaultValue: this.properties.range[newVal].name
          })
        }
      }
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    arrows: '../../pages/bindPhoneNumber/images/arrow-down@2x.png',
    defaultValue: '请选择'
  },

  /**
   * 组件的方法列表
   */
  methods: {
    pickerChange(e) {
      const value = e.detail.value;
      const index = this.data.index;
      const selectReason = this.data.range[e.detail.value];
      this.setData({
        defaultValue: selectReason.name
      });
      this.triggerEvent('pickerselect', { ...selectReason, index, reasonIndex: value });
    }
  }
})