custom-tabbar.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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)"
  5. :style="{backgroundImage: 'url(' + item.iconPath + ')'}"></view>
  6. </view>
  7. </view>
  8. </template>
  9. <script>
  10. import {
  11. useTabBarHistory
  12. } from '@/utils/emitEvents.js';
  13. import cacheManager from "@/utils/cacheManager.js";
  14. import {
  15. toast,getUserIdentity
  16. } from "@/utils/common";
  17. export default {
  18. data() {
  19. return {
  20. tabList: [{
  21. iconPath: 'static/images/tabbar/unselect/plan-sj.png',
  22. path: `/pages/study/index`
  23. },
  24. {
  25. iconPath: 'static/images/tabbar/unselect/partner-sj.png',
  26. path: '/pages/game/index'
  27. },
  28. {
  29. iconPath: 'static/images/tabbar/unselect/my-sj.png',
  30. path: `/pages/my/index`
  31. },
  32. ],
  33. };
  34. },
  35. props: {
  36. nianji: {
  37. type: String,
  38. },
  39. cardId: {
  40. type: String,
  41. },
  42. zhangId: {
  43. type: String,
  44. },
  45. },
  46. methods: {
  47. switchTab(path, params = {}) {
  48. console.log(path)
  49. /* if(path =='/pages/game/index'){
  50. toast("功能暂未开放!")
  51. return false
  52. } */
  53. if (getUserIdentity() == 'Visitor') {
  54. if (path === '/pages/game/index') {
  55. // 游戏需要返回功能
  56. uni.navigateTo({
  57. url: path
  58. });
  59. return ;
  60. }
  61. uni.redirectTo({
  62. url: path + '?nianji=' + this.nianji + '&cardId=' + this.cardId + '&zhangId=' + this
  63. .zhangId
  64. });
  65. }else{
  66. if (path === '/pages/game/index') {
  67. // 游戏需要返回功能
  68. uni.navigateTo({
  69. url: path
  70. });
  71. return ;
  72. }
  73. uni.redirectTo({
  74. url: path
  75. });
  76. }
  77. },
  78. },
  79. created() {
  80. console.log(this.nianji);
  81. }
  82. }
  83. </script>
  84. <style scoped>
  85. .custom-tabbar {
  86. display: flex;
  87. justify-content: space-around;
  88. align-items: center;
  89. /* 其他样式 */
  90. }
  91. .tab-item {
  92. flex: 1;
  93. /* 样式 */
  94. }
  95. .tab-icon {
  96. /* 图标样式 */
  97. }
  98. </style>