profile.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <div class="profile" id="profile">
  3. <header>
  4. <h5>个人介绍</h5>
  5. <div v-if="editing" class="opts">
  6. <el-button type="info" @click="editing = false">取消</el-button>
  7. <el-button type="primary" @click="onSubmit">保存</el-button>
  8. </div>
  9. <div v-else class="opts">
  10. <el-button type="primary" @click="handleEdit">编辑</el-button>
  11. </div>
  12. </header>
  13. <div v-if="!content&&!editing" class="empty">点击右上角“编辑”按钮添加个人介绍</div>
  14. <div v-else-if="editing" class="edit">
  15. <editor :hideImage="true" :content="content" @change="handleChange"></editor>
  16. </div>
  17. <!-- <div v-else class="show" v-html="content"></div> -->
  18. <div v-else class="show ql-snow ql-editor" v-html="content"></div>
  19. </div>
  20. </template>
  21. <script>
  22. import { mapState } from "vuex";
  23. import editor from "@/components/editor";
  24. export default {
  25. data() {
  26. return {
  27. editing: false,
  28. content: ""
  29. };
  30. },
  31. components: { editor },
  32. watch: {
  33. // content: function(val) {
  34. // console.log(val);
  35. // }
  36. },
  37. computed: {
  38. ...mapState(["userinfo"])
  39. },
  40. async mounted() {
  41. let res = await this.$axios.$post("/api/user/get_resume");
  42. this.content = res.data ? res.data.personaldetails : "";
  43. },
  44. methods: {
  45. handleEdit() {
  46. if (this.userinfo && this.userinfo.realname_verify_status === "0") {
  47. this.$message.error("请先进行实名认证");
  48. return;
  49. }
  50. this.editing = true;
  51. },
  52. handleChange(val) {
  53. this.content = val;
  54. },
  55. async onSubmit() {
  56. this.cnzz("签约","签约页面+个人介绍保存","");
  57. if (!this.content) {
  58. this.$message.error("请输入个人介绍");
  59. return false;
  60. }
  61. if (this.content.length < 150) {
  62. this.$message.error("个人介绍不得低于150字");
  63. return false;
  64. }
  65. if (!this.content.length > 3000) {
  66. this.$message.error("个人介绍不得 超过3000字");
  67. return false;
  68. }
  69. const formData = {
  70. personaldetails: this.content
  71. };
  72. let res = await this.$axios.$post("/api/user/update_resume", formData);
  73. if (res.status === 1) {
  74. this.$message.success("保存成功!");
  75. this.editing = false;
  76. } else {
  77. this.$message.error(res.info);
  78. }
  79. }
  80. }
  81. };
  82. </script>
  83. <style lang="scss">
  84. .profile {
  85. .edit {
  86. padding: 0 20px;
  87. width: 1000px;
  88. min-height: 244px;
  89. > div {
  90. border: 0 !important;
  91. }
  92. & > .ql-toolbar.ql-snow {
  93. border: 0 !important;
  94. }
  95. }
  96. .show {
  97. padding: 20px;
  98. * {
  99. word-break: break-all;
  100. }
  101. }
  102. .empty {
  103. margin: 112px auto 104px;
  104. font-size: 27px;
  105. font-family: PingFangSC-Regular;
  106. font-weight: 400;
  107. text-align: center;
  108. color: rgba(205, 205, 205, 1);
  109. line-height: 38px;
  110. }
  111. }
  112. </style>