更改邮箱和手机号码后不能及时刷新

This commit is contained in:
bob
2025-02-27 16:10:01 +08:00
parent a90d6c5a72
commit 56e56a338c
4 changed files with 15 additions and 7 deletions

View File

@@ -5,7 +5,7 @@ import { userModifySelfService } from '@/api/user'
import { ElMessage } from 'element-plus'
defineProps(['modelValue'])
const emit = defineEmits(['update:modelValue'])
const emit = defineEmits(['update:modelValue', 'success'])
const userData = userStore()
@@ -60,6 +60,7 @@ const onComfirm = async () => {
res.then(() => {
ElMessage.success('绑定邮箱修改成功')
emit('update:modelValue', false)
emit('success')
})
res.finally(() => {
isLoading.value = false

View File

@@ -5,7 +5,7 @@ import { userModifySelfService } from '@/api/user'
import { ElMessage } from 'element-plus'
defineProps(['modelValue'])
const emit = defineEmits(['update:modelValue'])
const emit = defineEmits(['update:modelValue', 'success'])
const userData = userStore()
@@ -60,6 +60,7 @@ const onComfirm = async () => {
res.then(() => {
ElMessage.success('绑定手机修改成功')
emit('update:modelValue', false)
emit('success')
})
res.finally(() => {
isLoading.value = false

View File

@@ -15,9 +15,11 @@ const formModel = ref({})
const isLoading = ref(false)
const isShowEditAvatar = ref(false)
onMounted(() => {
formModel.value = cloneDeep(userData.user)
formModel.value.birthday = showTimeFormat(userData.user.birthday)
onMounted(async () => {
userData.updateUser().then(() => {
formModel.value = cloneDeep(userData.user)
formModel.value.birthday = showTimeFormat(userData.user.birthday)
})
})
const onNewAvatar = ({ avatar, avatarThumb }) => {

View File

@@ -26,6 +26,10 @@ const emailDesc = computed(() => {
return '已绑定邮箱:' + userData.user.email
}
})
const onUpdateUser = () => {
userData.updateUser()
}
</script>
<template>
@@ -71,8 +75,8 @@ const emailDesc = computed(() => {
</div>
<EditPassword v-model="isShowEditPassword"></EditPassword>
<EditPhone v-model="isShowEditPhone"></EditPhone>
<EditEmail v-model="isShowEditEmail"></EditEmail>
<EditPhone v-model="isShowEditPhone" @success="onUpdateUser"></EditPhone>
<EditEmail v-model="isShowEditEmail" @success="onUpdateUser"></EditEmail>
</template>
<style lang="scss" scoped>