Quellcode durchsuchen

commit- 项目富文本优化

zhengjinyi vor 2 Jahren
Ursprung
Commit
bc226c7b42

+ 0 - 22
common/css/common.scss

@@ -229,28 +229,6 @@ button::after{
 		padding: 0 10rpx;
 	}
 }
-/*富文本样式调整*/
-.product-rich-text{
-	rich-text.h4,rich-text.p,rich-text.h2{
-		padding: 0 24rpx;
-	}
-}
-.rich-text-temp {
-	rich-text.div, rich-text.h4, rich-text.p {
-		line-height: 58rpx;
-	}
-	rich-text.h4, rich-text.p {
-		font-size: 30rpx;
-	}
-	rich-text.div {
-		margin-bottom: 30rpx;
-		font-size: 28rpx;
-	}
-	rich-text.img {
-		width: 100%;
-		height: auto;
-	}
-}
 .form-item {
 	display: flex;
 	color: $text-color;

+ 20 - 41
components/cm-module/listTemplate/richTextTemplate.vue

@@ -1,50 +1,29 @@
 <template>
-	<view class="content">
-		<mp-html :content="html" :tag-style="tagStyle" />
-		<!-- <parser :html="html" :img-mode="widthFix"></parser> -->
-	</view>
+	<view class="content"> <mp-html :content="html" :tag-style="tagStyle" /> </view>
 </template>
 
 <script>
-	import parser from '@/components/jyf-Parser/index'
-	var self
-	export default{
-		components: {
-		   parser,
-		   // uPars
-		},
-		data() {
-			return{
-				serverUrl: '',
-				type: '',
-				html:'',
-				tagStyle:{
-					div:'line-height: 58rpx;margin-bottom: 10rpx;font-size: 28rpx;',
-					h4:'line-height: 54rpx;font-size: 30rpx;color:#666666;',
-					h3:'line-height: 54rpx;font-size: 30rpx;color:#666666;',
-					h2:'line-height: 54rpx;font-size: 30rpx;color:#666666;',
-					p:'line-height: 50rpx;font-size: 30rpx;color:#666666;',
-					a:'line-height: 50rpx;font-size: 30rpx;color:#666666;',
-					span:'line-height: 50rpx;font-size: 30rpx;color:#666666;',
-					img:'width: 100%;height: auto;'
-				}
-			}
-		},
-		created(){
-			self = this		
-		},
-		methods:{
-
+import { articleTagStyle } from '@/plugins/mp-html/config.js'
+export default {
+	data() {
+		return {
+			serverUrl: '',
+			type: '',
+			html: '',
+			tagStyle: articleTagStyle
 		}
-	}
+	},
+	created() {},
+	methods: {}
+}
 </script>
 
 <style lang="scss">
-	page{
-		background: #FFFFFF;
-		border-top: 1px solid #EBEBEB;
-	}
-	.content {
-		padding: 40rpx 24rpx;
-	}
+page {
+	background: #ffffff;
+	border-top: 1px solid #ebebeb;
+}
+.content {
+	padding: 40rpx 24rpx;
+}
 </style>

+ 0 - 158
components/jyf-Parser/CssHandler.js

@@ -1,158 +0,0 @@
-//CssHandler.js
-// #ifdef MP-WEIXIN
-const CanIUse = require('./api.js').versionHigherThan('2.7.1');
-// #endif
-function CssHandler(style, tagStyle) {
-	this._style = new CssTokenizer(style, tagStyle).parse();
-}
-CssHandler.prototype.match = function(name, attrs) {
-	let matched = this._style[name] ? (this._style[name] + ';') : '';
-	if (attrs.id)
-		matched += (this._style['#' + attrs.id] ? (this._style['#' + attrs.id] + ';') : '');
-	if (attrs.class)
-		for (var Class of attrs.class.split(' '))
-			matched += (this._style['.' + Class] ? (this._style['.' + Class] + ';') : '');
-	return matched;
-}
-
-function CssTokenizer(style = '', tagStyle = {}) {
-	this.res = this.initClass(tagStyle);
-	this._state = "SPACE";
-	this._buffer = style;
-	this._sectionStart = 0;
-	this._index = 0;
-	this._name = '';
-	this._content = '';
-	this._list = [];
-	this._comma = false;
-}
-CssTokenizer.prototype.initClass = function(tagStyle) {
-	let initStyle = JSON.parse(JSON.stringify(tagStyle));
-	initStyle.a = "display:inline;color:#366092;word-break:break-all;" + (initStyle.a || "");
-	initStyle.address = "font-style:italic;" + (initStyle.address || "");
-	initStyle.blockquote = initStyle.blockquote ||
-		'background-color:#f6f6f6;border-left:3px solid #dbdbdb;color:#6c6c6c;padding:5px 0 5px 10px;';
-	initStyle.center = 'text-align:center;' + (initStyle.center || "");
-	initStyle.cite = "font-style:italic;" + (initStyle.cite || "");
-	initStyle.code = initStyle.code ||
-		'padding:0 1px 0 1px;margin-left:2px;margin-right:2px;background-color:#f8f8f8;border:1px solid #cccccc;border-radius:3px;';
-	initStyle.dd = "margin-left:40px;" + (initStyle.dd || "");
-	initStyle.img = "max-width:100%;" + (initStyle.img || "");
-	initStyle.mark = "display:inline;background-color:yellow;" + (initStyle.mark || "");
-	initStyle.pre = "overflow:scroll;" + (initStyle.pre || 'background-color:#f6f8fa;padding:5px;border-radius:5px;');
-	initStyle.s = "display:inline;text-decoration:line-through;" + (initStyle.s || "");
-	initStyle.u = "display:inline;text-decoration:underline;" + (initStyle.u || "");
-	// #ifdef MP-WEIXIN
-	//低版本兼容
-	if (!CanIUse) {
-		// #endif
-		initStyle.big = "display:inline;font-size:1.2em;" + (initStyle.big || "");
-		initStyle.small = "display:inline;font-size:0.8em;" + (initStyle.small || "");
-		initStyle.pre = "font-family:monospace;white-space:pre;" + initStyle.pre;
-		// #ifdef MP-WEIXIN
-	}
-	// #endif
-	return initStyle;
-}
-CssTokenizer.prototype.SPACE = function(c) {
-	if (/[a-zA-Z.#]/.test(c)) {
-		this._sectionStart = this._index;
-		this._state = "InName";
-	} else if (c == '@') this._state = "Ignore1";
-	else if (c == '/') this._state = "BeforeComment";
-};
-CssTokenizer.prototype.BeforeComment = function(c) {
-	if (c == '*') this._state = "InComment";
-	else {
-		this._index--;
-		this._state = "SPACE";
-	}
-};
-CssTokenizer.prototype.InComment = function(c) {
-	if (c == '*') this._state = "AfterComment";
-};
-CssTokenizer.prototype.AfterComment = function(c) {
-	if (c == '/') this._state = "SPACE";
-	else {
-		this._index--;
-		this._state = "InComment"
-	}
-};
-CssTokenizer.prototype.InName = function(c) {
-	if (c == '{') {
-		this._list.push(this._buffer.substring(this._sectionStart, this._index))
-		this._sectionStart = this._index + 1;
-		this._state = "InContent";
-	} else if (c == ',') {
-		this._list.push(this._buffer.substring(this._sectionStart, this._index));
-		this._sectionStart = this._index + 1;
-		this._comma = true;
-	} else if ((c == '.' || c == '#') && !this._comma) {
-		this._buffer = this._buffer.splice(this._index, 1, ' ');
-	} else if (/\s/.test(c)) {
-		this._name = this._buffer.substring(this._sectionStart, this._index);
-		this._state = "NameSpace";
-	} else if (/[>:\[]/.test(c)) {
-		if (this._list.length) this._state = "IgnoreName";
-		else this._state = "Ignore1";
-	} else this._comma = false;
-};
-CssTokenizer.prototype.NameSpace = function(c) {
-	if (c == '{') {
-		this._list.push(this._name);
-		this._sectionStart = this._index + 1;
-		this._state = "InContent";
-	} else if (c == ',') {
-		this._comma = true;
-		this._list.push(this._name);
-		this._sectionStart = this._index + 1;
-		this._state = "InName"
-	} else if (/\S/.test(c)) {
-		if (this._comma) {
-			this._sectionStart = this._index;
-			this._index--;
-			this._state = "InName";
-		} else if (this._list.length) this._state = "IgnoreName";
-		else this._state = "Ignore1"
-	}
-};
-CssTokenizer.prototype.InContent = function(c) {
-	if (c == '}') {
-		this._content = this._buffer.substring(this._sectionStart, this._index);
-		for (let item of this._list)
-			this.res[item] = (this.res[item] || '') + ";" + this._content;
-		this._list = [];
-		this._comma = false;
-		this._state = "SPACE";
-	}
-};
-CssTokenizer.prototype.IgnoreName = function(c) {
-	if (c == ',') {
-		this._sectionStart = this._index + 1;
-		this._state = "InName";
-	} else if (c == '{') {
-		this._sectionStart = this._index + 1;
-		this._state = "InContent";
-	}
-}
-CssTokenizer.prototype.Ignore1 = function(c) {
-	if (c == ';') {
-		this._state = "SPACE";
-		this._sectionStart = this._index + 1;
-	} else if (c == '{') this._state = "Ignore2";
-};
-CssTokenizer.prototype.Ignore2 = function(c) {
-	if (c == '}') {
-		this._state = "SPACE";
-		this._sectionStart = this._index + 1;
-	} else if (c == '{') this._state = "Ignore3";
-};
-CssTokenizer.prototype.Ignore3 = function(c) {
-	if (c == '}') this._state = "Ignore2";
-};
-CssTokenizer.prototype.parse = function() {
-	for (; this._index < this._buffer.length; this._index++)
-		this[this._state](this._buffer[this._index]);
-	return this.res;
-};
-module.exports = CssHandler;

+ 0 - 411
components/jyf-Parser/DomHandler.js

@@ -1,411 +0,0 @@
-//DomHandler.js
-var emoji; // 使用emoji补丁包时将此句改为 const emoji = require('./emoji.js');
-const CssHandler = require('./CssHandler.js');
-// #ifdef MP-WEIXIN
-const CanIUse = require('./api.js').versionHigherThan('2.7.1');
-// #endif
-const trustTag = {
-	a: 0,
-	abbr: 1,
-	ad: 0,
-	audio: 0,
-	b: 1,
-	blockquote: 1,
-	br: 0,
-	code: 1,
-	col: 0,
-	colgroup: 0,
-	dd: 1,
-	del: 1,
-	dl: 1,
-	dt: 1,
-	div: 1,
-	em: 1,
-	fieldset: 0,
-	font: 1,
-	h1: 0,
-	h2: 0,
-	h3: 0,
-	h4: 0,
-	h5: 0,
-	h6: 0,
-	hr: 0,
-	i: 1,
-	img: 1,
-	ins: 1,
-	label: 1,
-	legend: 0,
-	li: 0,
-	ol: 0,
-	p: 1,
-	q: 1,
-	source: 0,
-	span: 1,
-	strong: 1,
-	sub: 0,
-	sup: 0,
-	table: 0,
-	tbody: 0,
-	td: 0,
-	tfoot: 0,
-	th: 0,
-	thead: 0,
-	tr: 0,
-	u: 1,
-	ul: 0,
-	video: 1
-};
-const blockTag = {
-	address: true,
-	article: true,
-	aside: true,
-	body: true,
-	center: true,
-	cite: true,
-	footer: true,
-	header: true,
-	html: true,
-	nav: true,
-	pre: true,
-	section: true
-};
-const ignoreTag = {
-	area: true,
-	base: true,
-	basefont: true,
-	canvas: true,
-	circle: true,
-	command: true,
-	ellipse: true,
-	embed: true,
-	frame: true,
-	head: true,
-	iframe: true,
-	input: true,
-	isindex: true,
-	keygen: true,
-	line: true,
-	link: true,
-	map: true,
-	meta: true,
-	param: true,
-	path: true,
-	polygon: true,
-	polyline: true,
-	rect: true,
-	script: true,
-	stop: true,
-	textarea: true,
-	title: true,
-	track: true,
-	use: true,
-	wbr: true
-};
-// #ifdef MP-WEIXIN
-if (CanIUse) {
-	trustTag.bdi = 0;
-	trustTag.bdo = 0;
-	trustTag.caption = 0;
-	trustTag.rt = 0;
-	trustTag.ruby = 0;
-	ignoreTag.rp = true;
-	trustTag.big = 1;
-	trustTag.small = 1;
-	trustTag.pre = 0;
-	delete blockTag.pre;
-} else blockTag.caption = true;
-// #endif
-
-function randomId() {
-	var res = "";
-	for (var i = 0; i < 5; i++) {
-		let rand = parseInt(Math.random() * 52);
-		if (rand < 26)
-			res = res + String.fromCharCode(65 + rand);
-		else
-			res = res + String.fromCharCode(71 + rand);
-	}
-	return res;
-}
-
-function DomHandler(style, options) {
-	this.imgList = [];
-	this.imgIndex = 0;
-	this.nodes = [];
-	this.title = "";
-	this._CssHandler = new CssHandler(style, options.tagStyle);
-	this._tagStack = [];
-	this._videoNum = 0;
-	// #ifdef MP-BAIDU || MP-TOUTIAO || H5
-	this._imgMode = options.imgMode;
-	// #endif
-	this._whiteSpace = false;
-	this._domain = options.domain;
-	this._protocol = /:\/\//.test(options.domain) ? options.domain.split(/:\/\//)[0] : "http";
-	this._useAnchor = options.useAnchor;
-}
-DomHandler.prototype._addDomElement = function(element) {
-	if (element.name == 'pre' || (element.attrs && /white-space\s*:\s*pre/.test(element.attrs.style))) {
-		this._whiteSpace = true;
-		element.pre = true;
-	}
-	let parent = this._tagStack[this._tagStack.length - 1];
-	let siblings = parent ? parent.children : this.nodes;
-	siblings.push(element);
-};
-DomHandler.prototype._bubbling = function() {
-	for (let i = this._tagStack.length - 1; i >= 0; i--) {
-		if (trustTag[this._tagStack[i].name])
-			this._tagStack[i].continue = true;
-		else
-			return this._tagStack[i].name;
-	}
-}
-DomHandler.prototype.onopentag = function(name, attrs) {
-	let element = {
-		children: []
-	};
-	let matched = this._CssHandler.match(name, attrs, element);
-	//处理属性
-	switch (name) {
-		case 'div':
-		case 'p':
-			if (attrs.align) {
-				attrs.style += (';text-align:' + attrs.align);
-				delete attrs.align;
-			}
-			break;
-		case 'img':
-			if (attrs.width) {
-				attrs.style = 'width:' + attrs.width + (/[0-9]/.test(attrs.width[attrs.width.length - 1]) ? 'px' : '') + ';' +
-					attrs.style;
-				delete attrs.width;
-			}
-			if (attrs['data-src']) {
-				attrs.src = attrs.src || attrs['data-src'];
-				delete attrs['data-src'];
-			}
-			// #ifdef MP-BAIDU || MP-TOUTIAO || H5
-			if (this._imgMode == "widthFix") attrs.style += ";height:auto !important;";
-			// #endif
-			if (!attrs.hasOwnProperty('ignore') && attrs.src) {
-				if (this._bubbling() == 'a') {
-					attrs.ignore = "true"; // 图片在链接中不可预览
-					break;
-				}
-				var url = attrs.src;
-				// #ifdef MP-WEIXIN || MP-QQ || MP-BAIDU || MP-TOUTIAO
-				// 去重,至多重试10次
-				for (let i = 0; this.imgList.indexOf(url) != -1 && i < 10; i++) {
-					// 网络链接
-					if (/^http/.test(url)) {
-						url = url.replace(/^(https*):\/\/([\S]+?)\//, function() {
-							var domain = "";
-							for (var c of arguments[2]) {
-								if (/[a-zA-Z]/.test(c))
-									domain += (Math.random() >= 0.5 ? c.toUpperCase() : c);
-								else domain += c;
-							}
-							return (arguments[1] + '://' + domain + '/');
-						})
-					}
-					// base64
-					else if (/base64/.test(url)) {
-						url = url.replace(/^data:(image\/\S+);base64,/, function() {
-							var head = "";
-							for (var c of arguments[1]) {
-								if (/[a-zA-Z]/.test(c))
-									head += (Math.random() >= 0.5 ? c.toUpperCase() : c);
-								else head += c;
-							}
-							return ('data:' + head + ';base64,');
-						})
-					} else break;
-				}
-				// #endif
-				element.current = this.imgList.length;
-				this.imgList.push(url);
-			} else
-				attrs.ignore = "true";
-			if (this._domain && attrs.src[0] == '/') {
-				if (attrs.src[1] == '/') attrs.src = this._protocol + ":" + attrs.src;
-				else attrs.src = this._domain + attrs.src;
-			}
-			break;
-		case 'font':
-			name = 'span';
-			if (attrs.color) {
-				attrs.style += (';color:' + attrs.color);
-				delete attrs.color;
-			}
-			if (attrs.face) {
-				attrs.style += (";font-family:" + attrs.face);
-				delete attrs.face;
-			}
-			if (attrs.size) {
-				var size = parseInt(attrs.size);
-				if (size < 1) size = 1;
-				else if (size > 7) size = 7;
-				let map = [10, 13, 16, 18, 24, 32, 48];
-				attrs.style += (";font-size:" + map[size - 1] + "px");
-				delete attrs.size;
-			}
-			break;
-		case 'a':
-		case 'ad':
-			this._bubbling();
-			break;
-		case 'video':
-		case 'audio':
-			attrs.loop = attrs.hasOwnProperty('loop');
-			attrs.controls = attrs.hasOwnProperty('controls');
-			attrs.autoplay = attrs.hasOwnProperty('autoplay');
-			if (name == 'video') {
-				attrs.muted = attrs.hasOwnProperty('muted');
-				if (attrs.width) {
-					attrs.style = 'width:' + parseFloat(attrs.width) + 'px;' + attrs.style;
-					delete attrs.width;
-				}
-				if (attrs.height) {
-					attrs.style = 'height:' + parseFloat(attrs.height) + 'px;' + attrs.style;
-					delete attrs.height;
-				}
-			}
-			attrs.id = randomId() + (name == 'video' ? ++this._videoNum : '');
-			attrs.source = [];
-			if (attrs.src) attrs.source.push(attrs.src);
-			if (!attrs.controls && !attrs.autoplay)
-				console.warn('存在没有controls属性的' + name + '标签,可能导致无法播放', attrs);
-			this._bubbling();
-			break;
-		case 'source':
-			let parent = this._tagStack[this._tagStack.length - 1];
-			if (parent && (parent.name == 'video' || parent.name == 'audio')) {
-				parent.attrs.source.push(attrs.src);
-				if (!parent.attrs.src) parent.attrs.src = attrs.src;
-			}
-			this._tagStack.push(element);
-			return;
-	}
-	if(this._useAnchor && attrs.id) this._bubbling();
-	attrs.style = matched + attrs.style;
-	if (blockTag[name]) name = 'div';
-	else if (!trustTag.hasOwnProperty(name)) name = 'span';
-	element.name = name;
-	element.attrs = attrs;
-	this._addDomElement(element);
-	this._tagStack.push(element);
-};
-DomHandler.prototype.ontext = function(data) {
-	if (!this._whiteSpace) {
-		if (!/\S/.test(data))
-			return;
-		data = data.replace(/\s+/g, " ");
-	}
-	// #ifndef MP-WEIXIN || MP-QQ || APP-PLUS || H5
-	let entities = {
-		lt: "<",
-		gt: ">",
-		nbsp: "\u00A0",
-		ensp: "\u2002",
-		emsp: "\u2003",
-		amp: "&",
-		apos: "'",
-		quot: '"',
-		ndash: "–",
-		mdash: "—",
-		middot: "·",
-		lsquo: "‘",
-		rsquo: "’",
-		ldquo: "“",
-		rdquo: "”",
-		bull: "•",
-		hellip: "…",
-		permil: "‰",
-		copy: "©",
-		reg: "®",
-		trade: "™",
-		times: "×",
-		divide: "÷",
-		cent: "¢",
-		pound: "£",
-		yen: "¥",
-		euro: "€",
-		sect: "§"
-	};
-	data = data.replace(/&(\S{1,8}?);/g, function() {
-		if (entities[arguments[1]]) return entities[arguments[1]];
-		return "";
-	});
-	// #endif
-	let element = {
-		type: 'text'
-	};
-	// #ifdef MP-WEIXIN || MP-QQ || H5 || APP-PLUS
-	data = data.replace(/&nbsp;/g, '&#xA0;'); // 解决连续&nbsp;失效问题
-	if (/&#*((?!sp|lt|gt).){2,8};/.test(data)) element.decode = true;
-	// #endif
-	if (emoji) data = emoji.parseEmoji(data);
-	element.text = data;
-	this._addDomElement(element);
-};
-DomHandler.prototype.onclosetag = function(name) {
-	let element = this._tagStack.pop();
-	let parent = this._tagStack.length ? this._tagStack[this._tagStack.length - 1].children : this.nodes;
-	if (ignoreTag[name]) {
-		if (name == 'title') {
-			try {
-				this.title = element.children[0].text;
-			} catch (e) {}
-		}
-		parent.pop();
-	}
-	// 设置表格的边框
-	if (name == 'table') {
-		if (element.attrs.border)
-			element.attrs.style += (";border:" + element.attrs.border + "px solid gray;");
-		if (element.attrs.hasOwnProperty("cellspacing"))
-			element.attrs.style += (";border-spacing:" + element.attrs.cellspacing + "px");
-
-		function setBorder(node) {
-			if (node.type == 'text') return;
-			if (node.name == 'th' || node.name == 'td') {
-				if (element.attrs.border)
-					node.attrs.style += ";border:" + element.attrs.border + "px solid gray;";
-				if (element.attrs.hasOwnProperty("cellpadding"))
-					node.attrs.style += ";padding:" + element.attrs.cellpadding + "px";
-			}
-			for (var child of node.children)
-				setBorder(child);
-		}
-		if (element.attrs.border || element.attrs.hasOwnProperty("cellpadding")) {
-			for (var child of element.children)
-				setBorder(child);
-		}
-	}
-	// 合并一些不必要的层,减小节点深度
-	if (element.children.length == 1 && element.name == 'div') {
-		let child = element.children[0];
-		if (child.name == 'div' && !(/padding/.test(element.attrs.style)) && !(/margin/.test(element.attrs.style) &&
-				/margin/.test(child.attrs.style)) && !(/display/.test(element.attrs.style)) && !(/display/.test(child.attrs.style)) &&
-			!(element.attrs.id && child.attrs.id) && !(element.attrs.class && child.attrs.class)) {
-			if (/padding/.test(child.attrs.style))
-				child.attrs.style = ";box-sizing:border-box;" + child.attrs.style;
-			child.attrs.style = element.attrs.style + ";" + child.attrs.style;
-			child.attrs.id = (child.attrs.id || "") + (element.attrs.id || "");
-			child.attrs.class = (child.attrs.class || "") + (element.attrs.class || "");
-			parent[parent.indexOf(element)] = child;
-		}
-	}
-	if (element.pre) {
-		this._whiteSpace = false;
-		for (var ele of this._tagStack)
-			if (ele.pre)
-				this._whiteSpace = true;
-		delete element.pre;
-	}
-	// 多层样式处理 
-	if (this._CssHandler.pop)
-		this._CssHandler.pop(element);
-};
-module.exports = DomHandler;

+ 0 - 240
components/jyf-Parser/Parser.js

@@ -1,240 +0,0 @@
-//Parser.js
-const Tokenizer = require("./Tokenizer.js");
-const DomHandler = require("./DomHandler.js");
-const trustAttrs = {
-	align: true,
-	alt: true,
-	// #ifdef MP-BAIDU
-	appid: true,
-	apid: true,
-	// #endif
-	author: true,
-	autoplay: true,
-	border: true,
-	cellpadding: true,
-	cellspacing: true,
-	class: true,
-	color: true,
-	colspan: true,
-	controls: true,
-	"data-src": true,
-	dir: true,
-	face: true,
-	height: true,
-	href: true,
-	id: true,
-	ignore: true,
-	loop: true,
-	muted: true,
-	name: true,
-	poster: true,
-	rowspan: true,
-	size: true,
-	span: true,
-	src: true,
-	start: true,
-	style: true,
-	type: true,
-	// #ifdef MP-WEIXIN || MP-QQ
-	"unit-id": true,
-	// #endif
-	width: true,
-};
-// #ifdef MP-BAIDU || MP-TOUTIAO || H5
-const textTag = {
-  abbr: true,
-  b: true,
-  big: true,
-  code: true,
-  del: true,
-  em: true,
-  font: true,
-  i: true,
-  ins: true,
-  label: true,
-  mark: true,
-  q: true,
-  s: true,
-  small: true,
-  span: true,
-  strong: true,
-  sub: true,
-  sup: true,
-  u: true
-}
-const _traverse = function(nodes) {
-	for (var element of nodes) {
-		if (element.type == "text")
-			continue;
-		if (!element.continue) {
-			// #ifdef H5
-			if(textTag[element.name]){
-				element.continue = true;
-				_traverse(element.children);
-				continue;
-			}
-			// #endif
-			var res = "";
-			var style = element.attrs.style;
-			var reg = /float\s*:\s*[^;]*/i;
-			if (reg.test(style)) res += reg.exec(style)[0];
-			reg = /margin[^;]*/gi;
-			var margin = reg.exec(style);
-			while (margin) {
-				res += (';' + margin[0]);
-				margin = reg.exec(style);
-			}
-			reg = /display\s*:\s*([^;]*)/i;
-			if (reg.test(style) && reg.exec(style)[1] != "flex") res += (';' + reg.exec(style)[0]);
-			// #ifdef MP-BAIDU || MP-TOUTIAO
-			else if(textTag[element.name]) res+=";display:inline";
-			// #endif
-			else res += (";display:" + (element.name == 'img' ? 'inline-block' : 'block'));
-			reg = /flex\s*:[^;]*/i;
-			if (reg.test(style)) res += (';' + reg.exec(style)[0]);
-			reg = /[^;\s]*width[^;]*/ig;
-			var width = reg.exec(style);
-			while (width) {
-				res += (';' + width[0]);
-				width = reg.exec(style);
-			}
-			element.attrs.containStyle = res;
-			if (/[^-]width[^pev;]+/.test(";" + style))
-				element.attrs.style += ";width:100%";
-			let addMargin = "";
-			if (/margin\s*:/.test(style)) addMargin = ';margin:0';
-			else if (/margin-top/.test(style)) addMargin = ';margin-top:0';
-			else if (/margin-bottom/.test(style)) addMargin = ';margin-bottom:0';
-			element.attrs.style = element.attrs.style.replace(/margin[^;]*/gi, "");
-			element.attrs.style += addMargin;
-		} else _traverse(element.children);
-	}
-};
-// #endif
-const voidTag = {
-	area: true,
-	base: true,
-	basefont: true,
-	br: true,
-	col: true,
-	circle: true,
-	command: true,
-	ellipse: true,
-	embed: true,
-	frame: true,
-	hr: true,
-	img: true,
-	input: true,
-	isindex: true,
-	keygen: true,
-	line: true,
-	link: true,
-	meta: true,
-	param: true,
-	path: true,
-	polygon: true,
-	polyline: true,
-	rect: true,
-	source: true,
-	stop: true,
-	track: true,
-	use: true,
-	wbr: true
-};
-
-function Parser(cbs, callback) {
-	this._cbs = cbs;
-	this._callback = callback;
-	this._tagname = "";
-	this._attribname = "";
-	this._attribvalue = "";
-	this._attribs = null;
-	this._stack = [];
-	this._tokenizer = new Tokenizer(this);
-}
-Parser.prototype.ontext = function(data) {
-	this._cbs.ontext(data);
-};
-Parser.prototype.onopentagname = function(name) {
-	name = name.toLowerCase();
-	this._tagname = name;
-	this._attribs = {
-		style: ''
-	};
-	if (!voidTag[name]) this._stack.push(name);
-};
-Parser.prototype.onopentagend = function() {
-	if (this._attribs) {
-		this._cbs.onopentag(this._tagname, this._attribs);
-		this._attribs = null;
-	}
-	if (voidTag[this._tagname]) this._cbs.onclosetag(this._tagname);
-	this._tagname = "";
-};
-Parser.prototype.onclosetag = function(name) {
-	name = name.toLowerCase();
-	if (this._stack.length && !voidTag[name]) {
-		var pos = this._stack.lastIndexOf(name);
-		if (pos !== -1) {
-			pos = this._stack.length - pos;
-			while (pos--) this._cbs.onclosetag(this._stack.pop());
-		} else if (name === "p") {
-			this.onopentagname(name);
-			this._closeCurrentTag();
-		}
-	} else if (name === "br" || name === "hr" || name === "p") {
-		this.onopentagname(name);
-		this._closeCurrentTag();
-	}
-};
-Parser.prototype._closeCurrentTag = function() {
-	let name = this._tagname;
-	this.onopentagend();
-	if (this._stack[this._stack.length - 1] === name) {
-		this._cbs.onclosetag(name);
-		this._stack.pop();
-	}
-};
-Parser.prototype.onattribend = function() {
-	this._attribvalue = this._attribvalue.replace(/&quot;/g, '"');
-	if (this._attribs && trustAttrs[this._attribname]) {
-		this._attribs[this._attribname] = this._attribvalue;
-	}
-	this._attribname = "";
-	this._attribvalue = "";
-};
-Parser.prototype.onend = function() {
-	for (
-		var i = this._stack.length; i > 0; this._cbs.onclosetag(this._stack[--i])
-	);
-	this._callback({
-		'nodes': this._cbs.nodes,
-		'title': this._cbs.title,
-		'imgList': this._cbs.imgList
-	});
-};
-Parser.prototype.write = function(chunk) {
-	this._tokenizer.parse(chunk);
-};
-
-function html2nodes(data, options) {
-	return new Promise(function(resolve, reject) {
-		try {
-			let style = '';
-			data = data.replace(/<style.*?>([\s\S]*?)<\/style>/gi, function() {
-				style += arguments[1];
-				return '';
-			});
-			let handler = new DomHandler(style, options);
-			new Parser(handler, (res) => {
-				// #ifdef MP-BAIDU || MP-TOUTIAO || H5
-				_traverse(res.nodes);
-				// #endif
-				return resolve(res);
-			}).write(data);
-		} catch (err) {
-			return reject(err);
-		}
-	})
-}
-module.exports = html2nodes;

+ 0 - 218
components/jyf-Parser/Tokenizer.js

@@ -1,218 +0,0 @@
-//Tokenizer.js
-function Tokenizer(cbs) {
-	this._state = "TEXT";
-	this._buffer = "";
-	this._sectionStart = 0;
-	this._index = 0;
-	this._cbs = cbs;
-}
-Tokenizer.prototype.TEXT = function(c) {
-	var index = this._buffer.indexOf("<", this._index);
-	if (index != -1) {
-		this._index = index;
-		this._cbs.ontext(this._getSection());
-		this._state = "BeforeTag";
-		this._sectionStart = this._index;
-	} else this._index = this._buffer.length;
-};
-Tokenizer.prototype.BeforeTag = function(c) {
-	switch (c) {
-		case "/":
-			this._state = "BeforeCloseTag";
-			break;
-		case "!":
-			this._state = "BeforeDeclaration";
-			break;
-		case "?":
-			let index = this._buffer.indexOf(">", this._index);
-			if (index != -1) {
-				this._index = index;
-				this._sectionStart = this._index + 1;
-			} else this._sectionStart = this._index = this._buffer.length;
-			this._state = "TEXT";
-			break;
-		case ">":
-			this._state = "TEXT";
-			break;
-		case "<":
-			this._cbs.ontext(this._getSection());
-			this._sectionStart = this._index;
-			break;
-		default:
-			if (/\s/.test(c)) this._state = "TEXT";
-			else {
-				this._state = "InTag";
-				this._sectionStart = this._index;
-			}
-	}
-};
-Tokenizer.prototype.InTag = function(c) {
-	if (c === "/" || c === ">" || /\s/.test(c)) {
-		this._cbs.onopentagname(this._getSection());
-		this._state = "BeforeAttrsName";
-		this._index--;
-	}
-};
-Tokenizer.prototype.BeforeAttrsName = function(c) {
-	if (c === ">") {
-		this._cbs.onopentagend();
-		this._state = "TEXT";
-		this._sectionStart = this._index + 1;
-	} else if (c === "/") {
-		this._state = "InSelfCloseTag";
-	} else if (!(/\s/.test(c))) {
-		this._state = "InAttrsName";
-		this._sectionStart = this._index;
-	}
-};
-Tokenizer.prototype.InAttrsName = function(c) {
-	if (c === "=" || c === "/" || c === ">" || /\s/.test(c)) {
-		this._cbs._attribname = this._getSection().toLowerCase();
-		this._sectionStart = -1;
-		this._state = "AfterAttrsName";
-		this._index--;
-	}
-};
-Tokenizer.prototype.AfterAttrsName = function(c) {
-	if (c === "=") {
-		this._state = "BeforeAttrsValue";
-	} else if (c === "/" || c === ">") {
-		this._cbs.onattribend();
-		this._state = "BeforeAttrsName";
-		this._index--;
-	} else if (!(/\s/.test(c))) {
-		this._cbs.onattribend();
-		this._state = "InAttrsName";
-		this._sectionStart = this._index;
-	}
-};
-Tokenizer.prototype.BeforeAttrsValue = function(c) {
-	if (c === '"') {
-		this._state = "InAttrsValueDQ";
-		this._sectionStart = this._index + 1;
-	} else if (c === "'") {
-		this._state = "InAttrsValueSQ";
-		this._sectionStart = this._index + 1;
-	} else if (!(/\s/.test(c))) {
-		this._state = "InAttrsValueNQ";
-		this._sectionStart = this._index;
-		this._index--;
-	}
-};
-Tokenizer.prototype.InAttrsValueDQ = function(c) {
-	if (c === '"') {
-		this._cbs._attribvalue += this._getSection();
-		this._cbs.onattribend();
-		this._state = "BeforeAttrsName";
-	}
-};
-Tokenizer.prototype.InAttrsValueSQ = function(c) {
-	if (c === "'") {
-		this._cbs._attribvalue += this._getSection();
-		this._cbs.onattribend();
-		this._state = "BeforeAttrsName";
-	}
-};
-Tokenizer.prototype.InAttrsValueNQ = function(c) {
-	if (/\s/.test(c) || c === ">") {
-		this._cbs._attribvalue += this._getSection();
-		this._cbs.onattribend();
-		this._state = "BeforeAttrsName";
-		this._index--;
-	}
-};
-Tokenizer.prototype.BeforeCloseTag = function(c) {
-	if (/\s/.test(c));
-	else if (c === ">") {
-		this._state = "TEXT";
-	} else {
-		this._state = "InCloseTag";
-		this._sectionStart = this._index;
-	}
-};
-Tokenizer.prototype.InCloseTag = function(c) {
-	if (c === ">" || /\s/.test(c)) {
-		this._cbs.onclosetag(this._getSection());
-		this._state = "AfterCloseTag";
-		this._index--;
-	}
-};
-Tokenizer.prototype.InSelfCloseTag = function(c) {
-	if (c === ">") {
-		this._cbs.onopentagend();
-		this._state = "TEXT";
-		this._sectionStart = this._index + 1;
-	} else if (!(/\s/.test(c))) {
-		this._state = "BeforeAttrsName";
-		this._index--;
-	}
-};
-Tokenizer.prototype.AfterCloseTag = function(c) {
-	if (c === ">") {
-		this._state = "TEXT";
-		this._sectionStart = this._index + 1;
-	}
-};
-Tokenizer.prototype.BeforeDeclaration = function(c) {
-	if (c == '-') this._state = "InComment";
-	else if (c == '[') this._state = "BeforeCDATA1";
-	else this._state = "InDeclaration";
-};
-Tokenizer.prototype.InDeclaration = function(c) {
-	var index = this._buffer.indexOf(">", this._index);
-	if (index != -1) {
-		this._index = index;
-		this._sectionStart = index + 1;
-	} else this._sectionStart = this._index = this._buffer.length;
-	this._state = "TEXT";
-};
-Tokenizer.prototype.InComment = function(c) {
-	let key = (c == '-' ? '-->' : '>');
-	let index = this._buffer.indexOf(key, this._index);
-	if (index != -1) {
-		this._index = index + key.length - 1;
-		this._sectionStart = this._index + 1;
-	} else this._sectionStart = this._index = this._buffer.length;
-	this._state = "TEXT";
-};
-Tokenizer.prototype.BeforeCDATA1 = function(c) {
-	if (c == 'C') this._state = "BeforeCDATA2";
-	else this._state = "InDeclaration";
-};
-Tokenizer.prototype.BeforeCDATA2 = function(c) {
-	if (c == 'D') this._state = "BeforeCDATA3";
-	else this._state = "InDeclaration";
-};
-Tokenizer.prototype.BeforeCDATA3 = function(c) {
-	if (c == 'A') this._state = "BeforeCDATA4";
-	else this._state = "InDeclaration";
-};
-Tokenizer.prototype.BeforeCDATA4 = function(c) {
-	if (c == 'T') this._state = "BeforeCDATA5";
-	else this._state = "InDeclaration";
-};
-Tokenizer.prototype.BeforeCDATA5 = function(c) {
-	if (c == 'A') this._state = "InCDATA";
-	else this._state = "InDeclaration";
-};
-Tokenizer.prototype.InCDATA = function(c) {
-	let key = (c == '[' ? ']]>' : '>');
-	let index = this._buffer.indexOf(key, this._index);
-	if (index != -1) {
-		this._index = index + key.length - 1;
-		this._sectionStart = this._index + 1;
-	} else this._sectionStart = this._index = this._buffer.length;
-	this._state = "TEXT";
-};
-Tokenizer.prototype.parse = function(chunk) {
-	this._buffer += chunk;
-	for (; this._index < this._buffer.length; this._index++)
-		this[this._state](this._buffer[this._index]);
-	if (this._state === "TEXT" && this._sectionStart !== this._index)
-		this._cbs.ontext(this._buffer.substr(this._sectionStart));
-	this._cbs.onend();
-};
-Tokenizer.prototype._getSection = function() {
-	return this._buffer.substring(this._sectionStart, this._index);
-};
-module.exports = Tokenizer;

+ 0 - 41
components/jyf-Parser/api.js

@@ -1,41 +0,0 @@
-String.prototype.splice = function(start = 0, deleteCount = 0, addStr = '') {
-	if (start < 0) start = this.length + start;
-	if (deleteCount < 0) deleteCount = 0;
-	return this.substring(0, start) + addStr + this.substring(start + deleteCount);
-}
-// #ifndef MP-ALIPAY || H5 || APP-PLUS 
-const SDKVersion = uni.getSystemInfoSync().SDKVersion;
-// #endif
-module.exports = {
-	// #ifndef MP-ALIPAY || H5 || APP-PLUS 
-	versionHigherThan(version = '') {
-		var v1 = SDKVersion.split('.');
-		var v2 = version.split('.');
-		const len = Math.max(v1.length, v2.length);
-		while (v1.length < len) {
-			v1.push('0');
-		}
-		while (v2.length < len) {
-			v2.push('0');
-		}
-		for (let i = 0; i < len; i++) {
-			const num1 = parseInt(v1[i]);
-			const num2 = parseInt(v2[i]);
-			if (num1 > num2) {
-				return true;
-			} else if (num1 < num2) {
-				return false;
-			}
-		}
-		return true;
-	},
-	// #endif
-	html2nodes(html, tagStyle) {
-		const Parser = require('./Parser.js');
-		return Parser(html, tagStyle);
-	},
-	css2object(style, tagStyle) {
-		const CssHandler = require('./CssHandler.js');
-		return new CssHandler(style, tagStyle)._style;
-	}
-}

+ 0 - 70
components/jyf-Parser/handler.sjs

@@ -1,70 +0,0 @@
-var textTag = {
-	abbr: true,
-	b: true,
-	big: true,
-	code: true,
-	del: true,
-	em: true,
-	font: true,
-	i: true,
-	ins: true,
-	label: true,
-	mark: true,
-	q: true,
-	s: true,
-	small: true,
-	span: true,
-	strong: true,
-	u: true
-}
-export default {
-	getStyle: function(style, display) {
-		var res = "";
-		var reg = getRegExp("float\s*:\s*[^;]*", "i");
-		if (reg.test(style)) res += reg.exec(style)[0];
-		reg = getRegExp("margin[^;]*", "gi");
-		var margin = reg.exec(style);
-		while (margin) {
-			res += (';' + margin[0]);
-			margin = reg.exec(style);
-		}
-		reg = getRegExp("display\s*:\s*([^;]*)", "i");
-		if (reg.test(style) && reg.exec(style)[1] != "flex") res += (';' + reg.exec(style)[0]);
-		else res += (';display:' + display);
-		reg = getRegExp("flex\s*:[^;]*", "i");
-		if (reg.test(style)) res += (';' + reg.exec(style)[0]);
-		reg = getRegExp("[^;\s]*width[^;]*", "ig");
-		var width = reg.exec(style);
-		while (width) {
-			res += (';' + width[0]);
-			width = reg.exec(style);
-		}
-		return res;
-	},
-	setImgStyle: function(item, imgMode) {
-		if (imgMode == "widthFix")
-			item.attrs.style += ";height:auto !important";
-		if (getRegExp("[^-]width[^pev;]+").test(";" + item.attrs.style))
-			item.attrs.style += ";width:100%";
-		item.attrs.style = item.attrs.style.replace(getRegExp('margin[^;]*', "gi"), "");
-		return [item];
-	},
-	setStyle: function(item) {
-		if (getRegExp("[^-]width[^pev;]+").test(";" + item.attrs.style))
-			item.attrs.style += ";width:100%";
-		if (getRegExp('margin').test(item.attrs.style)) {
-			item.attrs.style = item.attrs.style.replace(getRegExp('margin[^;]*', "gi"), "");
-			item.attrs.style += ';margin:0'
-		}
-		return [item];
-	},
-	isContinue: function(item) {
-		if (textTag[item.name])
-			return false;
-		if (!item["continue"])
-			return true;
-		else if (item.name == 'a')
-			return true;
-		return false;
-	}
-}

+ 0 - 72
components/jyf-Parser/handler.wxs

@@ -1,72 +0,0 @@
-// Parser/trees/cssHandler.wxs
-var textTag = {
-	abbr: true,
-	b: true,
-	big: true,
-	code: true,
-	del: true,
-	em: true,
-	font: true,
-	i: true,
-	ins: true,
-	label: true,
-	mark: true,
-	q: true,
-	s: true,
-	small: true,
-	span: true,
-	strong: true,
-	u: true
-}
-module.exports = {
-	getStyle: function(style, display) {
-		var res = "";
-		var reg = getRegExp("float\s*:\s*[^;]*", "i");
-		if (reg.test(style)) res += reg.exec(style)[0];
-		reg = getRegExp("margin[^;]*", "gi");
-		var margin = reg.exec(style);
-		while (margin) {
-			res += (';' + margin[0]);
-			margin = reg.exec(style);
-		}
-		reg = getRegExp("display\s*:\s*([^;]*)", "i");
-		if (reg.test(style) && reg.exec(style)[1] != "flex") res += (';' + reg.exec(style)[0]);
-		else res += (';display:' + display);
-		reg = getRegExp("flex\s*:[^;]*", "i");
-		if (reg.test(style)) res += (';' + reg.exec(style)[0]);
-		reg = getRegExp("[^;\s]*width[^;]*", "ig");
-		var width = reg.exec(style);
-		while (width) {
-			res += (';' + width[0]);
-			width = reg.exec(style);
-		}
-		return res;
-	},
-	setImgStyle: function(item, imgMode, imgLoad) {
-		if (imgMode == "widthFix")
-			item.attrs.style += ";height:auto !important";
-		if (getRegExp("[^-]width[^pev;]+").test(";" + item.attrs.style))
-			item.attrs.style += ";width:100%";
-		item.attrs.style = item.attrs.style.replace(getRegExp('margin[^;]*', "gi"), "");
-		if (!imgLoad) {
-			delete item.attrs.src;
-			item.attrs.style += ";width:5px !important;height:5px !important"
-		}
-		return [item];
-	},
-	setStyle: function(item) {
-		if (getRegExp("[^-]width[^pev;]+").test(";" + item.attrs.style))
-			item.attrs.style += ";width:100%";
-		item.attrs.style = item.attrs.style.replace(getRegExp('margin[^;]*', "gi"), "");
-		return [item];
-	},
-	isContinue: function(item) {
-		if (textTag[item.name])
-			return false;
-		if (!item["continue"])
-			return true;
-		else if (item.name == 'a')
-			return true;
-		return false;
-	}
-}

+ 0 - 405
components/jyf-Parser/index.vue

@@ -1,405 +0,0 @@
-<template>
-	<view>
-		<!--#ifdef H5-->
-		<slot v-if="!html"></slot>
-		<iframe id="contain" :style="'width:100%;'+(selectable?'user-select:text;-webkit-user-select:text':'')+(showWithAnimation?('opacity:0;'+showAnimation):'')"
-		 frameborder="0"></iframe>
-		<!--#endif-->
-		<!--#ifndef H5-->
-		<slot v-if="!(html.nodes||((html&&(html[0].name||html[0].type))?1:nodes.length))"></slot>
-		<!--#endif-->
-		<!--#ifdef MP-ALIPAY || H5-->
-		<view class="contain" :style="(showWithAnimation?'opacity:0;':'')+(selectable?'user-select:text;-webkit-user-select:text':'')"
-		 :animation="showAnimation">
-			<trees :nodes="html.nodes||((html&&(html[0].name||html[0].type))?html:nodes)" :imgMode="imgMode" />
-		</view>
-		<!--#endif-->
-		<!--#ifndef MP-ALIPAY || H5-->
-		<trees class="contain" :style="'display:block'+(showWithAnimation?'opacity:0;':'')+(selectable?'user-select:text;-webkit-user-select:text':'')"
-		 :animation="showAnimation" :nodes="html.nodes||((html[0].name||html[0].type)?html:nodes)" :imgMode="imgMode"
-		 :lazyLoad="lazyLoad" :loadVideo="loadVideo" />
-		<!--#endif-->
-	</view>
-</template>
-
-<script>
-	import trees from "./trees"
-	const html2nodes = require("./Parser.js");
-	// #ifdef MP-WEIXIN || MP-QQ
-	const CanIUseObserver = require("./api.js").versionHigherThan('1.9.3');
-	// #endif
-	// #ifdef APP-PLUS
-	const CanIUseObserver = true;
-	// #endif
-	var Document; // 使用document补丁包时将此句改为 const Document = require('./document.js');
-	export default {
-		name: 'parser',
-		data() {
-			return {
-				nodes: [],
-				showAnimation: {},
-				// #ifdef APP-PLUS
-				loadVideo: false,
-				// #endif
-			}
-		},
-		components: {
-			trees
-		},
-		props: {
-			'html': {
-				type: null,
-				default: ''
-			},
-			'autocopy': {
-				type: Boolean,
-				default: true
-			},
-			// #ifndef MP-ALIPAY
-			'autopause': {
-				type: Boolean,
-				default: true
-			},
-			// #endif
-			'autopreview': {
-				type: Boolean,
-				default: true
-			},
-			'autosetTitle': {
-				type: Boolean,
-				default: true
-			},
-			'domain': {
-				type: String,
-				default: ''
-			},
-			'imgMode': {
-				type: String,
-				default: 'default'
-			},
-			// #ifdef MP-WEIXIN || MP-QQ || APP-PLUS
-			'lazyLoad': {
-				type: Boolean,
-				default: false
-			},
-			// #endif
-			'selectable': {
-				type: Boolean,
-				default: false
-			},
-			'tagStyle': {
-				type: Object,
-				default: () => {
-					return {};
-				}
-			},
-			'showWithAnimation': {
-				type: Boolean,
-				default: false
-			},
-			'animationDuration': {
-				type: Number,
-				default: 400
-			},
-			'useAnchor': {
-				type: Boolean,
-				default: false
-			}
-		},
-		mounted() {
-			this.execHtml(this.html);
-			// #ifndef MP-ALIPAY || H5
-			this.videoContext = [];
-			// #endif
-			// #ifdef MP-BAIDU || MP-ALIPAY
-			this.anchors = [];
-			// #endif
-		},
-		methods: {
-			execHtml(html) {
-				// #ifdef H5
-				var iframe = document.getElementById("contain");
-				// 支持 iframe.srcdoc
-				if (typeof(iframe.srcdoc) == "string") {
-					var script =
-						'<script>"use strict";function calcPageHeight(t){var e=Math.max(t.body.clientHeight,t.documentElement.clientHeight),n=Math.max(t.body.scrollHeight,t.documentElement.scrollHeight);return Math.max(e,n)}document.addEventListener("DOMContentLoaded",function(){for(var t=document.getElementsByTagName("img"),e=[],n=0;n<t.length;n++){var r=t[n];r.style+=";max-width:100%",e.push(r.src),r.index=n,"A"!=r.parentElement.nodeName&&(r.onclick=function(){parent.document.previewEvent(this,e)}),r.onerror=function(){parent.document.errorEvent(this,"img")};var o=document.getElementsByTagName("a"),a=!0,i=!1,c=void 0;try{for(var u,l=o[Symbol.iterator]();!(a=(u=l.next()).done);a=!0){u.value.onclick=function(t){if("#"==this.getAttribute("href")[0]){var e=document.getElementById(this.getAttribute("href").substring(1));return parent.document.tapEvent(this,e?e.offsetTop:-1)}return parent.document.tapEvent(this)}}}catch(t){i=!0,c=t}finally{try{!a&&l.return&&l.return()}finally{if(i)throw c}}var d=document.getElementsByTagName("video"),m=!0,h=!1,s=void 0;try{for(var v,y=d[Symbol.iterator]();!(m=(v=y.next()).done);m=!0){var f=v.value;f.style+=";max-width:100%",f.onerror=function(){parent.document.errorEvent(this,"video")},f.onplay=function(){parent.document.playEvent(this)}}}catch(t){h=!0,s=t}finally{try{!m&&y.return&&y.return()}finally{if(h)throw s}}parent.document.setVideoContext(d);var g=document.getElementsByTagName("audios"),p=!0,E=!1,x=void 0;try{for(var b,w=g[Symbol.iterator]();!(p=(b=w.next()).done);p=!0){b.value.onerror=function(t){parent.document.errorEvent(this,"audio")}}}catch(t){E=!0,x=t}finally{try{!p&&w.return&&w.return()}finally{if(E)throw x}}}},!1),window.onload=function(){var t=calcPageHeight(document);parent.document.getElementById("contain").style.height=t+"px",parent.document.setTitle(document.title)};<\/script>';
-					if (!html) return;
-					if (typeof html != 'string') {
-						if (typeof html == 'object') {
-							var str = "";
-							for (var node of (html.nodes || html))
-								str += this.Dom2Str(node);
-							html = str;
-						} else {
-							this.$emit('error', {
-								source: "parse",
-								errMsg: "传入的html格式不正确!"
-							});
-							return;
-						}
-					}
-					// 处理 rpx
-					if (/[0-9.]*?rpx/.test(html)) {
-						var rpx = uni.getSystemInfoSync().screenWidth / 750;
-						html = html.replace(/([0-9.]*?)rpx/g, function() {
-							return parseFloat(arguments[1]) * rpx + "px";
-						})
-					}
-					document.previewEvent = (img, imgList) => {
-						if (!img.hasAttribute('ignore')) {
-							var preview = true;
-							img.ignore = () => preview = false;
-							this.$emit('imgtap', img);
-							if (preview && this.autopreview) {
-								uni.previewImage({
-									current: img.index,
-									urls: imgList
-								});
-							}
-						}
-					}
-					document.tapEvent = (link, offsetTop) => {
-						var jump = true;
-						this.$emit('linkpress', {
-							href: link.getAttribute("href"),
-							ignore: () => jump = false
-						});
-						if (jump && link.getAttribute("href")) {
-							if (link.getAttribute("href")[0] == '#') {
-								if (this.useAnchor)
-									window.scrollTo(0, iframe.offsetTop + offsetTop);
-							} else if (/^http/.test(link.getAttribute("href"))) {
-								if (this.autocopy)
-									window.location.href = link.href;
-							} else {
-								uni.navigateTo({
-									url: link.getAttribute("href")
-								})
-							}
-						}
-						return false;
-					}
-					document.setTitle = (title) => {
-						if (title && this.autosetTitle) {
-							uni.setNavigationBarTitle({
-								title: title
-							})
-						}
-						if (html)
-							uni.createSelectorQuery().in(this).select("#contain").boundingClientRect(res => {
-								this.$emit('ready', res);
-							}).exec()
-					}
-					document.errorEvent = (target, source) => {
-						this.$emit('error', {
-							source,
-							target
-						});
-					}
-					document.setVideoContext = (videos) => {
-						this.videoContext = videos;
-					}
-					document.playEvent = (v) => {
-						if (this.autopause) {
-							for (var video of this.videoContext) {
-								if (video != v)
-									video.pause();
-							}
-						}
-					}
-					iframe.srcdoc = script + html;
-					this.showAnimation =
-						"opacity: 1; transition: opacity 400ms ease 0ms, -webkit-transform 400ms ease 0ms, transform 400ms ease 0ms; transform-origin: 50% 50% 0px;";
-					return;
-				}
-				// #endif
-				let showAnimation = {};
-				if (this.showWithAnimation) {
-					showAnimation = uni.createAnimation({
-						duration: this.animationDuration,
-						timingFunction: "ease"
-					}).opacity(1).step().export();
-				}
-				if (!html) {
-					this.nodes = [];
-				} else if (typeof html == 'string') {
-					html2nodes(html, this).then(res => {
-						// #ifdef APP-PLUS
-						this.loadVideo = false;
-						// #endif
-						this.nodes = res.nodes;
-						this.showAnimation = showAnimation;
-						this.imgList = res.imgList;
-						if (Document) this.document = new Document("nodes", res.nodes, this);
-						if (res.title && this.autosetTitle) {
-							uni.setNavigationBarTitle({
-								title: res.title
-							})
-						}
-						this.$emit('parser', res);
-						this.ready();
-					}).catch(err => {
-						this.$emit('error', {
-							source: "parse",
-							errMsg: err
-						});
-					})
-				} else if (html.constructor == Array) {
-					this.showAnimation = showAnimation;
-					this.imgList = [];
-					// #ifdef APP-PLUS
-					this.loadVideo = false;
-					// #endif
-					if (Document) this.document = new Document("html", html, this);
-					this.ready();
-				} else if (typeof html == 'object') {
-					if (!html.nodes || html.nodes.constructor != Array) {
-						if ((html.name && html.children && html.attrs) || (html.type == "text"))
-							return;
-						this.$emit('error', {
-							source: "parse",
-							errMsg: "传入的nodes数组格式不正确!应该传入的类型是array,实际传入的类型是:" + typeof html.nodes
-						});
-						return;
-					}
-					this.showAnimation = showAnimation;
-					this.imgList = html.imgList || [];
-					// #ifdef APP-PLUS
-					this.loadVideo = false;
-					// #endif
-					if (Document) this.document = new Document("html.nodes", html.nodes, this);
-					if (html.title && this.autosetTitle)
-						uni.setNavigationBarTitle({
-							title: html.title
-						})
-					this.ready();
-				} else {
-					this.$emit('error', {
-						source: "parse",
-						errMsg: "错误的html类型:" + typeof html
-					});
-				}
-			},
-			// #ifdef H5
-			Dom2Str(node) {
-				if (node.type == "text")
-					return node.text;
-				var elem = '<' + node.name;
-				for (var attr in node.attrs)
-					elem += (' ' + atts + '="' + node.attrs[attr] + '"');
-				elem += ">";
-				for (var child of node.children)
-					elem += Dom2Str(child);
-				elem += ("</" + node.name + ">");
-				return elem;
-			},
-			// #endif
-			// #ifndef H5
-			getContext(components) {
-				for (let component of components) {
-					let observered = false;
-					if (!component.nodes)
-						return this.getContext(component.$children);
-					for (let item of component.nodes) {
-						// #ifndef MP-ALIPAY
-						if (item.name == 'img' && !observered) {
-							observered = true;
-							if (component.lazyLoad && CanIUseObserver) {
-								component._observer = uni.createIntersectionObserver(component);
-								component._observer.relativeToViewport({
-									top: 1000,
-									bottom: 1000
-								}).observe('.img', res => {
-									component.imgLoad = true;
-									component._observer.disconnect();
-									component._observer = null;
-								})
-							} else
-								component.imgLoad = true;
-						} else if (item.name == 'video') {
-							this.videoContext.push({
-								id: item.attrs.id,
-								context: uni.createVideoContext(item.attrs.id, component)
-							});
-						}
-						// #endif
-						// #ifdef MP-BAIDU || MP-ALIPAY
-						if (item.attrs && item.attrs.id) {
-							this.anchors.push({
-								id: item.attrs.id,
-								node: component
-							})
-						}
-						// #endif
-					}
-					this.getContext(component.$children);
-				}
-			},
-			// #endif
-			ready() {
-				this.$nextTick(() => {
-					this.navigateTo = (obj) => {
-						obj.success = obj.success || function() {};
-						obj.fail = obj.fail || function() {};
-						var Scroll = (selector,component) => {
-							const query = uni.createSelectorQuery().in(component?component:this);
-							query.select(selector).boundingClientRect();
-							query.selectViewport().scrollOffset();
-							query.exec(res => {
-								if (!res || !res[0])
-									return obj.fail({
-										errMsg: "Label Not Found"
-									});
-								uni.pageScrollTo({
-									scrollTop: res[1].scrollTop + res[0].top,
-									success: obj.success,
-									fail: obj.fail
-								})
-							})
-						}
-						if (!obj.id) Scroll(".contain");
-						else {
-							// #ifndef MP-BAIDU || MP-ALIPAY
-							Scroll('.contain >>> #' + obj.id);
-							// #endif
-							// #ifdef MP-BAIDU || MP-ALIPAY
-							for (var anchor of this.anchors) {
-								if (anchor.id == obj.id) {
-									Scroll("#" + obj.id, anchor.node);
-								}
-							}
-							// #endif
-						}
-					}
-					uni.createSelectorQuery().in(this).select(".contain").boundingClientRect(res => {
-						this.$emit("ready", res);
-					}).exec()
-					// #ifndef H5
-					this.getContext(this.$children);
-					// #endif
-					// #ifdef APP-PLUS
-					setTimeout(() => {
-						this.loadVideo = true;
-					}, 2000);
-					// #endif
-				})
-			}
-		},
-		watch: {
-			html(html) {
-				this.execHtml(html);
-			}
-		}
-	}
-</script>
-
-<style>
-	/* #ifndef MP-BAIDU */
-	:host {
-		display: block;
-		overflow: scroll;
-		-webkit-overflow-scrolling: touch;
-	}
-
-	/* #endif */
-</style>

+ 0 - 363
components/jyf-Parser/trees.vue

@@ -1,363 +0,0 @@
-<template>
-	<view style="display: inherit;white-space: inherit;">
-		<block v-for='(item, index) in nodes' v-bind:key='index'>
-			<!--#ifdef MP-WEIXIN || MP-QQ || APP-PLUS || MP-ALIPAY-->
-			<block v-if="handler.isContinue(item)">
-				<!--#endif-->
-				<!--#ifdef MP-BAIDU || MP-TOUTIAO || H5-->
-				<block v-if="!item.continue">
-					<!--#endif-->
-					<!--图片-->
-					<!--#ifdef MP-WEIXIN || MP-QQ || APP-PLUS-->
-					<rich-text v-if="item.name=='img'" :id="item.attrs.id||''" class="img" :style="'text-indent:0;'+handler.getStyle(item.attrs.style,'inline-block')"
-					 :nodes='handler.setImgStyle(item,imgMode,imgLoad)' :data-ignore='item.attrs.ignore' :data-src='item.attrs.src'
-					 :data-current='item.current' @tap='previewEvent' />
-					<!--#endif-->
-					<!--#ifdef MP-ALIPAY-->
-					<rich-text v-if="item.name=='img'" :id="item.attrs.id||''" :style="'text-indent:0;'+handler.getStyle(item.attrs.style,'inline-block')"
-					 :nodes='handler.setImgStyle(item,imgMode)' :data-ignore='item.attrs.ignore' :data-src='item.attrs.src'
-					 :data-current='item.current' @tap='previewEvent' />
-					<!--#endif-->
-					<!--#ifdef MP-BAIDU || MP-TOUTIAO || H5-->
-					<rich-text v-if="item.name=='img'" :id="item.attrs.id||''" :style="'text-indent:0;'+item.attrs.containStyle" :nodes='[item]' :data-ignore='item.attrs.ignore'
-					 :data-src='item.attrs.src' :data-current='item.current' @tap='previewEvent' />
-					<!--#endif-->
-					<!--文本-->
-					<!--#ifdef MP-WEIXIN || MP-QQ || H5 || APP-PLUS-->
-					<block v-else-if="item.type=='text'">
-						<text v-if="!item.decode" decode>{{item.text}}</text>
-						<rich-text v-else style="display:inline-block" :nodes="[item]"></rich-text>
-					</block>
-					<!--#endif-->
-					<!--#ifdef MP-ALIPAY-->
-					<text v-else-if="item.type=='text'" decode>{{item.text}}</text>
-					<!--#endif-->
-					<text v-else-if="item.name=='br'">\n</text>
-					<!--视频-->
-					<block v-else-if="item.name=='video'">
-						<!--#ifdef APP-PLUS-->
-						<view v-if="(!loadVideo||item.attrs.id[item.attrs.id.length-1]>'3')&&(!controls[item.attrs.id]||!controls[item.attrs.id].play)"
-						 :class="'pvideo '+(item.attrs.class||'')" :style="item.attrs.style" :data-id="item.attrs.id" @tap="_loadVideo">
-							<view class="video-triangle"></view>
-						</view>
-						<!--#endif-->
-						<!--#ifndef APP-PLUS-->
-						<view v-if="item.attrs.id[item.attrs.id.length-1]>'3'&&(!controls[item.attrs.id]||!controls[item.attrs.id].play)"
-						 :class="'pvideo '+(item.attrs.class||'')" :style="item.attrs.style" :data-id="item.attrs.id" @tap="_loadVideo">
-							<view class="video-triangle"></view>
-						</view>
-						<!--#endif-->
-						<video v-else :src='controls[item.attrs.id]?item.attrs.source[controls[item.attrs.id].index]:item.attrs.src' :id="item.attrs.id||''"
-						 :loop='item.attrs.loop' :controls='item.attrs.controls' :autoplay="item.attrs.autoplay||(controls[item.attrs.id]&&controls[item.attrs.id].play)"
-						 :unit-id="item.attrs['unit-id']" :class="'v '+(item.attrs.class||'')" :muted="item.attrs.muted" :style="item.attrs.style"
-						 :data-id="item.attrs.id" :data-source="item.attrs.source" @play='playEvent' @error="videoError" />
-					</block>
-					<!--音频-->
-					<audio v-else-if="item.name=='audio'" :src='controls[item.attrs.id]?item.attrs.source[controls[item.attrs.id].index]:item.attrs.src'
-					 :id="item.attrs.id||''" :loop='item.attrs.loop' :controls='item.attrs.controls' :poster='item.attrs.poster' :name='item.attrs.name'
-					 :author='item.attrs.author' :class="item.attrs.class||''" :style="item.attrs.style" :data-id="item.attrs.id"
-					 :data-source="item.attrs.source" @error="audioError" />
-					<!--链接-->
-					<view v-else-if="item.name=='a'" :class="'a '+(item.attrs.class||'')" :style="item.attrs.style" :data-href='item.attrs.href'
-					 hover-class="navigator-hover" :hover-start-time="25" :hover-stay-time="300" @tap="tapEvent">
-						<!--#ifdef H5-->
-						<trees :nodes="item.children" :imgMode="imgMode" />
-						<!--#endif-->
-						<!--#ifndef H5-->
-						<trees :nodes="item.children" :imgMode="imgMode" :lazyLoad="lazyLoad" :loadVideo="loadVideo" />
-						<!--#endif-->
-					</view>
-					<!--广告-->
-					<!--#ifdef MP-WEIXIN || MP-QQ-->
-					<ad v-else-if="item.name=='ad'" :unit-id="item.attrs['unit-id']" :class="item.attrs.class||''" :style="item.attrs.style"
-					 @error="adError"></ad>
-					<!--#endif-->
-					<!--#ifdef MP-BAIDU-->
-					<ad v-else-if="item.name=='ad'" :appid="item.attrs.appid" :apid="item.attrs.apid" :type="item.attrs.type" :class="item.attrs.class||''"
-					 :style="item.attrs.style" @error="adError"></ad>
-					<!--#endif-->
-					<!--富文本-->
-					<!--#ifdef MP-WEIXIN || MP-QQ || MP-ALIPAY || APP-PLUS-->
-					<rich-text v-else :id="item.attrs.id||''" :class="item.name" :style="''+handler.getStyle(item.attrs.style,'block')" :nodes="handler.setStyle(item)" />
-					<!--#endif-->
-					<!--#ifdef MP-BAIDU || MP-TOUTIAO || H5-->
-					<rich-text v-else :id="item.attrs.id||''" :class="item.name" :style="item.attrs?item.attrs.containStyle:''" :nodes="[item]" />
-					<!--#endif-->
-				</block>
-				<!--#ifdef MP-ALIPAY || H5-->
-				<view v-else :id="item.attrs.id||''" :class="item.name+' '+(item.attrs.class||'')" :style="item.attrs.style">
-					<trees :nodes="item.children" :imgMode="imgMode" />
-				</view>
-				<!--#endif-->
-				<!--#ifndef MP-ALIPAY || H5-->
-				<trees v-else :id="item.attrs.id||''" :class="item.name+' '+(item.attrs.class||'')" :style="item.attrs.style" :nodes="item.children"
-				 :imgMode="imgMode" :lazyLoad="lazyLoad" :loadVideo="loadVideo" />
-				<!--#endif-->
-			</block>
-	</view>
-</template>
-<script module="handler" lang="wxs" src="./handler.wxs"></script>
-<script module="handler" lang="sjs" src="./handler.sjs"></script>
-<script>
-	import trees from "./trees"
-	export default {
-		components: {
-			trees
-		},
-		name: 'trees',
-		data() {
-			return {
-				controls: {},
-				// #ifdef MP-WEIXIN || MP-QQ || APP-PLUS
-				imgLoad: false
-				// #endif
-			}
-		},
-		props: {
-			nodes: {
-				type: Array,
-				default: []
-			},
-			// #ifdef MP-WEIXIN || MP-QQ || APP-PLUS
-			lazyLoad: {
-				type: Boolean,
-				default: false
-			},
-			// #endif
-			// #ifdef APP-PLUS
-			loadVideo: {
-				type: Boolean,
-				default: false
-			},
-			// #endif
-			imgMode: {
-				type: String,
-				default: "default"
-			}
-		},
-		mounted() {
-			// 获取顶层组件
-			this._top = this.$parent;
-			while (this._top.$options.name != 'parser') {
-				if (this._top._top) {
-					this._top = this._top._top;
-					break;
-				}
-				this._top = this._top.$parent;
-			}
-		},
-		// #ifdef MP-WEIXIN || MP-QQ || APP-PLUS
-		beforeDestroy() {
-			if (this._observer)
-				this._observer.disconnect();
-		},
-		// #endif
-		methods: {
-			// #ifndef MP-ALIPAY
-			playEvent(e) {
-				if (this._top.videoContext.length > 1 && this._top.autopause) {
-					for (let video of this._top.videoContext) {
-						if (video.id == e.currentTarget.dataset.id) continue;
-						video.context.pause();
-					}
-				}
-			},
-			// #endif
-			previewEvent(e) {
-				if (!e.currentTarget.dataset.ignore) {
-					var preview = true;
-					this._top.$emit('imgtap', {
-						id: e.target.id,
-						src: e.currentTarget.dataset.src,
-						ignore: () => preview = false
-					});
-					if (preview && this._top.autopreview) {
-						uni.previewImage({
-							current: parseInt(e.currentTarget.dataset.current),
-							urls: this._top.imgList.length ? this._top.imgList : [e.currentTarget.dataset.src]
-						});
-					}
-				}
-			},
-			tapEvent(e) {
-				var jump = true;
-				this._top.$emit('linkpress', {
-					href: e.currentTarget.dataset.href,
-					ignore: () => jump = false
-				});
-				if (jump && e.currentTarget.dataset.href) {
-					if (e.currentTarget.dataset.href[0]) {
-						if (this._top.useAnchor)
-							this._top.navigateTo({
-								id: e.currentTarget.dataset.href.substring(1)
-							})
-					} else if (/^http/.test(e.currentTarget.dataset.href)) {
-						if (this._top.autocopy) {
-							// #ifndef H5
-							uni.setClipboardData({
-								data: e.currentTarget.dataset.href,
-								success() {
-									uni.showToast({
-										title: '链接已复制'
-									});
-								}
-							});
-							// #endif
-							// #ifdef H5
-							window.location.href = e.currentTarget.dataset.href;
-							// #endif
-						}
-					} else
-						uni.navigateTo({
-							url: e.currentTarget.dataset.href
-						})
-				}
-			},
-			triggerError(source, target, errMsg, errCode) {
-				this._top.$emit('error', {
-					source,
-					target,
-					errMsg,
-					errCode
-				});
-			},
-			loadSource(currentTarget) {
-				if (!this.controls[currentTarget.id] && currentTarget.source.length > 1) {
-					this.$set(this.controls, currentTarget.id, {
-						play: false,
-						index: 1
-					})
-				} else if (this.controls[currentTarget.id] && currentTarget.source.length > this.controls[
-						currentTarget.id].index + 1) {
-					this.$set(this.controls[currentTarget.id], "index", this.controls[currentTarget.id].index + 1);
-				}
-			},
-			adError(e) {
-				this.triggerError("ad", e.currentTarget, "", e.detail.errorCode);
-			},
-			videoError(e) {
-				this.loadSource(e.currentTarget.dataset);
-				this.triggerError("video", e.currentTarget, e.detail.errMsg);
-			},
-			audioError(e) {
-				this.loadSource(e.currentTarget.dataset);
-				this.triggerError("audio", e.currentTarget, e.detail.errMsg);
-			},
-			_loadVideo(e) {
-				this.$set(this.controls, e.currentTarget.dataset.id, {
-					play: true,
-					index: 0
-				})
-			}
-		}
-	}
-</script>
-
-<style>
-	/* 可以在这里引入自定义的外部样式 */
-
-	/* 链接受到点击的hover-class,可自定义修改 */
-	.navigator-hover {
-		opacity: 0.7;
-		text-decoration: underline;
-	}
-
-	/* 以下内容不建议修改 */
-	:host {
-		display: inherit;
-		float: inherit;
-	}
-
-	.a {
-		display: inline;
-		color: #366092;
-	}
-
-	/* #ifdef MP-WEIXIN || MP-QQ || MP-ALIPAY */
-	.sub,
-	.sup,
-	.bdo,
-	.bdi,
-	.ruby,
-	.rt {
-		display: inline-block !important;
-	}
-
-	/* #endif */
-
-	.div,
-	.blockquote,
-	.p {
-		display: block;
-	}
-
-	.b,
-	.strong {
-		display: inline;
-		font-weight: bold;
-	}
-
-	.em,
-	.i {
-		display: inline;
-		font-style: italic;
-	}
-
-	.del {
-		display: inline;
-		text-decoration: line-through;
-	}
-
-	.ins {
-		display: inline;
-		text-decoration: underline;
-	}
-
-	.code {
-		display: inline;
-		font-family: monospace;
-	}
-
-	.big {
-		font-size: 1.2em;
-		display: inline;
-	}
-
-	.small {
-		font-size: 0.8em;
-		display: inline;
-	}
-
-	.q,
-	.span,
-	.label,
-	.abbr {
-		display: inline;
-	}
-
-	.q::before {
-		content: '"';
-	}
-
-	.q::after {
-		content: '"';
-	}
-
-	.pvideo {
-		background-color: black;
-		width: 300px;
-		height: 225px;
-		display: inline-block;
-		position: relative;
-	}
-
-	.video-triangle {
-		border-width: 15px 0 15px 30px;
-		border-style: solid;
-		border-color: transparent transparent transparent white;
-		position: absolute;
-		left: 50%;
-		top: 50%;
-		margin: -15px 0 0 -15px;
-	}
-</style>

+ 1 - 2
pages/goods/components/cm-return-instructions.vue

@@ -52,8 +52,7 @@ export default {
         color: #666666;
 
         .iconfont {
-            font-size: 28rpx;
-            color: #666;
+            color: #b2b2b2;
         }
     }
 }

+ 3 - 3
pages/goods/instrument-details.vue

@@ -49,7 +49,7 @@
 			</view>	
 			<view class="product-details service" v-show="tabCurrentIndex == 0">
 				<view class="content tui-banner product-rich-text tui-skeleton-rect">
-					<parser :html="html" :img-mode="widthFix"></parser>
+					<mp-html :content="html" :tag-style="tagStyle" />
 				</view>
 			</view>	
 			<view class="product-details service" v-show="tabCurrentIndex == 1">
@@ -129,20 +129,20 @@
 <script>
 	import { mapState,mapMutations } from 'vuex'
 	import authorize from '@/common/config/authorize.js'
-	import parser from "@/components/jyf-Parser/index" //富文本处理
 	import customP from '@/components/cm-custom/custom-p.vue' 		 //自定义导航
 	import recommend from "./components/instrument-recommend" //相关推荐
 	import wxLogin from "@/common/config/wxLogin.js"
+	import { productTagStyle } from '@/plugins/mp-html/config.js'
 	var isPreviewImg;
 	export default{
 		components:{
 			customP,
-			parser,
 			recommend,
 		},
 		data(){
 			return{			
 				html:'<div style="text-align: center;color:#333333;">暂无内容</div>',
+				tagStyle: productTagStyle,
 				disabledTabNavList:[{name:'相关推荐'}],
 				mode:'round',
 				iconClass:'icon-aixin',

+ 2 - 12
pages/goods/mixins/proMixins.js

@@ -1,6 +1,5 @@
-// 统计数据
-// 统计类型 1:首页banner;2:直播模块;3:最新活动;4:热门文章;5:新品橱窗;6:活动列表
 import Vue from 'vue'
+import { productTagStyle } from '@/plugins/mp-html/config.js'
 const proMixins = {
     data() {
         return {
@@ -13,16 +12,7 @@ const proMixins = {
                 userId: 0,
                 source: 1
             },
-            tagStyle:{
-                div:'line-height: 58rpx;margin-bottom: 10rpx;font-size: 28rpx;',
-                h4:'line-height: 54rpx;font-size: 30rpx;color:#666666;padding: 0 20rpx;font-weight: normal;',
-                h3:'line-height: 54rpx;font-size: 30rpx;color:#666666;padding: 0 20rpx;font-weight: normal;',
-                h2:'line-height: 54rpx;font-size: 30rpx;color:#666666;padding: 0 20rpx;font-weight: normal;',
-                p:'line-height: 54rpx;font-size: 30rpx;color:#666666;padding: 0 20rpx;',
-                a:'line-height: 54rpx;font-size: 30rpx;color:#666666;',
-                span:'line-height: 54rpx;font-size: 30rpx;color:#666666;',
-                img:'width: 100%;height: auto;'
-            }
+            tagStyle:productTagStyle
         }
     },
     methods: {

+ 0 - 3
pages/goods/product.vue

@@ -273,7 +273,6 @@
 						<view class="title"> <view class="title-tab">商品详情</view> </view>
 						<view class="content tui-banner product-rich-text tui-skeleton-rect">
 							<template v-if="!goodsData.isNoneDisabled && product.productDetail.detailInfo">
-								<!-- <parser :html="html" :img-mode="widthFix"></parser> -->
 								<mp-html :content="html" :tag-style="tagStyle" />
 							</template>
 							<view class="product-rich-text-none" v-else>暂无商品信息</view>
@@ -599,7 +598,6 @@
 <script>
 import { mapState, mapMutations } from 'vuex'
 import customP from './components/cm-header.vue' //自定义导航
-import parser from '@/components/jyf-Parser/index' //富文本处理
 import cmPrice from './components/cm-price.vue' //价格显示
 import cmAttributes from './components/cm-attributes.vue' //规格信息
 import cmRecommend from './components/recommend' //相关推荐
@@ -624,7 +622,6 @@ export default {
 	mixins: [payMixins,proMixins,cmSrsMixins],
 	components: {
 		customP,
-		parser,
 		cmRecommend,
 		cmPrice,
 		cmAttributes,

+ 21 - 0
plugins/mp-html/config.js

@@ -0,0 +1,21 @@
+// 富文本文案样式 公告文章 商品详情 项目详情
+export const productTagStyle = {
+    div: 'line-height: 58rpx;margin-bottom: 10rpx;font-size: 28rpx;',
+    h4: 'line-height: 54rpx;font-size: 30rpx;color:#666666;padding: 0 20rpx;font-weight: normal;',
+    h3: 'line-height: 54rpx;font-size: 30rpx;color:#666666;padding: 0 20rpx;font-weight: normal;',
+    h2: 'line-height: 54rpx;font-size: 30rpx;color:#666666;padding: 0 20rpx;font-weight: normal;',
+    p: 'line-height: 54rpx;font-size: 30rpx;color:#666666;padding: 0 20rpx;',
+    a: 'line-height: 54rpx;font-size: 30rpx;color:#666666;',
+    span: 'line-height: 54rpx;font-size: 30rpx;color:#666666;',
+    img: 'width: 100%;height: auto;'
+}
+export const articleTagStyle = {
+    div:'line-height: 58rpx;margin-bottom: 10rpx;font-size: 28rpx;',
+    h4:'line-height: 54rpx;font-size: 30rpx;color:#666666;',
+    h3:'line-height: 54rpx;font-size: 30rpx;color:#666666;',
+    h2:'line-height: 54rpx;font-size: 30rpx;color:#666666;',
+    p:'line-height: 50rpx;font-size: 30rpx;color:#666666;',
+    a:'line-height: 50rpx;font-size: 30rpx;color:#666666;',
+    span:'line-height: 50rpx;font-size: 30rpx;color:#666666;',
+    img:'width: 100%;height: auto;'
+}