step-profile.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <div class="sign-new-profile" id="profile">
  3. <header class="sign-new-header">
  4. <div class="sign-new-header-title">个人介绍</div>
  5. <div v-if="editing" class="opts">
  6. <el-button
  7. class="sign-new-profile-btn"
  8. type="info"
  9. @click="editing = false"
  10. >取消</el-button
  11. >
  12. <el-button class="sign-new-profile-btn" type="primary" @click="onSubmit"
  13. >保存</el-button
  14. >
  15. </div>
  16. <div v-else class="opts">
  17. <el-button
  18. class="sign-new-profile-btn"
  19. type="primary"
  20. @click="handleEdit"
  21. >编辑</el-button
  22. >
  23. </div>
  24. </header>
  25. <div class="sign-new-profile-main">
  26. <div v-if="!content && !editing" class="empty">
  27. 点击右上角“编辑”按钮添加个人介绍
  28. </div>
  29. <div v-else-if="editing" class="edit">
  30. <editor
  31. :hideImage="true"
  32. :content="content"
  33. @change="handleChange"
  34. :placeholder="placeholder"
  35. ></editor>
  36. </div>
  37. <!-- <div v-else class="show" v-html="content"></div> -->
  38. <div v-else class="show ql-snow ql-editor" v-html="content"></div>
  39. </div>
  40. </div>
  41. </template>
  42. <script>
  43. import { mapState } from "vuex";
  44. import editor from "@/components/editor";
  45. export default {
  46. data() {
  47. return {
  48. editing: false,
  49. content: "",
  50. placeholder:
  51. "我是程序员客栈的【昵称】,一名【二级方向】;\n我毕业于【大学名称】,担任过【公司1】的【职位】,担任过【公司2】的【职位】;\n负责过【项目1名称】,【项目2名称】,【项目3名称】的开发;\n熟练使用【技术栈1】,【技术栈2】,【技术栈3】,【技术栈4】,【技术栈5】;\n如果我能帮上您的忙,请点击“立即预约”或“发布需求”!"
  52. };
  53. },
  54. components: { editor },
  55. watch: {
  56. // content: function(val) {
  57. // console.log(val);
  58. // }
  59. },
  60. computed: {
  61. ...mapState(["userinfo"])
  62. },
  63. async mounted() {
  64. let res = await this.$axios.$post("/api/user/get_resume");
  65. this.content = res.data ? res.data.personaldetails : "";
  66. },
  67. methods: {
  68. handleEdit() {
  69. if (this.userinfo && this.userinfo.realname_verify_status === "0") {
  70. this.$message.error("请先进行实名认证");
  71. return;
  72. }
  73. this.editing = true;
  74. },
  75. handleChange(val) {
  76. this.content = val;
  77. },
  78. async onSubmit() {
  79. this.cnzz("签约", "签约页面+个人介绍保存", "");
  80. if (!this.content) {
  81. this.$message.error("请输入个人介绍");
  82. return false;
  83. }
  84. if (this.content.length < 150) {
  85. this.$message.error("个人介绍不得低于150字");
  86. return false;
  87. }
  88. if (!this.content.length > 3000) {
  89. this.$message.error("个人介绍不得 超过3000字");
  90. return false;
  91. }
  92. const formData = {
  93. personaldetails: this.content
  94. };
  95. let res = await this.$axios.$post("/api/user/update_resume", formData);
  96. if (res.status === 1) {
  97. this.$message.success("保存成功!");
  98. this.editing = false;
  99. } else {
  100. this.$message.error(res.info);
  101. }
  102. }
  103. }
  104. };
  105. </script>
  106. <style lang="scss">
  107. .sign-new-profile {
  108. .sign-new-profile-main {
  109. margin-top: 30px;
  110. }
  111. .edit {
  112. padding: 10px;
  113. min-height: 244px;
  114. border-radius: 4px;
  115. border: 1px solid #dcdfe6;
  116. > div {
  117. border: 0 !important;
  118. }
  119. & > .ql-toolbar.ql-snow {
  120. border: 0 !important;
  121. }
  122. }
  123. .show {
  124. padding: 20px 0;
  125. * {
  126. word-break: break-all;
  127. }
  128. }
  129. .empty {
  130. margin: 112px auto 104px;
  131. font-size: 27px;
  132. font-family: PingFangSC-Regular;
  133. font-weight: 400;
  134. text-align: center;
  135. color: rgba(205, 205, 205, 1);
  136. line-height: 38px;
  137. }
  138. .sign-new-header {
  139. border: none;
  140. }
  141. }
  142. .sign-new-profile-btn {
  143. height: 34px;
  144. padding: 0 20px;
  145. line-height: 34px;
  146. }
  147. </style>