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

227 lines
5.2 KiB

  1. <template>
  2. <view class="page__view highlight">
  3. <navbar title="图片直播" leftClick @leftClick="$utils.navigateBack" />
  4. <view class="swiper">
  5. <SYStackedCarousel
  6. height="536rpx"
  7. :images="list"
  8. :current="current"
  9. :autoplay="true"
  10. horizontalMargin="25"
  11. baseOpacity="0.5"
  12. bgColor="transparent"
  13. padding="0"
  14. @click="clickHandler"
  15. @change="changeHandler"
  16. >
  17. </SYStackedCarousel>
  18. <view class="flex flex-column" v-if="swiperCurrent">
  19. <view class="title">{{ swiperCurrent.title }}</view>
  20. <view class="tag">{{ swiperCurrent.createTime }}</view>
  21. </view>
  22. </view>
  23. <view class="main">
  24. <view class="flex header">
  25. <view>图片直播</view>
  26. <view class="btn btn-mark" @click="onMark">标记有我</view>
  27. </view>
  28. <view class="section" v-for="item in list" :key="item.id">
  29. <view class="flex section-header">
  30. <view class="flex title">
  31. <view>{{ item.title }}</view>
  32. <view v-if="isManager" class="btn btn-add" @click="onAdd(item.id)">新增记录</view>
  33. </view>
  34. <button class="flex btn btn-all" @click="showAll(item.id)">
  35. <view>查看全部</view>
  36. <image class="icon" src="@/static/image/icon-arrow-right.png" mode="widthFix"></image>
  37. </button>
  38. </view>
  39. <view class="section-content record">
  40. <view class="record-item" v-for="(image, imgIdx) in item.images" :key="imgIdx">
  41. <image class="img" :src="image" mode="aspectFill"></image>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. <markPopup ref="markPopup"></markPopup>
  47. <formPopup ref="formPopup" @submitted="getData"></formPopup>
  48. </view>
  49. </template>
  50. <script>
  51. import mixinsList from '@/mixins/list.js'
  52. import SYStackedCarousel from '@/uni_modules/SY-StackedCarousel/components/SY-StackedCarousel/SY-StackedCarousel.vue'
  53. import markPopup from '@/pages_order/growing/activity/markPopup.vue'
  54. import formPopup from './formPopup.vue'
  55. export default {
  56. mixins: [mixinsList],
  57. components: {
  58. SYStackedCarousel,
  59. markPopup,
  60. formPopup,
  61. },
  62. data() {
  63. return {
  64. current: 0,
  65. mixinsListApi: 'queryImageList',
  66. // todo: fetch
  67. isManager: true,
  68. }
  69. },
  70. computed: {
  71. swiperCurrent() {
  72. return this.list[this.current]
  73. },
  74. },
  75. async onLoad() {
  76. this.getData()
  77. },
  78. methods: {
  79. getDataThen(records) {
  80. this.list = records.map(item => {
  81. const { id, image, activityId_dictText, createTime } = item
  82. const images = image?.split?.(',') || []
  83. return {
  84. id,
  85. url: images?.[0],
  86. images,
  87. title: activityId_dictText,
  88. createTime: this.$dayjs(createTime).format('YYYY-MM-DD'),
  89. }
  90. })
  91. },
  92. clickHandler(item, index) {
  93. this.current = index
  94. },
  95. changeHandler(index) {
  96. console.log("当前触发change事件,返回索引: ", index);
  97. },
  98. onMark() {
  99. this.$refs.markPopup.open(this.id)
  100. },
  101. onAdd() {
  102. this.$refs.formPopup.open()
  103. },
  104. showAll(id) {
  105. this.$store.commit('setLiveInfo', this.list.find(item => item.id === id))
  106. this.$utils.navigateTo(`/pages_order/live/index?id=${id}`)
  107. },
  108. },
  109. }
  110. </script>
  111. <style lang="scss" scoped>
  112. .swiper {
  113. margin-top: 40rpx;
  114. .title {
  115. margin-top: 12rpx;
  116. font-size: 28rpx;
  117. font-weight: 600;
  118. color: #252545;
  119. }
  120. .tag {
  121. margin-top: 4rpx;
  122. padding: 2rpx 8rpx;
  123. font-size: 24rpx;
  124. color: #00A9FF;
  125. background: #E0F5FF;
  126. border-radius: 8rpx;
  127. }
  128. }
  129. .main {
  130. padding: 0 40rpx 40rpx 40rpx;
  131. }
  132. .header {
  133. justify-content: space-between;
  134. font-size: 40rpx;
  135. font-weight: 600;
  136. color: #252545;
  137. .btn-mark {
  138. padding: 6rpx 22rpx;
  139. font-family: PingFang SC;
  140. font-size: 28rpx;
  141. font-weight: 500;
  142. line-height: 1.5;
  143. color: #FFFFFF;
  144. background: linear-gradient(to right, #21FEEC, #019AF9);
  145. border: 2rpx solid #00A9FF;
  146. border-radius: 30rpx;
  147. }
  148. }
  149. .section {
  150. margin-top: 64rpx;
  151. &-header {
  152. justify-content: space-between;
  153. font-size: 36rpx;
  154. font-weight: 500;
  155. color: #191919;
  156. .title {
  157. flex: 1;
  158. justify-content: flex-start;
  159. column-gap: 8rpx;
  160. .btn-add {
  161. padding: 8rpx 24rpx;
  162. font-size: 28rpx;
  163. font-weight: 500;
  164. line-height: 1.5;
  165. color: #252545;
  166. border: 2rpx solid #252545;
  167. border-radius: 30rpx;
  168. }
  169. }
  170. .btn-all {
  171. column-gap: 4rpx;
  172. font-size: 24rpx;
  173. line-height: 1.4;
  174. color: #8B8B8B;
  175. .icon {
  176. width: 32rpx;
  177. height: auto;
  178. }
  179. }
  180. }
  181. &-content {
  182. margin-top: 24rpx;
  183. }
  184. }
  185. .record {
  186. display: grid;
  187. grid-template-columns: repeat(3, 1fr);
  188. gap: 16rpx;
  189. &-item {
  190. height: 300rpx;
  191. border: 2rpx solid #CDCDCD;
  192. border-radius: 12rpx;
  193. overflow: hidden;
  194. .img {
  195. width: 100%;
  196. height: 100%;
  197. }
  198. }
  199. }
  200. </style>