fix: daily page
This commit is contained in:
@@ -13,3 +13,11 @@ export const getDailyRandomGreeting = async (sceneId) => {
|
|||||||
method: "GET",
|
method: "GET",
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const saveDailyGreeting = async (data) => {
|
||||||
|
return request({
|
||||||
|
url: "/api/blessing/daily-greeting/send",
|
||||||
|
method: "POST",
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|||||||
@@ -142,33 +142,32 @@
|
|||||||
</button>
|
</button>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<!-- 登录弹窗 -->
|
||||||
|
<LoginPopup />
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed, onMounted, watch } from "vue";
|
import { ref, computed, onMounted } from "vue";
|
||||||
import { getBavBarHeight } from "@/utils/system";
|
|
||||||
import NavBar from "@/components/NavBar/NavBar.vue";
|
import NavBar from "@/components/NavBar/NavBar.vue";
|
||||||
import {
|
import { onShareAppMessage, onShareTimeline } from "@dcloudio/uni-app";
|
||||||
onShareAppMessage,
|
|
||||||
onShareTimeline,
|
|
||||||
onShow,
|
|
||||||
onLoad,
|
|
||||||
} from "@dcloudio/uni-app";
|
|
||||||
import { useUserStore } from "@/stores/user";
|
import { useUserStore } from "@/stores/user";
|
||||||
|
import {
|
||||||
import { getDailyInfo, getDailyRandomGreeting } from "@/api/daily";
|
getDailyInfo,
|
||||||
|
getDailyRandomGreeting,
|
||||||
|
saveDailyGreeting,
|
||||||
|
} from "@/api/daily";
|
||||||
|
import {
|
||||||
|
getShareToken,
|
||||||
|
saveViewRequest,
|
||||||
|
generateObjectId,
|
||||||
|
} from "@/utils/common.js";
|
||||||
|
import LoginPopup from "@/components/LoginPopup/LoginPopup.vue";
|
||||||
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
|
||||||
const navBarHeight = getBavBarHeight();
|
|
||||||
const streakDays = ref(0);
|
const streakDays = ref(0);
|
||||||
|
|
||||||
const dateStr = computed(() => {
|
|
||||||
const date = new Date();
|
|
||||||
return `${date.getFullYear()} 灵马送福 · 每日精选`;
|
|
||||||
});
|
|
||||||
|
|
||||||
const greetingTitle = computed(() => {
|
const greetingTitle = computed(() => {
|
||||||
const hour = new Date().getHours();
|
const hour = new Date().getHours();
|
||||||
if (hour < 9) return "早安,今天也要好运";
|
if (hour < 9) return "早安,今天也要好运";
|
||||||
@@ -227,6 +226,7 @@ const loadDailyInfo = async () => {
|
|||||||
author: authorName.value, // Will be reactive in template via authorName ref
|
author: authorName.value, // Will be reactive in template via authorName ref
|
||||||
backgroundUrl: backgroundUrl || "",
|
backgroundUrl: backgroundUrl || "",
|
||||||
id: greetingId,
|
id: greetingId,
|
||||||
|
content: greetingContent,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (greetingScene) {
|
if (greetingScene) {
|
||||||
@@ -276,6 +276,7 @@ const refreshQuote = async () => {
|
|||||||
highlight,
|
highlight,
|
||||||
backgroundUrl: backgroundUrl || "",
|
backgroundUrl: backgroundUrl || "",
|
||||||
id: greetingId,
|
id: greetingId,
|
||||||
|
content: greetingContent,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -309,7 +310,15 @@ const saveCard = () => {
|
|||||||
// });
|
// });
|
||||||
// };
|
// };
|
||||||
|
|
||||||
onShareAppMessage((res) => {
|
onShareAppMessage(async (options) => {
|
||||||
|
const id = createGreeting();
|
||||||
|
const shareToken = await getShareToken("daily_greeting", id);
|
||||||
|
|
||||||
|
return {
|
||||||
|
title: `${authorName.value}给你发来了一份今日问候`,
|
||||||
|
path: "/pages/greeting/share?shareToken=" + shareToken,
|
||||||
|
};
|
||||||
|
|
||||||
const fromUser = userStore.userInfo?.nickName || "神秘好友";
|
const fromUser = userStore.userInfo?.nickName || "神秘好友";
|
||||||
const fromAvatar = userStore.userInfo?.avatarUrl || "";
|
const fromAvatar = userStore.userInfo?.avatarUrl || "";
|
||||||
|
|
||||||
@@ -336,6 +345,19 @@ onShareAppMessage((res) => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const createGreeting = () => {
|
||||||
|
const id = generateObjectId();
|
||||||
|
saveDailyGreeting({
|
||||||
|
id,
|
||||||
|
greetingId: currentQuote.value.id,
|
||||||
|
content: currentQuote.value.content,
|
||||||
|
signature: authorName.value,
|
||||||
|
imageUrl: currentQuote.value.backgroundUrl,
|
||||||
|
sceneId: currentCategory.value,
|
||||||
|
});
|
||||||
|
return id;
|
||||||
|
};
|
||||||
|
|
||||||
onShareTimeline(() => {
|
onShareTimeline(() => {
|
||||||
const fromUser = userStore.userInfo?.nickName || "神秘好友";
|
const fromUser = userStore.userInfo?.nickName || "神秘好友";
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user