import { connect } from 'herculex';

const app = getApp();
Component(connect({
  mapStateToProps: {
    activeIndex: state => state.activeIndex,
    list: state => (state.$global.pageConfig[state.templateUUID] || {}).tabbar || [],
    templateUUID: state => state.templateUUID,
  },
})({
  props: {
    className: 'fixed',
    cardMode: '',
  },
  data: {
    imgSrcPrefix: app.globalData.imgSrcPrefix,
  },
  methods: {
    async handleTabBarChange(pageUuid) {
      // 改变当前componnentData，改变activeIndex
      await this.dispatch('startInTabBar', { pageUuid });
    },
  },
}));
