| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- <template>
- <view class="section">
- <view class="section-header">
- <text class="section-title">🔥 推荐活动</text>
- <text class="section-more" @click="$emit('moreActivities')">更多 ›</text>
- </view>
- <view class="activity-list">
- <!-- 无数据时显示占位卡片 -->
- <template v-if="!displayActivities || displayActivities.length === 0">
- <view class="activity-card" v-for="i in 3" :key="'ph-' + i">
- <view class="article-category" :style="{ background: gradientColors[(i-1) % gradientColors.length] }">
- <text class="article-category-text">推荐活动</text>
- </view>
- <text class="article-title">暂无推荐活动</text>
- <text class="article-summary">精彩活动即将上线,敬请期待</text>
- <view class="activity-bottom-placeholder">
- <text class="article-date">--</text>
- </view>
- </view>
- </template>
- <!-- 有数据时显示活动卡片(垂直布局) -->
- <template v-else><view class="activity-card" v-for="act in displayActivities" :key="act.id" @click.stop="$emit('activityClick', act)">
- <view class="activity-color-bar" :style="{ background: gradientColors[act.id % gradientColors.length] }">
- <text class="activity-color-text">{{ statusText(act.status) }}</text>
- </view>
- <text class="article-title">{{ act.title }}</text>
- <text class="article-summary" v-if="act.startTime">{{ act.startTime }}</text>
- <view class="article-meta">
- <text class="activity-fee" v-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>
- </template>
- </view>
- </view>
- </template>
- <script>
- var activityGradientColors = [
- 'linear-gradient(135deg, #10B981, #34D399)',
- 'linear-gradient(135deg, #5B9BD5, #8FC5E8)',
- 'linear-gradient(135deg, #8B5CF6, #C084FC)',
- 'linear-gradient(135deg, #F97316, #FB923C)',
- 'linear-gradient(135deg, #6366F1, #818CF8)'
- ]
- export default {
- props: {
- dimensionCode: { type: String, required: true },
- activities: { type: Array, default: function() { return [] } },
- isLoggedIn: { type: Boolean, default: false }
- },
- data: function() {
- return {
- gradientColors: activityGradientColors
- }
- },
- computed: {
- displayActivities: function() {
- return (this.activities || []).slice(0, 3)
- }
- },
- methods: {
- statusText: function(status) {
- var map = { upcoming: '即将开始', ongoing: '进行中', ended: '已结束', cancelled: '已取消' }
- return map[status] || '即将开始'
- },
- formatPriceWithSymbol: function(price) {
- if (price == null) return '免费'
- return '¥' + (Number(price) / 100).toFixed(0)
- }
- }
- }
- </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;
- gap: 16rpx;
- }
- .activity-card {
- background: #fff;
- border-radius: 16rpx;
- padding: 24rpx;
- box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
- }
- .activity-card:active {
- opacity: 0.8;
- }
- .activity-color-bar {
- display: inline-block;
- padding: 4rpx 14rpx;
- border-radius: 8rpx;
- margin-bottom: 10rpx;
- }
- .activity-color-text {
- font-size: 20rpx;
- color: #fff;
- }
- .activity-fee {
- font-size: 22rpx;
- color: #F97316;
- font-weight: 500;
- }
- .fee-free {
- color: #22C55E;
- }
- .activity-bottom-placeholder {
- display: flex;
- align-items: center;
- gap: 16rpx;
- }
- /* 共享文章卡片样式 */
- .article-category {
- display: inline-block;
- padding: 4rpx 14rpx;
- border-radius: 8rpx;
- margin-bottom: 10rpx;
- }
- .article-category-text {
- font-size: 20rpx;
- color: #fff;
- }
- .article-title {
- display: block;
- font-size: 28rpx;
- font-weight: bold;
- color: #333;
- margin-bottom: 8rpx;
- line-height: 1.4;
- }
- .article-summary {
- display: block;
- font-size: 24rpx;
- color: #888;
- line-height: 1.5;
- margin-bottom: 12rpx;
- overflow: hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-line-clamp: 2;
- -webkit-box-orient: vertical;
- }
- .article-meta {
- display: flex;
- align-items: center;
- gap: 16rpx;
- }
- .article-date {
- font-size: 22rpx;
- color: #bbb;
- }
- </style>
|