const app = getApp()
Component({
  data: {
    selected: null,
    selectedColor: "#ffffff",
    list: [{
      title:'Clock',
      pagePath: "/pages/clock/Clock"
    }, {
      title:'Metric',
      pagePath: "/pages/metric/Metric"
    }, {
      title:'Activity',
      pagePath: "/pages/activity/Activity"
    }, {
      title:'Profile',
      pagePath: "/pages/account/Profile"
    }]
  },
  attached() {
    global.tabBar = this
  },
  methods: {
    update(index){
      this.setData({
        selected:-1
      })
      this.setData({
        selected: index
      })

    },
    switchTab(e) {
      const data = e.currentTarget.dataset
      this.setData({
        selected:data.index
      })
      const url = data.path
      wx.switchTab({url})
      // this.setData({
      //   selected: null//data.index
      // })
    }
  }
})