fix: avatar chose
This commit is contained in:
@@ -149,7 +149,7 @@
|
||||
|
||||
<script setup>
|
||||
import { ref, computed } from "vue";
|
||||
import { onShareAppMessage } from "@dcloudio/uni-app";
|
||||
import { onShareAppMessage, onLoad } from "@dcloudio/uni-app";
|
||||
import { getBavBarHeight, getDeviceInfo } from "@/utils/system";
|
||||
import { useUserStore } from "@/stores/user";
|
||||
import {
|
||||
@@ -164,11 +164,7 @@ const loginPopupRef = ref(null);
|
||||
|
||||
const isLoggedIn = computed(() => !!userStore.userInfo.nickName);
|
||||
|
||||
const systemAvatars = [
|
||||
"https://file.lihailezzc.com/20260109082842_666_1.jpg",
|
||||
"https://file.lihailezzc.com/20260108222141_644_1.jpg",
|
||||
"https://file.lihailezzc.com/9a929a32-439f-453b-b603-fda7b04cbe08.png",
|
||||
];
|
||||
const systemAvatars = ref([]);
|
||||
const frames = [
|
||||
"https://file.lihailezzc.com/6.png",
|
||||
"https://file.lihailezzc.com/7.png",
|
||||
@@ -180,7 +176,7 @@ const decors = [
|
||||
"https://file.lihailezzc.com/7.png",
|
||||
];
|
||||
|
||||
const currentAvatar = ref(systemAvatars[0]);
|
||||
const currentAvatar = ref("");
|
||||
const selectedFrame = ref("");
|
||||
const selectedDecor = ref("");
|
||||
const activeTab = ref("frame");
|
||||
@@ -192,9 +188,36 @@ const page = ref(1);
|
||||
const hasMore = ref(true);
|
||||
const loading = ref(false);
|
||||
|
||||
const initSystemAvatars = async () => {
|
||||
try {
|
||||
const res = await getAvatarSystemList(1);
|
||||
const list = res?.list || [];
|
||||
if (list.length > 0) {
|
||||
// 取前3个展示在首页
|
||||
systemAvatars.value = list
|
||||
.slice(0, 3)
|
||||
.map((item) => item.imageUrl);
|
||||
// 默认选中第一个
|
||||
if (systemAvatars.value.length > 0) {
|
||||
currentAvatar.value = systemAvatars.value[0];
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Failed to load system avatars:", e);
|
||||
}
|
||||
};
|
||||
|
||||
onLoad(() => {
|
||||
initSystemAvatars();
|
||||
});
|
||||
|
||||
const openMorePopup = () => {
|
||||
morePopup.value.open();
|
||||
if (moreAvatars.value.length === 0) {
|
||||
// 重新加载第一页,因为 systemAvatars 只取了前3个,
|
||||
// 这里我们简单处理:重新请求第一页作为更多列表的开始
|
||||
// 或者你可以复用 systemAvatars 的数据,然后 page 从 2 开始请求
|
||||
// 为了逻辑简单和数据一致性,这里选择重新请求第一页填充更多列表
|
||||
loadMoreAvatars();
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user