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",
|
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>
|
<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();
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user