editDesc.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <template>
  2. <view class="content">
  3. <view><jinEdit :placeholder="isCompanyIntroduction?'输入公司简介内容':'输入个人简介内容'" @editBlur="editBlur" @editOk="editOk" :html="brief" uploadFileUrl="/#"></jinEdit></view>
  4. </view>
  5. </template>
  6. <script>
  7. const app = getApp();
  8. const req = require('../../utils/request.js');
  9. import jinEdit from '../components/jin-edit/jin-edit.vue';
  10. export default {
  11. components: {
  12. jinEdit
  13. },
  14. data() {
  15. return {
  16. id: '',
  17. brief: '',
  18. isReadOnly: true,
  19. isCompanyIntroduction:false
  20. };
  21. },
  22. onLoad(opt) {
  23. this.id = opt.id;
  24. let pages = getCurrentPages();
  25. let prevPage = pages[pages.length - 2];
  26. if(opt.isCompanyIntroduction){
  27. this.isCompanyIntroduction = true
  28. this.brief = prevPage.$vm.companyIntroduction;
  29. }else{
  30. this.brief = prevPage.$vm.brief;
  31. }
  32. },
  33. onUnload: function() {
  34. // 页面销毁时执行保存
  35. this.saveContent(this.brief, false);
  36. },
  37. methods: {
  38. editBlur(res) {
  39. this.brief = res.detail.html;
  40. },
  41. saveContent(content, isBack) {
  42. let pages = getCurrentPages(); //获取所有页面栈实例列表
  43. let prevPage = pages[pages.length - 2]; //上一页页面实例
  44. if(this.isCompanyIntroduction){
  45. prevPage.$vm.companyIntroduction = content;
  46. }else{
  47. prevPage.$vm.brief = content;
  48. }
  49. if (isBack) {
  50. uni.navigateBack({
  51. delta: 1
  52. });
  53. }
  54. },
  55. // 点击发布
  56. editOk(res) {
  57. this.saveContent(res.html, true);
  58. }
  59. }
  60. };
  61. </script>
  62. <style>
  63. @import './editDesc.css';
  64. .ql-editor.ql-blank:before {
  65. /* 此处设置 placeholder 样式 */
  66. color: rgba(204, 204, 204, 1);
  67. font-style: normal;
  68. min-height: 400px;
  69. }
  70. </style>