<template>
  <div class="personal-info">
    <el-form ref="form" label-width="80px">
      <el-form-item label="昵称"> 游客12345 </el-form-item>
      <el-form-item label="邮箱"> 117282299@qq.com </el-form-item>
      <el-form-item label="手机号"> 11728229911 </el-form-item>
      <el-form-item>
        <el-button @click="editInfo">修改个人信息</el-button>
        <el-button @click="editPassword">修改密码</el-button>
      </el-form-item>
    </el-form>
    <el-dialog title="修改个人信息" :visible.sync="dialogFormVisible" width="400px">
      <el-form :model="infoData" v-if="isEditBasicInfo" label-position="right" label-width="80px">
        <el-form-item label="昵称" >
          <el-input v-model="infoData.name" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="邮箱" >
          <el-input v-model="infoData.email" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="手机号" >
          <el-input v-model="infoData.phone" autocomplete="off"></el-input>
        </el-form-item>
      </el-form>
      <el-form :model="pwdData" v-else label-position="right" label-width="80px">
        <el-form-item label="旧密码" >
          <el-input
            v-model="pwdData.oldPwd"
            type="password"
          ></el-input>
        </el-form-item>
        <el-form-item label="新密码" >
          <el-input
            v-model="pwdData.newPwd"
            type="password"
          ></el-input>
        </el-form-item>
        <el-form-item label="重复密码" >
          <el-input
            v-model="pwdData.repeatPwd"
            type="password"
          ></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogFormVisible = false"
          >确 定</el-button
        >
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "Info",
  data() {
    return {
      dialogFormVisible: false,
      infoData: {
        name: "",
        email: "",
        phone: "",
      },
      pwdData: {
        oldPwd: "",
        newPwd: "",
        repeatPwd: "",
      },
      isEditBasicInfo: true,
    };
  },

  methods: {
    editInfo() {
      this.dialogFormVisible = true;
      this.isEditBasicInfo = true;
    },
    editPassword() {
      this.dialogFormVisible = true;
      this.isEditBasicInfo = false;
    },
  },
};
</script>
<style lang="scss" scoped>
.el-input{
    width: 80%;
}
</style>