const app = getApp();
const utils = require('../utils/util')
const wxService = require('../utils/wxService')

Component({
  //数据
  data: {
    currentHeight: 52,
    currentMarginTop: 25,
    currentPaddingTop: 5,
    selected: 0,//当前tabBar页面
    color: "#cdcdcd",//未选中tabBar时的文字颜色
    selectedColor: "#22385d",//选中时tabBar文字颜色
    addImgPath:'/assets/imgs/7_1_0/share_un.png',//添加发布图标
    // tabBar对象集合
    list: [
      {
        pagePath: "/pages/userCenter/userCenter",
        iconPath: "/assets/imgs/7_1_0/home_un.png",
        selectedIconPath: "/assets/imgs/7_1_0/home.png",
        text: "首页"
      },
      {
        pagePath: "/pages/category/category",
        iconPath: "/assets/imgs/7_1_0/category_un.png",
        selectedIconPath: "/assets/imgs/7_1_0/category.png",
        text: "分类"
      },
      {
        pagePath: "/pages/cart/cart",
        iconPath: "/assets/imgs/7_1_0/cart_un.png",
        selectedIconPath: "/assets/imgs/7_1_0/cart.png",
        text: "购物车"
      },
      {
        pagePath: "/pages/my/my",
        iconPath: "/assets/imgs/7_1_0/my_un.png",
        selectedIconPath: "/assets/imgs/7_1_0/my.png",
        text: "我的"
      }
    ]
  },
  ready() {
    wxService.getSystemInfo().then(res => {
      const {statusBarHeight} = res 
      const {currentHeight,currentMarginTop,currentPaddingTop} = this.data
        this.setData({
        currentHeight: currentHeight + statusBarHeight,
        currentMarginTop: currentMarginTop + (statusBarHeight) / 6,
        currentPaddingTop: statusBarHeight== 44 ? currentPaddingTop + 5 : currentPaddingTop,
      })
    })
    
  },
  methods: {
    // tabBar切换事件
    tab_bar_index(e) {
      const data = e.currentTarget.dataset
      const url = data.path
      wx.switchTab({ url })
    },

    // 发布添加按钮跳转
    tab_bar_add() {
      var url = "/pages/shareNumber/shareNumber"
      wx.navigateTo({url})
    }
  }
})