fix: daily page
This commit is contained in:
@@ -7,9 +7,9 @@ export const getDailyInfo = async () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getDailyRandomGreeting = async () => {
|
export const getDailyRandomGreeting = async (sceneId) => {
|
||||||
return request({
|
return request({
|
||||||
url: "/api/blessing/daily-greeting/random",
|
url: `/api/blessing/daily-greeting/random?sceneId=${sceneId}`,
|
||||||
method: "GET",
|
method: "GET",
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ import {
|
|||||||
} from "@dcloudio/uni-app";
|
} from "@dcloudio/uni-app";
|
||||||
import { useUserStore } from "@/stores/user";
|
import { useUserStore } from "@/stores/user";
|
||||||
|
|
||||||
import { getDailyInfo } from "@/api/daily";
|
import { getDailyInfo, getDailyRandomGreeting } from "@/api/daily";
|
||||||
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
|
||||||
@@ -250,19 +250,37 @@ const hotList = ref([
|
|||||||
|
|
||||||
const selectCategory = (id) => {
|
const selectCategory = (id) => {
|
||||||
currentCategory.value = id;
|
currentCategory.value = id;
|
||||||
// TODO: Call API to get quote for this category if API supports it
|
|
||||||
// For now, we just reload daily info which might not be category specific
|
|
||||||
// If the API supports category param, we should use it.
|
|
||||||
// Assuming getDailyInfo might accept params but user didn't specify.
|
|
||||||
// Or maybe we should just rely on refreshQuote?
|
|
||||||
refreshQuote();
|
refreshQuote();
|
||||||
};
|
};
|
||||||
|
|
||||||
const refreshQuote = () => {
|
const refreshQuote = async () => {
|
||||||
// Since we don't have a specific refresh API in the prompt, re-call loadDailyInfo
|
try {
|
||||||
// This might just reload the same "daily" greeting or a new one.
|
const res = await getDailyRandomGreeting(currentCategory.value);
|
||||||
// Ideally there should be a refresh API.
|
if (res) {
|
||||||
loadDailyInfo();
|
const { greetingContent, backgroundUrl, greetingId } = res;
|
||||||
|
let text = "";
|
||||||
|
let highlight = "";
|
||||||
|
if (greetingContent) {
|
||||||
|
const parts = greetingContent.split(" ");
|
||||||
|
if (parts.length > 1) {
|
||||||
|
highlight = parts.pop();
|
||||||
|
text = parts.join("\n");
|
||||||
|
} else {
|
||||||
|
text = greetingContent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
currentQuote.value = {
|
||||||
|
...currentQuote.value,
|
||||||
|
text,
|
||||||
|
highlight,
|
||||||
|
backgroundUrl: backgroundUrl || "",
|
||||||
|
id: greetingId,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Failed to refresh quote:", e);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const useHotItem = (item) => {
|
const useHotItem = (item) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user