Jelajahi Sumber

商品创建详情页面优化

lishanshan 9 bulan lalu
induk
melakukan
9a45836306
3 mengubah file dengan 34 tambahan dan 12 penghapusan
  1. 31 9
      pages/product/creatProduct.vue
  2. 1 1
      pages/product/details.vue
  3. 2 2
      pages/product/index.vue

+ 31 - 9
pages/product/creatProduct.vue

@@ -502,6 +502,9 @@ export default {
 			toolbarConfig: {
 				excludeKeys: ['header', 'lineHeight', 'letterSpacing', 'marginTop', 'export', 'marginBottom', 'fontFamily', 'indentDec', 'indentInc', 'scriptSub', 'scriptSuper', 'direction', 'video', 'listCheck', 'divider', 'removeFormat'],
 			},
+			editorInitialized: false, // 标记编辑器是否已初始化
+			pendingRichText: '', // 存储待设置的富文本内容
+			editorCtx: null, // 编辑器上下文
 			video: '',
 			tabIndex: '0',
 			mode: 5,
@@ -516,7 +519,7 @@ export default {
 				saleTime: '',
 				virtualSales: '',
 				sellingTimeType: '',
-				serviceDescription: [],
+				serviceDescription: ["期限", "范围‌"],
 				richText: '',
 				// 为"每天"选项添加单独的时间段数组
 				sellingDay: [],
@@ -541,12 +544,12 @@ export default {
 			],
 			optionsDescription: [
 				{
-					text: '说明1',
-					value: '说明1'
+					text: '期限',
+					value: '期限'
 				},
 				{
-					text: '说明2',
-					value: '说明2'
+					text: '范围‌',
+					value: '范围‌'
 				}
 			],
 			fmImageList: [], //封面图回显
@@ -1323,14 +1326,12 @@ export default {
 						this.form.localProductSellingWeeks = this.localProductSellingWeeks
 					}
 					if (!res.data.result.serviceDescription) {
-						this.form.serviceDescription = []
+						this.form.serviceDescription = ["期限", "范围‌"]
 					}
 					// 初始化编辑器内容
 					if (res.data.result.richText) {
 						this.form.richText = res.data.result.richText || ''
-						this.editorCtx.setContents({
-							html: this.form.richText
-						})
+						this.setEditorContent(this.form.richText)
 					}
 					uni.setStorage({
 						key: 'group',
@@ -1365,7 +1366,28 @@ export default {
 		onEditorInit(editorCtx, editorId) {
 			this.editorCtx = editorCtx // 保存编辑器上下文
 			this.editorId = editorId   // 保存编辑器ID
+			this.editorInitialized = true // 标记编辑器已初始化
 			console.log('编辑器初始化完成')
+
+			// 如果有待设置的内容,现在设置它
+			if (this.pendingRichText) {
+				this.setEditorContent(this.pendingRichText)
+				this.pendingRichText = '' // 清空待设置内容
+			}
+		},
+		// 设置编辑器内容
+		setEditorContent(content) {
+			if (!this.editorInitialized || !this.editorCtx) {
+				// 如果编辑器未初始化,存储内容等待初始化完成
+				this.pendingRichText = content
+				return
+			}
+
+			this.$nextTick(() => {
+				this.editorCtx.setContents({
+					html: content
+				})
+			})
 		},
 		// 实时获取富文本内容
 		onEditorInput(e) {

+ 1 - 1
pages/product/details.vue

@@ -309,7 +309,7 @@ export default {
 					this.detailImages = res.data.result.detailImages.split(',')
 				}
 				this.form.groupingName = res.data.result.groupingName || ''
-				this.form.serviceDescription = res.data.result.serviceDescription || []
+				this.form.serviceDescription = res.data.result.serviceDescription || ["期限", "范围‌"]
 				if (!res.data.result.sellingDay) {
 					this.form.sellingDay = []
 				}

+ 2 - 2
pages/product/index.vue

@@ -70,11 +70,11 @@
 						<!-- <view class="repertory">库存:{{ item.stockQuantity }} <span
 								@click.stop="goUser(item)">销量:{{ item.soldQuantity }}</span> </view> -->
 						<view class="price">
-							<span style="font-size: 22rpx;margin: 0px;">¥</span>{{ item.soldPrice }}
+							<span style="font-size: 22rpx;margin: 0px;">¥</span>{{ item.categoryId == 1945013773786701826 ? item.soldPrice : item.price }}
 							<span v-if="item.categoryId == 1945013773786701826">~</span>
 							<span style="font-size: 22rpx;font-size: 30rpx;font-weight: 600;"
 								v-if="item.categoryId == 1945013773786701826">¥{{ item.price }}</span>
-							<span style="color:#999 ;font-size: 22rpx; text-decoration: line-through;" v-else>¥{{ item.price }}</span>
+							<span style="color:#999 ;font-size: 22rpx; text-decoration: line-through;" v-else>¥{{ item.soldPrice }}</span>
 						</view>
 						<image src="/static/product/ticket.png" mode="" class="ticket" v-if="item.isRights == 1"></image>
 					</view>