custom-tabbar.vue 3.1 KB

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