fix: 页面字段/接口调整
This commit is contained in:
@@ -3,12 +3,13 @@ import { Modal, message } from 'ant-design-vue/es';
|
||||
import { FileType } from 'ant-design-vue/es/upload/interface';
|
||||
import { UploadRequestOption } from 'ant-design-vue/es/vc-upload/interface';
|
||||
import { onMounted, reactive, ref, toRaw } from 'vue';
|
||||
import { updateUserProfile, uploadAvatar } from '@/api/profile';
|
||||
import { updateUserProfile } from '@/api/profile';
|
||||
import { regExpEmail, regExpMobile, regExpNick } from '@/utils/regular-utils';
|
||||
import useUserStore from '@/store/modules/user';
|
||||
import useDictStore from '@/store/modules/dict';
|
||||
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
||||
import useI18n from '@/hooks/useI18n';
|
||||
import { uploadFile } from '@/api/tool/file';
|
||||
const { t } = useI18n();
|
||||
const uerStore = useUserStore();
|
||||
const { getDict } = useDictStore();
|
||||
@@ -26,8 +27,9 @@ let stateForm = reactive({
|
||||
form: {
|
||||
nickName: '',
|
||||
email: '',
|
||||
phonenumber: '',
|
||||
sex: '0',
|
||||
phone: '',
|
||||
sex: undefined,
|
||||
avatar: '',
|
||||
},
|
||||
/**表单提交点击状态 */
|
||||
formClick: false,
|
||||
@@ -96,20 +98,37 @@ function fnUpload(up: UploadRequestOption) {
|
||||
content: t('views.account.settings.uploadTip'),
|
||||
onOk() {
|
||||
// 发送请求
|
||||
const hide = message.loading(t('common.loading'), 0);
|
||||
const hide = message.loading('请稍等...', 0);
|
||||
upState.value = true;
|
||||
let formData = new FormData();
|
||||
formData.append('file', up.file);
|
||||
uploadAvatar(formData).then(res => {
|
||||
upState.value = false;
|
||||
hide();
|
||||
if (res.code === RESULT_CODE_SUCCESS) {
|
||||
message.success(t('views.account.settings.uploadOk'), 3);
|
||||
uerStore.setAvatar(res.data);
|
||||
} else {
|
||||
message.error(res.msg, 3);
|
||||
}
|
||||
});
|
||||
formData.append('subPath', 'avatar');
|
||||
uploadFile(formData)
|
||||
.then(res => {
|
||||
if (res.code === RESULT_CODE_SUCCESS) {
|
||||
return res.data.filePath;
|
||||
}
|
||||
return '';
|
||||
})
|
||||
.then(filePath => {
|
||||
if (filePath === '') return undefined;
|
||||
const form = toRaw(stateForm.form);
|
||||
form.avatar = filePath;
|
||||
return updateUserProfile(form);
|
||||
})
|
||||
.then(res => {
|
||||
if (res === undefined) return;
|
||||
if (res.code === RESULT_CODE_SUCCESS) {
|
||||
message.success(t('views.account.settings.uploadOk'), 3);
|
||||
uerStore.setAvatar(res.data);
|
||||
} else {
|
||||
message.error(res.msg, 3);
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
hide();
|
||||
upState.value = false;
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -156,21 +175,21 @@ onMounted(() => {
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item
|
||||
:label="t('views.account.settings.phonenumber')"
|
||||
name="phonenumber"
|
||||
:label="t('views.account.settings.phone')"
|
||||
name="phone"
|
||||
:rules="[
|
||||
{
|
||||
required: false,
|
||||
pattern: regExpMobile,
|
||||
message: t('views.account.settings.phonenumberPleace'),
|
||||
message: t('views.account.settings.phonePleace'),
|
||||
},
|
||||
]"
|
||||
>
|
||||
<IntlTelInput
|
||||
v-model:value="stateForm.form.phonenumber"
|
||||
v-model:value="stateForm.form.phone"
|
||||
allow-clear
|
||||
:maxlength="20"
|
||||
:placeholder="t('views.account.settings.phonenumberPleace')"
|
||||
:placeholder="t('views.account.settings.phonePleace')"
|
||||
></IntlTelInput>
|
||||
</a-form-item>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts" setup>
|
||||
import { Modal, message } from 'ant-design-vue/es';
|
||||
import { reactive } from 'vue';
|
||||
import { updateUserPwd } from '@/api/profile';
|
||||
import { updateUserPassword } from '@/api/profile';
|
||||
import { regExpPasswd } from '@/utils/regular-utils';
|
||||
import useUserStore from '@/store/modules/user';
|
||||
import { useRouter } from 'vue-router';
|
||||
@@ -49,7 +49,7 @@ function fnFinish() {
|
||||
state.formClick = true;
|
||||
// 发送请求
|
||||
const hide = message.loading(t('common.loading'), 0);
|
||||
updateUserPwd(state.form.oldPassword, state.form.confirmPassword)
|
||||
updateUserPassword(state.form.oldPassword, state.form.confirmPassword)
|
||||
.then(res => {
|
||||
if (res.code === RESULT_CODE_SUCCESS) {
|
||||
Modal.success({
|
||||
|
||||
Reference in New Issue
Block a user