diff --git a/jiuyi2/common/js/config.js b/jiuyi2/common/js/config.js index 6522293b..d9448b2f 100644 --- a/jiuyi2/common/js/config.js +++ b/jiuyi2/common/js/config.js @@ -7,7 +7,6 @@ const config = { // #endif // #ifndef H5 host: 'http://91f.xyz:8080', - host: 'https://b433d23.r24.cpolar.top/', // #endif // 支付方式配置 payType: { diff --git a/jiuyi2/common/js/util.js b/jiuyi2/common/js/util.js index ff57358a..76099e25 100644 --- a/jiuyi2/common/js/util.js +++ b/jiuyi2/common/js/util.js @@ -260,11 +260,11 @@ const util = { }) }, - // 替换图片的宽度为最大宽度100% (移动端解析html富文本专用) - imgReplace(value, th) { - if (!th) { - value = value.replace(//ig, '

') .replace(/ { - // 初始化 + // 创建编辑器上下文对象 onEditorReady() }) - // 初始化 + // 创建编辑器上下文对象 function onEditorReady() { uni.createSelectorQuery().select('#editor').context((res) => { editorCtx.value = res.context }).exec() } + // 初始化编辑器上下文对象 + function init(html) { + editorCtx.value.setContents({ + html, + }) + } + + // 获取内容 + function getEditorContents() { + editorCtx.value.getContents({ + success: rs => { + return rs + } + }) + } + // 撤销 function undo() { editorCtx.value.undo() @@ -65,7 +85,7 @@ } = event.target.dataset if (!name) return editorCtx.value.format(name, value) - } + } /** * 编辑器状态被变化 @@ -158,6 +178,16 @@ } }) } + + // 富文本编辑 + function handleEditorInput(event) { + emit('update:modelValue', event.detail.html) + } + + defineExpose({ + init, + getEditorContents, + })