鸿宇研学生前端代码
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.

198 lines
4.1 KiB

  1. <template>
  2. <view class="live">
  3. <view class="flex live-header">
  4. <view>图片直播</view>
  5. <button class="flex btn" @click="showAll">
  6. <view>查看全部</view>
  7. <image class="img" src="@/static/image/icon-arrow-right.png" mode="widthFix"></image>
  8. </button>
  9. </view>
  10. <!-- todo: auto scroll -->
  11. <!-- <view class="live-content">
  12. <view class="live-item" v-for="item in liveList" :key="item.id">
  13. <image class="live-item-bg" :src="item.image" mode="aspectFill"></image>
  14. <view class="live-item-info">
  15. <view class="text-ellipsis live-item-info-title">{{ item.title }}</view>
  16. <view class="live-item-info-time">{{ item.time }}</view>
  17. </view>
  18. </view>
  19. </view> -->
  20. <swiper
  21. class="swiper"
  22. :current="current"
  23. :autoplay="true"
  24. :display-multiple-items="3.2"
  25. >
  26. <swiper-item v-for="item in liveList" :key="item.id" style="display: inline-block;">
  27. <view class="swiper-item">
  28. <view class="swiper-item-content" @click="jumpToLive(item.id)">
  29. <image class="live-item-bg" :src="item.image" mode="aspectFill"></image>
  30. <view class="live-item-info">
  31. <view class="text-ellipsis live-item-info-title">{{ item.title }}</view>
  32. <view class="live-item-info-time">{{ item.time }}</view>
  33. </view>
  34. </view>
  35. </view>
  36. </swiper-item>
  37. </swiper>
  38. </view>
  39. </template>
  40. <script>
  41. export default {
  42. data() {
  43. return {
  44. liveList: [],
  45. }
  46. },
  47. created() {
  48. this.getData()
  49. },
  50. methods: {
  51. getData() {
  52. // todo: fetch
  53. this.liveList = [
  54. {
  55. id: '001',
  56. image: '/static/image/temp-15.png',
  57. title: '苕溪露营漂流',
  58. time: '2025-04-18',
  59. },
  60. {
  61. id: '002',
  62. image: '/static/image/temp-16.png',
  63. title: '科技奇遇记',
  64. time: '2025-04-18',
  65. },
  66. {
  67. id: '003',
  68. image: '/static/image/temp-17.png',
  69. title: '满陇桂雨',
  70. time: '2025-04-18',
  71. },
  72. {
  73. id: '004',
  74. image: '/static/image/temp-18.png',
  75. title: '跟着皇帝游江南',
  76. time: '2025-04-18',
  77. },
  78. {
  79. id: '005',
  80. image: '/static/image/temp-15.png',
  81. title: '苕溪露营漂流',
  82. time: '2025-04-18',
  83. },
  84. {
  85. id: '006',
  86. image: '/static/image/temp-16.png',
  87. title: '科技奇遇记',
  88. time: '2025-04-18',
  89. },
  90. ]
  91. },
  92. jumpToLive(id) {
  93. // todo
  94. },
  95. showAll() {
  96. // todo
  97. }
  98. },
  99. }
  100. </script>
  101. <style scoped lang="scss">
  102. .live {
  103. width: 100%;
  104. padding: 32rpx;
  105. box-sizing: border-box;
  106. background-image: linear-gradient(164deg,#DAF3FF, #FBFEFF , #FBFEFF);
  107. border: 2rpx solid #FFFFFF;
  108. border-radius: 32rpx;
  109. &-header {
  110. justify-content: space-between;
  111. font-size: 36rpx;
  112. font-weight: 500;
  113. color: #191919;
  114. .btn {
  115. column-gap: 4rpx;
  116. font-size: 24rpx;
  117. color: #8B8B8B;
  118. .img {
  119. width: 32rpx;
  120. height: auto;
  121. }
  122. }
  123. }
  124. &-content {
  125. margin-top: 16rpx;
  126. white-space: nowrap;
  127. width: 100%;
  128. overflow-x: auto;
  129. font-size: 0;
  130. }
  131. &-item {
  132. flex: none;
  133. display: inline-block;
  134. width: 180rpx;
  135. height: 240rpx;
  136. border-radius: 12rpx;
  137. overflow: hidden;
  138. position: relative;
  139. & + & {
  140. margin-left: 16rpx;
  141. }
  142. &-bg {
  143. width: 100%;
  144. height: 100%;
  145. }
  146. &-info {
  147. position: absolute;
  148. left: 0;
  149. bottom: 0;
  150. width: 100%;
  151. padding: 8rpx 12rpx;
  152. box-sizing: border-box;
  153. &-title {
  154. font-size: 26rpx;
  155. font-weight: 600;
  156. color: #FFFFFF;
  157. }
  158. &-time {
  159. font-size: 22rpx;
  160. color: #FFFFFF;
  161. }
  162. }
  163. }
  164. }
  165. .swiper {
  166. width: 100%;
  167. height: 240rpx;
  168. &-item {
  169. width: 180rpx;
  170. height: 240rpx;
  171. &-content {
  172. position: relative;
  173. width: 100%;
  174. height: 100%;
  175. border-radius: 12rpx;
  176. overflow: hidden;
  177. }
  178. }
  179. }
  180. </style>