瀏覽代碼

优化商品详情页

lishanshan 8 月之前
父節點
當前提交
e74748e07e
共有 1 個文件被更改,包括 36 次插入3 次删除
  1. 36 3
      pages/product/details.vue

+ 36 - 3
pages/product/details.vue

@@ -58,10 +58,14 @@
 						</view>
 					</view>
 					<view class="item" v-if="form.richText">
-						<rich-text :nodes="form.richText"></rich-text>
+						<!-- 使用Editor组件代替rich-text -->
+						<Editor :readOnly="true" :toolbarConfig="toolbarConfig" @init="onEditorInit" />
 					</view>
+					<!-- <view class="item" v-if="form.richText">
+						<rich-text :nodes="form.richText"></rich-text>
+					</view> -->
 				</view>
-				<view class="data" style="border:none">
+				<view class="data">
 					<span class="span">搜索关键字</span>{{ form.searchKeywords }}
 				</view>
 				<!-- <view class="data" v-if="form.categoryId != '1945013773786701826'">
@@ -181,7 +185,12 @@
 </template>
 
 <script>
+import Editor from '@/uni_modules/sp-editor/components/sp-editor/sp-editor.vue';
+
 export default {
+	components: {
+		Editor
+	},
 	data() {
 		return {
 			form: {},
@@ -192,7 +201,14 @@ export default {
 			productId: '',
 			imageHttp: 'http://192.168.0.36:8080/jeecg-boot/',
 			specItems: [],
-			fmImageList: []
+			fmImageList: [],
+			// 编辑器配置
+			toolbarConfig: {
+				keys: [], // 只读模式下不显示工具栏
+				excludeKeys: []
+			},
+			editorCtx: null, // 编辑器上下文
+			editorId: null   // 编辑器ID
 		}
 	},
 	methods: {
@@ -202,6 +218,19 @@ export default {
 				delta: 1
 			});
 		},
+		// 编辑器初始化完成时触发
+		onEditorInit(editorCtx, editorId) {
+			this.editorCtx = editorCtx // 保存编辑器上下文
+			this.editorId = editorId   // 保存编辑器ID
+			console.log('编辑器初始化完成')
+
+			// 初始化编辑器内容
+			if (this.form.richText) {
+				this.editorCtx.setContents({
+					html: this.form.richText
+				})
+			}
+		}
 	},
 	onLoad(options) {
 		this.productId = options.productId
@@ -541,4 +570,8 @@ export default {
 	width: 200upx;
 	height: 200upx;
 }
+
+::v-deep .editor-container {
+	height: 260rpx;
+}
 </style>