custom-tabbar.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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,index)"
  5. :style="{ backgroundImage: 'url(' + (currentTab == index ? item.activePath : item.iconPath) + ')' }">
  6. </view>
  7. </view>
  8. </view>
  9. <tip-big-dialog ref="youkeDialogRef" @confirm-btn="ykConfirm" imgShow="false"></tip-big-dialog>
  10. </template>
  11. <script>
  12. import {
  13. MESSAGE_VISITER_TO_LOGIN
  14. } from "@/utils/constant.js"
  15. import tipMiddleDialog from '@/components/dialog/tipMiddleDialog.vue';
  16. import tipBigDialog from '@/components/dialog/tipBigDialog.vue';
  17. import {
  18. useTabBarHistory
  19. } from '@/utils/emitEvents.js';
  20. import cacheManager from "@/utils/cacheManager.js";
  21. import {
  22. toast,
  23. getUserIdentity
  24. } from "@/utils/common";
  25. import {
  26. nextTick,
  27. } from "vue";
  28. export default {
  29. components: {
  30. tipMiddleDialog,
  31. tipBigDialog
  32. },
  33. data() {
  34. return {
  35. tabList: [{
  36. iconPath: 'static/images/tabbar/unselect/plan-sj.png',
  37. activePath: 'static/images/tabbar/select/plan-sj.png',
  38. path: `/pages/study/index`
  39. },
  40. {
  41. iconPath: 'static/images/tabbar/unselect/partner-sj.png',
  42. activePath: 'static/images/tabbar/select/partner-sj.png',
  43. path: '/pages/game/index'
  44. },
  45. {
  46. iconPath: 'static/images/tabbar/unselect/my-sj.png',
  47. activePath: 'static/images/tabbar/select/my-sj.png',
  48. path: `/pages/my/index`
  49. },
  50. ],
  51. currentTab: 0,
  52. MESSAGE_VISITER_TO_LOGIN
  53. };
  54. },
  55. props: {
  56. nianji: {
  57. type: String,
  58. },
  59. cardId: {
  60. type: String,
  61. },
  62. zhangId: {
  63. type: String,
  64. },
  65. currentTabNumber: {
  66. type: Number,
  67. },
  68. tipFlag: {
  69. type: String,
  70. },
  71. },
  72. methods: {
  73. // 游客弹窗---确定
  74. ykConfirm() {
  75. uni.redirectTo({
  76. url: '/pages/login/index'
  77. });
  78. },
  79. switchTab(path, index) {
  80. if (path !== '/pages/game/index') {
  81. this.currentTab = index;
  82. }
  83. if (getUserIdentity() == 'Visitor') {
  84. if (path === '/pages/game/index') {
  85. this.$refs.youkeDialogRef.handleShow();
  86. return;
  87. }
  88. uni.redirectTo({
  89. url: path + '?nianji=' + this.nianji + '&cardId=' + this.cardId + '&zhangId=' +
  90. this.zhangId+ '&tipFlag=' + this.tipFlag
  91. });
  92. } else {
  93. if (path === '/pages/game/index') {
  94. // 游戏需要返回功能
  95. uni.navigateTo({
  96. url: path,
  97. "animationType": "fade-in",
  98. "animationDuration":0
  99. });
  100. return;
  101. }
  102. uni.navigateTo({
  103. url: path,
  104. "animationType": "fade-in",
  105. "animationDuration":0
  106. });
  107. }
  108. },
  109. },
  110. created() {
  111. this.currentTab =this.currentTabNumber
  112. }
  113. }
  114. </script>
  115. <style scoped>
  116. .custom-tabbar {
  117. display: flex;
  118. justify-content: space-around;
  119. align-items: center;
  120. /* 其他样式 */
  121. }
  122. .tab-item {
  123. flex: 1;
  124. /* 样式 */
  125. }
  126. .tab-icon {
  127. /* 图标样式 */
  128. }
  129. </style>