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

@@ -28,3 +28,13 @@ export const getMyAvatar = async (page = 1) => {
method: "GET", method: "GET",
}); });
}; };
export const userAvatarChange = async (imageUrl) => {
return request({
url: "/api/blessing/user/avatar/change",
method: "POST",
data: {
imageUrl,
},
});
};

View File

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