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

  },

  /**
   * 组件的初始数据
   */
  data: {
    list: [{
      value: 1,
      selected: true,
      text: '增值税普通电子发票'
    }, {
      value: 2,
      selected: false,
      text: '增值税电子专用发票'
    }]
  },

  /**
   * 组件的方法列表
   */
  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
      })
    }
  }
})