list.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <view class="salon-page">
  3. <view class="section-card">
  4. <text class="section-title">周末沙龙</text>
  5. <text class="card-desc">探索AI前沿,共创成长空间</text>
  6. <view v-if="loading" class="empty-tip">加载中…</view>
  7. <view v-else-if="salons.length === 0" class="empty-tip">暂无活动沙龙</view>
  8. <view v-else>
  9. <view class="salon-card" v-for="item in salons" :key="item.id">
  10. <view class="salon-head">
  11. <text class="salon-theme">{{ mapTheme(item.theme) }}</text>
  12. <text class="salon-title">{{ item.title }}</text>
  13. </view>
  14. <view class="salon-info">
  15. <view class="info-item">
  16. <text class="info-label">时间:</text>
  17. <text class="info-value">{{ formatDateTime(item.time) }}</text>
  18. </view>
  19. <view class="info-item">
  20. <text class="info-label">地点:</text>
  21. <text class="info-value">{{ item.place }}</text>
  22. </view>
  23. <view class="info-item">
  24. <text class="info-label">余位:</text>
  25. <text class="info-value">{{ item.num }} / {{ item.capacity }}</text>
  26. </view>
  27. </view>
  28. <view class="salon-price-box">
  29. <text class="salon-price" v-if="item.price > 0">¥{{ fenToYuan(item.price) }}</text>
  30. <text class="salon-price-free" v-else>免费</text>
  31. <text class="member-price" v-if="item.memberPrice > 0 && item.memberPrice < item.price">
  32. 会员价 ¥{{ fenToYuan(item.memberPrice) }}
  33. </text>
  34. </view>
  35. <view class="salon-foot">
  36. <button
  37. class="enroll-btn"
  38. :disabled="item.num <= 0"
  39. @click="handleEnrollClick(item)"
  40. >
  41. {{ item.num <= 0 ? '已满' : '立即报名' }}
  42. </button>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. import { getSalonList } from '@/utils/api.js'
  51. import { fenToYuan, formatDateTime } from '@/utils/format.js'
  52. import { guardPage } from '@/utils/guard.js'
  53. export default {
  54. data() {
  55. return {
  56. salons: [],
  57. loading: false,
  58. themeMap: {
  59. ai_basic: 'AI 认知基础',
  60. wealth: '家庭财富管理',
  61. health: '健康管理',
  62. growth: '孩子成长陪伴'
  63. }
  64. }
  65. },
  66. onShow() {
  67. if (!guardPage()) return
  68. this.loadSalons()
  69. },
  70. methods: {
  71. fenToYuan: fenToYuan,
  72. formatDateTime: formatDateTime,
  73. mapTheme(theme) {
  74. return this.themeMap[theme] || theme || '通用主题'
  75. },
  76. loadSalons() {
  77. var self = this
  78. self.loading = true
  79. getSalonList().then(function(resp) {
  80. self.salons = resp.data || []
  81. }).catch(function() {
  82. uni.showToast({ title: '加载沙龙失败', icon: 'none' })
  83. }).finally(function() {
  84. self.loading = false
  85. })
  86. },
  87. handleEnrollClick(item) {
  88. var userInfo = uni.getStorageSync('userInfo') || {}
  89. uni.navigateTo({
  90. url: '/pages/salon/form?salonId=' + item.id +
  91. '&theme=' + encodeURIComponent(this.mapTheme(item.theme)) +
  92. '&title=' + encodeURIComponent(item.title) +
  93. '&name=' + encodeURIComponent(userInfo.name || '') +
  94. '&phone=' + encodeURIComponent(userInfo.phone || '')
  95. })
  96. }
  97. }
  98. }
  99. </script>
  100. <style scoped>
  101. .salon-page { min-height: 100vh; background: #F5F5F5; padding: 32rpx; }
  102. .section-card { background: #FFF; border-radius: 16rpx; padding: 32rpx; }
  103. .section-title { display: block; font-size: 32rpx; font-weight: 700; color: #1E293B; margin-bottom: 8rpx; border-left: 8rpx solid #F97316; padding-left: 16rpx; }
  104. .card-desc { display: block; font-size: 26rpx; color: #64748B; margin-bottom: 24rpx; }
  105. .empty-tip { font-size: 26rpx; color: #94A3B8; padding: 32rpx 0; text-align: center; }
  106. .salon-card { border: 2rpx solid #E2E8F0; border-radius: 12rpx; padding: 24rpx; margin-bottom: 20rpx; }
  107. .salon-head { margin-bottom: 16rpx; }
  108. .salon-theme { display: block; background: #FFF7ED; color: #F97316; font-size: 22rpx; font-weight: 600; padding: 4rpx 12rpx; border-radius: 4rpx; width: fit-content; margin-bottom: 8rpx; }
  109. .salon-title { display: block; font-size: 30rpx; font-weight: 600; color: #1E293B; }
  110. .salon-info { margin-bottom: 16rpx; }
  111. .info-item { display: flex; align-items: center; margin-bottom: 4rpx; }
  112. .info-label { font-size: 24rpx; color: #64748B; width: 70rpx; flex-shrink: 0; }
  113. .info-value { font-size: 26rpx; color: #475569; }
  114. .salon-price-box { display: flex; align-items: center; gap: 16rpx; margin-bottom: 16rpx; }
  115. .salon-price { font-size: 28rpx; color: #F97316; font-weight: 600; }
  116. .salon-price-free { font-size: 28rpx; color: #22C55E; font-weight: 600; }
  117. .member-price { font-size: 24rpx; color: #64748B; }
  118. .salon-foot { display: flex; align-items: center; justify-content: flex-end; }
  119. .enroll-btn { width: 200rpx; height: 64rpx; line-height: 64rpx; font-size: 26rpx; background: #F97316; color: #FFF; border-radius: 32rpx; border: none; margin: 0; }
  120. .enroll-btn:active { opacity: 0.85; }
  121. .enroll-btn:disabled { background: #CBD5E1; }
  122. </style>