ActivityFeedSection.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <view class="section">
  3. <view class="section-header">
  4. <text class="section-title">🔥 热门活动</text>
  5. <text class="section-more" @click="$emit('view-all')">查看更多 ›</text>
  6. </view>
  7. <view v-if="activities.length === 0" class="empty-state" style="padding: 40rpx 0;">
  8. <text class="empty-text">暂无活动</text>
  9. </view>
  10. <view class="activity-list" v-else>
  11. <view class="activity-card" v-for="act in activities" :key="act.id" @click="$emit('tap-activity', act)">
  12. <image class="activity-cover" :src="coverOf(act)" 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')">{{ act.status === 'ongoing' ? '进行中' : act.status === 'ended' ? '已结束' : '即将开始' }}</text>
  20. <text class="activity-fee" v-if="act.price && act.price > 0">¥{{ (act.price / 100).toFixed(0) }}</text>
  21. <text class="activity-fee fee-free" v-else>免费</text>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. import config from '@/config.js'
  30. export default {
  31. name: 'ActivityFeedSection',
  32. props: {
  33. activities: {
  34. type: Array,
  35. default: function() { return [] }
  36. }
  37. },
  38. methods: {
  39. coverOf: function(act) {
  40. return this.resolveUrl(act && act.coverImage) || '/static/default-activity.png'
  41. },
  42. resolveUrl: function(path) {
  43. var s = String(path || '').trim()
  44. if (!s || s === 'null' || s === 'undefined' || s === '/null') return ''
  45. if (s.indexOf('http://') === 0 || s.indexOf('https://') === 0) return s
  46. return config.API_BASE_URL + (s.charAt(0) === '/' ? s : '/' + s)
  47. }
  48. }
  49. }
  50. </script>
  51. <style scoped lang="scss">
  52. /* 未登录态 — 热门活动(无条件展示);样式与 pages/index-home/index.vue 原内联区块一致。
  53. 页面专有色阶(状态色)局部定义并注释来源(见 uni.scss §1 Material 色板) */
  54. $c-success-tint: $mat-green-tint; // green-50 极浅底
  55. $c-success-ink: $mat-green-strong; // green-800 深文字
  56. $c-info-tint: $mat-blue-tint; // blue-50 极浅底
  57. $c-info-ink: $mat-blue-strong; // blue-800 深文字
  58. .section {
  59. margin: 20rpx $uni-space-lg;
  60. }
  61. .section-header {
  62. display: flex;
  63. justify-content: space-between;
  64. align-items: center;
  65. margin-bottom: 20rpx;
  66. }
  67. .section-title {
  68. font-size: calc(30rpx * var(--font-scale, 1));
  69. font-weight: bold;
  70. color: $facade-text-strong;
  71. }
  72. .section-more {
  73. font-size: calc(24rpx * var(--font-scale, 1));
  74. color: $brand-primary;
  75. }
  76. .empty-state {
  77. display: flex;
  78. justify-content: center;
  79. padding: 60rpx 0;
  80. }
  81. .empty-text {
  82. font-size: calc(26rpx * var(--font-scale, 1));
  83. color: $facade-text-muted;
  84. }
  85. /* 活动列表 */
  86. .activity-list {
  87. display: flex;
  88. flex-direction: column;
  89. gap: 16rpx;
  90. }
  91. .activity-card {
  92. background: $app-surface;
  93. border-radius: 16rpx;
  94. overflow: hidden;
  95. display: flex;
  96. flex-direction: row;
  97. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  98. }
  99. .activity-card:active {
  100. opacity: 0.8;
  101. }
  102. .activity-cover {
  103. width: 200rpx;
  104. height: 160rpx;
  105. flex-shrink: 0;
  106. background: $facade-fill;
  107. }
  108. .activity-info {
  109. flex: 1;
  110. padding: 16rpx;
  111. display: flex;
  112. flex-direction: column;
  113. justify-content: space-between;
  114. }
  115. .activity-name {
  116. font-size: calc(28rpx * var(--font-scale, 1));
  117. font-weight: bold;
  118. color: $facade-text-strong;
  119. margin-bottom: 8rpx;
  120. }
  121. .line-clamp-1 {
  122. overflow: hidden;
  123. text-overflow: ellipsis;
  124. white-space: nowrap;
  125. }
  126. .activity-meta {
  127. display: flex;
  128. align-items: center;
  129. margin-bottom: 8rpx;
  130. }
  131. .activity-time {
  132. font-size: calc(22rpx * var(--font-scale, 1));
  133. color: $facade-text-muted;
  134. }
  135. .activity-bottom {
  136. display: flex;
  137. align-items: center;
  138. gap: 12rpx;
  139. }
  140. .activity-status {
  141. font-size: calc(20rpx * var(--font-scale, 1));
  142. padding: 2rpx 10rpx;
  143. border-radius: 8rpx;
  144. background: $c-success-tint;
  145. color: $c-success-ink;
  146. }
  147. .activity-status.status-upcoming {
  148. background: $c-info-tint;
  149. color: $c-info-ink;
  150. }
  151. .activity-status.status-ended {
  152. background: $facade-fill-2;
  153. color: $facade-text-muted;
  154. }
  155. .activity-fee {
  156. font-size: calc(24rpx * var(--font-scale, 1));
  157. color: $brand-primary;
  158. font-weight: bold;
  159. }
  160. .activity-fee.fee-free {
  161. color: $mat-green;
  162. }
  163. </style>