fix: main avatar page
This commit is contained in:
10
api/mine.js
10
api/mine.js
@@ -28,3 +28,13 @@ export const getMyAvatar = async (page = 1) => {
|
||||
method: "GET",
|
||||
});
|
||||
};
|
||||
|
||||
export const userAvatarChange = async (imageUrl) => {
|
||||
return request({
|
||||
url: "/api/blessing/user/avatar/change",
|
||||
method: "POST",
|
||||
data: {
|
||||
imageUrl,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
@@ -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();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user