diff --git a/src/views/system/user/userInfo/index.vue b/src/views/system/user/userInfo/index.vue
index e73df39..abde766 100644
--- a/src/views/system/user/userInfo/index.vue
+++ b/src/views/system/user/userInfo/index.vue
@@ -79,8 +79,7 @@
@@ -101,8 +101,11 @@
-
- 保存
+
+ 保存
@@ -130,6 +133,7 @@
interface InfoState {
currentCardKey: string;
baseInfoBtnLoading: boolean;
+ uploadAvatarBtnLoading: boolean;
uploadAvatarLoading: boolean;
userInfo: User | any;
imageUrl?: string;
@@ -152,6 +156,7 @@
currentCardKey: 'baseInfo',
baseInfoBtnLoading: false,
uploadAvatarLoading: false,
+ uploadAvatarBtnLoading: false,
userInfo: undefined,
imageUrl: undefined,
tabList: [
@@ -217,31 +222,30 @@
'font-size': '14px'
}));
- const beforeUpload = async (file: File) => {
+ function handleBeforeUpload (file: File) {
const isJpgOrPng = file.type?.includes('image/'),
isLt2M = file.size / 1024 / 1024 < 10;
!isJpgOrPng && createMessage.error('您只能上传 image/* 格式的文件!');
!isLt2M && createMessage.error('图片必须小于 10MB!');
+ return isJpgOrPng && isLt2M;
+ }
- // 开始上传图片
- if (isJpgOrPng && isLt2M) {
- try {
- state.uploadAvatarLoading = true;
- const { data } = await commonUpload({
- file: file,
- name: 'file',
- }, (progressEvent: ProgressEvent) => {
- const complete = ((progressEvent.loaded / progressEvent.total) * 100) | 0;
- if (complete >= 100) state.uploadAvatarLoading = false;
- });
- state.imageUrl = apiUrl + data.url;
- } finally {
- state.uploadAvatarLoading = false;
- }
+ async function handleUploadAvatar(file) {
+ try {
+ state.uploadAvatarLoading = true;
+ const { data } = await commonUpload({
+ file: file.file,
+ name: 'file',
+ }, (progressEvent: ProgressEvent) => {
+ const complete = ((progressEvent.loaded / progressEvent.total) * 100) | 0;
+ if (complete >= 100) state.uploadAvatarLoading = false;
+ });
+ state.imageUrl = apiUrl + data.url;
+ } finally {
+ state.uploadAvatarLoading = false;
}
- return false;
- };
+ }
@@ -284,14 +288,18 @@
margin: 10px 10px 10px 0px;
::v-deep(.avatar-uploader) > .ant-upload {
- width: 128px;
- height: 128px;
+ width: 180px;
+ height: 180px;
}
::v-deep(.ant-upload-select-picture-card .ant-upload-text) {
margin-top: 8px;
color: #666;
}
+
+ ::v-deep(.upload-avatar-form) > .ant-row {
+ margin-bottom: 0px;
+ }
}