展品维保小程序前端代码接口
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.

406 lines
10 KiB

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