fix: avatar view

This commit is contained in:
zzc
2026-01-28 16:41:05 +08:00
parent 227a5b035e
commit 3bd65b0ae1
3 changed files with 27 additions and 23 deletions

View File

@@ -65,7 +65,7 @@
<view class="section-header">
<view class="left">
<view class="bar"></view>
<text class="title">热门新春头像</text>
<text class="title">热门新春头像</text>
</view>
<text class="more" @tap="goToMake">查看全部</text>
</view>
@@ -77,9 +77,15 @@
@tap="goToMake"
>
<view class="frame-img-box">
<image :src="item.url" class="frame-img" mode="aspectFit" />
<image :src="item.imageUrl" class="frame-img" mode="aspectFit" />
</view>
<text class="frame-name">{{ item.name || "新春相框" }}</text>
<text class="frame-name">{{
item.type === "decor"
? "新春饰品"
: item.type === "avatar"
? "新春头像"
: "新春相框"
}}</text>
</view>
</view>
</view>
@@ -133,8 +139,9 @@
import { ref, onMounted } from "vue";
import { onLoad } from "@dcloudio/uni-app";
import { getBavBarHeight } from "@/utils/system";
import { getAvatarFrameList } from "@/api/avatar.js";
import { getPageDetail } from "@/api/system.js";
import { getAvatarRecommendList } from "@/api/avatar.js";
import { saveViewRequest } from "@/utils/common.js";
const defaultAvatar =
"https://file.lihailezzc.com/resource/d9b329082b32f8305101f708593a4882.png";
@@ -173,6 +180,7 @@ const fetchDetail = async () => {
try {
// uni.showLoading({ title: "加载中..." });
const res = await getPageDetail(shareToken.value);
saveViewRequest(shareToken.value, "avatar_download", res.id);
if (res) {
detailData.value = res;
}
@@ -186,11 +194,8 @@ const fetchDetail = async () => {
const fetchFrames = async () => {
try {
const res = await getAvatarFrameList(1);
if (res) {
const list = Array.isArray(res) ? res : res.list || [];
frameList.value = list.slice(0, 3); // Take first 3
}
const res = await getAvatarRecommendList();
frameList.value = res;
} catch (e) {
console.error(e);
}

View File

@@ -275,7 +275,7 @@ const initSystemAvatars = async () => {
.slice(0, 3)
.map((item) => ({ id: item.id, imageUrl: item.imageUrl }));
// 默认选中第一个
if (systemAvatars.value.length > 0) {
if (systemAvatars.value.length > 0 && !currentAvatar.value) {
currentAvatar.value = systemAvatars.value[0];
}
}
@@ -299,19 +299,11 @@ onLoad((options) => {
if (options.type === "frame") {
activeTab.value = "frame";
selectedFrame.value = recommendItem;
// 如果 frames 列表中有这个 id更新引用以保持选中状态可选但推荐
const found = frames.value.find((f) => f.id === recommendItem.id);
if (found) selectedFrame.value = found;
} else if (options.type === "decor") {
activeTab.value = "decor";
selectedDecor.value = recommendItem;
const found = decors.value.find((d) => d.id === recommendItem.id);
if (found) selectedDecor.value = found;
} else if (options.type === "avatar") {
currentAvatar.value = recommendItem;
// 检查系统头像列表
const found = systemAvatars.value.find((a) => a.id === recommendItem.id);
if (found) currentAvatar.value = found;
}
}
});
@@ -679,11 +671,11 @@ onShareAppMessage(async () => {
};
}
const id = createAvatarId();
// const shareTokenRes = {
// shareToken: "iFmK8WjRm6TK",
// };
const shareTokenRes = await getShareToken("avatar_download", id);
completeCardInfo(id);
const shareTokenRes = {
shareToken: "iFmK8WjRm6TK",
};
// const shareTokenRes = await getShareToken("avatar_download", id);
// completeCardInfo(id);
return {
title: "制作我的新春头像",
path: `/pages/avatar/detail?shareToken=${shareTokenRes.shareToken}`,