// components/inner-device-card/index.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    item: Object,
    action: {
      type: String,
      // record
      value: ''
    },
    showStatus: {
      type: Boolean,
      value: true
    },
    showChecked: {
      type: Boolean,
      value: false
    },
    showDelete: {
      type: Boolean,
      value: false
    },
    index: {
      type: String,
      value: ''
    },
    editDate: {
      type: Boolean,
      value: false
    }
  },

  /**
   * 组件的初始数据
   */
  data: {

  },

  /**
   * 组件的方法列表
   */
  methods: {
    navigate: function(e) {
      var url = e.currentTarget.dataset.url
      wx.navigateTo({
        url: url,
      })
    },
    switchChecked: function(e) {
      if(!this.properties.showChecked) return false;
      var index = e.currentTarget.dataset.index
      this.triggerEvent('checked', {
        index
      }, {})
    },
    delete: function(e) {
      var index = e.currentTarget.dataset.index
      this.triggerEvent('delete', {
        index
      }, {})
    },
    editDate: function(e) {
      var index = e.currentTarget.dataset.index
      this.triggerEvent('editDate', {
        index
      }, {})
    }
  }
})
