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

176 lines
3.6 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.url" 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. try {
  55. this.list = (await this.$fetch('queryImageList', { pageNo: 1, pageSize: 8 }))?.records?.map(item => {
  56. const { id, image, activityId_dictText, createTime } = item
  57. const images = image?.split?.(',') || []
  58. return {
  59. id,
  60. url: images?.[0],
  61. images,
  62. title: activityId_dictText,
  63. createTime: this.$dayjs(createTime).format('YYYY-MM-DD'),
  64. }
  65. })
  66. } catch (err) {
  67. }
  68. },
  69. jumpToLive(id) {
  70. this.$store.commit('setLiveInfo', this.list.find(item => item.id === id))
  71. this.$utils.navigateTo(`/pages_order/live/index?id=${id}`)
  72. },
  73. showAll() {
  74. this.$utils.navigateTo(`/pages_order/live/list`)
  75. }
  76. },
  77. }
  78. </script>
  79. <style scoped lang="scss">
  80. .live {
  81. width: 100%;
  82. padding: 32rpx;
  83. box-sizing: border-box;
  84. background-image: linear-gradient(164deg,#DAF3FF, #FBFEFF , #FBFEFF);
  85. border: 2rpx solid #FFFFFF;
  86. border-radius: 32rpx;
  87. &-header {
  88. justify-content: space-between;
  89. font-size: 36rpx;
  90. font-weight: 500;
  91. color: #191919;
  92. .btn {
  93. column-gap: 4rpx;
  94. font-size: 24rpx;
  95. color: #8B8B8B;
  96. .img {
  97. width: 32rpx;
  98. height: auto;
  99. }
  100. }
  101. }
  102. &-content {
  103. margin-top: 16rpx;
  104. white-space: nowrap;
  105. width: 100%;
  106. overflow-x: auto;
  107. font-size: 0;
  108. }
  109. &-item {
  110. flex: none;
  111. display: inline-block;
  112. width: 180rpx;
  113. height: 240rpx;
  114. border-radius: 12rpx;
  115. overflow: hidden;
  116. position: relative;
  117. & + & {
  118. margin-left: 16rpx;
  119. }
  120. &-bg {
  121. width: 100%;
  122. height: 100%;
  123. }
  124. &-info {
  125. position: absolute;
  126. left: 0;
  127. bottom: 0;
  128. width: 100%;
  129. padding: 8rpx 12rpx;
  130. box-sizing: border-box;
  131. &-title {
  132. font-size: 26rpx;
  133. font-weight: 600;
  134. color: #FFFFFF;
  135. }
  136. &-time {
  137. font-size: 22rpx;
  138. color: #FFFFFF;
  139. }
  140. }
  141. }
  142. }
  143. .swiper {
  144. width: 100%;
  145. height: 240rpx;
  146. &-item {
  147. width: 180rpx;
  148. height: 240rpx;
  149. &-content {
  150. position: relative;
  151. width: 100%;
  152. height: 100%;
  153. border-radius: 12rpx;
  154. overflow: hidden;
  155. }
  156. }
  157. }
  158. </style>