Compare commits

...

11 Commits

Author SHA1 Message Date
zzc
88f06d0b42 fix: make move content 2026-02-06 01:15:47 +08:00
zzc
27fe2e5a52 fix: make move content 2026-02-06 00:50:55 +08:00
zzc
b3de7defdc fix: make move content 2026-02-06 00:20:34 +08:00
zzc
dced5471c5 fix: make move content 2026-02-06 00:07:53 +08:00
zzc
068391269e fix: watch user info 2026-02-06 00:00:38 +08:00
zzc
d5d60b8d5d fix: index page 2026-02-05 23:52:31 +08:00
zzc
d76269b154 fix: share token 2026-02-05 23:43:51 +08:00
zzc
3f764693c1 fix: avatar page 2026-02-05 22:36:54 +08:00
zzc
931ede6f8a fix: avatar page 2026-02-05 22:26:13 +08:00
zzc
c0e7ce069e fix: index 2026-02-05 22:17:52 +08:00
zzc
b0cc473a78 fix: index 2026-02-05 21:58:56 +08:00
11 changed files with 852 additions and 797 deletions

View File

@@ -23,9 +23,9 @@ export const getCardTemplateList = async (page = 1) => {
});
};
export const getCardTemplateContentList = async () => {
export const getCardTemplateContentList = async (page = 1) => {
return request({
url: "/api/blessing/card/template-content/list",
url: "/api/blessing/card/template-content/list?page=" + page,
method: "GET",
});
};
@@ -36,4 +36,3 @@ export const getCardTemplateTitleList = async (page = 1) => {
method: "GET",
});
};

View File

@@ -59,3 +59,10 @@ export const msgCheckApi = async (content) => {
method: "get",
});
};
export const getRandomGreeting = async () => {
return request({
url: "/api/blessing/random/greeting",
method: "get",
});
};

View File

@@ -13,7 +13,7 @@
"path": "pages/make/index",
"style": {
"navigationBarTitleText": "讨论",
"enablePullDownRefresh": false,
"enablePullDownRefresh": true,
"navigationStyle": "custom"
}
},

File diff suppressed because it is too large Load Diff

View File

@@ -119,10 +119,14 @@ import { getDeviceInfo } from "@/utils/system";
import { onLoad, onShow, onShareAppMessage } from "@dcloudio/uni-app";
import { abilityCheck } from "@/api/system.js";
import { drawFortune } from "@/api/fortune.js";
import { createShareToken, getShareReward } from "@/api/system.js";
import { getShareReward } from "@/api/system.js";
import LoginPopup from "@/components/LoginPopup/LoginPopup.vue";
import { useUserStore } from "@/stores/user";
import { saveRemoteImageToLocal, saveRecordRequest } from "@/utils/common.js";
import {
getShareToken,
saveRemoteImageToLocal,
saveRecordRequest,
} from "@/utils/common.js";
import NavBar from "@/components/NavBar/NavBar.vue";
const userStore = useUserStore();
@@ -158,16 +162,11 @@ onUnmounted(() => {
});
onShareAppMessage(async () => {
const deviceInfo = getDeviceInfo();
const shareTokenRes = await createShareToken({
targetId: cardId.value,
scene: "fortune_draw",
...deviceInfo,
});
const shareToken = await getShareToken("fortune_draw", cardId.value);
getRewardByShare();
return {
title: "马年运势我已经抽过了,你的会是什么?",
path: `${cardId.value ? `/pages/fortune/detail?shareToken=${shareTokenRes.shareToken}` : `/pages/fortune/index?shareToken=${shareTokenRes.shareToken}`}`,
path: `${cardId.value ? `/pages/fortune/detail?shareToken=${shareToken}` : `/pages/fortune/index?shareToken=${shareTokenRes.shareToken}`}`,
imageUrl:
"https://file.lihailezzc.com/resource/cfed2edbfa19250b836a87a4bbf0d5ad.png",
};

View File

@@ -105,9 +105,11 @@ import {
onPullDownRefresh,
onShareAppMessage,
onReachBottom,
onLoad,
} from "@dcloudio/uni-app";
import { getBavBarHeight } from "@/utils/system";
import { getRecommendList } from "@/api/system";
import { getRecommendList, getRandomGreeting } from "@/api/system";
import { getShareToken, saveViewRequest } from "@/utils/common.js";
const countdownText = ref("");
@@ -146,31 +148,40 @@ const updateCountdown = () => {
const todayDate = ref("");
const dailyGreeting = ref("");
const inspirationList = [
"岁岁常欢愉,年年皆胜意。愿你新的一年,多喜乐,长安宁。",
"新的一年,愿日子如熹光,温柔又安详。你我赤诚且勇敢,欣喜也在望。",
"祝你:百事无忌,平安喜乐。万事胜意,得偿所愿。",
"凡是过往皆为序章。愿2026年烟火向星辰所愿皆成真。",
"愿新的一年,仍有阳光满路,温暖如初。",
"辞暮尔尔,烟火年年。朝朝暮暮,岁岁平安。",
"愿你即使单枪匹马,也能勇敢无畏。新的一年,万事尽可期待。",
"所求皆如愿,所行化坦途。多喜乐,长安宁。",
"愿你手握山河,且行且歌。新年快乐,万事大吉。",
"长路浩浩荡荡,万物尽可期待。祝你新年好运。",
"何其有幸,年岁并进。新的一年,愿你快乐,不止新年。",
"愿新年,胜旧年。无病无灾,岁岁平安。",
"烟火起,照人间,举杯敬此年。烟花落,看人间,家家户户皆团圆。",
"家人闲坐,灯火可亲。新年伊始,喜乐安宁。",
"愿今年所有的遗憾,都是明年惊喜的铺垫。",
];
onLoad((options) => {
if (options.shareToken) saveViewRequest(options.shareToken, "index");
const copyGreeting = () => {
uni.setClipboardData({
data: dailyGreeting.value,
success: () => {
uni.showToast({ title: "复制成功", icon: "none" });
},
});
updateCountdown();
getRandomGreetingText();
fetchRecommendList();
const date = new Date();
todayDate.value = `${date.getMonth() + 1}${date.getDate()}`;
// Daily Inspiration Logic
// const startOfYear = new Date(date.getFullYear(), 0, 0);
// const diff = date - startOfYear;
// const oneDay = 1000 * 60 * 60 * 24;
// const dayOfYear = Math.floor(diff / oneDay);
// const index = dayOfYear % inspirationList.length;
// dailyGreeting.value = inspirationList[index];
});
onShareAppMessage(async () => {
const shareToken = await getShareToken("index");
return {
title: "新春祝福",
path: `/pages/index/index?shareToken=${shareToken}`,
imageUrl:
"https://file.lihailezzc.com/resource/cfed2edbfa19250b836a87a4bbf0d5ad.png",
};
});
const getRandomGreetingText = async () => {
const content = await getRandomGreeting();
dailyGreeting.value =
content || "烟火起,照人间,举杯敬此年。烟花落,看人间,家家户户皆团圆。";
};
const useGreeting = () => {
@@ -180,23 +191,6 @@ const useGreeting = () => {
});
};
onMounted(() => {
updateCountdown();
const date = new Date();
todayDate.value = `${date.getMonth() + 1}${date.getDate()}`;
// Daily Inspiration Logic
const startOfYear = new Date(date.getFullYear(), 0, 0);
const diff = date - startOfYear;
const oneDay = 1000 * 60 * 60 * 24;
const dayOfYear = Math.floor(diff / oneDay);
const index = dayOfYear % inspirationList.length;
dailyGreeting.value = inspirationList[index];
fetchRecommendList();
});
const features = ref([
{
title: "新春祝福卡片",
@@ -342,25 +336,11 @@ onReachBottom(() => {
fetchRecommendList();
});
const onMore = () => {
uni.showToast({ title: "更多模板即将上线~", icon: "none" });
};
onPullDownRefresh(async () => {
await fetchRecommendList(true);
setTimeout(() => {
uni.stopPullDownRefresh();
uni.showToast({ title: "已为你更新内容", icon: "success" });
}, 600);
});
onShareAppMessage(() => {
return {
title: "新春祝福",
path: "/pages/index/index",
imageUrl:
"https://file.lihailezzc.com/resource/cfed2edbfa19250b836a87a4bbf0d5ad.png",
};
updateCountdown();
await Promise.all([fetchRecommendList(true), getRandomGreetingText()]);
uni.stopPullDownRefresh();
uni.showToast({ title: "已为你更新内容", icon: "success" });
});
</script>

View File

@@ -51,6 +51,9 @@
<view
class="bubble"
@tap="openTool('text')"
@touchstart.stop="handleBubbleTouchStart"
@touchmove.stop="handleBubbleTouchMove"
@touchend.stop="handleBubbleTouchEnd"
:style="{
marginTop: 230 + bubbleOffsetY + 'rpx',
maxWidth: bubbleMaxWidth + 80 + 'rpx',
@@ -95,7 +98,7 @@
<view class="tip-line">
<view class="interaction-tip">
<uni-icons type="hand-up" size="14" color="#ff3b30"></uni-icons>
<text>点击标题或个人信息可拖动双指可缩放标题</text>
<text>标题祝福语个人信息可拖动改变位置双指可缩放标题</text>
</view>
</view>
@@ -120,111 +123,124 @@
<!-- 弹出编辑面板 -->
<view class="panel-container" :class="{ show: showPanel }">
<view class="panel-mask" @tap="closePanel"></view>
<view
<scroll-view
scroll-y
class="panel-content"
:class="{
'glass-effect': activeTool === 'text' || activeTool === 'position',
}"
@scrolltolower="onPanelScrollToLower"
>
<view class="panel-handle" @tap="closePanel"></view>
<view class="panel-inner">
<view class="panel-handle" @tap="closePanel"></view>
<!-- 标题选择区 -->
<view v-if="activeTool === 'title'" class="section">
<view class="section-title">
<text>选择标题</text>
</view>
<view class="tpl-scroll">
<view class="tpl-grid">
<view
v-for="(title, i) in titles"
:key="i"
class="tpl-card title-card"
:class="{ selected: title?.id === currentTitle?.id }"
@tap="selectTitle(title)"
>
<image
:src="title.imageUrl"
class="title-cover"
mode="aspectFit"
/>
<view v-if="title?.id === currentTitle?.id" class="tpl-check"
></view
>
</view>
<!-- 标题选择区 -->
<view v-if="activeTool === 'title'" class="section">
<view class="section-title">
<text>选择标题</text>
</view>
<view v-if="loadingTitles" class="loading-more">加载中...</view>
<view
v-else-if="!hasMoreTitles && titles.length > 0"
class="no-more"
>没有更多了</view
>
</view>
</view>
<!-- 模板区 -->
<view v-if="activeTool === 'template'" class="section">
<view class="section-title">
<text>热门模板</text>
</view>
<view class="tpl-scroll">
<view class="tpl-grid">
<view
v-for="(tpl, i) in templates"
:key="i"
class="tpl-card"
:class="{ selected: tpl?.id === currentTemplate?.id }"
@tap="applyTemplate(tpl)"
>
<image
:src="tpl.imageUrl"
class="tpl-cover"
mode="aspectFill"
/>
<view class="tpl-name">{{ tpl.name }}</view>
<view v-if="tpl?.id === currentTemplate?.id" class="tpl-check"
></view
>
</view>
</view>
<view v-if="loadingTemplates" class="loading-more">加载中...</view>
<view
v-else-if="!hasMoreTemplates && templates.length > 0"
class="no-more"
>没有更多了</view
>
</view>
</view>
<!-- 文字编辑 -->
<view v-if="activeTool === 'text'" class="section text-edit-section">
<view class="form-item">
<text class="label">祝福对象</text>
<input
class="input-box"
v-model="targetName"
placeholder="请输入称呼"
placeholder-style="color:#ccc"
maxlength="10"
@blur="handleTargetNameBlur"
/>
</view>
<!-- 祝福语库 -->
<view class="form-item">
<view class="label-row">
<text class="label">祝福语库</text>
<view class="refresh-btn" @tap="refreshGreetings">
<text class="refresh-icon"></text> 换一批
</view>
</view>
<scroll-view
scroll-x
class="greeting-scroll"
show-scrollbar="false"
>
<view class="greeting-list">
<view class="tpl-scroll">
<view class="tpl-grid">
<view
v-for="(text, index) in displayedGreetings"
v-for="(title, i) in titles"
:key="i"
class="tpl-card title-card"
:class="{ selected: title?.id === currentTitle?.id }"
@tap="selectTitle(title)"
>
<image
:src="title.imageUrl"
class="title-cover"
mode="aspectFit"
/>
<view v-if="title?.id === currentTitle?.id" class="tpl-check"
></view
>
</view>
</view>
<view v-if="loadingTitles" class="loading-more">加载中...</view>
<view
v-else-if="!hasMoreTitles && titles.length > 0"
class="no-more"
>没有更多了</view
>
</view>
</view>
<!-- 模板区 -->
<view v-if="activeTool === 'template'" class="section">
<view class="section-title">
<text>热门模板</text>
</view>
<view class="tpl-scroll">
<view class="tpl-grid">
<view
v-for="(tpl, i) in templates"
:key="i"
class="tpl-card"
:class="{ selected: tpl?.id === currentTemplate?.id }"
@tap="applyTemplate(tpl)"
>
<image
:src="tpl.imageUrl"
class="tpl-cover"
mode="aspectFill"
/>
<view class="tpl-name">{{ tpl.name }}</view>
<view v-if="tpl?.id === currentTemplate?.id" class="tpl-check"
></view
>
</view>
</view>
<view v-if="loadingTemplates" class="loading-more"
>加载中...</view
>
<view
v-else-if="!hasMoreTemplates && templates.length > 0"
class="no-more"
>没有更多了</view
>
</view>
</view>
<!-- 文字编辑 -->
<view v-if="activeTool === 'text'" class="section text-edit-section">
<view class="form-item">
<text class="label">祝福对象</text>
<input
class="input-box"
v-model="targetName"
placeholder="请输入称呼"
placeholder-style="color:#ccc"
maxlength="10"
@blur="handleTargetNameBlur"
/>
</view>
<!-- 署名 -->
<view class="form-item">
<text class="label">署名</text>
<view class="input-wrapper">
<input
class="input-box"
v-model="signatureName"
placeholder="请输入署名"
placeholder-style="color:#ccc"
maxlength="10"
@blur="handleSignatureBlur"
/>
<text class="edit-icon"></text>
</view>
</view>
<!-- 祝福语库 -->
<view class="form-item">
<view class="label-row">
<text class="label">祝福语库</text>
</view>
<view class="greeting-grid">
<view
v-for="(text, index) in greetingLib"
:key="index"
class="greeting-card"
:class="{ active: blessingText.content === text.content }"
@@ -238,84 +254,107 @@
>
</view>
</view>
</scroll-view>
</view>
<!-- 署名 -->
<view class="form-item">
<text class="label">署名</text>
<view class="input-wrapper">
<input
class="input-box"
v-model="signatureName"
placeholder="请输入署名"
placeholder-style="color:#ccc"
maxlength="10"
@blur="handleSignatureBlur"
/>
<text class="edit-icon"></text>
<view v-if="loadingBlessings" class="loading-more"
>加载中...</view
>
<view
v-else-if="!hasMoreBlessings && greetingLib.length > 0"
class="no-more"
>没有更多了</view
>
</view>
</view>
<!-- 字体选择 -->
<view class="form-item">
<text class="label">字体样式</text>
<scroll-view scroll-x class="font-scroll" show-scrollbar="false">
<view class="font-list">
<!-- 样式与位置 -->
<view
v-if="activeTool === 'position'"
class="section position-section"
>
<view class="section-title">
<text>调整样式与位置</text>
</view>
<!-- 字体大小 -->
<view class="form-item" style="margin-top: 20rpx">
<text class="label">字体大小</text>
<slider
:value="fontSize"
min="24"
max="64"
show-value
@change="(e) => (fontSize = e.detail.value)"
activeColor="#ff3b30"
/>
</view>
<view class="form-item">
<text class="label">祝福语宽窄</text>
<slider
:value="bubbleMaxWidth"
min="200"
max="460"
show-value
@change="(e) => (bubbleMaxWidth = e.detail.value)"
activeColor="#ff3b30"
/>
</view>
<!-- 字体选择 -->
<view class="form-item">
<text class="label">字体样式</text>
<scroll-view scroll-x class="font-scroll" show-scrollbar="false">
<view class="font-list">
<view
v-for="(font, index) in fontList"
:key="index"
class="font-item"
:class="{ active: selectedFont.family === font.family }"
@tap="changeFont(font)"
>
<text :style="{ fontFamily: font.family }">{{
font.name
}}</text>
</view>
</view>
</scroll-view>
</view>
<!-- 文字颜色 -->
<view class="form-item">
<text class="label">祝福语颜色</text>
<view class="color-list">
<view
v-for="(font, index) in fontList"
v-for="(color, index) in textColors"
:key="index"
class="font-item"
:class="{ active: selectedFont.family === font.family }"
@tap="changeFont(font)"
class="color-item"
:style="{ background: color }"
@tap="selectedColor = color"
>
<text :style="{ fontFamily: font.family }">{{
font.name
}}</text>
<view v-if="selectedColor === color" class="color-check"
></view
>
</view>
</view>
</scroll-view>
</view>
</view>
<!-- 字体大小 -->
<view class="form-item">
<text class="label">字体大小</text>
<slider
:value="fontSize"
min="24"
max="64"
show-value
@change="(e) => (fontSize = e.detail.value)"
activeColor="#ff3b30"
/>
</view>
<!-- 文字颜色 -->
<view class="form-item">
<text class="label">祝福语颜色</text>
<view class="color-list">
<view
v-for="(color, index) in textColors"
:key="index"
class="color-item"
:style="{ background: color }"
@tap="selectedColor = color"
>
<view v-if="selectedColor === color" class="color-check"
></view
<view class="form-item">
<text class="label">署名颜色</text>
<view class="color-list">
<view
v-for="(color, index) in textColors"
:key="index"
class="color-item"
:style="{ background: color }"
@tap="signatureColor = color"
>
<view v-if="signatureColor === color" class="color-check"
></view
>
</view>
</view>
</view>
</view>
</view>
<!-- 位置调整 -->
<view v-if="activeTool === 'position'" class="section position-section">
<view class="section-title">
<text>调整位置</text>
</view>
<view class="form-item" style="margin-top: 20rpx">
<!-- <view class="form-item">
<text class="label">祝福语气泡 (上下)</text>
<slider
:value="bubbleOffsetY"
@@ -327,18 +366,6 @@
/>
</view>
<view class="form-item">
<text class="label">祝福语气泡宽度</text>
<slider
:value="bubbleMaxWidth"
min="200"
max="460"
show-value
@change="(e) => (bubbleMaxWidth = e.detail.value)"
activeColor="#ff3b30"
/>
</view>
<view class="form-item">
<text class="label">个人信息 (上下)</text>
<slider
@@ -361,26 +388,10 @@
@change="(e) => (userOffsetX = e.detail.value)"
activeColor="#ff3b30"
/>
</view>
<view class="form-item">
<text class="label">署名颜色</text>
<view class="color-list">
<view
v-for="(color, index) in textColors"
:key="index"
class="color-item"
:style="{ background: color }"
@tap="signatureColor = color"
>
<view v-if="signatureColor === color" class="color-check"
></view
>
</view>
</view>
</view> -->
</view>
</view>
</view>
</scroll-view>
</view>
<canvas
@@ -395,7 +406,7 @@
</template>
<script setup>
import { ref, computed } from "vue";
import { ref, computed, watch } from "vue";
import { getBavBarHeight, getDeviceInfo } from "@/utils/system";
import { generateObjectId, getShareToken } from "@/utils/common";
@@ -406,17 +417,13 @@ import {
getCardTemplateContentList,
getCardTemplateTitleList,
} from "@/api/make";
import {
createShareToken,
abilityCheck,
getShareReward,
msgCheckApi,
} from "@/api/system";
import { abilityCheck, getShareReward, msgCheckApi } from "@/api/system";
import {
onShareAppMessage,
onLoad,
onReachBottom,
onShow,
onPullDownRefresh,
} from "@dcloudio/uni-app";
import { useUserStore } from "@/stores/user";
import LoginPopup from "@/components/LoginPopup/LoginPopup.vue";
@@ -426,6 +433,9 @@ const userStore = useUserStore();
const loginPopupRef = ref(null);
const isLoggedIn = computed(() => !!userStore.userInfo.nickName);
const DEFAULT_AVATAR =
"https://file.lihailezzc.com/resource/96023631c6ab9c3496b7620097af3d6f.png";
const templatePage = ref(1);
const loadingTemplates = ref(false);
const hasMoreTemplates = ref(true);
@@ -512,6 +522,31 @@ const handleUserTouchMove = (e) => {
}
};
// 祝福语触摸交互相关
let startBubbleTouches = [];
let initialBubbleOffsetY = 0;
const handleBubbleTouchStart = (e) => {
startBubbleTouches = e.touches;
initialBubbleOffsetY = bubbleOffsetY.value;
};
const handleBubbleTouchEnd = () => {
startBubbleTouches = [];
};
const handleBubbleTouchMove = (e) => {
if (!startBubbleTouches.length) return;
if (e.touches.length === 1 && startBubbleTouches.length === 1) {
// 单指拖拽 (仅上下)
const moveY = e.touches[0].clientY - startBubbleTouches[0].clientY;
let newY = initialBubbleOffsetY + moveY * pxToRpx;
// 合理范围限制,参考 slider 的 min/max
bubbleOffsetY.value = Math.min(Math.max(newY, -200), 400);
}
};
const handleTitleTouchMove = (e) => {
if (!currentTitle.value || !startTouches.length) return;
@@ -584,10 +619,7 @@ const handleSignatureBlur = async () => {
oldSignatureName.value = signatureName.value;
}
};
const userAvatar = ref(
userStore?.userInfo?.avatarUrl ||
"https://file.lihailezzc.com/resource/96023631c6ab9c3496b7620097af3d6f.png",
);
const userAvatar = ref(userStore?.userInfo?.avatarUrl || DEFAULT_AVATAR);
const blessingText = ref({});
const fontSize = ref(32);
@@ -664,7 +696,9 @@ const changeFont = (font) => {
};
const greetingLib = ref([]);
const greetingIndex = ref(0);
const blessingPage = ref(1);
const loadingBlessings = ref(false);
const hasMoreBlessings = ref(true);
const bubbleOffsetY = ref(0);
const bubbleMaxWidth = ref(400); // 默认宽度
@@ -677,7 +711,30 @@ onLoad((options) => {
getTemplateTitleList();
});
const syncUserInfo = () => {
if (isLoggedIn.value) {
if (signatureName.value === "xxx" || !signatureName.value) {
signatureName.value = userStore.userInfo.nickName;
oldSignatureName.value = userStore.userInfo.nickName;
}
if (userAvatar.value === DEFAULT_AVATAR || !userAvatar.value) {
userAvatar.value = userStore.userInfo.avatarUrl;
}
}
};
watch(
() => userStore.userInfo,
(newVal) => {
if (newVal?.nickName) {
syncUserInfo();
}
},
{ deep: true },
);
onShow(() => {
syncUserInfo();
const recommendData = uni.getStorageSync("RECOMMEND_CARD_DATA");
if (recommendData) {
uni.removeStorageSync("RECOMMEND_CARD_DATA");
@@ -713,10 +770,31 @@ onReachBottom(() => {
loadMoreTemplates();
} else if (activeTool.value === "title") {
loadMoreTitles();
} else if (activeTool.value === "text") {
loadMoreBlessings();
}
});
const handleLogind = async () => {};
onPullDownRefresh(async () => {
templatePage.value = 1;
hasMoreTemplates.value = true;
titlePage.value = 1;
hasMoreTitles.value = true;
blessingPage.value = 1;
hasMoreBlessings.value = true;
await Promise.all([
getTemplateList(),
getTemplateTitleList(),
getTemplateContentList(),
]);
uni.stopPullDownRefresh();
uni.showToast({ title: "已为你更新内容", icon: "success" });
});
const handleLogind = async () => {
syncUserInfo();
};
const createCard = () => {
const id = generateObjectId();
@@ -765,6 +843,9 @@ const getTemplateList = async (isLoadMore = false) => {
console.error("加载模板失败:", error);
} finally {
loadingTemplates.value = false;
if (!isLoadMore && hasMoreTemplates.value) {
getTemplateList(true);
}
}
};
@@ -803,6 +884,9 @@ const getTemplateTitleList = async (isLoadMore = false) => {
console.error("加载标题失败:", error);
} finally {
loadingTitles.value = false;
if (!isLoadMore && hasMoreTitles.value) {
getTemplateTitleList(true);
}
}
};
@@ -810,21 +894,65 @@ const loadMoreTitles = () => {
getTemplateTitleList(true);
};
const getTemplateContentList = async () => {
const res = await getCardTemplateContentList();
if (res.length) {
greetingLib.value = res;
displayedGreetings.value = greetingLib.value.slice(0, 2);
if (!blessingText.value.content) {
blessingText.value = greetingLib.value[0] || {};
const getTemplateContentList = async (isLoadMore = false) => {
if (loadingBlessings.value || (!hasMoreBlessings.value && isLoadMore)) return;
loadingBlessings.value = true;
try {
const res = await getCardTemplateContentList(blessingPage.value);
const list = Array.isArray(res) ? res : res.list || [];
if (list.length > 0) {
if (isLoadMore) {
greetingLib.value = [...greetingLib.value, ...list];
} else {
greetingLib.value = list;
if (list.length > 0 && !blessingText.value.content) {
blessingText.value = list[0];
}
}
if (typeof res.hasNext !== "undefined") {
hasMoreBlessings.value = res.hasNext;
} else {
hasMoreBlessings.value = list.length >= 8;
}
if (hasMoreBlessings.value) {
blessingPage.value++;
}
} else {
if (!isLoadMore) greetingLib.value = [];
hasMoreBlessings.value = false;
}
} catch (error) {
console.error("加载祝福语失败:", error);
} finally {
loadingBlessings.value = false;
if (!isLoadMore && hasMoreBlessings.value) {
getTemplateContentList(true);
}
}
};
const loadMoreBlessings = () => {
getTemplateContentList(true);
};
const loadMoreTemplates = () => {
getTemplateList(true);
};
const onPanelScrollToLower = () => {
if (activeTool.value === "template") {
loadMoreTemplates();
} else if (activeTool.value === "title") {
loadMoreTitles();
} else if (activeTool.value === "text") {
loadMoreBlessings();
}
};
onShareAppMessage(async (options) => {
getShareReward({ scene: "card_generate" });
if (options.from === "button") {
@@ -843,45 +971,25 @@ onShareAppMessage(async (options) => {
};
}
const deviceInfo = getDeviceInfo();
const shareTokenRes = await createShareToken({
scene: "card_generate",
targetId: id,
...deviceInfo,
});
const shareToken = await getShareToken("card_generate", id);
shareOrSave(id);
return {
title: "我刚做了一张祝福卡片,送给你",
path: "/pages/detail/index?shareToken=" + shareTokenRes.shareToken,
path: "/pages/detail/index?shareToken=" + shareToken,
imageUrl:
"https://file.lihailezzc.com/resource/13ec1134e6614feadeeaaa9ef21ea96e.png",
};
} else {
const shareTokenRes = await getShareToken("card_generate_index", "");
const shareToken = await getShareToken("card_generate_index", "");
return {
title: "新春祝福",
path: `/pages/index/index?shareToken=${shareTokenRes.shareToken}`,
path: `/pages/index/index?shareToken=${shareToken}`,
imageUrl:
"https://file.lihailezzc.com/resource/cfed2edbfa19250b836a87a4bbf0d5ad.png",
};
}
});
const displayedGreetings = ref([]);
const refreshGreetings = () => {
if (!greetingLib.value.length) return;
const nextIndex = (greetingIndex.value + 2) % greetingLib.value.length;
greetingIndex.value = nextIndex;
let next = greetingLib.value.slice(nextIndex, nextIndex + 2);
if (next.length < 2) {
next = [...next, ...greetingLib.value.slice(0, 2 - next.length)];
}
displayedGreetings.value = next;
};
const selectGreeting = (text) => {
blessingText.value = text;
};
@@ -889,8 +997,8 @@ const selectGreeting = (text) => {
const tools = [
{ type: "template", text: "1. 选模板", icon: "🎨", step: 1 },
{ type: "title", text: "2. 选标题", icon: "🧧", step: 2 },
{ type: "text", text: "3. 改文字", icon: "✍️", step: 3 },
{ type: "position", text: "4. 调位置", icon: "🎯", step: 4 },
{ type: "text", text: "3. 写祝福", icon: "✍️", step: 3 },
{ type: "position", text: "4. 设样式", icon: "", step: 4 },
];
const activeTool = ref("template");
const showPanel = ref(false);
@@ -1521,11 +1629,12 @@ function drawRoundRect(ctx, x, y, w, h, r, color) {
right: 0;
background: #fff;
border-radius: 40rpx 40rpx 0 0;
padding: 30rpx 40rpx calc(40rpx + env(safe-area-inset-bottom));
transform: translateY(100%);
transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1);
max-height: 80vh;
overflow-y: auto;
height: 80vh;
}
.panel-inner {
padding: 30rpx 40rpx calc(40rpx + env(safe-area-inset-bottom));
}
.panel-container.show .panel-content {
transform: translateY(0);
@@ -1721,22 +1830,19 @@ function drawRoundRect(ctx, x, y, w, h, r, color) {
margin-right: 6rpx;
font-size: 24rpx;
}
.greeting-scroll {
width: 100%;
}
.greeting-list {
display: flex;
padding-bottom: 10rpx;
.greeting-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 16rpx;
padding-bottom: 20rpx;
}
.greeting-card {
flex-shrink: 0;
width: 320rpx;
width: 100%;
height: 160rpx;
background: #fff;
border: 2rpx solid #eee;
border-radius: 16rpx;
padding: 20rpx;
margin-right: 20rpx;
position: relative;
box-sizing: border-box;
}

View File

@@ -126,21 +126,21 @@ onReachBottom(() => {
onShareAppMessage(async (options) => {
if (options.from === "button") {
const shareTokenRes = await getShareToken(
const shareToken = await getShareToken(
"card_generate",
options?.target?.dataset?.item?.id,
);
return {
title: "我刚做了一张祝福卡片,送给你",
path: "/pages/detail/index?shareToken=" + shareTokenRes.shareToken,
path: "/pages/detail/index?shareToken=" + shareToken,
imageUrl:
"https://file.lihailezzc.com/resource/13ec1134e6614feadeeaaa9ef21ea96e.png",
};
} else {
const shareTokenRes = await getShareToken("greeting_page", "");
const shareToken = await getShareToken("greeting_page", "");
return {
title: "新春祝福",
path: `/pages/index/index?shareToken=${shareTokenRes.shareToken}`,
path: `/pages/index/index?shareToken=${shareToken}`,
imageUrl:
"https://file.lihailezzc.com/resource/cfed2edbfa19250b836a87a4bbf0d5ad.png",
};

View File

@@ -106,19 +106,19 @@ const isRefreshing = ref(false);
onShareAppMessage(async (options) => {
getShareReward({ scene: "wallpaper_download" });
if (options.from === "button") {
const shareTokenRes = await getShareToken(
const shareToken = await getShareToken(
"wallpaper_download",
options?.target?.dataset?.item?.id,
);
return {
title: "快来挑选喜欢的新春壁纸吧",
path: `/pages/wallpaper/detail?shareToken=${shareTokenRes.shareToken}`,
path: `/pages/wallpaper/detail?shareToken=${shareToken}`,
};
} else {
const shareTokenRes = await getShareToken("wallpaper_download", "");
const shareToken = await getShareToken("wallpaper_download", "");
return {
title: "新春祝福",
path: `/pages/index/index?shareToken=${shareTokenRes.shareToken}`,
path: `/pages/index/index?shareToken=${shareToken}`,
imageUrl:
"https://file.lihailezzc.com/resource/cfed2edbfa19250b836a87a4bbf0d5ad.png",
};

View File

@@ -54,7 +54,7 @@ export const saveRecordRequest = async (path, targetId, scene, imageUrl) => {
});
};
export const saveViewRequest = async (shareToken, scene, targetId) => {
export const saveViewRequest = async (shareToken, scene, targetId = "") => {
const deviceInfo = getDeviceInfo();
viewRecord({
shareToken,
@@ -92,7 +92,12 @@ export const saveRemoteImageToLocal = (imageUrl) => {
});
};
export const getShareToken = async (scene, targetId) => {
export const getShareToken = async (scene, targetId = "") => {
const deviceInfo = getDeviceInfo();
return await createShareToken({ scene, targetId, ...deviceInfo });
const shareTokenRes = await createShareToken({
scene,
targetId,
...deviceInfo,
});
return shareTokenRes?.shareToken || "";
};

View File

@@ -1,6 +1,6 @@
const BASE_URL = "https://api.ai-meng.com";
// const BASE_URL = "https://api.ai-meng.com";
// const BASE_URL = 'http://127.0.0.1:3999'
// const BASE_URL = "http://192.168.1.3:3999";
const BASE_URL = "http://192.168.1.3:3999";
// const BASE_URL = "http://192.168.31.253:3999";
import { useUserStore } from "@/stores/user";