You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
1.9 KiB
74 lines
1.9 KiB
<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: {
|
|
introduction: "",
|
|
}
|
|
};
|
|
},
|
|
onLoad: function(option) {
|
|
// this.activityBaseInfo.introduction = option.introduction;
|
|
console.log("options>>>", option)
|
|
// let t = JSON.parse(decodeURIComponent(option.introduction));
|
|
// this.htmlStr = t.html
|
|
let t = option.introduction == "undefined" ?"":option.introduction;
|
|
|
|
this.htmlStr = t
|
|
|
|
},
|
|
created() {
|
|
this.topBarHeight = getApp().globalData.totalHeightPx
|
|
},
|
|
mounted() {
|
|
|
|
},
|
|
methods: {
|
|
insert(e) {
|
|
this.chooseUpload(9)
|
|
.then((res) => {
|
|
console.log("url>>>>", res);
|
|
this.$refs.rich.insertUrlImage(res.urls)
|
|
})
|
|
},
|
|
getHtml() {
|
|
return this.$refs.rich.getHtml();
|
|
},
|
|
rightBtnClick() {
|
|
console.log(this.getHtml())
|
|
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.introduction = newMsg
|
|
// this.data.activityBaseInfo.introduction = this.getHtml()
|
|
this.SetResult(this.activityBaseInfo)
|
|
},
|
|
}
|
|
|
|
};
|
|
</script>
|
|
|
|
<style>
|
|
|
|
</style>
|
|
|