金诚优选前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

127 lines
2.8 KiB

  1. <template>
  2. <view>
  3. <view class="occupy-position"></view>
  4. <view class="content">
  5. <view class="tabbar-box">
  6. <view class="tab-item"
  7. :class="{'tab-active': currentTabBar == index}"
  8. :style="{'width': 100 / tabbars.length +'%'}"
  9. @click="clickTab(item, index)"
  10. v-for="(item, index) in tabbars" :key="index">
  11. <view class="tab-icon">
  12. <text class="lf-font-40 lf-iconfont" :class="item.icon"></text>
  13. </view>
  14. <view class="tab-name">{{ item.text }}</view>
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. import { mapGetters } from "vuex";
  22. export default {
  23. props: {
  24. type: {
  25. type: String, // 默认跳转方式redirect,可选switch
  26. default: 'redirect'
  27. }
  28. },
  29. data(){
  30. return {
  31. }
  32. },
  33. computed: {
  34. ...mapGetters(['currentTabBar', 'tabbars', 'isShowTabBar'])
  35. },
  36. created(){
  37. // 组件被创建时检查当前在哪个页面,然后校验currentTabBar是否与之匹配
  38. let pages = getCurrentPages();
  39. let page = pages[pages.length - 1].route;
  40. let tabbars = this.tabbars;
  41. let tabbar_name = tabbars[this.currentTabBar].path;
  42. let current = 0;
  43. tabbars.map((item, index) => {
  44. if(item.path == '/'+ page){
  45. current = index;
  46. }
  47. })
  48. if(tabbar_name != '/'+ page){
  49. this.$store.commit('setCurrentTabBar', current);
  50. }
  51. },
  52. methods: {
  53. clickTab(item, index){
  54. if(this.currentTabBar == index) return;
  55. this.$store.commit('setCurrentTabBar', index);
  56. this.$url(item.path, {type: this.type});
  57. }
  58. }
  59. }
  60. </script>
  61. <style lang="scss" scoped="scoped">
  62. .lf-font-40{
  63. font-size: 40rpx;
  64. }
  65. .occupy-position{
  66. width: 750rpx;
  67. height: 120rpx;
  68. box-sizing: content-box;
  69. padding-bottom: constant(safe-area-inset-bottom);
  70. padding-bottom: env(safe-area-inset-bottom);
  71. }
  72. .content{
  73. width: 750rpx;
  74. height: 120rpx;
  75. background-color: #FFFFFF;
  76. border-radius: 60rpx 60rpx 0 0;
  77. box-shadow: 0rpx -2rpx 8rpx 1rpx rgba(0, 0, 0, 0.1);
  78. position: fixed;
  79. bottom: 0;
  80. left: 0;
  81. z-index: 99999;
  82. padding-bottom: constant(safe-area-inset-bottom);
  83. padding-bottom: env(safe-area-inset-bottom);
  84. display: flex;
  85. align-items: center;
  86. box-sizing: content-box;
  87. .tabbar-box{
  88. width: 100%;
  89. height: 100rpx;
  90. display: flex;
  91. .tab-item{
  92. display: flex;
  93. justify-content: center;
  94. align-items: center;
  95. flex-direction: column;
  96. .tab-name{
  97. font-size: 24rpx;
  98. color: #777777;
  99. }
  100. &.tab-active{
  101. .tab-icon{
  102. background-color: #15716E;
  103. width: 60rpx;
  104. height: 60rpx;
  105. display: flex;
  106. justify-content: center;
  107. align-items: center;
  108. transform: translateY(-20rpx) scale(1.4);
  109. border-radius: 50%;
  110. color: #FFFFFF;
  111. overflow: hidden;
  112. text{
  113. transform: scale(0.6);
  114. }
  115. }
  116. .tab-name{
  117. color: #15716E;
  118. font-weight: bold;
  119. }
  120. }
  121. }
  122. }
  123. }
  124. </style>