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

393 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 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 && 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 && 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. <button class="action-item" open-type="share" >
  78. <uv-icon name="share" size="24" color="#000"></uv-icon>
  79. <text class="action-text">分享</text>
  80. </button>
  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. token: uni.getStorageSync('token')
  154. })
  155. this.activityData = res.result
  156. },
  157. previewImage(current, urls) {
  158. uni.previewImage({
  159. current: current,
  160. urls: urls
  161. })
  162. },
  163. async collectActivity() {
  164. const res = await this.$api.activity.collectionActivity({
  165. activityId: this.activityId,
  166. })
  167. await this.loadActivityDetail(this.activityId)
  168. uni.showToast({
  169. title: `${res.message}`,
  170. icon: 'none'
  171. })
  172. },
  173. async scanQRCode() {
  174. // 扫码签到功能
  175. uni.scanCode({
  176. success: async (res) => {
  177. const { activityId } = JSON.parse(res.result)
  178. const scanRes = await this.$api.activity.signActivity({ activityId })
  179. if (scanRes.code === 200) {
  180. this.status = 'signed'
  181. uni.navigateTo({
  182. url: `/subPages/my/signupSuccess?score=${this.activityData.score}`
  183. })
  184. } else {
  185. uni.showToast({
  186. title: scanRes.message,
  187. icon: 'none'
  188. })
  189. }
  190. },
  191. fail: (err) => {
  192. console.log('扫码失败:', err)
  193. uni.showToast({
  194. title: '扫码失败',
  195. icon: 'none'
  196. })
  197. }
  198. })
  199. }
  200. }
  201. }
  202. </script>
  203. <style lang="scss" scoped>
  204. .activity-detail {
  205. min-height: 100vh;
  206. background: #f8f8f8;
  207. padding-bottom: 120rpx;
  208. .banner-container {
  209. width: 100%;
  210. height: 450rpx;
  211. .banner-swiper {
  212. width: 100%;
  213. height: 100%;
  214. .banner-image {
  215. width: 100%;
  216. height: 100%;
  217. }
  218. }
  219. }
  220. .activity-info {
  221. background: #ffffff;
  222. margin: 20rpx;
  223. border-radius: 16rpx;
  224. padding: 30rpx;
  225. .title-section {
  226. display: flex;
  227. align-items: center;
  228. margin-bottom: 30rpx;
  229. .activity-badge {
  230. background: #218CDD;
  231. border-radius: 8rpx;
  232. padding: 4rpx 10rpx;
  233. margin-right: 16rpx;
  234. .badge-text {
  235. color: #ffffff;
  236. font-size: 24rpx;
  237. font-weight: 500;
  238. }
  239. }
  240. .activity-title {
  241. font-size: 36rpx;
  242. font-weight: bold;
  243. color: #333333;
  244. flex: 1;
  245. }
  246. }
  247. .info-section {
  248. background: #F3F7F8;
  249. margin-bottom: 40rpx;
  250. border: 2rpx dashed #F3F7F8;
  251. .info-item {
  252. display: flex;
  253. align-items: center;
  254. margin-bottom: 20rpx;
  255. &:last-child {
  256. margin-bottom: 0;
  257. }
  258. .info-label {
  259. font-size: 28rpx;
  260. color: #999999;
  261. margin-left: 12rpx;
  262. margin-right: 8rpx;
  263. }
  264. .info-value {
  265. font-size: 28rpx;
  266. color: #999999;
  267. flex: 1;
  268. }
  269. }
  270. }
  271. .detail-section {
  272. margin-bottom: 40rpx;
  273. .section-title {
  274. margin-bottom: 20rpx;
  275. .title-text {
  276. font-size: 32rpx;
  277. font-weight: bold;
  278. color: #333333;
  279. }
  280. }
  281. .detail-content {
  282. .detail-text {
  283. display: block;
  284. font-size: 28rpx;
  285. color: #666666;
  286. line-height: 1.6;
  287. margin-bottom: 16rpx;
  288. &:last-child {
  289. margin-bottom: 0;
  290. }
  291. }
  292. }
  293. }
  294. .gallery-section {
  295. .section-title {
  296. margin-bottom: 20rpx;
  297. .title-text {
  298. font-size: 32rpx;
  299. font-weight: bold;
  300. color: #333333;
  301. }
  302. }
  303. .gallery-grid {
  304. display: grid;
  305. grid-template-columns: repeat(2, 1fr);
  306. gap: 16rpx;
  307. .gallery-image {
  308. width: 100%;
  309. height: 200rpx;
  310. border-radius: 12rpx;
  311. }
  312. }
  313. }
  314. }
  315. .bottom-action {
  316. position: fixed;
  317. bottom: 0;
  318. left: 0;
  319. right: 0;
  320. background: #ffffff;
  321. padding: 20rpx 30rpx;
  322. border-top: 1rpx solid #eeeeee;
  323. display: flex;
  324. align-items: center;
  325. justify-content: space-between;
  326. z-index: 100;
  327. .action-left {
  328. display: flex;
  329. align-items: center;
  330. gap: 100rpx;
  331. .action-item {
  332. display: flex;
  333. flex-direction: column;
  334. align-items: center;
  335. gap: 8rpx;
  336. .action-text {
  337. font-size: 22rpx;
  338. color: #000;
  339. }
  340. .participants-count {
  341. font-size: 24rpx;
  342. color: #333333;
  343. }
  344. }
  345. }
  346. .action-right {
  347. flex-shrink: 0;
  348. }
  349. }
  350. }
  351. </style>