market.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template>
  2. <view class="content">
  3. <view class="head">
  4. <view class="status"></view>
  5. <view class="search" @click="goSearch">
  6. <i class="hxicon-search"></i>
  7. <text class="tit">搜索店铺</text>
  8. </view>
  9. </view>
  10. <view class="tabs-box">
  11. <view class="hx-tabs">
  12. <view class="hx-tabs-item" v-for="(item,i) in tabs" :key="i"
  13. :class="{'hx-tabs-active': swiperCurrent == i}" @click="swiperChange(i)"
  14. :style="{transition: transtionTime + 'ms'}">
  15. <text>{{item.name}}</text>
  16. </view>
  17. <view class="hx-tabs-slider-box"
  18. :style="{width: (100/tabs.length) + '%',transition: transtionTime + 'ms',left:swiperCurrentSliderLeft + '%'}">
  19. <view class="hx-tabs-slider"></view>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. export default {
  27. data() {
  28. return {
  29. swiperCurrent: 0,
  30. transtionTime: 100,
  31. swiperCurrentSliderLeft: 0,
  32. tabs: [{
  33. name: '综合推荐',
  34. data: [],
  35. api: '',
  36. load: false
  37. },
  38. {
  39. name: '距离优先',
  40. data: [],
  41. api: '',
  42. load: false
  43. },
  44. ],
  45. }
  46. },
  47. methods: {
  48. swiperChange(index) {
  49. this.swiperCurrent = index;
  50. this.swiperCurrentSliderLeft = (100 / this.tabs.length) * index;
  51. let url = this.tabs[index].api;
  52. // index 0全部,1待支付,2待收货,3待评价,4退款
  53. // 假如滑动了tab则 去获取对应的数据
  54. if (this.tabs[index].data.length == 0) {
  55. // 只获取一次数据
  56. // this.getOrderData(index)
  57. }
  58. },
  59. }
  60. }
  61. </script>
  62. <style scoped lang="scss">
  63. .head {
  64. background: linear-gradient(100deg, #FFEB3B, #FFC107);
  65. padding-bottom: 10px;
  66. padding-top: 10px;
  67. .status {
  68. height: var(--status-bar-height);
  69. }
  70. .search {
  71. height: 40px;
  72. background-color: #fff;
  73. border-radius: 10px;
  74. margin: 0 15px;
  75. display: flex;
  76. align-items: center;
  77. padding: 0 15px;
  78. font-size: 14px;
  79. color: #888;
  80. i {
  81. font-weight: bold;
  82. font-size: 16px;
  83. }
  84. .tit {
  85. margin-left: 6px;
  86. }
  87. }
  88. }
  89. .tabs-box {
  90. display: flex;
  91. justify-content: center;
  92. align-items: center;
  93. width: 100%;
  94. position: sticky;
  95. top: calc(44px + var(--status-bar-height));
  96. z-index: 10;
  97. background-color: white;
  98. height: 50px;
  99. padding-bottom: 10px;
  100. .hx-tabs {
  101. position: relative;
  102. display: flex;
  103. height: 100%;
  104. width: 100%;
  105. justify-content: space-evenly;
  106. &-item {
  107. display: flex;
  108. flex: 1;
  109. flex-direction: row;
  110. justify-content: center;
  111. align-items: center;
  112. width: 70px;
  113. color: #666666;
  114. text {
  115. font-size: 16px;
  116. }
  117. }
  118. &-active {
  119. color: #333333;
  120. font-weight: bold;
  121. }
  122. &-slider-box {
  123. position: absolute;
  124. display: flex;
  125. justify-content: center;
  126. bottom: 0;
  127. width: 20%;
  128. }
  129. &-slider {
  130. display: flex;
  131. background: #f6d200;
  132. width: 30px;
  133. height: 3px;
  134. }
  135. }
  136. }
  137. </style>