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

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