custom-tabbar.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <view class="ezy-custom-tabbar">
  3. <view class="tabbar-item-box" v-for="(item, index) in tabList" :key="index" @click="switchTab(item.path,index)">
  4. <view class="tabbar-item"
  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="true"></tip-big-dialog>
  10. <tishiDlVue ref="popupRef"></tishiDlVue>
  11. </template>
  12. <script>
  13. import {
  14. MESSAGE_VISITER_TO_LOGIN
  15. } from "@/utils/constant.js"
  16. import tipMiddleDialog from '@/components/dialog/tipMiddleDialog.vue';
  17. import tipBigDialog from '@/components/dialog/tipBigDialog.vue';
  18. import {
  19. useTabBarHistory
  20. } from '@/utils/emitEvents.js';
  21. import cacheManager from "@/utils/cacheManager.js";
  22. import {
  23. toast,
  24. getUserIdentity
  25. } from "@/utils/common";
  26. import {
  27. nextTick,
  28. } from "vue";
  29. import tishiDlVue from './tishiDl.vue';
  30. export default {
  31. components: {
  32. tipMiddleDialog,
  33. tipBigDialog,
  34. tishiDlVue
  35. },
  36. data() {
  37. return {
  38. tabList: [{
  39. iconPath: 'static/images/tabbar/unselect/xuanke-sj.png',
  40. activePath: 'static/images/tabbar/select/xuanke-sj.png',
  41. path: `/pages/chanpinXuanze/index`
  42. },
  43. {
  44. iconPath: 'static/images/tabbar/unselect/xuexi-sj.png',
  45. activePath: 'static/images/tabbar/select/xuexi-sj.png',
  46. path: `/pages/chanpinneirong/index`
  47. },
  48. {
  49. iconPath: 'static/images/tabbar/unselect/faxian-sj.png',
  50. activePath: 'static/images/tabbar/select/faxian-sj.png',
  51. path: '/pages/game/index'
  52. },
  53. {
  54. iconPath: 'static/images/tabbar/unselect/wode-sj.png',
  55. activePath: 'static/images/tabbar/select/wode-sj.png',
  56. path: `/pages/chanpinMy/my`
  57. },
  58. ],
  59. currentTab: 0,
  60. isNavigating: false,
  61. MESSAGE_VISITER_TO_LOGIN
  62. };
  63. },
  64. props: {
  65. levelId: {
  66. type: String,
  67. },
  68. typeId: {
  69. type: String,
  70. },
  71. subjectId: {
  72. type: String,
  73. },
  74. currentTabNumber: {
  75. type: Number,
  76. },
  77. tipFlag: {
  78. type: String,
  79. },
  80. },
  81. methods: {
  82. // 游客弹窗---确定
  83. ykConfirm() {
  84. uni.redirectTo({
  85. url: '/pages/login/index'
  86. });
  87. },
  88. switchTab(path, index) {
  89. if (index == this.currentTab) {
  90. // 同页面不刷新
  91. return;
  92. }
  93. if (path == '/pages/chanpinneirong/index' && !cacheManager.get('auth').chanpinId) {
  94. this.$refs.popupRef.open();
  95. return false
  96. }
  97. this.currentTab = index;
  98. this.navigateToEditPage(path)
  99. },
  100. navigateToEditPage(path) {
  101. if (this.isNavigating) {
  102. uni.showToast({
  103. title: '正在跳转中...',
  104. icon: 'none'
  105. });
  106. return;
  107. }
  108. this.isNavigating = true;
  109. uni.showLoading({
  110. title: '加载中'
  111. }); // 显示Loading
  112. uni.navigateTo({
  113. url: path,
  114. complete: () => {
  115. uni.hideLoading();
  116. this.isNavigating = false;
  117. }
  118. });
  119. }
  120. },
  121. created() {
  122. this.currentTab = this.currentTabNumber
  123. }
  124. }
  125. </script>