custom-tabbar.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <view class="ezy-custom-tabbar">
  3. <view class="tabbar-item-box">
  4. <view class="tabbar-item" v-for="(item, index) in tabList" :key="index" @click="switchTab(item.path)"
  5. :style="{backgroundImage: 'url(' + item.iconPath + ')'}"></view>
  6. </view>
  7. </view>
  8. </template>
  9. <script>
  10. import {
  11. useTabBarHistory
  12. } from '@/utils/emitEvents.js';
  13. import {
  14. toast
  15. } from '@/utils/common'
  16. import cacheManager from "@/utils/cacheManager.js";
  17. import {
  18. getUserIdentity
  19. } from "@/utils/common.js"
  20. export default {
  21. data() {
  22. return {
  23. tabList: [{
  24. iconPath: 'static/images/tabbar/unselect/plan-sj.png',
  25. path: `/pages/study/index`
  26. },
  27. {
  28. iconPath: 'static/images/tabbar/unselect/partner-sj.png',
  29. path: '/pages/game/index'
  30. },
  31. {
  32. iconPath: 'static/images/tabbar/unselect/my-sj.png',
  33. path: `/pages/my/index`
  34. },
  35. ],
  36. };
  37. },
  38. props: {
  39. nianji: {
  40. type: String,
  41. },
  42. cardId: {
  43. type: String,
  44. },
  45. zhangId: {
  46. type: String,
  47. },
  48. },
  49. methods: {
  50. switchTab(path, params = {}) {
  51. if (getUserIdentity() == 'Visitor') {
  52. uni.redirectTo({
  53. url: path + '?nianji=' + this.nianji + '&cardId=' + this.cardId + '&zhangId=' + this
  54. .zhangId
  55. });
  56. }
  57. },
  58. },
  59. created() {
  60. console.log(this.nianji);
  61. }
  62. }
  63. </script>
  64. <style scoped>
  65. .custom-tabbar {
  66. display: flex;
  67. justify-content: space-around;
  68. align-items: center;
  69. /* 其他样式 */
  70. }
  71. .tab-item {
  72. flex: 1;
  73. /* 样式 */
  74. }
  75. .tab-icon {
  76. /* 图标样式 */
  77. }
  78. </style>