feat: 添加修改头像入口、AI订单记录展示 状态
This commit is contained in:
+54
-3
@@ -5,7 +5,7 @@
|
||||
<view class="con" :style="{ paddingTop: paddingTop + 'px' }">
|
||||
<view class="con_top flex-center ju-flex-start">
|
||||
<view class="head_info">
|
||||
<view class="head">
|
||||
<view class="head head-upload-entry" @click="openAvatarCrop">
|
||||
<image v-if="dataInfo?.avatar" :src="dataInfo?.avatar" mode="scaleToFill" />
|
||||
<image v-else :src="`${$url}home/head.png`" mode="scaleToFill" />
|
||||
</view>
|
||||
@@ -120,6 +120,7 @@
|
||||
import { ref, reactive, onMounted, onUnmounted, getCurrentInstance, watch, nextTick, computed } from 'vue';
|
||||
import { onShow } from '@dcloudio/uni-app';
|
||||
import { getWallet } from '@/sheep/api/home/pay';
|
||||
import UserApi from '@/sheep/api/member/user';
|
||||
|
||||
import OrderApi from '@/sheep/api/trade/order';
|
||||
let { proxy } = getCurrentInstance();
|
||||
@@ -279,6 +280,52 @@
|
||||
});
|
||||
}
|
||||
};
|
||||
const updateAvatar = async (avatar) => {
|
||||
if (!avatar) return;
|
||||
const res = await UserApi.updateUser({
|
||||
...dataInfo.value,
|
||||
avatar,
|
||||
});
|
||||
if (res.code !== 0) {
|
||||
uni.showToast({
|
||||
title: '头像更新失败',
|
||||
icon: 'none',
|
||||
});
|
||||
return;
|
||||
}
|
||||
dataInfo.value.avatar = avatar;
|
||||
getData();
|
||||
};
|
||||
const openAvatarCrop = () => {
|
||||
uni.chooseImage({
|
||||
count: 1,
|
||||
sizeType: ['original', 'compressed'],
|
||||
success: (res) => {
|
||||
const filePath = res?.tempFilePaths?.[0] || '';
|
||||
const size = res?.tempFiles?.[0]?.size;
|
||||
if (typeof size === 'number' && size > 1048576) {
|
||||
uni.showToast({
|
||||
title: '上传图片大小不能超过1MB',
|
||||
icon: 'none',
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!filePath) return;
|
||||
uni.navigateTo({
|
||||
url: `/pages/public/avatarCrop?src=${encodeURIComponent(filePath)}`,
|
||||
success: (navRes) => {
|
||||
const eventChannel = navRes?.eventChannel;
|
||||
if (!eventChannel) return;
|
||||
eventChannel.on('success', ({ url }) => {
|
||||
if (!url) return;
|
||||
updateAvatar(url);
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
fail: () => {},
|
||||
});
|
||||
};
|
||||
const getData = () => {
|
||||
sheep
|
||||
.$store('user')
|
||||
@@ -310,8 +357,7 @@
|
||||
});
|
||||
};
|
||||
onShow(async () => {
|
||||
let res = await getData();
|
||||
|
||||
getData();
|
||||
getNumData();
|
||||
});
|
||||
</script>
|
||||
@@ -358,6 +404,7 @@
|
||||
height: 130rpx;
|
||||
border-radius: 50%;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
|
||||
image {
|
||||
width: 100%;
|
||||
@@ -365,6 +412,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
.head-upload-entry {
|
||||
box-shadow: 0 10rpx 24rpx rgba(0, 0, 0, 0.12);
|
||||
}
|
||||
|
||||
.con_info {
|
||||
margin-left: 24rpx;
|
||||
display: flex;
|
||||
|
||||
Reference in New Issue
Block a user