activity-detail.vue 35 KB

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