From 9b958bdb3ce92fac87a48de9624f947a01dff808 Mon Sep 17 00:00:00 2001 From: zzc <1761997216@qq.com> Date: Sun, 25 Jan 2026 23:00:05 +0800 Subject: [PATCH] fix: avatar chose --- pages/avatar/index.vue | 159 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 159 insertions(+) diff --git a/pages/avatar/index.vue b/pages/avatar/index.vue index ce5b496..09376d0 100644 --- a/pages/avatar/index.vue +++ b/pages/avatar/index.vue @@ -40,6 +40,10 @@ 选择底图 + + 查看更多 + + @@ -110,6 +114,36 @@ + + + + + + 选择头像 + + + + + + + + + 加载中... + + 没有更多了 + + + + @@ -151,6 +185,58 @@ const selectedFrame = ref(""); const selectedDecor = ref(""); const activeTab = ref("frame"); +// More Popup logic +const morePopup = ref(null); +const moreAvatars = ref([]); +const page = ref(1); +const hasMore = ref(true); +const loading = ref(false); + +const openMorePopup = () => { + morePopup.value.open(); + if (moreAvatars.value.length === 0) { + loadMoreAvatars(); + } +}; + +const closeMorePopup = () => { + morePopup.value.close(); +}; + +const loadMoreAvatars = async () => { + if (loading.value || !hasMore.value) return; + loading.value = true; + try { + const res = await getAvatarSystemList(page.value); + const list = res?.list || []; + + if (list.length > 0) { + const newAvatars = list.map((item) => item.imageUrl); + moreAvatars.value.push(...newAvatars); + page.value++; + } + + // 根据接口返回的 hasNext 字段判断是否还有更多数据 + // 如果接口没有返回 hasNext,则降级使用列表长度判断(假设每页10条) + if (typeof res.hasNext !== "undefined") { + hasMore.value = res.hasNext; + } else { + if (list.length < 10) { + hasMore.value = false; + } + } + } catch (e) { + console.error(e); + } finally { + loading.value = false; + } +}; + +const selectMoreAvatar = (url) => { + currentAvatar.value = url; + closeMorePopup(); +}; + const toggleFrame = (frame) => { if (selectedFrame.value === frame) { selectedFrame.value = ""; @@ -598,4 +684,77 @@ const loadImage = (url) => { left: -9999px; top: -9999px; } + +/* More Popup Styles */ +.more-btn { + margin-left: auto; + font-size: 24rpx; + color: #999; + display: flex; + align-items: center; +} +.arrow { + font-size: 32rpx; + margin-left: 4rpx; + line-height: 1; + position: relative; + top: -2rpx; +} + +.popup-content { + background: #fff; + border-radius: 24rpx 24rpx 0 0; + height: 60vh; + display: flex; + flex-direction: column; + overflow: hidden; +} +.popup-header { + padding: 32rpx; + display: flex; + align-items: center; + justify-content: center; + position: relative; + border-bottom: 2rpx solid #f5f5f5; +} +.popup-title { + font-size: 32rpx; + font-weight: 600; +} +.close-btn { + position: absolute; + right: 32rpx; + top: 50%; + transform: translateY(-50%); + font-size: 32rpx; + color: #999; + padding: 10rpx; +} +.popup-scroll { + flex: 1; + height: 0; +} +.popup-grid { + display: grid; + grid-template-columns: repeat(3, 1fr); + gap: 20rpx; + padding: 24rpx; +} +.popup-item { + aspect-ratio: 1; + border-radius: 16rpx; + overflow: hidden; + background: #f5f5f5; +} +.popup-img { + width: 100%; + height: 100%; +} +.loading-text, +.no-more-text { + text-align: center; + padding: 24rpx; + color: #999; + font-size: 24rpx; +}