Commit 3143dafabf7a7775ef58be62b86ec09789c88c80

Authored by fengtao
1 parent 620c62bb

pref:优化个人资料上传头像显示加载状态

@@ -42,8 +42,9 @@ @@ -42,8 +42,9 @@
42 alt="avatar" 42 alt="avatar"
43 /> 43 />
44 <div v-else> 44 <div v-else>
45 - <div style="">  
46 - <PlusOutlined style="font-size: 30px" /> 45 + <div>
  46 + <LoadingOutlined style="font-size: 30px" v-if="loading" />
  47 + <PlusOutlined v-else style="font-size: 30px" />
47 </div> 48 </div>
48 </div> 49 </div>
49 </Upload> 50 </Upload>
@@ -92,6 +93,7 @@ @@ -92,6 +93,7 @@
92 import { PlusOutlined } from '@ant-design/icons-vue'; 93 import { PlusOutlined } from '@ant-design/icons-vue';
93 import { useUserStore } from '/@/store/modules/user'; 94 import { useUserStore } from '/@/store/modules/user';
94 import type { FileItem } from '/@/components/Upload/src/typing'; 95 import type { FileItem } from '/@/components/Upload/src/typing';
  96 + import { LoadingOutlined } from '@ant-design/icons-vue';
95 97
96 const schema: DescItem[] = [ 98 const schema: DescItem[] = [
97 { 99 {
@@ -121,9 +123,10 @@ @@ -121,9 +123,10 @@
121 ]; 123 ];
122 export default defineComponent({ 124 export default defineComponent({
123 name: 'Index', 125 name: 'Index',
124 - components: { BasicModal, BasicForm, Description, Upload, PlusOutlined }, 126 + components: { BasicModal, BasicForm, Description, Upload, PlusOutlined, LoadingOutlined },
125 emits: ['refreshPersonl', 'register'], 127 emits: ['refreshPersonl', 'register'],
126 setup(_, { emit }) { 128 setup(_, { emit }) {
  129 + const loading = ref(false);
127 const userInfo = getAuthCache(USER_INFO_KEY); 130 const userInfo = getAuthCache(USER_INFO_KEY);
128 const { createMessage } = useMessage(); 131 const { createMessage } = useMessage();
129 const getPersonalValue: any = ref({}); 132 const getPersonalValue: any = ref({});
@@ -143,11 +146,14 @@ @@ -143,11 +146,14 @@
143 146
144 const customUploadqrcodePic = async ({ file }) => { 147 const customUploadqrcodePic = async ({ file }) => {
145 if (beforeUploadqrcodePic(file)) { 148 if (beforeUploadqrcodePic(file)) {
  149 + peresonalPic.value = '';
  150 + loading.value = true;
146 const formData = new FormData(); 151 const formData = new FormData();
147 formData.append('file', file); 152 formData.append('file', file);
148 const response = await uploadApi(formData); 153 const response = await uploadApi(formData);
149 if (response.fileStaticUri) { 154 if (response.fileStaticUri) {
150 peresonalPic.value = response.fileStaticUri; 155 peresonalPic.value = response.fileStaticUri;
  156 + loading.value = false;
151 } 157 }
152 } 158 }
153 }; 159 };
@@ -240,6 +246,7 @@ @@ -240,6 +246,7 @@
240 schema, 246 schema,
241 registerModal, 247 registerModal,
242 registerForm, 248 registerForm,
  249 + loading,
243 }; 250 };
244 }, 251 },
245 }); 252 });