| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- <template>
- <view class="section">
- <view class="section-header">
- <text class="section-title">🔥 热门活动</text>
- <text class="section-more" @click="$emit('view-all')">查看更多 ›</text>
- </view>
- <view v-if="activities.length === 0" class="empty-state" style="padding: 40rpx 0;">
- <text class="empty-text">暂无活动</text>
- </view>
- <view class="activity-list" v-else>
- <view class="activity-card" v-for="act in activities" :key="act.id" @click="$emit('tap-activity', act)">
- <image class="activity-cover" :src="coverOf(act)" mode="aspectFill" />
- <view class="activity-info">
- <text class="activity-name line-clamp-1">{{ act.title }}</text>
- <view class="activity-meta">
- <text class="activity-time">{{ act.startTime }}</text>
- </view>
- <view class="activity-bottom">
- <text class="activity-status" :class="'status-' + (act.status || 'upcoming')">{{ act.status === 'ongoing' ? '进行中' : act.status === 'ended' ? '已结束' : '即将开始' }}</text>
- <text class="activity-fee" v-if="act.price && act.price > 0">¥{{ (act.price / 100).toFixed(0) }}</text>
- <text class="activity-fee fee-free" v-else>免费</text>
- </view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import config from '@/config.js'
- export default {
- name: 'ActivityFeedSection',
- props: {
- activities: {
- type: Array,
- default: function() { return [] }
- }
- },
- methods: {
- coverOf: function(act) {
- return this.resolveUrl(act && act.coverImage) || '/static/default-activity.png'
- },
- resolveUrl: function(path) {
- var s = String(path || '').trim()
- if (!s || s === 'null' || s === 'undefined' || s === '/null') return ''
- if (s.indexOf('http://') === 0 || s.indexOf('https://') === 0) return s
- return config.API_BASE_URL + (s.charAt(0) === '/' ? s : '/' + s)
- }
- }
- }
- </script>
- <style scoped lang="scss">
- /* 未登录态 — 热门活动(无条件展示);样式与 pages/index-home/index.vue 原内联区块一致。
- 页面专有色阶(状态色)局部定义并注释来源(见 uni.scss §1 Material 色板) */
- $c-success-tint: $mat-green-tint; // green-50 极浅底
- $c-success-ink: $mat-green-strong; // green-800 深文字
- $c-info-tint: $mat-blue-tint; // blue-50 极浅底
- $c-info-ink: $mat-blue-strong; // blue-800 深文字
- .section {
- margin: 20rpx $uni-space-lg;
- }
- .section-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 20rpx;
- }
- .section-title {
- font-size: calc(30rpx * var(--font-scale, 1));
- font-weight: bold;
- color: $facade-text-strong;
- }
- .section-more {
- font-size: calc(24rpx * var(--font-scale, 1));
- color: $brand-primary;
- }
- .empty-state {
- display: flex;
- justify-content: center;
- padding: 60rpx 0;
- }
- .empty-text {
- font-size: calc(26rpx * var(--font-scale, 1));
- color: $facade-text-muted;
- }
- /* 活动列表 */
- .activity-list {
- display: flex;
- flex-direction: column;
- gap: 16rpx;
- }
- .activity-card {
- background: $app-surface;
- border-radius: 16rpx;
- overflow: hidden;
- display: flex;
- flex-direction: row;
- box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
- }
- .activity-card:active {
- opacity: 0.8;
- }
- .activity-cover {
- width: 200rpx;
- height: 160rpx;
- flex-shrink: 0;
- background: $facade-fill;
- }
- .activity-info {
- flex: 1;
- padding: 16rpx;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- }
- .activity-name {
- font-size: calc(28rpx * var(--font-scale, 1));
- font-weight: bold;
- color: $facade-text-strong;
- margin-bottom: 8rpx;
- }
- .line-clamp-1 {
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .activity-meta {
- display: flex;
- align-items: center;
- margin-bottom: 8rpx;
- }
- .activity-time {
- font-size: calc(22rpx * var(--font-scale, 1));
- color: $facade-text-muted;
- }
- .activity-bottom {
- display: flex;
- align-items: center;
- gap: 12rpx;
- }
- .activity-status {
- font-size: calc(20rpx * var(--font-scale, 1));
- padding: 2rpx 10rpx;
- border-radius: 8rpx;
- background: $c-success-tint;
- color: $c-success-ink;
- }
- .activity-status.status-upcoming {
- background: $c-info-tint;
- color: $c-info-ink;
- }
- .activity-status.status-ended {
- background: $facade-fill-2;
- color: $facade-text-muted;
- }
- .activity-fee {
- font-size: calc(24rpx * var(--font-scale, 1));
- color: $brand-primary;
- font-weight: bold;
- }
- .activity-fee.fee-free {
- color: $mat-green;
- }
- </style>
|