market.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <view class="market-box">
  3. <gap height="10rpx" />
  4. <view class="market-tab">
  5. <view v-for="(item , index) in marketTab"
  6. :class="['market-tab-item' , index === marketTabIndex ? 'active-tab-item' : '' ]"
  7. @click.stop="marketTabIndex = index">
  8. {{ item }}
  9. </view>
  10. </view>
  11. <swiper :duration="150" class="market-content" :style="{'height': scrollHeight + 'px' }" :current="marketTabIndex">
  12. <swiper-item>
  13. <scroll-view :style="{'height': scrollHeight + 'px' }" class="market-scroll" scroll-y>
  14. <!-- <add-optional ref="addOptionalRef" /> -->
  15. <marketplace ref="optionalRef" :marketplaceList="optional" />
  16. </scroll-view>
  17. </swiper-item>
  18. <swiper-item>
  19. <scroll-view :style="{'height': scrollHeight + 'px' }" class="market-scroll" scroll-y>
  20. <marketplace ref="marketplaceRef" :marketplaceList="market" />
  21. </scroll-view>
  22. </swiper-item>
  23. </swiper>
  24. </view>
  25. </template>
  26. <!-- array.sort(function (x,y) {
  27. return x-y;
  28. }); -->
  29. <script>
  30. import {
  31. mapGetters
  32. } from 'vuex'
  33. export default {
  34. name: "marketModules",
  35. props: {
  36. market: {
  37. type: Array,
  38. default: () => []
  39. }
  40. },
  41. computed: {
  42. ...mapGetters([
  43. 'PageContentHeight',
  44. 'tabBarHeight'
  45. ]),
  46. },
  47. data() {
  48. return {
  49. scrollHeight: 0,
  50. marketTabIndex: 1,
  51. marketTab: [
  52. '自选',
  53. '市场'
  54. ],
  55. optional:[]
  56. };
  57. },
  58. watch: {
  59. market:{
  60. handler(newArr){
  61. if(newArr && newArr.length > 0){
  62. this.optional = newArr.slice(0,6)
  63. }
  64. },
  65. immediate:true,
  66. deep:true
  67. },
  68. PageContentHeight: {
  69. handler(newH) {
  70. this.scrollHeight = newH - uni.upx2px(114) - uni.upx2px(10) - this.tabBarHeight;
  71. },
  72. immediate: true
  73. }
  74. },
  75. }
  76. </script>
  77. <style lang="scss" scoped>
  78. .market-box {
  79. width: 100%;
  80. .market-tab {
  81. padding: 0 $pages-padding ;
  82. width: 100%;
  83. height: 114rpx;
  84. display: flex;
  85. align-items: center;
  86. .market-tab-item {
  87. font-size: 28rpx;
  88. font-family: PingFang SC, PingFang SC-Bold;
  89. font-weight: 700;
  90. color: #1a1a1a;
  91. line-height: 40rpx;
  92. letter-spacing: 0.6rpx;
  93. +.market-tab-item {
  94. margin-left: 50rpx;
  95. }
  96. }
  97. .active-tab-item {
  98. font-size: 34rpx;
  99. color: #20B482;
  100. position: relative;
  101. &::before {
  102. position: absolute;
  103. left: 50%;
  104. transform: translateX(-50%);
  105. bottom: -20rpx;
  106. content: '';
  107. width: 80%;
  108. height: 3px;
  109. border-radius: 2px;
  110. background-color: #20B482;
  111. }
  112. }
  113. }
  114. .market-content {
  115. width: 100%;
  116. .market-scroll {
  117. width: 100%;
  118. }
  119. }
  120. }
  121. </style>