fix: main avatar page

This commit is contained in:
zzc
2026-01-28 23:40:10 +08:00
parent adb5f00988
commit 17f5b62ef0
2 changed files with 24 additions and 4 deletions

View File

@@ -39,8 +39,8 @@
<text>{{ currentAvatar.decorName || "金马贺岁挂饰" }}</text>
</view>
</view>
<view class="change-btn" @tap="goToMake">
<text>去更换</text>
<view class="change-btn" @tap="changeUserAvatar(currentAvatar.imageUrl)">
<text>替换头像</text>
</view>
</view>
@@ -103,7 +103,7 @@
<script setup>
import { ref, onMounted } from "vue";
import { onPullDownRefresh, onReachBottom } from "@dcloudio/uni-app";
import { getMyAvatar } from "@/api/mine.js";
import { getMyAvatar, userAvatarChange } from "@/api/mine.js";
import { useUserStore } from "@/stores/user";
const userStore = useUserStore();
@@ -152,7 +152,6 @@ const fetchList = async (reset = false) => {
loading.value = true;
try {
const res = await getMyAvatar(page.value);
console.log(111111, res);
const dataList = res?.list || [];
totalCount.value = res?.totalCount || 0;
@@ -180,6 +179,17 @@ const fetchList = async (reset = false) => {
}
};
const changeUserAvatar = async (imageUrl) => {
const res = await userAvatarChange(imageUrl)
if(res.success) {
uni.showToast({
title: "头像更换成功",
icon: "success",
});
}
};
const loadMore = () => {
fetchList();
};