DimensionActivities.vue 3.9 KB

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