custom-tabbar.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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/xinqing-sj.png',
  42. activePath: 'static/images/tabbar/select/xinqing-sj.png',
  43. path: `/pages/zhuanti/index`
  44. },
  45. {
  46. iconPath: 'static/images/tabbar/unselect/partner-sj.png',
  47. activePath: 'static/images/tabbar/select/partner-sj.png',
  48. path: '/pages/game/index'
  49. },
  50. {
  51. iconPath: 'static/images/tabbar/unselect/my-sj.png',
  52. activePath: 'static/images/tabbar/select/my-sj.png',
  53. path: `/pages/my/index`
  54. },
  55. ],
  56. currentTab: 0,
  57. isNavigating: false,
  58. MESSAGE_VISITER_TO_LOGIN
  59. };
  60. },
  61. props: {
  62. nianji: {
  63. type: String,
  64. },
  65. cardId: {
  66. type: String,
  67. },
  68. zhangId: {
  69. type: String,
  70. },
  71. currentTabNumber: {
  72. type: Number,
  73. },
  74. tipFlag: {
  75. type: String,
  76. },
  77. },
  78. methods: {
  79. // 游客弹窗---确定
  80. ykConfirm() {
  81. uni.redirectTo({
  82. url: '/pages/login/index'
  83. });
  84. },
  85. switchTab(path, index) {
  86. if (index == this.currentTab) {
  87. // 同页面不刷新
  88. return;
  89. }
  90. if (path !== '/pages/game/index') {
  91. this.currentTab = index;
  92. }
  93. if (getUserIdentity() == 'Visitor') {
  94. if (path === '/pages/game/index') {
  95. this.$refs.youkeDialogRef.handleShow();
  96. return;
  97. }
  98. uni.redirectTo({
  99. url: path + '?nianji=' + this.nianji + '&cardId=' + this.cardId + '&zhangId=' +
  100. this.zhangId + '&tipFlag=' + this.tipFlag
  101. });
  102. } else {
  103. /* if (path === '/pages/game/index') {
  104. // 游戏需要返回功能
  105. uni.navigateTo({
  106. url: path,
  107. "animationType": "fade-in",
  108. "animationDuration":0
  109. });
  110. return;
  111. } */
  112. this.navigateToEditPage(path)
  113. }
  114. },
  115. navigateToEditPage(path) {
  116. if (this.isNavigating) {
  117. uni.showToast({
  118. title: '正在跳转中...',
  119. icon: 'none'
  120. });
  121. return;
  122. }
  123. this.isNavigating = true;
  124. uni.showLoading({
  125. title: '加载中'
  126. }); // 显示Loading
  127. uni.redirectTo({
  128. url: path,
  129. complete: () => {
  130. uni.hideLoading();
  131. this.isNavigating = false;
  132. }
  133. });
  134. }
  135. },
  136. created() {
  137. this.currentTab = this.currentTabNumber
  138. }
  139. }
  140. </script>