info.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <div class="page-my-info">
  3. <div class="title">基本信息</div>
  4. <el-form size="small" label-width="100px" :model="form" :disabled="saving">
  5. <el-form-item label="头像">
  6. <cl-upload v-model="form.headImg"></cl-upload>
  7. </el-form-item>
  8. <el-form-item label="昵称">
  9. <el-input v-model="form.nickName" placeholder="请填写昵称"></el-input>
  10. </el-form-item>
  11. <el-form-item label="密码">
  12. <el-input type="password" v-model="form.password"></el-input>
  13. </el-form-item>
  14. <el-form-item label="">
  15. <el-button type="primary" @click="save" :disabled="saving">保存修改</el-button>
  16. </el-form-item>
  17. </el-form>
  18. </div>
  19. </template>
  20. <script>
  21. import { mapGetters } from "vuex";
  22. export default {
  23. data() {
  24. return {
  25. form: {},
  26. saving: false
  27. };
  28. },
  29. computed: {
  30. ...mapGetters(["userInfo"])
  31. },
  32. mounted() {
  33. this.form = this.userInfo;
  34. },
  35. methods: {
  36. save() {
  37. this.saving = true;
  38. const { headImg, nickName, password } = this.form;
  39. this.$service.common
  40. .userUpdate({
  41. headImg,
  42. nickName,
  43. password
  44. })
  45. .then(() => {
  46. this.form.password = "";
  47. this.$message.success("修改成功");
  48. this.$store.dispatch("userInfo");
  49. })
  50. .catch((err) => {
  51. this.$message.error(err);
  52. })
  53. .done(() => {
  54. this.saving = false;
  55. });
  56. }
  57. }
  58. };
  59. </script>
  60. <style lang="scss">
  61. .page-my-info {
  62. background-color: #fff;
  63. height: 100%;
  64. padding: 20px;
  65. box-sizing: border-box;
  66. .el-form {
  67. width: 400px;
  68. max-width: 100%;
  69. }
  70. .title {
  71. color: #000;
  72. margin-bottom: 30px;
  73. font-size: 15px;
  74. }
  75. }
  76. </style>