| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- <template>
- <view class="section">
- <view class="section-header">
- <text class="section-title">🔥 推荐活动</text>
- <text class="section-more" @click="$emit('moreActivities')">更多 ›</text>
- </view>
- <view v-if="!displayActivities || displayActivities.length === 0" class="empty-state">
- <text class="empty-tip">{{ isLoggedIn ? '暂无相关活动' : '登录后查看更多活动' }}</text>
- </view>
- <view class="activity-list" v-if="displayActivities && displayActivities.length > 0">
- <view class="activity-card" v-for="act in displayActivities" :key="act.id" @click.stop="$emit('activityClick', act)">
- <image class="activity-cover" :src="act.coverImage || '/static/default-activity.png'" 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')">{{ statusText(act.status) }}</text>
- <text class="activity-fee" v-if="!isLoggedIn">登录查看</text>
- <text class="activity-fee" v-else-if="act.priceLabel">{{ act.priceLabel }}</text>
- <text class="activity-fee" v-else-if="act.price && act.price > 0">{{ formatPriceWithSymbol(act.price) }}</text>
- <text class="activity-fee fee-free" v-else>免费</text>
- </view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- props: {
- dimensionCode: { type: String, required: true },
- activities: { type: Array, default: function() { return [] } },
- isLoggedIn: { type: Boolean, default: false }
- },
- data: function() {
- return {
- }
- },
- computed: {
- displayActivities: function() {
- return (this.activities || []).slice(0, 3)
- }
- },
- methods: {
- statusText: function(status) {
- var map = { upcoming: '即将开始', ongoing: '进行中', ended: '已结束', cancelled: '已取消' }
- return map[status] || '即将开始'
- }
- }
- }
- </script>
- <style scoped>
- .section {
- margin: 20rpx 20rpx;
- }
- .section-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 20rpx;
- }
- .section-title {
- font-size: 30rpx;
- font-weight: bold;
- color: #333;
- }
- .section-more {
- font-size: 24rpx;
- color: #999;
- }
- .activity-list {
- display: flex;
- flex-direction: column;
- }
- .activity-card {
- display: flex;
- flex-direction: row;
- background: #fff;
- border-radius: 16rpx;
- overflow: hidden;
- box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
- margin-bottom: 20rpx;
- }
- .activity-card:active { opacity: 0.8; }
- .activity-cover {
- width: 220rpx;
- height: 200rpx;
- flex-shrink: 0;
- background: #f0f0f0;
- }
- .activity-info {
- flex: 1;
- padding: 16rpx 20rpx;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- }
- .activity-name {
- font-size: 28rpx;
- color: #333;
- font-weight: 500;
- }
- .activity-meta {
- margin-top: 8rpx;
- }
- .activity-time {
- font-size: 24rpx;
- color: #999;
- }
- .activity-bottom {
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- align-items: center;
- margin-top: 12rpx;
- }
- .activity-status {
- font-size: 22rpx;
- padding: 4rpx 12rpx;
- border-radius: 8rpx;
- }
- .status-upcoming { background: #FFF7ED; color: #F97316; }
- .status-ongoing { background: #F0FDF4; color: #22C55E; }
- .status-ended { background: #F5F5F5; color: #999; }
- .status-cancelled { background: #FEE2E2; color: #EF4444; }
- .activity-fee {
- font-size: 24rpx;
- color: #F97316;
- font-weight: 500;
- }
- .fee-free {
- color: #22C55E;
- }
- .empty-state {
- display: flex;
- justify-content: center;
- padding: 40rpx 0;
- }
- .empty-tip {
- font-size: 24rpx;
- color: #999;
- }
- .line-clamp-1 {
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- </style>
|