Page({
  data: {
    background: ['/assets/images/godzilla.png', '/assets/images/godzilla.png', '/assets/images/xian/swiper1.png'],
    indicatorDots: true,
    indicatorColor: '#FFFFFF',
    indicatorActiveColor: '#EE742F',
    autoplay: false,
    circular: true,
    interval: 2000,
    duration: 500,
    device_list: [
      {
        name: '智能电饭煲1',
        imgUrl: '/assets/images/xian/home_device1.png',
        switch : true,
      },
      {
        name: '电热水壶',
        imgUrl: '/assets/images/xian/home_device2.png',
        switch : false,
      },
      {
        name: '智能电饭煲2',
        imgUrl: '/assets/images/xian/home_device3.png',
        switch : true,
      },
    ]
  },

  onShow() {
    this.setData({
      // device_list: [],
    })
    ty.hideMenuButton();
  },

  goMessage() {
    ty.navigateTo({url: '/pages/message/index'})
  },

  goAddDevice() {
    ty.navigateTo({url: '/pages/adddevice/index'})
  },

  handleSwitch(e) {
    const index = e.currentTarget.dataset.id;
    let list = this.data.device_list
    list[index].switch = !list[index].switch
    this.setData({
      device_list: list
    })
  }

})
