Files
spring-festival-greetings/pages/index/index.vue

601 lines
14 KiB
Vue
Raw Normal View History

2026-01-09 11:24:40 +08:00
<template>
<view class="spring-page" :style="{ paddingTop: getBavBarHeight() + 'px' }">
<!-- 顶部 Banner -->
<view class="hero">
<view class="hero-badge">
<text class="badge-dot"></text>
2026-01-22 22:19:41 +08:00
<text class="badge-text">{{ countdownText }}</text>
2026-01-09 11:24:40 +08:00
</view>
<view class="hero-title">
<text class="year">2026</text>
<text class="main">新春祝福</text>
</view>
<text class="hero-sub">新年快乐万事如意!</text>
2026-01-15 08:43:10 +08:00
<!-- <image class="hero-decor" src="https://file.lihailezzc.com/resource/58c8d19e5f2d9c958a7b8b9f44b8c3e3.png" mode="aspectFill" /> -->
2026-01-09 11:24:40 +08:00
</view>
<!-- 功能入口宫格 -->
<view class="feature-grid">
<view
v-for="(item, idx) in features"
:key="idx"
class="feature-item"
@tap="onFeatureTap(item)"
>
2026-01-15 08:43:10 +08:00
<image
class="feature-icon"
:src="item.icon"
mode="aspectFill"
:style="{
backgroundColor: idx < 2 ? '#FEF2F2' : '#FFFBEC',
}"
/>
2026-01-09 11:24:40 +08:00
<view class="feature-texts">
<text class="feature-title">{{ item.title }}</text>
<text class="feature-sub">{{ item.subtitle }}</text>
</view>
</view>
</view>
2026-01-22 23:54:56 +08:00
<!-- 今日灵感 -->
<view class="daily-section">
<view class="daily-header">
<text class="daily-title">今日灵感</text>
<text class="daily-date">{{ todayDate }}</text>
</view>
<view class="daily-card">
<view class="daily-content">
<text class="quote-mark"></text>
<text class="daily-text">{{ dailyGreeting }}</text>
<text class="quote-mark right"></text>
</view>
<view class="daily-actions">
<view class="action-btn copy" @tap="copyGreeting">
<text class="icon"></text> 复制
</view>
<view class="action-btn use" @tap="useGreeting">
<text class="icon"></text> 去制作
</view>
</view>
</view>
</view>
2026-01-09 11:24:40 +08:00
<!-- 大家都在用竖向列表左图右文 -->
<view class="section">
<view class="section-header">
<view class="section-bar"></view>
<text class="section-title">大家都在用</text>
<text class="section-more" @tap="onMore('use')">查看更多 ></text>
</view>
<view class="use-list">
<view
v-for="(card, i) in popularCards"
:key="i"
class="use-row"
@tap="previewCard(card)"
>
<view class="thumb-wrap">
<image :src="card.cover" class="thumb" mode="aspectFill" />
<view v-if="card.type === 'video'" class="thumb-play"></view>
</view>
<view class="use-right">
<view class="title-line">
<text class="use-title">{{ card.title }}</text>
2026-01-15 08:43:10 +08:00
<text
v-if="card.tag"
class="tag"
:class="`tag--${card.tagType || 'default'}`"
>{{ card.tag }}</text
>
2026-01-09 11:24:40 +08:00
</view>
<text class="use-desc">{{ card.desc }}</text>
2026-01-15 08:43:10 +08:00
<text class="use-cta" @tap.stop="onCta(card)"
>{{ card.cta }} ></text
>
2026-01-09 11:24:40 +08:00
</view>
</view>
</view>
</view>
</view>
</template>
<script setup>
2026-01-22 22:19:41 +08:00
import { ref, onMounted } from "vue";
2026-01-15 08:43:10 +08:00
import { onPullDownRefresh, onShareAppMessage } from "@dcloudio/uni-app";
import { getBavBarHeight } from "@/utils/system";
2026-01-09 11:24:40 +08:00
2026-01-22 22:19:41 +08:00
const countdownText = ref("");
const updateCountdown = () => {
const now = new Date();
const springFestival = new Date("2026-02-17T00:00:00"); // 2026春节
// 只比较日期,忽略时分秒
now.setHours(0, 0, 0, 0);
springFestival.setHours(0, 0, 0, 0);
const diffTime = now.getTime() - springFestival.getTime();
const days = Math.floor(diffTime / (1000 * 60 * 60 * 24));
if (days < 0) {
countdownText.value = `距春节还有 ${Math.abs(days)}`;
} else if (days === 0) {
countdownText.value = "大年初一";
} else {
const cnNums = ["一", "二", "三", "四", "五", "六", "七", "八", "九", "十"];
if (days < 10) {
countdownText.value = `大年初${cnNums[days]}`;
} else if (days < 15) {
const sub = days + 1 - 10;
const subCn = ["一", "二", "三", "四", "五"][sub - 1];
countdownText.value = `正月十${subCn}`;
} else if (days === 14) {
// days=14是第15天
countdownText.value = "元宵节";
} else {
countdownText.value = "蛇年大吉";
}
}
};
2026-01-22 23:54:56 +08:00
const todayDate = ref("");
const dailyGreeting = ref(
"岁岁常欢愉,年年皆胜意。愿你新的一年,多喜乐,长安宁。",
);
const copyGreeting = () => {
uni.setClipboardData({
data: dailyGreeting.value,
success: () => {
uni.showToast({ title: "复制成功", icon: "none" });
},
});
};
const useGreeting = () => {
uni.setStorageSync("TEMP_BLESSING_TEXT", dailyGreeting.value);
uni.switchTab({
url: "/pages/make/index",
});
};
2026-01-22 22:19:41 +08:00
onMounted(() => {
updateCountdown();
2026-01-22 23:54:56 +08:00
const date = new Date();
todayDate.value = `${date.getMonth() + 1}${date.getDate()}`;
2026-01-22 22:19:41 +08:00
});
2026-01-09 11:24:40 +08:00
const features = ref([
2026-01-15 08:43:10 +08:00
{
title: "新春祝福卡片",
subtitle: "定制专属贺卡",
icon: "/static/icon/celebrate.png",
type: "card",
},
{
2026-01-22 23:43:49 +08:00
title: "新年运势",
subtitle: "抽取新年关键词",
icon: "/static/icon/yunshi.png",
type: "fortune",
2026-01-15 08:43:10 +08:00
},
{
2026-01-15 10:27:14 +08:00
title: "新春头像",
2026-01-15 08:43:10 +08:00
subtitle: "焕上节日新饰",
icon: "/static/icon/guashi.png",
type: "avatar_decor",
},
{
2026-01-22 23:43:49 +08:00
title: "精美壁纸",
subtitle: "获取精美壁纸",
icon: "/static/icon/bizhi.png",
type: "video",
2026-01-15 08:43:10 +08:00
},
]);
2026-01-09 11:24:40 +08:00
const popularCards = ref([
{
2026-01-15 08:43:10 +08:00
title: "招财进宝金框",
tag: "热门",
tagType: "hot",
desc: "2026马年限定汉字金框金光闪烁财运亨通。适合送亲友的新春祝福。",
cta: "立即制作",
cover:
"https://file.lihailezzc.com/9a929a32-439f-453b-b603-fda7b04cbe08.png",
2026-01-09 11:24:40 +08:00
},
{
2026-01-15 08:43:10 +08:00
title: "大吉大利卡片",
tag: "精选",
tagType: "featured",
desc: "经典红色大拜年卡片,适合送长辈、老师、同学,传递满满的新春喜气。",
cta: "去写祝福",
cover:
"https://file.lihailezzc.com/b5fe8ffb-5901-48d2-94fb-48191e36cbf5.png",
2026-01-09 11:24:40 +08:00
},
{
2026-01-15 08:43:10 +08:00
title: "合家团圆模板",
tag: "爆款",
tagType: "hot2",
desc: "一键生成合家福贺图,支持换装、特效装饰、朋友圈海报等。",
cta: "开始创作",
cover:
"https://file.lihailezzc.com/91cd1611-bb87-442b-a338-24e9d79e4ee9.png",
type: "video",
},
]);
2026-01-09 11:24:40 +08:00
const onFeatureTap = (item) => {
2026-01-15 10:27:14 +08:00
if (item.type === "fortune") {
uni.navigateTo({ url: "/pages/fortune/index" });
return;
}
if (item.type === "card") {
2026-01-22 23:43:49 +08:00
uni.switchTab({ url: "/pages/make/index" });
return;
}
if (item.type === "avatar_decor" || item.type === "avatar_frame") {
uni.navigateTo({ url: "/pages/avatar/index" });
2026-01-15 10:27:14 +08:00
return;
}
2026-01-15 08:43:10 +08:00
uni.showToast({ title: `进入:${item.title}`, icon: "none" });
};
2026-01-09 11:24:40 +08:00
const previewCard = (card) => {
2026-01-15 08:43:10 +08:00
uni.previewImage({ urls: [card.cover] });
};
2026-01-09 11:24:40 +08:00
const onMore = () => {
2026-01-15 08:43:10 +08:00
uni.showToast({ title: "更多模板即将上线~", icon: "none" });
};
2026-01-09 11:24:40 +08:00
const onCta = (card) => {
2026-01-15 08:43:10 +08:00
uni.showToast({ title: `${card.cta} · ${card.title}`, icon: "none" });
};
2026-01-09 11:24:40 +08:00
onPullDownRefresh(() => {
setTimeout(() => {
2026-01-15 08:43:10 +08:00
uni.stopPullDownRefresh();
uni.showToast({ title: "已为你更新内容", icon: "success" });
}, 600);
});
onShareAppMessage(() => {
return {
title: "新春祝福",
path: "/pages/detail/index",
imageUrl: "/static/images/bg.jpg",
success: function (res) {
uni.showToast({ title: "分享成功", icon: "success" });
},
fail: function (res) {
uni.showToast({ title: "分享失败", icon: "none" });
},
};
});
2026-01-09 11:24:40 +08:00
</script>
<style lang="scss" scoped>
.spring-page {
min-height: 100vh;
box-sizing: border-box;
2026-01-15 08:43:10 +08:00
background: #f8f6f6;
2026-01-09 11:24:40 +08:00
}
/* 顶部 Banner */
.hero {
position: relative;
margin: 24rpx auto;
padding: 32rpx;
height: 324rpx;
width: 92vw;
border-radius: 24rpx;
color: #fff;
background: url("http://file.lihailezzc.com/77ea2597-569c-4f13-b5af-22606742adcfssss.jpg");
background-size: cover;
overflow: hidden;
.hero-badge {
display: inline-flex;
align-items: center;
2026-01-15 08:43:10 +08:00
background: rgba(255, 255, 255, 0.2);
2026-01-09 11:24:40 +08:00
border-radius: 999rpx;
padding: 8rpx 16rpx;
font-size: 22rpx;
2026-01-15 08:43:10 +08:00
.badge-dot {
margin-right: 8rpx;
}
2026-01-09 11:24:40 +08:00
}
.hero-title {
margin-top: 24rpx;
display: flex;
align-items: baseline;
2026-01-15 08:43:10 +08:00
.year {
font-size: 44rpx;
font-weight: 700;
margin-right: 12rpx;
}
.main {
font-size: 44rpx;
font-weight: 700;
}
}
.hero-sub {
margin-top: 8rpx;
font-size: 24rpx;
opacity: 0.9;
2026-01-09 11:24:40 +08:00
}
.hero-decor {
2026-01-15 08:43:10 +08:00
position: absolute;
right: 12rpx;
bottom: 12rpx;
width: 160rpx;
height: 160rpx;
opacity: 0.3;
border-radius: 16rpx;
2026-01-09 11:24:40 +08:00
}
}
/* 功能入口宫格 - 2x2 */
.feature-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-gap: 20rpx;
padding: 0 24rpx;
margin-top: 8rpx;
.feature-item {
2026-01-15 08:43:10 +08:00
position: relative;
display: flex;
2026-01-09 11:24:40 +08:00
align-items: left;
flex-direction: column;
2026-01-15 08:43:10 +08:00
padding: 20rpx;
border-radius: 18rpx;
background: #fff;
box-shadow: 0 6rpx 16rpx rgba(0, 0, 0, 0.04);
2026-01-09 11:24:40 +08:00
}
.feature-item::after {
content: "";
position: absolute;
top: 0;
right: 0;
width: 60rpx;
height: 60rpx;
border-bottom-left-radius: 80rpx;
z-index: 1;
2026-01-15 08:43:10 +08:00
}
.feature-item:nth-child(1)::after,
.feature-item:nth-child(2)::after {
background: #fef2f2; /* 可换成你的主题粉 */
}
.feature-item:nth-child(3)::after,
.feature-item:nth-child(4)::after {
background: #fffbec; /* 温柔一点的黄 */
}
2026-01-09 11:24:40 +08:00
.feature-icon {
2026-01-15 08:43:10 +08:00
width: 60rpx;
height: 60rpx;
2026-01-09 11:24:40 +08:00
border-radius: 50%;
padding: 5rpx;
}
.feature-texts {
margin-top: 20rpx;
2026-01-15 08:43:10 +08:00
display: flex;
2026-01-09 11:24:40 +08:00
flex-direction: column;
2026-01-15 08:43:10 +08:00
.feature-title {
font-size: 28rpx;
color: #222;
font-weight: 600;
}
.feature-sub {
font-size: 22rpx;
color: #888;
margin-top: 4rpx;
}
2026-01-09 11:24:40 +08:00
}
}
2026-01-22 23:54:56 +08:00
/* 今日灵感 */
.daily-section {
margin: 24rpx 24rpx 0;
.daily-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 16rpx;
.daily-title {
font-size: 32rpx;
font-weight: 700;
color: #333;
}
.daily-date {
font-size: 24rpx;
color: #999;
font-family: monospace;
}
}
.daily-card {
background: #fff;
border-radius: 20rpx;
padding: 30rpx;
box-shadow: 0 8rpx 24rpx rgba(255, 59, 48, 0.08);
position: relative;
overflow: hidden;
}
.daily-card::before {
content: "";
position: absolute;
top: 0;
left: 0;
width: 8rpx;
height: 100%;
background: #ff3b30;
}
.daily-content {
position: relative;
padding: 10rpx 20rpx;
.quote-mark {
font-size: 60rpx;
color: #ff3b30;
opacity: 0.2;
position: absolute;
line-height: 1;
font-family: serif;
}
.quote-mark:first-child {
top: -10rpx;
left: -10rpx;
}
.quote-mark.right {
bottom: -20rpx;
right: 0;
}
.daily-text {
font-size: 30rpx;
color: #444;
line-height: 1.8;
font-style: italic;
display: block;
text-align: justify;
}
}
.daily-actions {
display: flex;
justify-content: flex-end;
margin-top: 30rpx;
gap: 20rpx;
.action-btn {
display: flex;
align-items: center;
padding: 12rpx 24rpx;
border-radius: 999rpx;
font-size: 24rpx;
transition: all 0.2s;
.icon {
margin-right: 6rpx;
font-size: 26rpx;
}
}
.action-btn.copy {
background: #f5f5f5;
color: #666;
}
.action-btn.use {
background: #ff3b30;
color: #fff;
box-shadow: 0 4rpx 12rpx rgba(255, 59, 48, 0.3);
}
}
}
2026-01-09 11:24:40 +08:00
/* 通用区块标题 */
2026-01-15 08:43:10 +08:00
.section {
margin-top: 28rpx;
}
2026-01-09 11:24:40 +08:00
.section-header {
2026-01-15 08:43:10 +08:00
display: flex;
align-items: center;
padding: 0 24rpx;
.section-bar {
width: 10rpx;
height: 30rpx;
border-radius: 6rpx;
background: #ff3b30;
margin-right: 12rpx;
}
.section-title {
font-size: 28rpx;
color: #222;
flex: 1;
font-weight: 600;
}
.section-more {
font-size: 24rpx;
color: #ff3b30;
}
2026-01-09 11:24:40 +08:00
}
/* 大家都在用 - 竖向列表 */
2026-01-15 08:43:10 +08:00
.use-list {
padding: 0 24rpx;
margin-top: 16rpx;
}
2026-01-09 11:24:40 +08:00
.use-row {
2026-01-15 08:43:10 +08:00
display: flex;
align-items: center;
background: #fff;
border-radius: 18rpx;
box-shadow: 0 8rpx 20rpx rgba(0, 0, 0, 0.06);
padding: 16rpx;
margin-bottom: 18rpx;
2026-01-09 11:24:40 +08:00
}
.thumb-wrap {
2026-01-15 08:43:10 +08:00
position: relative;
width: 120rpx;
height: 120rpx;
border-radius: 16rpx;
overflow: hidden;
margin-right: 16rpx;
}
.thumb {
width: 100%;
height: 100%;
2026-01-09 11:24:40 +08:00
}
.thumb-play {
2026-01-15 08:43:10 +08:00
position: absolute;
right: 8rpx;
bottom: 8rpx;
width: 40rpx;
height: 40rpx;
border-radius: 50%;
background: rgba(0, 0, 0, 0.55);
color: #fff;
font-size: 22rpx;
display: flex;
align-items: center;
justify-content: center;
}
.use-right {
flex: 1;
display: flex;
flex-direction: column;
}
.title-line {
display: flex;
align-items: center;
}
.use-title {
font-size: 28rpx;
color: #222;
font-weight: 600;
margin-right: 12rpx;
2026-01-09 11:24:40 +08:00
}
.tag {
2026-01-15 08:43:10 +08:00
font-size: 22rpx;
border-radius: 999rpx;
padding: 4rpx 10rpx;
margin-left: 4rpx;
&.tag--hot {
color: #ff6a00;
background: #fff4eb;
}
&.tag--featured {
color: #ff4d6d;
background: #fff0f3;
}
&.tag--hot2 {
color: #7c4dff;
background: #f3efff;
}
}
.use-desc {
margin-top: 6rpx;
font-size: 24rpx;
color: #777;
line-height: 1.5;
}
.use-cta {
margin-top: 10rpx;
font-size: 24rpx;
color: #ff3b30;
2026-01-09 11:24:40 +08:00
}
2026-01-15 08:43:10 +08:00
</style>