每日运势小程序

This commit is contained in:
cjd
2025-11-09 18:41:07 +08:00
parent 1cc0241cda
commit abd82782af
34 changed files with 2204 additions and 0 deletions

View File

@@ -0,0 +1,63 @@
const fortuneStore = require("../../store/fortuneStore");
const { normalizeFortunePayload } = require("../../utils/fortuneFormatter");
const { getPageSafeTop } = require("../../utils/safeArea");
function showToast(title) {
if (typeof tt === "undefined" || !tt.showToast) {
console.warn("Toast:", title);
return;
}
tt.showToast({
title,
icon: "none",
duration: 2000
});
}
Page({
data: {
safeAreaTop: 64,
fortuneDate: "",
summary: "",
narrative: "",
dimensions: [],
luckyGuide: null,
profile: null,
overallScore: 0
},
onLoad() {
this.updateSafeAreaPadding();
const { currentFortune } = fortuneStore.getState();
if (!currentFortune) {
showToast("暂无结果,请返回重新生成");
setTimeout(() => {
if (typeof tt !== "undefined" && tt.navigateBack) {
tt.navigateBack();
}
}, 1000);
return;
}
const normalized = normalizeFortunePayload(currentFortune);
if (normalized) {
this.setData(normalized);
}
},
updateSafeAreaPadding() {
const padding = getPageSafeTop();
this.setData({ safeAreaTop: padding });
},
handleBack() {
if (typeof tt !== "undefined" && tt.navigateBack) {
tt.navigateBack();
return;
}
if (typeof tt !== "undefined" && tt.redirectTo) {
tt.redirectTo({ url: "/pages/home/index" });
}
},
handleGoHistory() {
if (typeof tt !== "undefined" && tt.navigateTo) {
tt.navigateTo({ url: "/pages/history/index" });
}
}
});