activity-detail.vue 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194
  1. <template>
  2. <view class="container">
  3. <!-- 加载状态 -->
  4. <view v-if="loading" class="loading-wrap">
  5. <view class="loading-spinner"></view>
  6. <text class="loading-text">加载中...</text>
  7. </view>
  8. <!-- 错误状态 -->
  9. <view v-else-if="error" class="error-wrap">
  10. <text class="error-icon">📋</text>
  11. <text class="error-text">{{ errorMsg }}</text>
  12. <button class="retry-btn" @click="loadDetail(activityId)">重新加载</button>
  13. </view>
  14. <!-- 活动内容 -->
  15. <scroll-view v-else-if="activity.id" scroll-y class="content">
  16. <!-- 封面图 -->
  17. <image
  18. v-if="activity.coverImage"
  19. class="cover"
  20. :src="activity.coverImage"
  21. mode="widthFix"
  22. />
  23. <image v-else class="cover placeholder-cover" src="/static/default-activity.png" mode="aspectFill" />
  24. <view class="info-section">
  25. <text class="activity-title">{{ activity.title }}</text>
  26. <!-- 活动状态标签 -->
  27. <view class="status-row">
  28. <text class="status-tag" :class="'status-' + (activity.status || 'upcoming')">{{ statusText(activity.status) }}</text>
  29. </view>
  30. <!-- 活动元信息 -->
  31. <view class="meta-list">
  32. <view class="meta-item" v-if="activity.startTime">
  33. <text class="meta-icon">🕐</text>
  34. <text class="meta-text">{{ formatDate(activity.startTime) }}{{ activity.endTime ? ' ~ ' + formatDate(activity.endTime) : '' }}</text>
  35. </view>
  36. <view class="meta-item" v-if="activity.endTime && activity.requireRegistration === 1">
  37. <text class="meta-icon">⏰</text>
  38. <text class="meta-text">报名截止: {{ formatDate(activity.endTime) }}</text>
  39. </view>
  40. <view class="meta-item" v-if="activity.location">
  41. <text class="meta-icon">📍</text>
  42. <text class="meta-text">{{ activity.location }}</text>
  43. </view>
  44. <view class="meta-item" v-if="activity.maxParticipants">
  45. <text class="meta-icon">👥</text>
  46. <text class="meta-text">{{ activity.currentParticipants || 0 }} / {{ activity.maxParticipants }} 人</text>
  47. </view>
  48. <view class="meta-item">
  49. <text class="meta-icon">💰</text>
  50. <view class="meta-text" v-if="activity.memberPrice && activity.memberPrice > 0 && activity.memberPrice < activity.price">
  51. <text>会员价 ¥{{ activity.memberPrice }} 普通价 ¥{{ activity.price }}</text>
  52. </view>
  53. <text class="meta-text" v-else>{{ activity.priceLabel || (activity.price > 0 ? '¥' + activity.price : '免费') }}</text>
  54. </view>
  55. </view>
  56. <!-- 活动简介 -->
  57. <view class="desc-section" v-if="activity.description">
  58. <text class="section-title">活动介绍</text>
  59. <mp-html :content="activity.description" />
  60. </view>
  61. <!-- 付费不退费说明 -->
  62. <view class="refund-notice" v-if="activity.price > 0">
  63. <text class="refund-notice-icon">⚠️</text>
  64. <text class="refund-notice-text">本活动为付费活动,报名成功后不支持退费</text>
  65. </view>
  66. </view>
  67. <!-- 底部操作栏 -->
  68. <view class="bottom-bar">
  69. <view class="price-info">
  70. <text class="bottom-type">活动</text>
  71. <text class="bottom-vendor" v-if="activity.vendorName">{{ activity.vendorName }}</text>
  72. </view>
  73. <view class="action-btns">
  74. <button class="share-btn" open-type="share" @click="onShareTap">
  75. <text class="share-btn-icon">📤</text>
  76. <text class="share-btn-text">分享</text>
  77. </button>
  78. <!-- 报名按钮(仅 requireRegistration=1 时显示) -->
  79. <button
  80. v-if="activity.requireRegistration === 1 && !registrationStatus"
  81. class="btn-register"
  82. @click="onRegister"
  83. >
  84. <text v-if="activity.price > 0">¥{{ activity.price }} 立即报名</text>
  85. <text v-else>立即报名</text>
  86. </button>
  87. <!-- 已报名待审核 -->
  88. <button
  89. v-if="activity.requireRegistration === 1 && registrationStatus === 'pending'"
  90. class="btn-register-done"
  91. disabled
  92. >
  93. <text>报名待审核</text>
  94. </button>
  95. <!-- 已报名可取消 -->
  96. <button
  97. v-if="activity.requireRegistration === 1 && registrationStatus === 'approved'"
  98. class="btn-cancel"
  99. :disabled="registrationLoading"
  100. @click="onCancelRegistration"
  101. >
  102. <text>取消报名</text>
  103. </button>
  104. <!-- 签到按钮 -->
  105. <button
  106. class="btn-checkin"
  107. :class="{ 'btn-checkin-done': checkinDone, 'btn-checkin-loading': checkinLoading }"
  108. :disabled="checkinLoading || checkinDone"
  109. @click="onCheckin"
  110. >
  111. <text v-if="checkinLoading">签到中...</text>
  112. <text v-else-if="checkinDone && activity.requireCheckinReview === 1">已签到待审核</text>
  113. <text v-else-if="checkinDone">已签到 ✓</text>
  114. <text v-else>签到</text>
  115. </button>
  116. <text v-if="activity.requireCheckinReview === 1 && !checkinDone" class="checkin-review-hint">签到需要管理员审核</text>
  117. </view>
  118. </view>
  119. <!-- 能量扣减提示弹窗 -->
  120. <modal v-if="showPenaltyModal" class="penalty-modal" :show="showPenaltyModal" @close="showPenaltyModal = false">
  121. <view class="penalty-content">
  122. <text class="penalty-title">签到成功但已扣能量</text>
  123. <text class="penalty-desc">您未报名参加此活动,已被扣除 {{ penaltyAmount }} 点能量值</text>
  124. <button class="penalty-btn" @click="showPenaltyModal = false">我知道了</button>
  125. </view>
  126. </modal>
  127. <!-- 活动评价 -->
  128. <view class="feedback-section" v-if="activity.status === 'ended' && checkinDone">
  129. <view class="feedback-header">
  130. <text class="feedback-title">活动评价</text>
  131. </view>
  132. <!-- Already submitted feedback -->
  133. <view v-if="submittedFeedback" class="feedback-submitted">
  134. <view class="feedback-ratings-display">
  135. <view class="fr-row" v-for="(val, key) in parsedSubmittedRatings" :key="key">
  136. <text class="fr-label">{{ key }}</text>
  137. <text class="fr-stars">{{ getStarDisplay(val) }}</text>
  138. </view>
  139. </view>
  140. <text class="feedback-comment-text" v-if="submittedFeedback.comment">{{ submittedFeedback.comment }}</text>
  141. <text class="feedback-thanks">感谢您的评价!</text>
  142. </view>
  143. <!-- Submit feedback button -->
  144. <button v-else class="feedback-btn" @click="openFeedbackModal">
  145. <text>提交活动评价</text>
  146. </button>
  147. </view>
  148. <!-- 评价弹窗 -->
  149. <modal v-if="showFeedbackModal" class="feedback-modal-overlay" :show="showFeedbackModal" @close="showFeedbackModal = false">
  150. <view class="feedback-modal">
  151. <text class="feedback-modal-title">活动评价</text>
  152. <view class="rating-row" v-for="(dim, dimIdx) in feedbackDimensions" :key="dimIdx">
  153. <text class="rating-label">{{ dim }}</text>
  154. <view class="stars">
  155. <text v-for="star in 5" :key="star"
  156. class="star-icon"
  157. :class="{'star-active': star <= (feedbackRatings[dim] || 0)}"
  158. @click="feedbackRatings[dim] = star">★</text>
  159. </view>
  160. </view>
  161. <textarea class="feedback-textarea" v-model="feedbackComment" placeholder="说说您的体验..." maxlength="500" />
  162. <view class="feedback-modal-actions">
  163. <button class="feedback-cancel-btn" @click="showFeedbackModal = false">取消</button>
  164. <button class="feedback-submit-btn" :disabled="feedbackSubmitting" @click="submitFeedback">
  165. <text v-if="feedbackSubmitting">提交中...</text>
  166. <text v-else>提交评价</text>
  167. </button>
  168. </view>
  169. </view>
  170. </modal>
  171. <!-- 报名表单弹窗 -->
  172. <modal v-if="showRegModal" class="reg-modal-overlay" :show="showRegModal" @close="showRegModal = false">
  173. <view class="reg-modal">
  174. <text class="reg-modal-title">活动报名</text>
  175. <!-- 家庭成员选择 -->
  176. <view class="reg-family-section" v-if="familyMembers.length > 0">
  177. <text class="reg-section-label">从家庭成员中选择</text>
  178. <view class="reg-family-list">
  179. <view
  180. class="reg-family-item"
  181. v-for="member in familyMembers"
  182. :key="member.id"
  183. :class="{'reg-family-item-selected': isMemberSelected(member)}"
  184. @click="toggleFamilyMember(member)"
  185. >
  186. <view class="reg-family-info">
  187. <text class="reg-family-name">{{ member.name }}</text>
  188. <text class="reg-family-relation">{{ member.relation }}</text>
  189. </view>
  190. <text class="reg-checkmark" v-if="isMemberSelected(member)">✓</text>
  191. </view>
  192. </view>
  193. </view>
  194. <!-- 报名人列表 -->
  195. <view class="reg-list">
  196. <text class="reg-section-label">报名人</text>
  197. <view class="reg-entry" v-for="(entry, idx) in registrants" :key="idx">
  198. <input class="reg-input reg-input-name" v-model="entry.name" placeholder="姓名" />
  199. <input class="reg-input reg-input-phone" v-model="entry.phone" placeholder="手机号" type="number" maxlength="11" />
  200. <text class="reg-remove" @click="removeRegistrant(idx)">✕</text>
  201. </view>
  202. <button class="reg-add-btn" @click="addManualEntry">+ 添加报名人</button>
  203. </view>
  204. <!-- 合计 -->
  205. <view class="reg-total" v-if="activity.price > 0">
  206. <text>共 {{ registrants.length }} 人 · 合计 ¥{{ activity.price * registrants.length }}</text>
  207. </view>
  208. <!-- 操作按钮 -->
  209. <view class="reg-actions">
  210. <button class="reg-cancel" @click="closeRegModal">取消</button>
  211. <button class="reg-submit" :disabled="regSubmitting || registrants.length === 0" @click="submitRegistration">
  212. <text v-if="regSubmitting">提交中...</text>
  213. <text v-else>确认报名</text>
  214. </button>
  215. </view>
  216. </view>
  217. </modal>
  218. </scroll-view>
  219. <!-- 空状态 -->
  220. <view v-else class="empty-wrap">
  221. <text class="empty-text">活动不存在或已下架</text>
  222. </view>
  223. </view>
  224. </template>
  225. <script>
  226. import { getActivityDetail, activityCheckin, registerActivity, cancelActivityRegistration, getMyActivityRegistrations, submitActivityFeedback, getActivityFeedbackList, getMyActivityFeedback, getFamilyMembers } from '@/utils/api.js'
  227. import shareMixin from '../../../components/share-mixin.js'
  228. import MpHtml from '@/components/mp-html/mp-html.vue'
  229. export default {
  230. mixins: [shareMixin],
  231. components: { MpHtml },
  232. data() {
  233. return {
  234. activityId: null,
  235. activity: {},
  236. loading: false,
  237. error: false,
  238. errorMsg: '',
  239. checkinLoading: false,
  240. checkinDone: false,
  241. checkinPoints: 0,
  242. registrationStatus: null,
  243. registrationLoading: false,
  244. showPenaltyModal: false,
  245. penaltyAmount: 0,
  246. showFeedbackModal: false,
  247. feedbackDimensions: [],
  248. feedbackRatings: {},
  249. feedbackComment: '',
  250. submittedFeedback: null,
  251. feedbackSubmitting: false,
  252. feedbackList: [],
  253. // registration form modal
  254. showRegModal: false,
  255. familyMembers: [],
  256. registrants: [],
  257. regSubmitting: false
  258. }
  259. },
  260. onLoad: function(options) {
  261. if (options && options.id) {
  262. this.activityId = options.id
  263. this.loadDetail(options.id)
  264. } else {
  265. this.error = true
  266. this.errorMsg = '缺少活动ID'
  267. }
  268. // 检查是否已经签到(从路由参数获取)
  269. if (options && options.checkinDone === '1') {
  270. this.checkinDone = true
  271. }
  272. },
  273. methods: {
  274. // ===== 工具方法 =====
  275. formatDate: function(dateStr) {
  276. if (!dateStr) return ''
  277. var d = new Date(dateStr.replace(/-/g, '/'))
  278. if (isNaN(d.getTime())) return dateStr
  279. var year = d.getFullYear()
  280. var month = d.getMonth() + 1
  281. var day = d.getDate()
  282. var hour = d.getHours()
  283. var minute = d.getMinutes()
  284. var ampm = hour < 12 ? '上午' : '下午'
  285. var h12 = hour % 12
  286. if (h12 === 0) h12 = 12
  287. var minStr = minute < 10 ? '0' + minute : minute
  288. return year + '年' + month + '月' + day + '日 ' + ampm + h12 + ':' + minStr
  289. },
  290. loadDetail: function(id) {
  291. var self = this
  292. self.loading = true
  293. self.error = false
  294. getActivityDetail(id).then(function(res) {
  295. self.loading = false
  296. if (res && res.code === 200 && res.data) {
  297. self.activity = res.data
  298. self.setShareInfo('推荐活动: ' + (res.data.title || ''), '/pages/activity/activity-detail/activity-detail?id=' + id)
  299. self.parseFeedbackDimensions()
  300. self.loadFeedbackStatus()
  301. // Load registration status if logged in and activity requires registration
  302. if (self.activity.requireRegistration === 1) {
  303. var childId = uni.getStorageSync('currentChildId')
  304. if (childId) {
  305. getMyActivityRegistrations({ childId: childId, page: 1, size: 50 }).then(function(regRes) {
  306. if (regRes && regRes.data && regRes.data.records) {
  307. var records = regRes.data.records
  308. for (var i = 0; i < records.length; i++) {
  309. if (records[i].activityId === self.activity.id) {
  310. self.registrationStatus = records[i].status
  311. break
  312. }
  313. }
  314. }
  315. }).catch(function() {})
  316. }
  317. }
  318. } else {
  319. self.error = true
  320. self.errorMsg = (res && res.message) || '加载失败'
  321. }
  322. }).catch(function(err) {
  323. self.loading = false
  324. self.error = true
  325. self.errorMsg = '网络异常,请稍后重试'
  326. })
  327. },
  328. statusText: function(status) {
  329. var map = { draft: '草稿', published: '进行中', ended: '已结束' }
  330. return map[status] || '未知'
  331. },
  332. onCheckin: function() {
  333. var self = this
  334. if (self.checkinLoading || self.checkinDone) return
  335. var childId = uni.getStorageSync('currentChildId')
  336. if (!childId) {
  337. uni.showToast({ title: '请选择孩子身份', icon: 'none' })
  338. return
  339. }
  340. self.checkinLoading = true
  341. activityCheckin({ id: self.activity.id, childId: childId }).then(function(res) {
  342. self.checkinLoading = false
  343. if (res && res.code === 200 && res.data) {
  344. self.loadFeedbackStatus()
  345. // 检查是否有能量扣减
  346. if (res.data.energyPenalty) {
  347. self.penaltyAmount = res.data.energyPenalty
  348. self.showPenaltyModal = true
  349. self.checkinDone = true
  350. return
  351. }
  352. if (res.data.alreadyCompleted) {
  353. self.checkinDone = true
  354. uni.showToast({ title: '已签到', icon: 'success' })
  355. } else if (res.data.pointsEarned && res.data.pointsEarned > 0) {
  356. self.checkinDone = true
  357. self.checkinPoints = res.data.pointsEarned
  358. uni.showToast({ title: '签到成功 +' + res.data.pointsEarned + '积分', icon: 'success' })
  359. } else {
  360. self.checkinDone = true
  361. uni.showToast({ title: '签到成功', icon: 'success' })
  362. }
  363. } else {
  364. var msg = (res && res.message) || '签到失败'
  365. // 如果是报名待审核,提示用户
  366. if (msg.indexOf('报名') !== -1 || msg.indexOf('审核') !== -1) {
  367. uni.showModal({ title: '提示', content: msg, showCancel: false })
  368. } else {
  369. uni.showToast({ title: msg, icon: 'none' })
  370. }
  371. }
  372. }).catch(function(err) {
  373. self.checkinLoading = false
  374. uni.showToast({ title: '网络异常', icon: 'none' })
  375. })
  376. },
  377. onRegister: function() {
  378. var self = this
  379. // Open registration form modal
  380. self.showRegModal = true
  381. self.registrants = []
  382. self.loadFamilyMembers()
  383. },
  384. onCancelRegistration: function() {
  385. var self = this
  386. uni.showModal({
  387. title: '提示',
  388. content: '确定要取消报名吗?',
  389. success: function(res) {
  390. if (res.confirm) {
  391. var childId = uni.getStorageSync('currentChildId')
  392. self.registrationLoading = true
  393. cancelActivityRegistration({ id: self.activity.id, childId: childId }).then(function(res) {
  394. self.registrationLoading = false
  395. if (res && res.code === 200) {
  396. self.registrationStatus = null
  397. uni.showToast({ title: '已取消报名', icon: 'success' })
  398. } else {
  399. uni.showToast({ title: (res && res.message) || '取消失败', icon: 'none' })
  400. }
  401. }).catch(function() {
  402. self.registrationLoading = false
  403. uni.showToast({ title: '网络异常', icon: 'none' })
  404. })
  405. }
  406. }
  407. })
  408. },
  409. // ===== 活动评价 =====
  410. parseFeedbackDimensions: function() {
  411. var dims = ['组织形式', '会场气氛', '主持人', '专家']
  412. if (this.activity.feedbackDimensions) {
  413. try {
  414. var parsed = JSON.parse(this.activity.feedbackDimensions)
  415. if (parsed && parsed.length > 0) {
  416. dims = parsed
  417. }
  418. } catch(e) {}
  419. }
  420. this.feedbackDimensions = dims
  421. this.initRatings()
  422. },
  423. initRatings: function() {
  424. var r = {}
  425. for (var i = 0; i < this.feedbackDimensions.length; i++) {
  426. r[this.feedbackDimensions[i]] = 0
  427. }
  428. this.feedbackRatings = r
  429. },
  430. loadFeedbackStatus: function() {
  431. var self = this
  432. var childId = uni.getStorageSync('currentChildId')
  433. if (!childId || !self.activity || !self.activity.id) return
  434. getMyActivityFeedback({ activityId: self.activity.id, childId: childId }).then(function(res) {
  435. if (res && res.code === 200 && res.data) {
  436. self.submittedFeedback = res.data
  437. }
  438. }).catch(function() {})
  439. },
  440. openFeedbackModal: function() {
  441. this.showFeedbackModal = true
  442. },
  443. submitFeedback: function() {
  444. var self = this
  445. // Validate at least one rating
  446. var hasRating = false
  447. for (var key in self.feedbackRatings) {
  448. if (self.feedbackRatings[key] > 0) { hasRating = true; break }
  449. }
  450. if (!hasRating) {
  451. uni.showToast({ title: '请至少评价一项', icon: 'none' })
  452. return
  453. }
  454. self.feedbackSubmitting = true
  455. var childId = uni.getStorageSync('currentChildId')
  456. submitActivityFeedback({
  457. activityId: self.activity.id,
  458. childId: childId,
  459. ratings: JSON.stringify(self.feedbackRatings),
  460. comment: self.feedbackComment
  461. }).then(function(res) {
  462. self.feedbackSubmitting = false
  463. if (res && res.code === 200) {
  464. self.showFeedbackModal = false
  465. self.loadFeedbackStatus()
  466. uni.showToast({ title: '评价成功', icon: 'success' })
  467. } else {
  468. uni.showToast({ title: (res && res.message) || '提交失败', icon: 'none' })
  469. }
  470. }).catch(function() {
  471. self.feedbackSubmitting = false
  472. uni.showToast({ title: '网络异常', icon: 'none' })
  473. })
  474. },
  475. getStarDisplay: function(val) {
  476. var full = parseInt(val) || 0
  477. var empty = 5 - full
  478. return '★'.repeat(full) + '☆'.repeat(empty)
  479. },
  480. // ===== 报名表单 =====
  481. loadFamilyMembers: function() {
  482. var self = this
  483. getFamilyMembers().then(function(res) {
  484. if (res && res.code === 200 && res.data) {
  485. var list = []
  486. // parents
  487. var parents = res.data.parents || []
  488. for (var i = 0; i < parents.length; i++) {
  489. list.push({
  490. id: 'p_' + parents[i].id,
  491. name: parents[i].nickname || parents[i].name || '',
  492. phone: parents[i].phone || '',
  493. relation: '家长',
  494. childId: parents[i].id,
  495. source: 'parent'
  496. })
  497. }
  498. // children
  499. var children = res.data.children || []
  500. for (var j = 0; j < children.length; j++) {
  501. list.push({
  502. id: 'c_' + children[j].id,
  503. name: children[j].nickname || children[j].name || '',
  504. phone: children[j].phone || '',
  505. relation: '孩子',
  506. childId: children[j].userId || children[j].id,
  507. source: 'child'
  508. })
  509. }
  510. self.familyMembers = list
  511. }
  512. }).catch(function() {})
  513. },
  514. isMemberSelected: function(member) {
  515. for (var i = 0; i < this.registrants.length; i++) {
  516. if (this.registrants[i].memberId === member.id) return true
  517. }
  518. return false
  519. },
  520. toggleFamilyMember: function(member) {
  521. for (var i = 0; i < this.registrants.length; i++) {
  522. if (this.registrants[i].memberId === member.id) {
  523. this.registrants.splice(i, 1)
  524. return
  525. }
  526. }
  527. this.registrants.push({
  528. memberId: member.id,
  529. name: member.name,
  530. phone: member.phone,
  531. childId: member.childId
  532. })
  533. },
  534. addManualEntry: function() {
  535. this.registrants.push({
  536. memberId: null,
  537. name: '',
  538. phone: '',
  539. childId: null
  540. })
  541. },
  542. removeRegistrant: function(idx) {
  543. this.registrants.splice(idx, 1)
  544. },
  545. closeRegModal: function() {
  546. this.showRegModal = false
  547. this.registrants = []
  548. this.familyMembers = []
  549. },
  550. submitRegistration: function() {
  551. var self = this
  552. // Validate
  553. if (self.registrants.length === 0) {
  554. uni.showToast({ title: '请至少添加一个报名人', icon: 'none' })
  555. return
  556. }
  557. for (var i = 0; i < self.registrants.length; i++) {
  558. var entry = self.registrants[i]
  559. if (!entry.name || entry.name.trim() === '') {
  560. uni.showToast({ title: '请输入第 ' + (i + 1) + ' 个报名人的姓名', icon: 'none' })
  561. return
  562. }
  563. var phone = (entry.phone || '').trim()
  564. if (phone === '') {
  565. uni.showToast({ title: '请输入第 ' + (i + 1) + ' 个报名人的手机号', icon: 'none' })
  566. return
  567. }
  568. if (!/^1[3-9]\d{9}$/.test(phone)) {
  569. uni.showToast({ title: '请输入第 ' + (i + 1) + ' 个报名人的正确手机号', icon: 'none' })
  570. return
  571. }
  572. }
  573. // 付费活动 → 先确认支付
  574. if (self.activity && self.activity.price > 0) {
  575. var total = self.activity.price * self.registrants.length
  576. uni.showModal({
  577. title: '确认报名',
  578. content: '共 ' + self.registrants.length + ' 人,需支付 ¥' + total + ',报名成功后不支持退费。是否继续?',
  579. confirmText: '确认支付',
  580. cancelText: '再想想',
  581. success: function(confirmRes) {
  582. if (confirmRes.confirm) {
  583. self.doBatchRegister()
  584. }
  585. }
  586. })
  587. } else {
  588. self.doBatchRegister()
  589. }
  590. },
  591. doBatchRegister: function() {
  592. var self = this
  593. self.regSubmitting = true
  594. var registrantsData = []
  595. for (var i = 0; i < self.registrants.length; i++) {
  596. var entry = self.registrants[i]
  597. registrantsData.push({
  598. name: entry.name.trim(),
  599. phone: entry.phone || '',
  600. childId: entry.childId
  601. })
  602. }
  603. registerActivity({ id: self.activity.id, registrants: registrantsData }).then(function(res) {
  604. self.regSubmitting = false
  605. if (res && res.code === 200) {
  606. self.closeRegModal()
  607. self.registrationStatus = 'pending'
  608. uni.showToast({ title: '报名成功,请等待审核', icon: 'success' })
  609. } else {
  610. uni.showToast({ title: (res && res.message) || '报名失败', icon: 'none' })
  611. }
  612. }).catch(function() {
  613. self.regSubmitting = false
  614. uni.showToast({ title: '网络异常', icon: 'none' })
  615. })
  616. }
  617. },
  618. computed: {
  619. parsedSubmittedRatings: function() {
  620. if (!this.submittedFeedback || !this.submittedFeedback.ratings) return {}
  621. try {
  622. return JSON.parse(this.submittedFeedback.ratings)
  623. } catch(e) {
  624. return {}
  625. }
  626. }
  627. }
  628. }
  629. </script>
  630. <style scoped>
  631. .container {
  632. min-height: 100vh;
  633. background: #FFF7ED;
  634. }
  635. /* 加载 / 错误 / 空状态 */
  636. .loading-wrap,
  637. .error-wrap,
  638. .empty-wrap {
  639. display: flex;
  640. flex-direction: column;
  641. align-items: center;
  642. justify-content: center;
  643. padding: 120rpx 40rpx;
  644. }
  645. .loading-spinner {
  646. width: 60rpx;
  647. height: 60rpx;
  648. border: 4rpx solid #FDE68A;
  649. border-top-color: #F97316;
  650. border-radius: 50%;
  651. animation: spin 0.8s linear infinite;
  652. margin-bottom: 20rpx;
  653. }
  654. @keyframes spin {
  655. to { transform: rotate(360deg); }
  656. }
  657. .loading-text,
  658. .error-text,
  659. .empty-text {
  660. font-size: 28rpx;
  661. color: #999;
  662. margin-bottom: 20rpx;
  663. }
  664. .error-icon {
  665. font-size: 60rpx;
  666. margin-bottom: 16rpx;
  667. }
  668. .retry-btn {
  669. background: #F97316;
  670. color: #fff;
  671. border: none;
  672. border-radius: 40rpx;
  673. padding: 12rpx 40rpx;
  674. font-size: 26rpx;
  675. line-height: 1.5;
  676. }
  677. /* 内容区 */
  678. .content {
  679. height: 100vh;
  680. padding-bottom: 120rpx;
  681. }
  682. .cover {
  683. width: 100%;
  684. display: block;
  685. }
  686. .placeholder-cover {
  687. height: 400rpx;
  688. background: #f0f0f0;
  689. }
  690. /* 信息区 */
  691. .info-section {
  692. padding: 30rpx;
  693. }
  694. .activity-title {
  695. font-size: 36rpx;
  696. font-weight: bold;
  697. color: #1f2937;
  698. line-height: 1.4;
  699. }
  700. .status-row {
  701. margin-top: 16rpx;
  702. }
  703. .status-tag {
  704. display: inline-block;
  705. font-size: 22rpx;
  706. padding: 4rpx 16rpx;
  707. border-radius: 8rpx;
  708. }
  709. .status-draft { background: #F5F5F5; color: #999; }
  710. .status-published { background: #F0FDF4; color: #22C55E; }
  711. .status-ended { background: #F5F5F5; color: #999; }
  712. .status-upcoming { background: #FFF7ED; color: #F97316; }
  713. /* 元信息列表 */
  714. .meta-list {
  715. margin-top: 24rpx;
  716. background: #fff;
  717. border-radius: 16rpx;
  718. padding: 24rpx;
  719. }
  720. .meta-item {
  721. display: flex;
  722. flex-direction: row;
  723. align-items: center;
  724. margin-bottom: 16rpx;
  725. }
  726. .meta-item:last-child {
  727. margin-bottom: 0;
  728. }
  729. .meta-icon {
  730. font-size: 28rpx;
  731. margin-right: 12rpx;
  732. width: 32rpx;
  733. text-align: center;
  734. }
  735. .meta-text {
  736. font-size: 26rpx;
  737. color: #4b5563;
  738. flex: 1;
  739. line-height: 1.4;
  740. }
  741. /* 活动介绍 */
  742. .desc-section {
  743. margin-top: 30rpx;
  744. background: #fff;
  745. border-radius: 16rpx;
  746. padding: 24rpx;
  747. }
  748. .section-title {
  749. font-size: 28rpx;
  750. font-weight: 600;
  751. color: #1f2937;
  752. display: block;
  753. margin-bottom: 12rpx;
  754. }
  755. .desc-text {
  756. font-size: 26rpx;
  757. color: #4b5563;
  758. line-height: 1.6;
  759. }
  760. /* 付费不退费说明 */
  761. .refund-notice {
  762. margin-top: 20rpx;
  763. margin-left: 30rpx;
  764. margin-right: 30rpx;
  765. margin-bottom: 10rpx;
  766. background: #FEF2F2;
  767. border: 2rpx solid #FECACA;
  768. border-radius: 12rpx;
  769. padding: 16rpx 20rpx;
  770. display: flex;
  771. flex-direction: row;
  772. align-items: center;
  773. }
  774. .refund-notice-icon {
  775. font-size: 24rpx;
  776. margin-right: 10rpx;
  777. flex-shrink: 0;
  778. }
  779. .refund-notice-text {
  780. font-size: 24rpx;
  781. color: #DC2626;
  782. line-height: 1.4;
  783. }
  784. /* 底部操作栏 */
  785. .bottom-bar {
  786. position: fixed;
  787. left: 0;
  788. right: 0;
  789. bottom: 0;
  790. background: #fff;
  791. padding: 20rpx 30rpx;
  792. padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
  793. display: flex;
  794. flex-direction: row;
  795. align-items: center;
  796. justify-content: space-between;
  797. box-shadow: 0 -2rpx 12rpx rgba(0,0,0,0.06);
  798. }
  799. .price-info {
  800. display: flex;
  801. flex-direction: column;
  802. }
  803. .bottom-type {
  804. font-size: 22rpx;
  805. color: #999;
  806. }
  807. .bottom-vendor {
  808. font-size: 22rpx;
  809. color: #999;
  810. margin-top: 4rpx;
  811. }
  812. .action-btns {
  813. display: flex;
  814. flex-direction: row;
  815. gap: 16rpx;
  816. }
  817. .btn-checkin {
  818. background: linear-gradient(135deg, #F97316, #FB923C);
  819. color: #fff;
  820. border: none;
  821. border-radius: 40rpx;
  822. padding: 16rpx 48rpx;
  823. font-size: 28rpx;
  824. font-weight: 600;
  825. line-height: 1.5;
  826. min-width: 160rpx;
  827. text-align: center;
  828. }
  829. .btn-checkin:active {
  830. opacity: 0.85;
  831. }
  832. .btn-checkin-done {
  833. background: #22C55E;
  834. }
  835. .btn-checkin-loading {
  836. opacity: 0.7;
  837. }
  838. /* 报名按钮 */
  839. .btn-register {
  840. background: linear-gradient(135deg, #10B981, #34D399);
  841. color: #fff;
  842. border: none;
  843. border-radius: 40rpx;
  844. padding: 16rpx 32rpx;
  845. font-size: 26rpx;
  846. font-weight: 600;
  847. line-height: 1.5;
  848. min-width: 140rpx;
  849. text-align: center;
  850. }
  851. .btn-register:active { opacity: 0.85; }
  852. .btn-register-loading { opacity: 0.7; }
  853. .btn-register-done {
  854. background: #F5F5F5;
  855. color: #999;
  856. border: none;
  857. border-radius: 40rpx;
  858. padding: 16rpx 32rpx;
  859. font-size: 26rpx;
  860. line-height: 1.5;
  861. min-width: 140rpx;
  862. text-align: center;
  863. }
  864. .btn-cancel {
  865. background: #fff;
  866. color: #999;
  867. border: 2rpx solid #ddd;
  868. border-radius: 40rpx;
  869. padding: 14rpx 28rpx;
  870. font-size: 24rpx;
  871. line-height: 1.5;
  872. min-width: 120rpx;
  873. text-align: center;
  874. }
  875. .btn-cancel:active { opacity: 0.7; }
  876. /* 能量扣减弹窗 */
  877. .penalty-modal {
  878. position: fixed;
  879. top: 0;
  880. left: 0;
  881. right: 0;
  882. bottom: 0;
  883. background: rgba(0,0,0,0.5);
  884. display: flex;
  885. align-items: center;
  886. justify-content: center;
  887. z-index: 999;
  888. }
  889. .penalty-content {
  890. background: #fff;
  891. border-radius: 24rpx;
  892. padding: 48rpx 40rpx;
  893. width: 560rpx;
  894. text-align: center;
  895. }
  896. .penalty-title {
  897. font-size: 32rpx;
  898. font-weight: bold;
  899. color: #EF4444;
  900. display: block;
  901. margin-bottom: 20rpx;
  902. }
  903. .penalty-desc {
  904. font-size: 26rpx;
  905. color: #666;
  906. display: block;
  907. margin-bottom: 40rpx;
  908. line-height: 1.6;
  909. }
  910. .penalty-btn {
  911. background: #F97316;
  912. color: #fff;
  913. border: none;
  914. border-radius: 40rpx;
  915. padding: 16rpx 60rpx;
  916. font-size: 28rpx;
  917. }
  918. /* 活动评价 */
  919. .feedback-section {
  920. padding: 30rpx;
  921. margin: 20rpx;
  922. background: #fff;
  923. border-radius: 16rpx;
  924. }
  925. .feedback-header { margin-bottom: 20rpx; }
  926. .feedback-title { font-size: 32rpx; font-weight: bold; color: #333; }
  927. .feedback-btn {
  928. background: #F97316; color: #fff; border: none;
  929. border-radius: 40rpx; padding: 20rpx 40rpx; font-size: 28rpx;
  930. text-align: center;
  931. }
  932. .feedback-submitted { padding: 10rpx 0; }
  933. .feedback-ratings-display { margin-bottom: 16rpx; }
  934. .fr-row { display: flex; justify-content: space-between; padding: 8rpx 0; }
  935. .fr-label { font-size: 28rpx; color: #333; }
  936. .fr-stars { font-size: 28rpx; color: #F97316; }
  937. .feedback-comment-text { font-size: 26rpx; color: #666; margin: 10rpx 0; line-height: 1.5; }
  938. .feedback-thanks { font-size: 24rpx; color: #999; text-align: center; margin-top: 16rpx; }
  939. .feedback-modal-overlay {
  940. position: fixed;
  941. top: 0;
  942. left: 0;
  943. right: 0;
  944. bottom: 0;
  945. background: rgba(0,0,0,0.5);
  946. display: flex;
  947. align-items: center;
  948. justify-content: center;
  949. z-index: 999;
  950. }
  951. .feedback-modal {
  952. background: #fff; border-radius: 20rpx; padding: 40rpx;
  953. width: 80%; max-width: 600rpx;
  954. }
  955. .feedback-modal-title {
  956. font-size: 34rpx; font-weight: bold; color: #333;
  957. text-align: center; margin-bottom: 30rpx;
  958. }
  959. .rating-row {
  960. display: flex; justify-content: space-between; align-items: center;
  961. padding: 16rpx 0;
  962. }
  963. .rating-label { font-size: 28rpx; color: #333; min-width: 120rpx; }
  964. .stars { display: flex; }
  965. .star-icon { font-size: 40rpx; color: #ddd; padding: 0 6rpx; }
  966. .star-active { color: #F97316; }
  967. .feedback-textarea {
  968. width: 100%; height: 160rpx; margin-top: 20rpx;
  969. border: 1rpx solid #eee; border-radius: 12rpx;
  970. padding: 16rpx; font-size: 26rpx; box-sizing: border-box;
  971. }
  972. .feedback-modal-actions {
  973. display: flex; justify-content: space-between; margin-top: 30rpx;
  974. }
  975. .feedback-cancel-btn {
  976. flex: 1; background: #f5f5f5; color: #666; border: none;
  977. border-radius: 40rpx; padding: 20rpx; font-size: 28rpx;
  978. text-align: center; margin-right: 20rpx;
  979. }
  980. .feedback-submit-btn {
  981. flex: 1; background: #F97316; color: #fff; border: none;
  982. border-radius: 40rpx; padding: 20rpx; font-size: 28rpx;
  983. text-align: center;
  984. }
  985. .share-btn { height: 64rpx; line-height: 64rpx; background: #f5f5f5; color: #666; font-size: 24rpx; border-radius: 32rpx; padding: 0 20rpx; display: flex; align-items: center; border: none; flex-shrink: 0; }
  986. .share-btn::after { border: none; }
  987. .share-btn-icon { font-size: 28rpx; margin-right: 4rpx; }
  988. .share-btn-text { font-size: 24rpx; }
  989. /* 报名表单弹窗 */
  990. .reg-modal-overlay {
  991. position: fixed;
  992. top: 0;
  993. left: 0;
  994. right: 0;
  995. bottom: 0;
  996. background: rgba(0,0,0,0.5);
  997. display: flex;
  998. align-items: center;
  999. justify-content: center;
  1000. z-index: 999;
  1001. }
  1002. .reg-modal {
  1003. background: #fff;
  1004. border-radius: 24rpx;
  1005. padding: 40rpx;
  1006. width: 85%;
  1007. max-height: 80vh;
  1008. overflow-y: auto;
  1009. }
  1010. .reg-modal-title {
  1011. font-size: 34rpx;
  1012. font-weight: bold;
  1013. color: #333;
  1014. text-align: center;
  1015. display: block;
  1016. margin-bottom: 30rpx;
  1017. }
  1018. .reg-section-label {
  1019. font-size: 28rpx;
  1020. font-weight: 600;
  1021. color: #555;
  1022. display: block;
  1023. margin-bottom: 16rpx;
  1024. }
  1025. .reg-family-section {
  1026. margin-bottom: 24rpx;
  1027. }
  1028. .reg-family-list {
  1029. max-height: 300rpx;
  1030. overflow-y: auto;
  1031. }
  1032. .reg-family-item {
  1033. display: flex;
  1034. flex-direction: row;
  1035. align-items: center;
  1036. justify-content: space-between;
  1037. padding: 16rpx 20rpx;
  1038. background: #f9f9f9;
  1039. border-radius: 12rpx;
  1040. margin-bottom: 10rpx;
  1041. }
  1042. .reg-family-item-selected {
  1043. background: #FFF7ED;
  1044. border: 2rpx solid #F97316;
  1045. }
  1046. .reg-family-info {
  1047. display: flex;
  1048. flex-direction: row;
  1049. align-items: center;
  1050. }
  1051. .reg-family-name {
  1052. font-size: 28rpx;
  1053. color: #333;
  1054. margin-right: 12rpx;
  1055. }
  1056. .reg-family-relation {
  1057. font-size: 22rpx;
  1058. color: #999;
  1059. background: #eee;
  1060. padding: 2rpx 12rpx;
  1061. border-radius: 8rpx;
  1062. }
  1063. .reg-checkmark {
  1064. color: #F97316;
  1065. font-size: 32rpx;
  1066. font-weight: bold;
  1067. }
  1068. .reg-list {
  1069. margin-bottom: 20rpx;
  1070. }
  1071. .reg-entry {
  1072. display: flex;
  1073. flex-direction: row;
  1074. align-items: center;
  1075. margin-bottom: 12rpx;
  1076. gap: 10rpx;
  1077. }
  1078. .reg-input {
  1079. flex: 1;
  1080. background: #f5f5f5;
  1081. border: none;
  1082. border-radius: 12rpx;
  1083. padding: 16rpx 20rpx;
  1084. font-size: 26rpx;
  1085. color: #333;
  1086. }
  1087. .reg-input-name {
  1088. flex: 2;
  1089. }
  1090. .reg-input-phone {
  1091. flex: 3;
  1092. }
  1093. .reg-remove {
  1094. color: #EF4444;
  1095. font-size: 28rpx;
  1096. padding: 10rpx;
  1097. flex-shrink: 0;
  1098. }
  1099. .reg-add-btn {
  1100. background: none;
  1101. border: 2rpx dashed #ddd;
  1102. border-radius: 12rpx;
  1103. padding: 16rpx;
  1104. font-size: 26rpx;
  1105. color: #F97316;
  1106. text-align: center;
  1107. width: 100%;
  1108. margin-top: 6rpx;
  1109. }
  1110. .reg-total {
  1111. text-align: center;
  1112. font-size: 30rpx;
  1113. font-weight: bold;
  1114. color: #F97316;
  1115. margin-bottom: 24rpx;
  1116. padding: 16rpx;
  1117. background: #FFF7ED;
  1118. border-radius: 12rpx;
  1119. }
  1120. .reg-actions {
  1121. display: flex;
  1122. flex-direction: row;
  1123. justify-content: space-between;
  1124. gap: 20rpx;
  1125. }
  1126. .reg-cancel {
  1127. flex: 1;
  1128. background: #f5f5f5;
  1129. color: #666;
  1130. border: none;
  1131. border-radius: 40rpx;
  1132. padding: 20rpx;
  1133. font-size: 28rpx;
  1134. text-align: center;
  1135. }
  1136. .reg-submit {
  1137. flex: 1;
  1138. background: linear-gradient(135deg, #10B981, #34D399);
  1139. color: #fff;
  1140. border: none;
  1141. border-radius: 40rpx;
  1142. padding: 20rpx;
  1143. font-size: 28rpx;
  1144. font-weight: 600;
  1145. text-align: center;
  1146. }
  1147. .reg-submit:active { opacity: 0.85; }
  1148. .reg-submit[disabled] { opacity: 0.5; }
  1149. </style>