<template>
	<view>
	<RefreshView ref="mescrollRef" :hasBack="true" text="编辑内容" :useDownScroll="false" :useUpScroll="false"
		useTitleRightBtn="1" titleRightBtnSource="确定" @rightBtn='rightBtnClick'>

		<RichTextEditor ref="rich" placeholder="请输入...." :html="htmlStr" :removeHeight="topBarHeight"
			@insertPic="insert">
		</RichTextEditor>
	</RefreshView>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				topBarHeight: '0px',
				htmlStr: "",
					activityBaseInfo: {
						disclaimer: "",
					}
			};
		},
		onLoad: function(option) {
			// this.activityBaseInfo.introduction = option.introduction;
			console.log("options>>>", option)
			let t = option.disclaimer == "undefined" ?"":option.disclaimer;
			
			this.htmlStr = t
		},
		created() {
			this.topBarHeight = getApp().globalData.totalHeightPx
		},
		mounted() {
		
		},
		methods: {
			insert(e) {
				console.log("11111111》》》》"+e)
				this.Upload({
					url: 'activity/uploadGameImg',
					filePath: e,
					key: "file",
					loading: true
				}).then((res) => {
					this.$refs.rich.insertUrlImage(res.data)
				}, (err) => {
		
				})
			},
			getHtml() {
				return this.$refs.rich.getHtml();
			},
			rightBtnClick() {
				let reg1 = new RegExp('<p>', 'g') //g代表全部
				let reg2 = new RegExp('</p>', 'g') //g代表全部
				let reg3 = new RegExp('<br>', 'g') //g代表全部
				let reg4 = new RegExp('"', 'g') //g代表全部
				let newMsg = JSON.stringify(this.getHtml()).replace(reg1, '').replace(reg2, '\n').replace(reg3, '').replace(reg4, '');
				 // let articleData = this.getHtml().replace('</p>*$<p>', /\n/g)
				
				console.log(newMsg)
				this.activityBaseInfo.disclaimer = newMsg
				// this.data.activityBaseInfo.introduction = this.getHtml()
				this.SetResult(this.activityBaseInfo)
			},
		}

	};
</script>

<style lang="less">
	.bottom {
		display: flex;
		height: 800rpx;
		margin-top: 20rpx;
		margin-left: 30rpx;
		margin-right: 30rpx;
		flex-direction: column;
		border: 1rpx solid #C8C7CC;
		padding: 30rpx 20rpx;
		background: #FDFBFB;
		border-radius: 8rpx;

		.input {
			margin-top: 10rpx;
			white-space: pre-line;
			font-size: 30rpx;
			color: #898989;
			height: 500rpx;
			line-height: 50rpx;

		}
	}

	.btn {
		justify-content: center;
		width: 100%;
		margin-top: 100rpx;
		padding: 30rpx;
		font-size: 28rpx;
		color: #FFFFFF;
		background: #007AFF;
		text-align: center;
		flex: 1;
		position: absolute;
		bottom: 0;
	}
</style>
