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

200 lines
4.2 KiB

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