step-profile.vue 4.4 KB

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