tabbar.vue 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <template>
  2. <!-- 使用得时候必须加上style 不然没有--colorxxxxx之类得变量 -->
  3. <view class="tabbar align-center" :style="$store.state.theme.currentMoban">
  4. <view v-for="(item, index) in tabbarList" :key="index" @click="switchTabs(item)" class="tablist">
  5. <view class="column align-center justify-center" >
  6. <image :src="actindex==index?item.selectedIconPath:item.iconPath" class="w48 h48"></image>
  7. <text class="fs24 base-textcol" :class="actindex==index?'actcolor':'morecolor'">{{item.Text}}</text>
  8. </view>
  9. </view>
  10. </view>
  11. </template>
  12. <script>
  13. export default {
  14. name: "tabbar",
  15. props: {
  16. actindex: {
  17. type: Number,
  18. default: 0
  19. }
  20. },
  21. data() {
  22. return {
  23. themes: 'beiliyou',
  24. tabbarList: [],
  25. };
  26. },
  27. mounted() {
  28. this.themeicon()
  29. console.log(this.$store.state.theme.currentMoban['--base-color'])
  30. },
  31. methods: {
  32. switchTabs(item) {
  33. // 到时候要设置两个tabbar 但是一教育页面得隐藏掉 这里得页面不能配置到tabbar得list里面
  34. uni.navigateTo({
  35. url: item.url
  36. })
  37. },
  38. themeicon() {
  39. const theme = this.themes
  40. this.tabbarList = [{
  41. iconPath: `/static/images/tabbar/${theme}/home.png`,
  42. selectedIconPath: `/static/images/tabbar/${theme}/home_on.png`,
  43. Text: '首页',
  44. url: '/pages/home/index'
  45. },
  46. {
  47. iconPath: `/static/images/tabbar/${theme}/ENCYCLOPEDIA.png`,
  48. selectedIconPath: `/static/images/tabbar/${theme}/ENCYCLOPEDIA_on.png`,
  49. Text: '企业理念',
  50. url: '/pages/enterprise/enterprise'
  51. },
  52. {
  53. iconPath: `/static/images/tabbar/${theme}/mall.png`,
  54. selectedIconPath: `/static/images/tabbar/${theme}/mall_on.png`,
  55. Text: '健康商城',
  56. url: '/pages/shopping/index'
  57. },
  58. {
  59. iconPath: `/static/images/tabbar/${theme}/mine.png`,
  60. selectedIconPath: `/static/images/tabbar/${theme}/mine_on.png`,
  61. Text: '会员中心',
  62. url: '/pages/user/index'
  63. },
  64. ]
  65. }
  66. }
  67. }
  68. </script>
  69. <style lang="scss" scoped>
  70. .tabbar {
  71. display: flex;
  72. position: fixed;
  73. bottom: 0;
  74. left: 0;
  75. right: 0;
  76. background-color: #fff;
  77. z-index: 1000;
  78. height: 100rpx;
  79. }
  80. .tablist {
  81. width: 25%;
  82. }
  83. .morecolor{
  84. color: #626468;
  85. }
  86. .actcolor {
  87. color: #018C39;
  88. }
  89. </style>