|
|
@@ -16,7 +16,7 @@
|
|
|
</header> -->
|
|
|
<van-form ref="formRef" @submit="onSubmit" class="mt10" required="auto">
|
|
|
<van-cell-group>
|
|
|
- <van-cell class="flex" is-link size="normal" title="头像" @click="editAvatar">
|
|
|
+ <van-cell class="flex" is-link size="normal" title="头像" @click="editAvatar" required>
|
|
|
<template #value>
|
|
|
<!-- <img class="avatar" width="30" height="30" :src="userInfos.avatar" alt="" /> -->
|
|
|
<van-image width="30px" height="30px" :src="userInfos.avatar" />
|
|
|
@@ -228,6 +228,7 @@ const uploadBaseFunc = (file) => {
|
|
|
if (res) {
|
|
|
if (res.data.Code == 200) {
|
|
|
// 图片上传成功,直接修改
|
|
|
+ state.form.avatar = res?.data.Data || '' // 更新表单中的头像字段
|
|
|
const [err]: ToResponse = await to(userApi.setAvatar({ fileUrl: res?.data.Data || '' }))
|
|
|
if (err) return
|
|
|
showNotify({
|
|
|
@@ -265,6 +266,16 @@ const initForm = async () => {
|
|
|
const onSubmit = async () => {
|
|
|
const [errValid] = await to(formRef.value.validate())
|
|
|
if (errValid) return
|
|
|
+
|
|
|
+ // 验证头像是否存在
|
|
|
+ if (!state.form.avatar && !userInfos.value.avatar) {
|
|
|
+ showNotify({
|
|
|
+ type: 'danger',
|
|
|
+ message: '请上传头像'
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
state.form.userId = state.form.id
|
|
|
const params = JSON.parse(JSON.stringify(state.form))
|
|
|
const [err]: ToResponse = await to(userApi.updateProfile(params))
|
|
|
@@ -337,4 +348,4 @@ onMounted(() => {
|
|
|
width: 500px;
|
|
|
}
|
|
|
}
|
|
|
-</style>
|
|
|
+</style>
|