fix: lucky page
This commit is contained in:
@@ -7,6 +7,20 @@ export const getAvatarSystemList = async (page = 1) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getAvatarSystemCategoryList = async () => {
|
||||||
|
return request({
|
||||||
|
url: `/api/blessing/avatar/system/category/list`,
|
||||||
|
method: "GET",
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getAvatarSystemListByCategory = async (categoryId, page = 1) => {
|
||||||
|
return request({
|
||||||
|
url: `/api/blessing/avatar/system/list?categoryId=${categoryId}&page=${page}`,
|
||||||
|
method: "GET",
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
export const getAvatarDecorList = async (page = 1) => {
|
export const getAvatarDecorList = async (page = 1) => {
|
||||||
return request({
|
return request({
|
||||||
url: `/api/blessing/avatar/decor/list?page=${page}`,
|
url: `/api/blessing/avatar/decor/list?page=${page}`,
|
||||||
|
|||||||
@@ -103,9 +103,8 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed } from "vue";
|
import { ref, computed } from "vue";
|
||||||
import {
|
import {
|
||||||
getAvatarSystemList,
|
getAvatarSystemCategoryList,
|
||||||
getAvatarDecorList,
|
getAvatarSystemListByCategory,
|
||||||
getAvatarFrameList,
|
|
||||||
avatarDownloadRecord,
|
avatarDownloadRecord,
|
||||||
} from "@/api/avatar.js";
|
} from "@/api/avatar.js";
|
||||||
import {
|
import {
|
||||||
@@ -127,12 +126,8 @@ const isLoggedIn = computed(() => !!userStore.userInfo.nickName);
|
|||||||
const userScore = computed(() => userStore.userInfo.score || 0);
|
const userScore = computed(() => userStore.userInfo.score || 0);
|
||||||
const downloadCost = ref(20);
|
const downloadCost = ref(20);
|
||||||
|
|
||||||
const categories = ref([
|
const categories = ref([]);
|
||||||
{ id: "system", name: "系统头像" },
|
const currentCategoryId = ref(null);
|
||||||
{ id: "frame", name: "头像框" },
|
|
||||||
{ id: "decor", name: "挂饰" },
|
|
||||||
]);
|
|
||||||
const currentCategoryId = ref("system");
|
|
||||||
const avatars = ref([]);
|
const avatars = ref([]);
|
||||||
const page = ref(1);
|
const page = ref(1);
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
@@ -198,6 +193,21 @@ const getThumbUrl = (url) => {
|
|||||||
return `${url}?imageView2/1/w/340/h/340/q/80`;
|
return `${url}?imageView2/1/w/340/h/340/q/80`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const fetchCategories = async () => {
|
||||||
|
try {
|
||||||
|
const res = await getAvatarSystemCategoryList();
|
||||||
|
const list = Array.isArray(res) ? res : res?.list || [];
|
||||||
|
if (list.length > 0) {
|
||||||
|
categories.value = list;
|
||||||
|
currentCategoryId.value = list[0].id;
|
||||||
|
loadAvatars(true);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Failed to fetch categories", e);
|
||||||
|
uni.showToast({ title: "获取分类失败", icon: "none" });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const switchCategory = (id) => {
|
const switchCategory = (id) => {
|
||||||
if (currentCategoryId.value === id) return;
|
if (currentCategoryId.value === id) return;
|
||||||
currentCategoryId.value = id;
|
currentCategoryId.value = id;
|
||||||
@@ -211,6 +221,7 @@ const switchCategory = (id) => {
|
|||||||
|
|
||||||
const loadAvatars = async (reset = false) => {
|
const loadAvatars = async (reset = false) => {
|
||||||
if (loading.value) return;
|
if (loading.value) return;
|
||||||
|
if (!currentCategoryId.value) return;
|
||||||
if (reset) {
|
if (reset) {
|
||||||
page.value = 1;
|
page.value = 1;
|
||||||
hasMore.value = true;
|
hasMore.value = true;
|
||||||
@@ -220,12 +231,10 @@ const loadAvatars = async (reset = false) => {
|
|||||||
|
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
let apiFunc;
|
const res = await getAvatarSystemListByCategory(
|
||||||
if (currentCategoryId.value === "system") apiFunc = getAvatarSystemList;
|
currentCategoryId.value,
|
||||||
else if (currentCategoryId.value === "frame") apiFunc = getAvatarFrameList;
|
page.value,
|
||||||
else if (currentCategoryId.value === "decor") apiFunc = getAvatarDecorList;
|
);
|
||||||
|
|
||||||
const res = await apiFunc(page.value);
|
|
||||||
const list = res?.list || [];
|
const list = res?.list || [];
|
||||||
hasMore.value = !!res?.hasNext;
|
hasMore.value = !!res?.hasNext;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user