// components/ticket-type/ticket-type.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   * 提交字段customerType 1:个人 2:企业
   */
  data: {
    list: [{
        value: 2,
        text: '企业',
        selected: true
      },
      {
        value: 1,
        text: '个人',
        selected: false
      }
    ]
  },

  /**
   * 组件的方法列表
   */
  methods: {
    select(e) {
      let index = Number(e.currentTarget.dataset.index)
      let list = this.data.list
      for (let i = 0; i < list.length; i++) {
        list[i].selected = false
      }
      list[index].selected = true
      this.setData({
        list
      })
      let value = list[index].value
      this.triggerEvent('select', {
        value
      })
    }
  }
})