diff --git a/src/pages/work/heartJourney/addEdit.vue b/src/pages/work/heartJourney/addEdit.vue index 870ecc1..adddc03 100644 --- a/src/pages/work/heartJourney/addEdit.vue +++ b/src/pages/work/heartJourney/addEdit.vue @@ -37,18 +37,9 @@ U - - H1 - - - H2 - - - 1. - - - + + @@ -66,9 +57,9 @@ @input="onEditorInput" @focus="editorFocus" @blur="editorBlur" - :show-img-size="false" - :show-img-toolbar="false" - :show-img-resize="false" + :show-img-size="true" + :show-img-toolbar="true" + :show-img-resize="true" > {{ contentLength }}/20000 @@ -194,6 +185,88 @@ onLoad((option) => { if (!editorCtx.value) return editorCtx.value.redo() } + + // 插入图片 + function insertImage() { + uni.chooseImage({ + count: 1, + sizeType: ['compressed'], + sourceType: ['album', 'camera'], + success: (res) => { + const tempFilePath = res.tempFilePaths[0] + + // 显示加载提示 + uni.showLoading({ + title: '上传中...' + }) + + // 上传图片到服务器 + uni.uploadFile({ + url: proxy.$config.baseUrl + '/common/upload', + filePath: tempFilePath, + name: 'file', + header: { + 'Authorization': 'Bearer ' + uni.getStorageSync('token') + }, + success: (uploadRes) => { + uni.hideLoading() + + try { + const data = JSON.parse(uploadRes.data) + if (data.code === 200) { + // 获取图片URL + const imageUrl = proxy.$config.baseUrl + data.fileName + + // 插入图片到编辑器 + if (editorCtx.value) { + editorCtx.value.insertImage({ + src: imageUrl, + width: '100%', + height: 'auto', + success: () => { + uni.showToast({ + title: '插入成功', + icon: 'success' + }) + }, + fail: (err) => { + console.error('插入图片失败', err) + uni.showToast({ + title: '插入失败', + icon: 'none' + }) + } + }) + } + } else { + uni.showToast({ + title: data.msg || '上传失败', + icon: 'none' + }) + } + } catch (e) { + console.error('解析上传结果失败', e) + uni.showToast({ + title: '上传失败', + icon: 'none' + }) + } + }, + fail: (err) => { + uni.hideLoading() + console.error('上传失败', err) + uni.showToast({ + title: '上传失败', + icon: 'none' + }) + } + }) + }, + fail: (err) => { + console.error('选择图片失败', err) + } + }) + } function getDict() { // 类型 getDicts('journey_type').then(res => { diff --git a/src/pages/work/heartJourney/details.vue b/src/pages/work/heartJourney/details.vue index 77c5d02..602f047 100644 --- a/src/pages/work/heartJourney/details.vue +++ b/src/pages/work/heartJourney/details.vue @@ -195,58 +195,7 @@ onLoad((option) => { padding: 20rpx; background: #f8f9fa; border-radius: 8rpx; - font-size: 26rpx; - color: #2c3e50; - line-height: 1.8; word-break: break-all; - - // 富文本样式 - :deep(p) { - margin: 12rpx 0; - &:first-child { - margin-top: 0; - } - &:last-child { - margin-bottom: 0; - } - } - - :deep(h1) { - font-size: 36rpx; - font-weight: 600; - margin: 20rpx 0 12rpx; - color: #1a1a1a; - } - - :deep(h2) { - font-size: 32rpx; - font-weight: 600; - margin: 16rpx 0 12rpx; - color: #333333; - } - - :deep(strong), :deep(b) { - font-weight: 600; - color: #1a1a1a; - } - - :deep(em), :deep(i) { - font-style: italic; - } - - :deep(u) { - text-decoration: underline; - } - - :deep(ol), :deep(ul) { - margin: 12rpx 0; - padding-left: 40rpx; - } - - :deep(li) { - margin: 8rpx 0; - line-height: 1.8; - } } } } diff --git a/src/pages/work/heartJourney/list.vue b/src/pages/work/heartJourney/list.vue index f3e2fe8..b408a7b 100644 --- a/src/pages/work/heartJourney/list.vue +++ b/src/pages/work/heartJourney/list.vue @@ -547,58 +547,7 @@ page { padding: 16rpx; background: #f8f9fa; border-radius: 8rpx; - font-size: 26rpx; - color: #2c3e50; - line-height: 1.8; word-break: break-all; - - // 富文本样式 - :deep(p) { - margin: 12rpx 0; - &:first-child { - margin-top: 0; - } - &:last-child { - margin-bottom: 0; - } - } - - :deep(h1) { - font-size: 34rpx; - font-weight: 600; - margin: 16rpx 0 12rpx; - color: #1a1a1a; - } - - :deep(h2) { - font-size: 30rpx; - font-weight: 600; - margin: 16rpx 0 10rpx; - color: #333333; - } - - :deep(strong), :deep(b) { - font-weight: 600; - color: #1a1a1a; - } - - :deep(em), :deep(i) { - font-style: italic; - } - - :deep(u) { - text-decoration: underline; - } - - :deep(ol), :deep(ul) { - margin: 12rpx 0; - padding-left: 40rpx; - } - - :deep(li) { - margin: 8rpx 0; - line-height: 1.8; - } } } }