custom-tabbar.vue 2.5 KB

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