DimensionActivities.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template>
  2. <view class="section">
  3. <view class="section-header">
  4. <text class="section-title">🔥 推荐活动</text>
  5. <text class="section-more" @click="$emit('moreActivities')">更多 ›</text>
  6. </view>
  7. <view v-if="!displayActivities || displayActivities.length === 0" class="empty-state">
  8. <text class="empty-tip">{{ isLoggedIn ? '暂无相关活动' : '登录后查看更多活动' }}</text>
  9. </view>
  10. <view class="activity-list" v-if="displayActivities && displayActivities.length > 0">
  11. <view class="activity-card" v-for="act in displayActivities" :key="act.id" @click.stop="$emit('activityClick', act)">
  12. <image class="activity-cover" :src="act.coverImage || '/static/default-activity.png'" mode="aspectFill" />
  13. <view class="activity-info">
  14. <text class="activity-name line-clamp-1">{{ act.title }}</text>
  15. <view class="activity-meta">
  16. <text class="activity-time">{{ act.startTime }}</text>
  17. </view>
  18. <view class="activity-bottom">
  19. <text class="activity-status" :class="'status-' + (act.status || 'upcoming')">{{ statusText(act.status) }}</text>
  20. <text class="activity-fee" v-if="act.priceLabel">{{ act.priceLabel }}</text>
  21. <text class="activity-fee" v-else-if="act.price && act.price > 0">{{ formatPriceWithSymbol(act.price) }}</text>
  22. <text class="activity-fee fee-free" v-else>免费</text>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. export default {
  31. props: {
  32. dimensionCode: { type: String, required: true },
  33. activities: { type: Array, default: function() { return [] } },
  34. isLoggedIn: { type: Boolean, default: false }
  35. },
  36. data: function() {
  37. return {
  38. }
  39. },
  40. computed: {
  41. displayActivities: function() {
  42. return (this.activities || []).slice(0, 3)
  43. }
  44. },
  45. methods: {
  46. statusText: function(status) {
  47. var map = { upcoming: '即将开始', ongoing: '进行中', ended: '已结束', cancelled: '已取消' }
  48. return map[status] || '即将开始'
  49. }
  50. }
  51. }
  52. </script>
  53. <style scoped>
  54. .section {
  55. margin: 20rpx 20rpx;
  56. }
  57. .section-header {
  58. display: flex;
  59. justify-content: space-between;
  60. align-items: center;
  61. margin-bottom: 20rpx;
  62. }
  63. .section-title {
  64. font-size: 30rpx;
  65. font-weight: bold;
  66. color: #333;
  67. }
  68. .section-more {
  69. font-size: 24rpx;
  70. color: #999;
  71. }
  72. .activity-list {
  73. display: flex;
  74. flex-direction: column;
  75. }
  76. .activity-card {
  77. display: flex;
  78. flex-direction: row;
  79. background: #fff;
  80. border-radius: 16rpx;
  81. overflow: hidden;
  82. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  83. margin-bottom: 20rpx;
  84. }
  85. .activity-card:active { opacity: 0.8; }
  86. .activity-cover {
  87. width: 220rpx;
  88. height: 200rpx;
  89. flex-shrink: 0;
  90. background: #f0f0f0;
  91. }
  92. .activity-info {
  93. flex: 1;
  94. padding: 16rpx 20rpx;
  95. display: flex;
  96. flex-direction: column;
  97. justify-content: space-between;
  98. }
  99. .activity-name {
  100. font-size: 28rpx;
  101. color: #333;
  102. font-weight: 500;
  103. }
  104. .activity-meta {
  105. margin-top: 8rpx;
  106. }
  107. .activity-time {
  108. font-size: 24rpx;
  109. color: #999;
  110. }
  111. .activity-bottom {
  112. display: flex;
  113. flex-direction: row;
  114. justify-content: space-between;
  115. align-items: center;
  116. margin-top: 12rpx;
  117. }
  118. .activity-status {
  119. font-size: 22rpx;
  120. padding: 4rpx 12rpx;
  121. border-radius: 8rpx;
  122. }
  123. .status-upcoming { background: #FFF7ED; color: #F97316; }
  124. .status-ongoing { background: #F0FDF4; color: #22C55E; }
  125. .status-ended { background: #F5F5F5; color: #999; }
  126. .status-cancelled { background: #FEE2E2; color: #EF4444; }
  127. .activity-fee {
  128. font-size: 24rpx;
  129. color: #F97316;
  130. font-weight: 500;
  131. }
  132. .fee-free {
  133. color: #22C55E;
  134. }
  135. .empty-state {
  136. display: flex;
  137. justify-content: center;
  138. padding: 40rpx 0;
  139. }
  140. .empty-tip {
  141. font-size: 24rpx;
  142. color: #999;
  143. }
  144. .line-clamp-1 {
  145. overflow: hidden;
  146. text-overflow: ellipsis;
  147. white-space: nowrap;
  148. }
  149. </style>