list.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <view class="salon-page">
  3. <view class="section-card">
  4. <view class="head-row">
  5. <view>
  6. <text class="section-title">沙龙</text>
  7. <text class="card-desc">探索AI前沿,共创成长空间</text>
  8. </view>
  9. <text class="mine-link" @click="goMine">我的报名</text>
  10. </view>
  11. <view v-if="loading" class="empty-tip">加载中…</view>
  12. <view v-else-if="salons.length === 0" class="empty-tip">暂无活动沙龙</view>
  13. <view v-else>
  14. <view class="salon-card" v-for="item in salons" :key="item.id">
  15. <view class="salon-head">
  16. <text class="salon-theme">{{ mapTheme(item.theme) }}</text>
  17. <text class="salon-title">{{ item.title }}</text>
  18. </view>
  19. <view class="salon-info">
  20. <view class="info-item">
  21. <text class="info-label">时间:</text>
  22. <text class="info-value">{{ formatDateTime(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">{{ item.num }} / {{ item.capacity }}</text>
  31. </view>
  32. </view>
  33. <view class="salon-price-box">
  34. <text class="salon-price" v-if="item.price > 0">¥{{ fenToYuan(item.price) }}</text>
  35. <text class="salon-price-free" v-else>免费</text>
  36. <text class="member-price" v-if="item.memberPrice > 0 && item.memberPrice < item.price">
  37. 会员价 ¥{{ fenToYuan(item.memberPrice) }}
  38. </text>
  39. </view>
  40. <view class="salon-foot">
  41. <button
  42. v-if="canMemberFree"
  43. class="member-btn"
  44. :disabled="item.num <= 0"
  45. @click="handleMemberEnroll(item)"
  46. >
  47. 会员免费
  48. </button>
  49. <button
  50. class="enroll-btn"
  51. :disabled="item.num <= 0"
  52. @click="handleEnrollClick(item)"
  53. >
  54. {{ item.num <= 0 ? '已满' : '立即报名' }}
  55. </button>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. </template>
  62. <script>
  63. import { getSalonList, getMyMember } from '@/utils/api.js'
  64. import { fenToYuan, formatDateTime } from '@/utils/format.js'
  65. import { guardPage } from '@/utils/guard.js'
  66. export default {
  67. data() {
  68. return {
  69. salons: [],
  70. loading: false,
  71. member: {},
  72. themeMap: {
  73. ai_basic: 'AI 认知基础',
  74. wealth: '家庭财富管理',
  75. health: '健康管理',
  76. growth: '孩子成长陪伴'
  77. }
  78. }
  79. },
  80. computed: {
  81. canMemberFree() {
  82. var m = this.member || {}
  83. // 生效中 + 剩余免费次数 > 0 才显示会员免费入口
  84. return m.status === 'active' && m.effective && (m.salonRemain || 0) > 0
  85. }
  86. },
  87. onShow() {
  88. if (!guardPage()) return
  89. this.loadSalons()
  90. this.loadMember()
  91. },
  92. methods: {
  93. fenToYuan: fenToYuan,
  94. formatDateTime: formatDateTime,
  95. mapTheme(theme) {
  96. return this.themeMap[theme] || theme || '通用主题'
  97. },
  98. loadSalons() {
  99. var self = this
  100. self.loading = true
  101. getSalonList().then(function(resp) {
  102. self.salons = resp.data || []
  103. }).catch(function() {
  104. uni.showToast({ title: '加载沙龙失败', icon: 'none' })
  105. }).finally(function() {
  106. self.loading = false
  107. })
  108. },
  109. loadMember() {
  110. var self = this
  111. getMyMember().then(function(resp) {
  112. self.member = resp.data || {}
  113. }).catch(function() {
  114. self.member = {}
  115. })
  116. },
  117. handleEnrollClick(item) {
  118. var userInfo = uni.getStorageSync('userInfo') || {}
  119. uni.navigateTo({
  120. url: '/pages/salon/form?salonId=' + item.id +
  121. '&theme=' + encodeURIComponent(this.mapTheme(item.theme)) +
  122. '&title=' + encodeURIComponent(item.title) +
  123. '&name=' + encodeURIComponent(userInfo.name || '') +
  124. '&phone=' + encodeURIComponent(userInfo.phone || '')
  125. })
  126. },
  127. handleMemberEnroll(item) {
  128. var userInfo = uni.getStorageSync('userInfo') || {}
  129. uni.navigateTo({
  130. url: '/pages/salon/form?salonId=' + item.id +
  131. '&member=1' +
  132. '&theme=' + encodeURIComponent(this.mapTheme(item.theme)) +
  133. '&title=' + encodeURIComponent(item.title) +
  134. '&name=' + encodeURIComponent(userInfo.name || '') +
  135. '&phone=' + encodeURIComponent(userInfo.phone || '')
  136. })
  137. },
  138. goMine() {
  139. uni.navigateTo({ url: '/pages/salon/mine' })
  140. }
  141. }
  142. }
  143. </script>
  144. <style scoped>
  145. .salon-page { min-height: 100vh; background: #F5F5F5; padding: 32rpx; }
  146. .section-card { background: #FFF; border-radius: 16rpx; padding: 32rpx; }
  147. .head-row { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 8rpx; }
  148. .mine-link { font-size: 24rpx; color: #FC7A57; flex-shrink: 0; padding-top: 4rpx; }
  149. .section-title { display: block; font-size: 32rpx; font-weight: 700; color: #2A2326; margin-bottom: 8rpx; border-left: 8rpx solid #FC7A57; padding-left: 16rpx; }
  150. .card-desc { display: block; font-size: 26rpx; color: #5A4F4B; margin-bottom: 24rpx; }
  151. .empty-tip { font-size: 26rpx; color: #94877F; padding: 32rpx 0; text-align: center; }
  152. .salon-card { border: 2rpx solid #E2E8F0; border-radius: 12rpx; padding: 24rpx; margin-bottom: 20rpx; }
  153. .salon-head { margin-bottom: 16rpx; }
  154. .salon-theme { display: block; background: #FFF0E8; color: #FC7A57; font-size: 22rpx; font-weight: 600; padding: 4rpx 12rpx; border-radius: 4rpx; width: fit-content; margin-bottom: 8rpx; }
  155. .salon-title { display: block; font-size: 30rpx; font-weight: 600; color: #2A2326; }
  156. .salon-info { margin-bottom: 16rpx; }
  157. .info-item { display: flex; align-items: center; margin-bottom: 4rpx; }
  158. .info-label { font-size: 24rpx; color: #5A4F4B; width: 70rpx; flex-shrink: 0; }
  159. .info-value { font-size: 26rpx; color: #475569; }
  160. .salon-price-box { display: flex; align-items: center; gap: 16rpx; margin-bottom: 16rpx; }
  161. .salon-price { font-size: 28rpx; color: #FC7A57; font-weight: 600; }
  162. .salon-price-free { font-size: 28rpx; color: #22C55E; font-weight: 600; }
  163. .member-price { font-size: 24rpx; color: #5A4F4B; }
  164. .salon-foot { display: flex; align-items: center; justify-content: flex-end; }
  165. .member-btn { width: 180rpx; height: 64rpx; line-height: 64rpx; font-size: 26rpx; background: #FFF0E8; color: #FC7A57; border-radius: 32rpx; border: 2rpx solid #FED7AA; margin: 0 16rpx 0 0; }
  166. .member-btn:active { opacity: 0.85; }
  167. .member-btn:disabled { background: #CBD5E1; color: #FFF; border-color: #CBD5E1; }
  168. .enroll-btn { width: 200rpx; height: 64rpx; line-height: 64rpx; font-size: 26rpx; background: #FC7A57; color: #FFF; border-radius: 32rpx; border: none; margin: 0; }
  169. .enroll-btn:active { opacity: 0.85; }
  170. .enroll-btn:disabled { background: #CBD5E1; }
  171. </style>