<template>
	<view><jinEdit placeholder="请填写" @editBlur="editBlur" @editOk="editOk" :html="content" uploadFileUrl="/#"></jinEdit></view>
</template>

<script>
const req = require('../../utils/request.js');
import jinEdit from '../components/jin-edit/jin-edit.vue';
export default {
	components: {
		jinEdit
	},
	data() {
		return {
			content: ''
		};
	},
	onLoad(options) {
		let pages = getCurrentPages(); //获取所有页面栈实例列表
		let prevPage = pages[pages.length - 2]; //上一页页面实例
		this.content = prevPage.$vm.text;
	},

	onShow() {},

	onUnload: function() {
		// 页面销毁时执行保存
		this.saveContent(this.content, false);
	},

	methods: {
		editBlur(res) {
			this.content = res.detail.html;
			console.log('编辑器的数据>>>>>', this.content);
		},

		saveContent(content, isBack) {
			let pages = getCurrentPages();
			let prevPage = pages[pages.length - 2];
			prevPage.$vm.text = content;
			if (isBack) {
				uni.navigateBack({
					delta: 1
				});
			}
		},

		// 点击发布
		editOk(res) {
			this.saveContent(res.html, true);
		}
	}
};
</script>

<style>
	page{background: #fff;}
</style>
<style>
@import './editorContent.css';
.ql-editor.ql-blank:before {
	/* 此处设置 placeholder 样式 */
	color: #999;
	font-style: normal;
}
</style>
