Bläddra i källkod

富文本部分修改

DELL 3 år sedan
förälder
incheckning
6bf3cc8caf

+ 4 - 14
src/packageGoods/goods/detail.vue

@@ -29,12 +29,7 @@
 			</view>
 			<view class="detail-goods">产品介绍</view>
 			<view class="detail-description">
-				<!-- #ifndef MP-ALIPAY -->
 				<u-parse :content="description" :selectable="true"></u-parse>
-				<!-- #endif -->
-				<!-- #ifdef MP-ALIPAY -->
-				<rich-text :nodes="description"></rich-text>
-				<!-- #endif -->
 			</view>
 			<view style="detail-merchant" @click="toCompanyData" v-if="info.merchantInfo?true:false">
 				<view class="detail-merchant-warp">
@@ -115,7 +110,6 @@
 	import { formatRichText } from '@/utils/util.js'
 	import ExchangePopop from '../components/exchange-popup/exchange-popup.vue'
 	import PurchasePopup from '../components/purchase-popup/purchase-popup.vue'
-	import parse from 'mini-html-parser2';
 	export default {
 		components: {
 			ExchangePopop,
@@ -174,14 +168,10 @@
 						// #endif
 						
 						// #ifdef MP-ALIPAY
-						parse(formatRichText(res.data.description),(err,nodes) => {
-							if(!err){
-								nodes[0].children.forEach(item => {
-									item.attrs.src = item.attrs.src + '?imageView2/2/w/750'
-								})
-								this.description = nodes
-							}
-						})
+						res.data.description.split(".jpg\"").join(".jpg?imageView2/2/w/750\"")
+						res.data.description.split(".jpeg\"").join(".jpeg?imageView2/2/w/750\"")
+						res.data.description.split(".png\"").join(".png?imageView2/2/w/750\"")
+						this.description = formatRichText(res.data.description);
 						// #endif
 						
 						this.skuListInit = res.data.skuList

+ 13 - 29
src/packageOperate/activity/index.vue

@@ -163,7 +163,7 @@
 			<!-- 图文介绍 -->
 			<view v-if="description" class="wrap-descriptiontwo">
 				<view style="padding: 36rpx 24rpx 36rpx;">图文介绍</view>
-				<view v-html="description">{{description}} </view>
+				<u-parse :content="description" :selectable="true"></u-parse>
 			</view>
 
 		</view>
@@ -226,6 +226,7 @@
 	import env from '../../config/env.js'
 	import $http from '@/utils/request.js'
 	import ActivityHelp from '@/components/activity-help/activity-help.vue'
+	import { formatRichText } from '@/utils/util.js'
 	export default {
 		components: {
 			ActivityHelp
@@ -302,10 +303,20 @@
 						})
 						this.awardsList = awardsList
 						// 处理富文本
+						// #ifndef MP-ALIPAY
 						const description = res.data.description.replaceAll(".jpg\"", ".jpg?imageView2/2/w/750\"")
 							.replaceAll(".jpeg\"", ".jpeg?imageView2/2/w/750\"").replaceAll(".png\"",
 								".png?imageView2/2/w/750\"");
-						this.description = this.formatRichText(description);
+						this.description = formatRichText(description);
+						// #endif
+						
+						// #ifdef MP-ALIPAY
+						res.data.description.split(".jpg\"").join(".jpg?imageView2/2/w/750\"")
+						res.data.description.split(".jpeg\"").join(".jpeg?imageView2/2/w/750\"")
+						res.data.description.split(".png\"").join(".png?imageView2/2/w/750\"")
+						this.description = formatRichText(res.data.description);
+						// #endif
+						
 						let timestamp = parseInt(new Date().getTime())
 						this.activityTime = this.info.endTime - timestamp
 						this.activityTimeTwo = this.info.startTime - timestamp
@@ -362,33 +373,6 @@
 				})
 			},
 
-
-			/**
-			 * 处理富文本里的图片宽度自适应
-			 * 1.去掉img标签里的style、width、height属性
-			 * 2.img标签添加style属性:max-width:100%;height:auto
-			 * 3.修改所有style里的width属性为max-width:100%
-			 * 4.去掉<br/>标签
-			 * @param html
-			 * @returns {void|string|*}
-			 */
-			formatRichText(html) { //控制小程序中图片大小
-				let newContent = html.replace(/<img[^>]*>/gi, function(match, capture) {
-					match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, '');
-					match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, '');
-					match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, '');
-					return match;
-				});
-				newContent = newContent.replace(/style="[^"]+"/gi, function(match, capture) {
-					match = match.replace(/width:[^;]+;/gi, 'max-width:100%;').replace(/width:[^;]+;/gi,
-						'max-width:100%;');
-					return match;
-				});
-				newContent = newContent.replace(/<br[^>]*\/>/gi, '');
-				newContent = newContent.replace(/\<img/gi,
-					'<img style="max-width:100%;height:auto;font-size: 0;margin-top: -5px;"');
-				return newContent;
-			},
 			getBaseInfo() {
 				$http.post('/api/v1/mp/user/getLoginUserinfo', {}).then(res => {
 					uni.hideLoading();

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 0
src/packageOther/about/conceal.vue


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 0
src/packageOther/about/protect.vue


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 0
src/packageOther/rule/index.vue


+ 10 - 0
src/packagePrize/goods/detail.vue

@@ -82,10 +82,20 @@
 							this.picUrlArr.push(env.filePublic + item + '?imageView2/2/w/750')
 						})
 						// 处理富文本
+						// #ifndef MP-ALIPAY
 						const description = res.data.description.replaceAll(".jpg\"", ".jpg?imageView2/2/w/750\"")
 							.replaceAll(".jpeg\"", ".jpeg?imageView2/2/w/750\"").replaceAll(".png\"",
 								".png?imageView2/2/w/750\"");
 						this.description = formatRichText(description);
+						// #endif
+						
+						// #ifdef MP-ALIPAY
+						res.data.description.split(".jpg\"").join(".jpg?imageView2/2/w/750\"")
+						res.data.description.split(".jpeg\"").join(".jpeg?imageView2/2/w/750\"")
+						res.data.description.split(".png\"").join(".png?imageView2/2/w/750\"")
+						this.description = formatRichText(res.data.description);
+						// #endif
+						
 					}
 				}).catch(() => {
 					uni.hideLoading();

Vissa filer visades inte eftersom för många filer har ändrats