tabbar.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <u-tabbar :value="curIndex" @change="changeMethods" :fixed="true" :activeColor="'#e46008'" :placeholder="false"
  3. :safeAreaInsetBottom="true">
  4. <u-tabbar-item v-for="(item,k) in list" :key="k" :text="item.text">
  5. <image class="u-page__item__slot-icon" slot="active-icon" :src="item.selectedIconPath"></image>
  6. <image class="u-page__item__slot-icon" slot="inactive-icon" :src="item.iconPath"></image>
  7. </u-tabbar-item>
  8. </u-tabbar>
  9. <!-- <view v-for="(item,k) in list" :key="k" class="items" @click="changeMethods(item.pagePath,k)">
  10. <u-image class="icon" width="56rpx" height="56rpx"
  11. :src="item.id == index ? item.selectedIconPath :item.iconPath" style="margin: auto;"></u-image>
  12. <view :class="{'actives':item.id== index}">{{item.text}}</view>
  13. </view> -->
  14. </template>
  15. <script>
  16. /*
  17. * 自定义底部导航栏
  18. */
  19. export default {
  20. name: "tabbar",
  21. props: {
  22. index: {
  23. type: Number,
  24. default: 1,
  25. }
  26. },
  27. data() {
  28. return {
  29. curIndex: this.index - 1,
  30. list: [{
  31. pagePath: "/pages/index/index",
  32. iconPath: "/static/icons/order-home.png",
  33. selectedIconPath: "/static/icons/order-home-active.png",
  34. text: '订单广场',
  35. },
  36. {
  37. pagePath: "/pages/order/index",
  38. iconPath: "/static/icons/order.png",
  39. selectedIconPath: "/static/icons/order-active.png",
  40. text: '我的订单',
  41. },
  42. {
  43. pagePath: "/pages/center/index",
  44. iconPath: "/static/icons/my.png",
  45. selectedIconPath: "/static/icons/my-active.png",
  46. text: '我的',
  47. }
  48. ],
  49. };
  50. },
  51. created() {
  52. },
  53. methods: {
  54. //底部导航选择操作
  55. changeMethods(index) {
  56. this.curIndex = index
  57. let path = typeof(this.list[index]) != 'undefined' ? this.list[index].pagePath : ''
  58. if (path) {
  59. uni.reLaunch({
  60. url: path
  61. })
  62. }
  63. }
  64. }
  65. }
  66. </script>
  67. <style lang="scss">
  68. .u-page__item__slot-icon {
  69. width: 42rpx;
  70. height: 42rpx;
  71. }
  72. // .tabbar {
  73. // background-color: #32302e;
  74. // color: #FFFFFF;
  75. // padding: 30rpx;
  76. // position: fixed;
  77. // bottom: 0px;
  78. // width: 100%;
  79. // height: 180rpx;
  80. // border-top-left-radius: 22rpx;
  81. // border-top-right-radius: 22rpx;
  82. // text-align: center;
  83. // display: flex;
  84. // z-index: 99;
  85. // }
  86. // .u-image {
  87. // height: 44rpx !important;
  88. // width: 44rpx !important;
  89. // margin-bottom: 16rpx !important;
  90. // }
  91. // .items {
  92. // width: 33.3%;
  93. // color: #6e6c6b;
  94. // text-align: center;
  95. // // float: left;
  96. // }
  97. // .actives {
  98. // color: #bb955e;
  99. // }
  100. </style>