index-tab-menu.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <template>
  2. <view class="content" :style="[{background:backGround}]">
  3. <view class="nav_wrap">
  4. <view class="nav_item" v-for="(item,index) in tabInfo" :key="index" @click="changeTab(index,item.categoryId)">
  5. <view :class="currIndex == index?'active_nav nav_text':'nav_text'">{{item.categoryName}}</view>
  6. <image :src="icon" mode="" class="nav_icon" v-if="currIndex == index"></image>
  7. </view>
  8. </view>
  9. <view class="gap_line"></view>
  10. <view class="sort_wrap" @click="toSortPage">
  11. <image :src="sortImg" mode=""></image>
  12. <text>分类</text>
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. export default{
  18. name:'tabMenu',
  19. data(){
  20. return {
  21. icon:getApp().globalData.imgUrl+'index/icon.png',
  22. sortImg:getApp().globalData.imgUrl+'index/sort.png',
  23. currIndex:0
  24. }
  25. },
  26. props: ['backGround','tabInfo'],
  27. methods:{
  28. changeTab(index,categoryId){
  29. this.currIndex = index
  30. if(index>0){
  31. let param = {}
  32. param.method = 'GET'
  33. param.url = 'v3/goods/front/goods/category/list?categoryId1='+categoryId
  34. this.$request(param).then(res=>{
  35. if(res.state == 200){
  36. this.$emit('getChildList',res.data.list[index-1],index)
  37. }
  38. })
  39. }else{
  40. this.$emit('getChildList',null,index)
  41. }
  42. },
  43. toSortPage(){
  44. uni.switchTab({
  45. url:`/pages/category/category`
  46. })
  47. }
  48. }
  49. }
  50. </script>
  51. <style lang='scss'>
  52. .content{
  53. position:fixed;
  54. top:0;
  55. /* left:0; */
  56. /* #ifdef APP-PLUS */
  57. top: var(--status-bar-height);
  58. /* #endif */
  59. width:750rpx;
  60. padding:0 20rpx;
  61. box-sizing: border-box;
  62. display: flex;
  63. align-items: center;
  64. /* #ifndef MP */
  65. padding-top:110rpx;
  66. /* #endif */
  67. /* #ifdef MP */
  68. padding-top:50px;
  69. /* #endif */
  70. background: linear-gradient(90deg, #6984a4 0%, #3a4b5c 100%);
  71. z-index: 1000;
  72. /* #ifndef H5 */
  73. left: 0;
  74. /* #endif */
  75. /* #ifndef MP */
  76. height: 160rpx;
  77. /* #endif */
  78. /* #ifdef MP */
  79. height: calc(50px + 60rpx);
  80. /* #endif */
  81. overflow-y: hidden;
  82. .nav_wrap{
  83. width:580rpx;
  84. /* #ifdef MP-WEIXIN */
  85. height:auto;
  86. /* #endif */
  87. /* #ifndef MP-WEIXIN */
  88. height:84rpx;
  89. /* #endif */
  90. display:flex;
  91. overflow-x: scroll;
  92. padding-top: -9rpx;
  93. float: left;
  94. .nav_item{
  95. margin-right:35rpx;
  96. display:flex;
  97. flex-direction: column;
  98. align-items: center;
  99. /* #ifndef MP-WEIXIN */
  100. padding-top: 12rpx;
  101. /* #endif */
  102. box-sizing: border-box;
  103. .nav_text{
  104. font-size:32rpx;
  105. color:#fff;
  106. white-space: nowrap;
  107. line-height: 38rpx;
  108. }
  109. .nav_icon{
  110. width:27rpx;
  111. height:9rpx;
  112. }
  113. }
  114. }
  115. .gap_line{
  116. width:13rpx;
  117. height:30rpx;
  118. background: linear-gradient(-90deg, #FFFFFF 0%, rgba(255, 255, 255, 0) 100%);
  119. opacity: 0.8;
  120. float: left;
  121. margin-right:6rpx;
  122. margin-left: 4rpx;
  123. align-self: end;
  124. /* #ifdef MP-WEIXIN */
  125. margin-top: 10rpx;
  126. /* #endif */
  127. }
  128. .sort_wrap{
  129. font-size:30rpx;
  130. color:#fff;
  131. display: flex;
  132. justify-content: flex-start;
  133. box-sizing: border-box;
  134. float: right;
  135. text-align: right;
  136. width: max-content;
  137. margin-top: -20rpx;
  138. image{
  139. width:32rpx;
  140. height:26rpx;
  141. margin:8rpx 7rpx 0 7rpx;
  142. }
  143. text{
  144. line-height:30rpx;
  145. display: inline-block;
  146. margin-top: 8rpx;
  147. }
  148. }
  149. }
  150. .active_nav{
  151. font-weight: bold;
  152. margin-bottom:6rpx;
  153. }
  154. </style>