diff --git a/src/views/home/components/Info keep.vue b/src/views/home/components/Info keep.vue new file mode 100644 index 0000000..d0c638b --- /dev/null +++ b/src/views/home/components/Info keep.vue @@ -0,0 +1,287 @@ + + + diff --git a/src/views/home/components/Info.vue b/src/views/home/components/Info.vue index ca1866a..05f4894 100644 --- a/src/views/home/components/Info.vue +++ b/src/views/home/components/Info.vue @@ -1,52 +1,20 @@ diff --git a/src/views/home/components/Status.vue b/src/views/home/components/Status.vue index 863458d..db53eda 100644 --- a/src/views/home/components/Status.vue +++ b/src/views/home/components/Status.vue @@ -3,17 +3,15 @@ import add from '@/assets/images/add.png' // import { Plus } from '@element-plus/icons-vue' import tool from '@/utils/oss.js' import { userChangeService } from '@/api/user/user.js' -const dialogFormVisible = ref(false) -import { ref } from 'vue' +import { ref, defineEmits } from 'vue' +import { ElMessage } from 'element-plus' const props = defineProps({ data: { type: Object, }, }) -// const data = ref(props.data, 'dsfd') const imageUrl = ref('') -//盒子隐藏 -const form = ref() +const dialogFormVisible = ref(false) //表单校验 // const rules = { // username: [ @@ -37,7 +35,13 @@ const form = ref() // ], // code: [{ message: '验证码不能为空', trigger: 'blur' }], // } -form.value = props.data +const form = ref() +// { +// username: '', +// nickName: '', +// phone: '', +// } +form.value = { ...props.data } const formLabelWidth = '70px' //设置头像显示 imageUrl.value = props.data.icon @@ -48,7 +52,11 @@ const upload = async (option) => { imageUrl.value = url changeInfo() } +const openInfo = () => { + dialogFormVisible.value = true +} //修改用户信息 +const emit = defineEmits(['get-message']) const changeInfo = async () => { const userInfo = { phone: form.value.phone, @@ -57,8 +65,18 @@ const changeInfo = async () => { icon: imageUrl.value, } const jsonData = JSON.stringify(userInfo) - await userChangeService(jsonData) + await userChangeService(jsonData).then(() => { + ElMessage.success('修改成功') + console.log(form.value.nickName, 'nickN') + emit('get-message', form.value.nickName) + }) + dialogFormVisible.value = false +} +const cancleInfo = () => { dialogFormVisible.value = false + form.value = { + ...props.data, + } }