mine.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <view class="mine-page">
  3. <view class="section-card">
  4. <text class="section-title">我的沙龙</text>
  5. <text class="card-desc">查看报名、现场签到与会后反馈</text>
  6. <LoadingSkeleton v-if="loading" :rows="3" />
  7. <ErrorState v-else-if="error" message="报名记录加载失败" @retry="loadMine" />
  8. <EmptyState v-else-if="list.length === 0" icon="📭" title="暂无报名记录" desc="报名沙龙后会在此展示" />
  9. <view v-else>
  10. <view class="salon-card" v-for="item in list" :key="item.enrollmentId">
  11. <view class="salon-head">
  12. <text class="salon-theme">{{ mapTheme(item.theme) }}</text>
  13. <view class="head-right">
  14. <text class="salon-state" :class="stateClass(item.displayStatus)">{{ stateText(item.displayStatus) }}</text>
  15. <text class="salon-status" v-if="item.checkedIn">已签到</text>
  16. </view>
  17. </view>
  18. <text class="salon-title">{{ item.title }}</text>
  19. <view class="salon-info">
  20. <view class="info-item">
  21. <text class="info-label">时间:</text>
  22. <text class="info-value">{{ item.time }}</text>
  23. </view>
  24. <view class="info-item">
  25. <text class="info-label">地点:</text>
  26. <text class="info-value">{{ item.place }}</text>
  27. </view>
  28. <view class="info-item">
  29. <text class="info-label">报名:</text>
  30. <text class="info-value">{{ statusText(item.status) }}</text>
  31. </view>
  32. </view>
  33. <view class="salon-foot">
  34. <button
  35. v-if="canCheckin(item)"
  36. class="mini-btn primary"
  37. :loading="checking"
  38. :disabled="checking"
  39. @click="handleCheckin(item)"
  40. >现场签到</button>
  41. <text v-else-if="item.checkedIn" class="foot-tip">已完成签到</text>
  42. <button
  43. v-if="canFeedback(item)"
  44. class="mini-btn plain"
  45. :disabled="submitting"
  46. @click="goFeedback(item)"
  47. >{{ item.feedbackSubmitted ? '查看反馈' : '去反馈' }}</button>
  48. <button
  49. v-if="isUnpaid(item)"
  50. class="mini-btn plain"
  51. @click="goPay(item)"
  52. >去支付</button>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. </template>
  59. <script>
  60. import { getMySalons, salonCheckin } from '@/utils/api.js'
  61. import { guardPage } from '@/utils/guard.js'
  62. import LoadingSkeleton from '@/components/loading-skeleton.vue'
  63. import ErrorState from '@/components/error-state.vue'
  64. import EmptyState from '@/components/empty-state.vue'
  65. export default {
  66. components: { LoadingSkeleton, ErrorState, EmptyState },
  67. data() {
  68. return {
  69. list: [],
  70. loading: false,
  71. error: false,
  72. checking: false,
  73. submitting: false,
  74. themeMap: {
  75. ai_basic: 'AI 认知基础',
  76. wealth: '家庭财富管理',
  77. health: '健康管理',
  78. growth: '孩子成长陪伴'
  79. }
  80. }
  81. },
  82. onShow() {
  83. if (!guardPage()) return
  84. this.loadMine()
  85. },
  86. methods: {
  87. mapTheme: function(theme) {
  88. return this.themeMap[theme] || theme || '通用主题'
  89. },
  90. statusText: function(status) {
  91. var map = {
  92. pending: '待支付',
  93. paid: '已支付',
  94. confirmed: '已确认',
  95. rejected: '已拒绝',
  96. cancelled: '已取消'
  97. }
  98. return map[status] || status || ''
  99. },
  100. stateText: function(s) {
  101. var map = { ended: '已结束', ongoing: '进行中', pending_start: '未开始', active: '进行中', draft: '草稿' }
  102. return map[s] || s || ''
  103. },
  104. stateClass: function(s) {
  105. if (s === 'ended' || s === 'draft') return 'state-end'
  106. if (s === 'pending_start') return 'state-wait'
  107. return 'state-go'
  108. },
  109. canCheckin: function(item) {
  110. // 已支付/已确认 + 时间窗内(displayStatus=ongoing)+ 未签到
  111. var inTime = item.displayStatus === 'ongoing'
  112. if (!inTime && !item.displayStatus) { inTime = item.salonStatus === 'active' }
  113. return (item.status === 'paid' || item.status === 'confirmed') && inTime && !item.checkedIn
  114. },
  115. canFeedback: function(item) {
  116. // 已支付/已确认即可反馈(已提交则入口改为查看)
  117. return item.status === 'paid' || item.status === 'confirmed'
  118. },
  119. isUnpaid: function(item) {
  120. return item.status === 'pending' && item.orderNo
  121. },
  122. loadMine: function() {
  123. var self = this
  124. self.loading = true
  125. self.error = false
  126. getMySalons().then(function(resp) {
  127. self.list = resp.data || []
  128. }).catch(function() {
  129. self.error = true
  130. }).finally(function() {
  131. self.loading = false
  132. })
  133. },
  134. handleCheckin: function(item) {
  135. var self = this
  136. if (self.checking) return
  137. self.checking = true
  138. salonCheckin(item.salonId).then(function(resp) {
  139. var data = resp && resp.data ? resp.data : {}
  140. var pts = data.pointsEarned || 0
  141. var msg = pts > 0 ? '签到成功,获得 ' + pts + ' 积分' : '签到成功'
  142. uni.showToast({ title: msg, icon: 'success' })
  143. item.checkedIn = true
  144. self.loadMine()
  145. }).catch(function(err) {
  146. uni.showToast({ title: (err && err.message) || '签到失败', icon: 'none' })
  147. }).finally(function() {
  148. self.checking = false
  149. })
  150. },
  151. goFeedback: function(item) {
  152. uni.navigateTo({
  153. url: '/pages/salon/feedback?salonId=' + item.salonId +
  154. '&title=' + encodeURIComponent(item.title)
  155. })
  156. },
  157. goPay: function(item) {
  158. uni.navigateTo({
  159. url: '/pages/pay/index?enrollmentId=' + item.enrollmentId
  160. })
  161. }
  162. }
  163. }
  164. </script>
  165. <style scoped>
  166. .mine-page { min-height: 100vh; background: #F5FAFE; padding: 32rpx; }
  167. .section-card { background: #FFF; border-radius: 16rpx; padding: 32rpx; }
  168. .section-title { display: block; font-size: 32rpx; font-weight: 700; color: #1E3A5F; margin-bottom: 8rpx; border-left: 8rpx solid #2E6FA8; padding-left: 16rpx; }
  169. .card-desc { display: block; font-size: 26rpx; color: #3B5A78; margin-bottom: 24rpx; }
  170. .empty-tip { font-size: 26rpx; color: #6B7B8C; padding: 32rpx 0; text-align: center; }
  171. .salon-card { border: 2rpx solid #E3ECF4; border-radius: 12rpx; padding: 24rpx; margin-bottom: 20rpx; }
  172. .salon-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8rpx; }
  173. .head-right { display: flex; align-items: center; gap: 12rpx; }
  174. .salon-state { font-size: 22rpx; font-weight: 600; padding: 2rpx 12rpx; border-radius: 4rpx; }
  175. .state-go { background: #E6F6EE; color: #0E8A4F; }
  176. .state-wait { background: #E8F3FC; color: #2E6FA8; }
  177. .state-end { background: #E3ECF4; color: #6B7B8C; }
  178. .salon-theme { display: block; background: #E8F3FC; color: #2E6FA8; font-size: 22rpx; font-weight: 600; padding: 4rpx 12rpx; border-radius: 4rpx; }
  179. .salon-status { font-size: 22rpx; color: #0E8A4F; font-weight: 600; }
  180. .salon-title { display: block; font-size: 30rpx; font-weight: 600; color: #1E3A5F; margin-bottom: 12rpx; }
  181. .salon-info { margin-bottom: 16rpx; }
  182. .info-item { display: flex; align-items: center; margin-bottom: 4rpx; }
  183. .info-label { font-size: 24rpx; color: #3B5A78; width: 70rpx; flex-shrink: 0; }
  184. .info-value { font-size: 26rpx; color: #3B5A78; }
  185. .salon-foot { display: flex; align-items: center; justify-content: flex-end; gap: 16rpx; }
  186. .mini-btn { height: 60rpx; line-height: 60rpx; font-size: 26rpx; border-radius: 30rpx; border: none; margin: 0; padding: 0 32rpx; }
  187. .mini-btn.primary { background: #2E6FA8; color: #FFF; }
  188. .mini-btn.plain { background: #FFF; color: #2E6FA8; border: 2rpx solid #2E6FA8; }
  189. .mini-btn:active { opacity: 0.85; }
  190. .foot-tip { font-size: 24rpx; color: #6B7B8C; }
  191. </style>