/**
 * Soul创业实验 - 自定义TabBar组件
 * 实现中间突出的"找伙伴"按钮
 */

Component({
  data: {
    selected: 0,
    color: '#8e8e93',
    selectedColor: '#00CED1',
    list: [
      {
        pagePath: '/pages/index/index',
        text: '首页',
        iconType: 'home'
      },
      {
        pagePath: '/pages/chapters/chapters',
        text: '目录',
        iconType: 'list'
      },
      {
        pagePath: '/pages/match/match',
        text: '找伙伴',
        iconType: 'match',
        isSpecial: true
      },
      {
        pagePath: '/pages/my/my',
        text: '我的',
        iconType: 'user'
      }
    ]
  },

  attached() {
    // 初始化时获取当前页面
  },

  methods: {
    switchTab(e) {
      const data = e.currentTarget.dataset
      const url = data.path
      const index = data.index
      
      if (this.data.selected === index) return
      
      wx.switchTab({ url })
    }
  }
})
