Files
spring-festival-greetings/pages/greeting/share.vue

286 lines
6.2 KiB
Vue
Raw Normal View History

2026-03-01 23:14:49 +08:00
<template>
<view class="share-page">
<NavBar title="今日问候" :transparent="true" color="#333" />
<!-- Top User Info -->
<view class="user-header" :style="{ paddingTop: navBarHeight + 'px' }">
<image
class="user-avatar"
:src="fromAvatar || defaultAvatar"
mode="aspectFill"
/>
<view class="user-info">
<view class="user-name">
<text>你的好友</text>
2026-03-02 22:29:41 +08:00
<text class="highlight-name">{{
author || fromUser || "神秘好友"
}}</text>
2026-03-01 23:14:49 +08:00
</view>
<text class="user-desc">给你发来了一份今日问候</text>
</view>
</view>
<!-- Main Card -->
<view class="main-card-container">
2026-03-02 21:32:26 +08:00
<view
2026-03-03 21:32:04 +08:00
class="quote-card"
2026-03-02 21:32:26 +08:00
:style="
backgroundUrl
? {
backgroundImage: `url(${backgroundUrl})`,
backgroundSize: 'cover',
backgroundPosition: 'center',
}
: {}
"
>
2026-03-03 21:32:04 +08:00
<view class="quote-icon"></view>
<view class="quote-content">
<text class="quote-text">{{ content }}</text>
<text class="quote-highlight" v-if="highlight">{{ highlight }}</text>
2026-03-01 23:14:49 +08:00
</view>
2026-03-03 21:32:04 +08:00
<view class="quote-divider"></view>
<view class="quote-author">
<text> {{ author ? ` ${author} 的专属问候` : "专属问候" }}</text>
2026-03-01 23:14:49 +08:00
</view>
</view>
</view>
<!-- Action Buttons -->
<view class="action-buttons">
2026-03-03 21:32:04 +08:00
<button class="btn primary-btn" @tap="navToMake">
<uni-icons type="paperplane-filled" size="20" color="#fff" />
2026-03-01 23:14:49 +08:00
<text>我也要送问候</text>
</button>
</view>
2026-03-03 21:32:04 +08:00
<view class="footer-tip safe-area-bottom">
<text>愿每一天都充满阳光与希望</text>
2026-03-01 23:14:49 +08:00
</view>
</view>
</template>
<script setup>
import { ref } from "vue";
import { onLoad, onShareAppMessage } from "@dcloudio/uni-app";
import { getBavBarHeight } from "@/utils/system";
import NavBar from "@/components/NavBar/NavBar.vue";
2026-03-02 21:32:26 +08:00
import { getPageDetail } from "@/api/system";
2026-03-01 23:14:49 +08:00
const navBarHeight = getBavBarHeight();
const defaultAvatar =
"https://file.lihailezzc.com/resource/96023631c6ab9c3496b7620097af3d6f.png";
const fromUser = ref("");
const fromAvatar = ref("");
const content = ref("万事顺遂\n岁岁平安\n愿你的生活\n日日有小确幸");
const author = ref("陈小明");
2026-03-02 21:32:26 +08:00
const highlight = ref("");
const backgroundUrl = ref("");
2026-03-01 23:14:49 +08:00
2026-03-02 21:32:26 +08:00
onLoad(async (options) => {
if (options.shareToken) {
const detail = await getPageDetail(options.shareToken);
if (detail) {
if (detail.from) {
fromUser.value = detail.from.nickname;
fromAvatar.value = detail.from.avatar;
}
if (detail.content) {
const parts = detail.content.split(" ");
if (parts.length > 1) {
highlight.value = parts.pop();
content.value = parts.join("\n");
} else {
content.value = detail.content;
highlight.value = "";
}
}
author.value = detail.signature || "专属问候";
backgroundUrl.value = detail.imageUrl || "";
}
}
2026-03-01 23:14:49 +08:00
});
const navToMake = () => {
uni.navigateTo({
url: "/pages/greeting/daily",
});
};
onShareAppMessage(() => {
return {
title: `${fromUser.value || "好友"}给你发来了一份今日问候`,
path: `/pages/greeting/share?content=${encodeURIComponent(content.value)}&author=${encodeURIComponent(author.value)}&fromUser=${encodeURIComponent(fromUser.value)}&fromAvatar=${encodeURIComponent(fromAvatar.value)}`,
};
});
</script>
<style lang="scss" scoped>
.share-page {
min-height: 100vh;
background: #fbfbf9;
padding-bottom: 200rpx;
}
.user-header {
padding: 20rpx 40rpx;
display: flex;
align-items: center;
gap: 20rpx;
margin-bottom: 20rpx;
}
.user-avatar {
width: 80rpx;
height: 80rpx;
border-radius: 50%;
border: 2rpx solid #fff;
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
}
.user-info {
display: flex;
flex-direction: column;
}
.user-name {
font-size: 28rpx;
color: #333;
margin-bottom: 4rpx;
.highlight-name {
color: #d81e06;
font-weight: bold;
margin-left: 8rpx;
}
}
.user-desc {
font-size: 24rpx;
color: #999;
}
2026-03-03 21:32:04 +08:00
/* Greeting Card - Adapted from daily.vue quote-card */
2026-03-01 23:14:49 +08:00
.main-card-container {
padding: 0 40rpx;
2026-03-03 21:32:04 +08:00
margin-bottom: 80rpx;
2026-03-01 23:14:49 +08:00
}
2026-03-03 21:32:04 +08:00
.quote-card {
2026-03-01 23:14:49 +08:00
background: #fff;
border-radius: 40rpx;
2026-03-03 21:32:04 +08:00
padding: 60rpx 40rpx 40rpx;
box-shadow: 0 20rpx 60rpx rgba(0, 0, 0, 0.08);
border: 4rpx solid #f5e6d3; /* Gold-ish border */
position: relative;
2026-03-01 23:14:49 +08:00
min-height: 700rpx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
2026-03-03 21:32:04 +08:00
/* Inner Border Effect */
&::after {
content: "";
2026-03-01 23:14:49 +08:00
position: absolute;
2026-03-03 21:32:04 +08:00
inset: 12rpx;
border: 2rpx solid #f9f3e8;
border-radius: 32rpx;
pointer-events: none;
2026-03-01 23:14:49 +08:00
}
2026-03-03 21:32:04 +08:00
}
2026-03-01 23:14:49 +08:00
2026-03-03 21:32:04 +08:00
.quote-icon {
font-size: 80rpx;
color: #f5e6d3;
margin-bottom: 40rpx;
line-height: 1;
2026-03-01 23:14:49 +08:00
}
2026-03-03 21:32:04 +08:00
.quote-content {
2026-03-01 23:14:49 +08:00
text-align: center;
2026-03-03 21:32:04 +08:00
margin-bottom: 60rpx;
2026-03-01 23:14:49 +08:00
}
2026-03-03 21:32:04 +08:00
.quote-text {
font-size: 40rpx;
2026-03-01 23:14:49 +08:00
color: #333;
font-weight: bold;
2026-03-03 21:32:04 +08:00
line-height: 1.6;
2026-03-01 23:14:49 +08:00
font-family: "Songti SC", serif;
2026-03-03 21:32:04 +08:00
display: block;
2026-03-01 23:14:49 +08:00
white-space: pre-wrap;
}
2026-03-03 21:32:04 +08:00
.quote-highlight {
2026-03-02 21:32:26 +08:00
display: block;
2026-03-03 21:32:04 +08:00
font-size: 44rpx;
2026-03-02 21:32:26 +08:00
color: #d81e06;
font-weight: 800;
margin-top: 20rpx;
font-family: "Songti SC", serif;
}
2026-03-03 21:32:04 +08:00
.quote-divider {
width: 80rpx;
2026-03-01 23:14:49 +08:00
height: 2rpx;
2026-03-03 21:32:04 +08:00
background: #eee;
2026-03-01 23:14:49 +08:00
margin-bottom: 30rpx;
}
2026-03-03 21:32:04 +08:00
.quote-author {
2026-03-01 23:14:49 +08:00
font-size: 28rpx;
2026-03-03 21:32:04 +08:00
color: #999;
2026-03-01 23:14:49 +08:00
font-style: italic;
font-family: "Songti SC", serif;
}
.action-buttons {
2026-03-03 21:32:04 +08:00
padding: 0 60rpx;
margin-bottom: 40rpx;
2026-03-01 23:14:49 +08:00
}
.btn {
display: flex;
align-items: center;
justify-content: center;
2026-03-03 21:32:04 +08:00
gap: 12rpx;
height: 96rpx;
border-radius: 48rpx;
font-size: 32rpx;
2026-03-01 23:14:49 +08:00
font-weight: bold;
border: none;
2026-03-03 21:32:04 +08:00
transition: all 0.2s;
2026-03-01 23:14:49 +08:00
&::after {
border: none;
}
&:active {
2026-03-03 21:32:04 +08:00
transform: scale(0.98);
2026-03-01 23:14:49 +08:00
}
}
2026-03-03 21:32:04 +08:00
.primary-btn {
background: linear-gradient(135deg, #8e0000 0%, #600000 100%);
2026-03-01 23:14:49 +08:00
color: #fff;
2026-03-03 21:32:04 +08:00
box-shadow: 0 8rpx 24rpx rgba(142, 0, 0, 0.3);
2026-03-01 23:14:49 +08:00
&:active {
2026-03-03 21:32:04 +08:00
box-shadow: 0 4rpx 12rpx rgba(142, 0, 0, 0.2);
2026-03-01 23:14:49 +08:00
}
}
2026-03-03 21:32:04 +08:00
.footer-tip {
text-align: center;
padding: 40rpx 0;
2026-03-01 23:14:49 +08:00
2026-03-03 21:32:04 +08:00
text {
font-size: 24rpx;
color: #ccc;
letter-spacing: 4rpx;
2026-03-01 23:14:49 +08:00
}
}
</style>