木邻有你前端代码仓库
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.

397 lines
9.9 KiB

1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
  1. <template>
  2. <view class="activity-detail">
  3. <!-- 轮播图 -->
  4. <view class="banner-container">
  5. <swiper class="banner-swiper" height="450rpx" :indicator-dots="true" :autoplay="true" :interval="3000" :duration="500">
  6. <swiper-item v-for="(image, index) in activityData.image.split(',')" :key="index">
  7. <image class="banner-image" :src="image" mode="aspectFill"></image>
  8. </swiper-item>
  9. </swiper>
  10. </view>
  11. <!-- 活动信息 -->
  12. <view class="activity-info">
  13. <!-- 活动标题和标签 -->
  14. <view class="title-section">
  15. <view class="activity-badge">
  16. <text class="badge-text">{{ activityData.score }}</text>
  17. </view>
  18. <text class="activity-title">{{ activityData.title }}</text>
  19. </view>
  20. <!-- 活动详细信息 -->
  21. <view class="info-section">
  22. <view class="info-item">
  23. <uv-icon name="calendar" size="16" color="#666"></uv-icon>
  24. <text class="info-label">活动时间</text>
  25. <text class="info-value">{{ activityData.activityTime }}</text>
  26. </view>
  27. <view class="info-item">
  28. <uv-icon name="clock" size="16" color="#666"></uv-icon>
  29. <text class="info-label">报名时间</text>
  30. <text class="info-value">{{ activityData.startTime }}</text>
  31. </view>
  32. <view class="info-item">
  33. <uv-icon name="account-fill" size="16" color="#666"></uv-icon>
  34. <text class="info-label">联系人</text>
  35. <text class="info-value">{{ activityData.contact }}</text>
  36. </view>
  37. <view class="info-item">
  38. <uv-icon name="phone" size="16" color="#666"></uv-icon>
  39. <text class="info-label">取消规则</text>
  40. <text class="info-value">{{ activityData.rule }}</text>
  41. </view>
  42. <view class="info-item">
  43. <uv-icon name="map-fill" size="16" color="#666"></uv-icon>
  44. <text class="info-label">活动地点</text>
  45. <text class="info-value">{{ activityData.address }}</text>
  46. </view>
  47. </view>
  48. <!-- 活动详情 -->
  49. <view class="detail-section">
  50. <view class="section-title">
  51. <text class="title-text">活动详情</text>
  52. </view>
  53. <view class="detail-content">
  54. <rich-text :nodes="activityData.details"></rich-text>
  55. </view>
  56. </view>
  57. <!-- 活动图集 -->
  58. <view class="gallery-section">
  59. <view class="section-title">
  60. <text class="title-text">活动图集</text>
  61. </view>
  62. <view class="gallery-grid">
  63. <image
  64. v-for="(image, index) in activityData.atlas.split(',')"
  65. :key="index"
  66. class="gallery-image"
  67. :src="image"
  68. mode="aspectFill"
  69. @click="previewImage(image, activityData.atlas.split(','))"
  70. ></image>
  71. </view>
  72. </view>
  73. </view>
  74. <!-- 固定底部操作栏 -->
  75. <view class="bottom-action">
  76. <view class="action-left">
  77. <view class="action-item" @click="shareActivity">
  78. <uv-icon name="share" size="24" color="#000"></uv-icon>
  79. <text class="action-text">分享</text>
  80. </view>
  81. <view class="action-item" @click="collectActivity">
  82. <uv-icon name="heart-fill" size="24" :color="activityData.isCollection === 1 ? '#ff4757' : '#999'"></uv-icon>
  83. <text class="action-text">收藏</text>
  84. </view>
  85. <view class="action-item">
  86. <text class="participants-count">
  87. <text :style="{'color': activityData.numActivity >= activityData.numLimit ? '#999' : '#1488DB'}">{{ activityData.numActivity }}</text>
  88. /{{ activityData.numLimit }}</text>
  89. <text class="action-text">已报名</text>
  90. </view>
  91. </view>
  92. <view class="action-right">
  93. <!-- 未签到状态 -->
  94. <uv-button
  95. v-if="status === 'unsigned'"
  96. type="primary"
  97. size="normal"
  98. text="扫码签到"
  99. shape="circle"
  100. @click="scanQRCode"
  101. ></uv-button>
  102. <!-- 已签到状态 -->
  103. <uv-button
  104. v-else-if="status === 'signed'"
  105. type="success"
  106. size="normal"
  107. text="已签到"
  108. shape="circle"
  109. :disabled="true"
  110. ></uv-button>
  111. <!-- 系统取消状态 -->
  112. <uv-button
  113. v-else-if="status === 'cancelled'"
  114. type="error"
  115. size="normal"
  116. text="系统取消"
  117. shape="circle"
  118. :disabled="true"
  119. ></uv-button>
  120. </view>
  121. </view>
  122. </view>
  123. </template>
  124. <script>
  125. export default {
  126. data() {
  127. return {
  128. status: 'unsigned', // unsigned: 未签到, signed: 已签到, cancelled: 系统取消
  129. activityData: {
  130. },
  131. activityId: null
  132. }
  133. },
  134. onLoad(options) {
  135. if (options.id) {
  136. this.activityId = options.id
  137. this.loadActivityDetail(options.id)
  138. } else {
  139. uni.showToast({
  140. title: '没有给活动id',
  141. icon: 'none'
  142. })
  143. }
  144. if (options.status) {
  145. this.status = options.status
  146. }
  147. },
  148. methods: {
  149. async loadActivityDetail(id) {
  150. // 根据ID加载活动详情
  151. const res = await this.$api.activity.queryActivityById({
  152. activityId: id
  153. })
  154. this.activityData = res.result
  155. },
  156. previewImage(current, urls) {
  157. uni.previewImage({
  158. current: current,
  159. urls: urls
  160. })
  161. },
  162. shareActivity() {
  163. uni.showToast({
  164. title: '分享功能',
  165. icon: 'none'
  166. })
  167. },
  168. async collectActivity() {
  169. const res = await this.$api.activity.collectionActivity({
  170. activityId: this.activityId
  171. })
  172. await this.loadActivityDetail(this.activityId)
  173. uni.showToast({
  174. title: `${res.message}`,
  175. icon: 'none'
  176. })
  177. },
  178. async scanQRCode() {
  179. // 扫码签到功能
  180. uni.scanCode({
  181. success: async (res) => {
  182. const { activityId } = JSON.parse(res.result)
  183. const scanRes = await this.$api.activity.signActivity({ activityId })
  184. if (scanRes.code === 200) {
  185. this.status = 'signed'
  186. uni.navigateTo({
  187. url: `/subPages/my/signupSuccess?score=${this.activityData.score}`
  188. })
  189. } else {
  190. uni.showToast({
  191. title: scanRes.message,
  192. icon: 'none'
  193. })
  194. }
  195. },
  196. fail: (err) => {
  197. console.log('扫码失败:', err)
  198. uni.showToast({
  199. title: '扫码失败',
  200. icon: 'none'
  201. })
  202. }
  203. })
  204. }
  205. }
  206. }
  207. </script>
  208. <style lang="scss" scoped>
  209. .activity-detail {
  210. min-height: 100vh;
  211. background: #f8f8f8;
  212. padding-bottom: 120rpx;
  213. .banner-container {
  214. width: 100%;
  215. height: 450rpx;
  216. .banner-swiper {
  217. width: 100%;
  218. height: 100%;
  219. .banner-image {
  220. width: 100%;
  221. height: 100%;
  222. }
  223. }
  224. }
  225. .activity-info {
  226. background: #ffffff;
  227. margin: 20rpx;
  228. border-radius: 16rpx;
  229. padding: 30rpx;
  230. .title-section {
  231. display: flex;
  232. align-items: center;
  233. margin-bottom: 30rpx;
  234. .activity-badge {
  235. background: #218CDD;
  236. border-radius: 8rpx;
  237. padding: 4rpx 10rpx;
  238. margin-right: 16rpx;
  239. .badge-text {
  240. color: #ffffff;
  241. font-size: 24rpx;
  242. font-weight: 500;
  243. }
  244. }
  245. .activity-title {
  246. font-size: 36rpx;
  247. font-weight: bold;
  248. color: #333333;
  249. flex: 1;
  250. }
  251. }
  252. .info-section {
  253. background: #F3F7F8;
  254. margin-bottom: 40rpx;
  255. border: 2rpx dashed #F3F7F8;
  256. .info-item {
  257. display: flex;
  258. align-items: center;
  259. margin-bottom: 20rpx;
  260. &:last-child {
  261. margin-bottom: 0;
  262. }
  263. .info-label {
  264. font-size: 28rpx;
  265. color: #999999;
  266. margin-left: 12rpx;
  267. margin-right: 8rpx;
  268. }
  269. .info-value {
  270. font-size: 28rpx;
  271. color: #999999;
  272. flex: 1;
  273. }
  274. }
  275. }
  276. .detail-section {
  277. margin-bottom: 40rpx;
  278. .section-title {
  279. margin-bottom: 20rpx;
  280. .title-text {
  281. font-size: 32rpx;
  282. font-weight: bold;
  283. color: #333333;
  284. }
  285. }
  286. .detail-content {
  287. .detail-text {
  288. display: block;
  289. font-size: 28rpx;
  290. color: #666666;
  291. line-height: 1.6;
  292. margin-bottom: 16rpx;
  293. &:last-child {
  294. margin-bottom: 0;
  295. }
  296. }
  297. }
  298. }
  299. .gallery-section {
  300. .section-title {
  301. margin-bottom: 20rpx;
  302. .title-text {
  303. font-size: 32rpx;
  304. font-weight: bold;
  305. color: #333333;
  306. }
  307. }
  308. .gallery-grid {
  309. display: grid;
  310. grid-template-columns: repeat(2, 1fr);
  311. gap: 16rpx;
  312. .gallery-image {
  313. width: 100%;
  314. height: 200rpx;
  315. border-radius: 12rpx;
  316. }
  317. }
  318. }
  319. }
  320. .bottom-action {
  321. position: fixed;
  322. bottom: 0;
  323. left: 0;
  324. right: 0;
  325. background: #ffffff;
  326. padding: 20rpx 30rpx;
  327. border-top: 1rpx solid #eeeeee;
  328. display: flex;
  329. align-items: center;
  330. justify-content: space-between;
  331. z-index: 100;
  332. .action-left {
  333. display: flex;
  334. align-items: center;
  335. gap: 100rpx;
  336. .action-item {
  337. display: flex;
  338. flex-direction: column;
  339. align-items: center;
  340. gap: 8rpx;
  341. .action-text {
  342. font-size: 22rpx;
  343. color: #000;
  344. }
  345. .participants-count {
  346. font-size: 24rpx;
  347. color: #333333;
  348. }
  349. }
  350. }
  351. .action-right {
  352. flex-shrink: 0;
  353. }
  354. }
  355. }
  356. </style>