hot-topic-list.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <view class="bg-white margin-top radius zaiui-hot-topic-box">
  3. <!--标题-->
  4. <view class="hot-topic-title">
  5. <view class="cu-list menu">
  6. <view class="cu-item">
  7. <view class="content">
  8. <text class="text-black text-lg">热门话题</text>
  9. </view>
  10. <view class="action">
  11. <text class="text-gray text-sm" @tap="viewAllTap">
  12. <text>查看全部</text>
  13. <text class="cuIcon-right"></text>
  14. </text>
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. <!--滑动列表-->
  20. <view class="hot-topic-scroll-box">
  21. <scroll-view class="hot-topic-scroll" scroll-x>
  22. <block v-for="(item,index) in list_num" :key="index">
  23. <view :id="[isSort + (index + 1 )]" class="hot-topic-scroll-item">
  24. <view class="cu-list menu-avatar">
  25. <block v-for="(items,indexs) in list_data" :key="indexs" v-if="getItmeList(index,indexs)">
  26. <view class="cu-item" @tap="listTap(items,indexs)">
  27. <view class="cu-avatar radius xl" :style="[{backgroundImage:'url('+ items.img +')'}]"></view>
  28. <view class="content">
  29. <view class="text-black">
  30. <view class="text-cut">{{items.title}}</view>
  31. </view>
  32. <view class="text-gray text-sm">
  33. <view class="text-cut">{{items.text}}</view>
  34. <view class="text-cut">{{items.num}}</view>
  35. </view>
  36. </view>
  37. </view>
  38. </block>
  39. </view>
  40. </view>
  41. </block>
  42. </scroll-view>
  43. <!--右边阴影-->
  44. <view class="zaiui-right-shadow-box"></view>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. import _tool from '@/static/zaiui/util/tools.js';
  50. export default {
  51. name: 'hot-topic-list',
  52. data() {
  53. return {
  54. list_num: 1,
  55. }
  56. },
  57. props: {
  58. list_data: {
  59. type: Array,
  60. default: () => {
  61. return []
  62. }
  63. },
  64. isSort: {
  65. type: String,
  66. default: "scroll"
  67. },
  68. },
  69. watch: {
  70. list_data() {
  71. this.getScrollPageNum(this.list_data);
  72. }
  73. },
  74. created() {
  75. this.getScrollPageNum(this.list_data);
  76. },
  77. methods: {
  78. listTap(data,index) {
  79. this.$emit('listTap', {
  80. data,
  81. index
  82. });
  83. },
  84. viewAllTap() {
  85. this.$emit('viewAllTap');
  86. },
  87. getScrollPageNum(data) {
  88. this.list_num = _tool.getPageNum(data.length,3);
  89. },
  90. getItmeList(index,indexs) {
  91. let max = (index + 1 ) * 3;
  92. let min = max - 3;
  93. if(indexs >= min && indexs < max) {
  94. return true;
  95. } else {
  96. return false;
  97. }
  98. }
  99. }
  100. }
  101. </script>
  102. <style lang="scss" scoped>
  103. .zaiui-hot-topic-box {
  104. border-radius: 18.18upx;
  105. .hot-topic-title {
  106. .cu-list.menu {
  107. border-radius: 18.18upx;
  108. }
  109. }
  110. .hot-topic-scroll-box {
  111. position: relative;
  112. width: 100%;
  113. .hot-topic-scroll {
  114. position: relative;
  115. height: 499.99upx;
  116. white-space: nowrap;
  117. width: 100%;
  118. .hot-topic-scroll-item {
  119. display: inline-block;
  120. width: 80%;
  121. .cu-list.menu-avatar>.cu-item {
  122. height: 154.54upx;
  123. .content {
  124. left: 181.81upx;
  125. width: calc(100% - 190.9upx);
  126. }
  127. &:after {
  128. width: 0;
  129. height: 0;
  130. border-bottom: 0;
  131. }
  132. }
  133. }
  134. }
  135. .zaiui-right-shadow-box {
  136. position: absolute;
  137. width: 118.18upx;
  138. top: 0;
  139. bottom: 0;
  140. right: 0;
  141. box-shadow: inset -63.63upx 0 127.27upx 0 rgba(255, 255, 255, 0.95);
  142. pointer-events: none;
  143. }
  144. }
  145. }
  146. </style>