| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279 | <template>	<view class="content2">       <view style="height: 72px;"></view>		<view class="top">			<view class="topline" @click="goIndex">首页</view>			<view class="topjt">></view>			<view class="topline" :class="{'c999':!twoName}" @click="goList()">{{topName}}</view>			<view class="topjt" v-if="twoName">></view>			<view class="topline" :class="{'c999':twoName}">{{twoName}}</view>		</view>		<view class="htmlBox">			<view class="htmlTitle">{{detailData.name}}</view>			<view class="time">{{detailData.publishTime}}</view>			<view class="html" v-html="detailData.contents"></view>		</view>		<view class="itemArr" v-if="itemArr.length>0">		  <view class="itemArrLine" :class="{'itemArrLineBottom':itemArr.length!=(index+1)}" v-for="(item,index) in itemArr">			  <view class="itemArrLeft" >				  <image src="../../static/pcimg/icon_fujian@2x.png" mode="" class="fileIcon"></image>				  <view class="fileName" @click="gofile(item.fileUrl)">{{item.fileName}}</view>			  </view>			<!-- <view class="dload">				  <a class="dloadbtn" :href="item.fileUrl" target='_blank' >下载</a>			  </view> -->		  </view>		</view>		<view class="lbel" v-if="topName">			<view class="topName" @click="goList">{{topName}}</view>		</view>       	</view></template><script>		export default {       props: ['newid','data'],		data() {			return {				id: '',				detailData: {},				couContent: '',				itemArr: [],				topName:'',				twoName:'',				comment:'',				parentCode:'',			}		},		watch:{			newid(newValue, oldValue){				console.log(newValue);				this.id = newValue				this.topName=this.data.categoryName;				this.twoName=this.data.twoName;				this.comment=this.data.comment;				this.parentCode=this.data.code				this.getDetailData() 				// uni.setNavigationBarTitle({				// 	title: this.topName				// })				uni.pageScrollTo({				   scrollTop: 0, duration: 100 				}); 			}		},		onLoad(opt) {			console.log('opt', opt);			/* this.id = opt.id            this.topName=opt.topName;			this.twoName=opt.twoName;			this.comment=opt.comment;			this.parentCode=opt.parentCode			this.getDetailData() */			// uni.setNavigationBarTitle({			// 	title: this.topName			// })		},		created() {			this.newidfn()		},		methods: {			newidfn(){				this.id = this.data.id				this.topName=this.data.categoryName;				this.twoName=this.data.twoName;				this.comment=this.data.comment;				this.parentCode=this.data.code				this.getDetailData() 				uni.pageScrollTo({				   scrollTop: 0, duration: 100 				}); 			},			test(){				console.log(55)			},			gofile(url){				window.location.href=url			},			goList(){				var code=this.parentCode.substring(0,3)				uni.navigateTo({					url:'list?code='+code+'&topName='+this.topName+'&comment='+this.comment				})			},             goIndex(){				this.$emit("getIndexList")			 },			getDetailData() {				uni.showLoading({					title: '加载中'				})				let url = '/trainingOpenApi/articleDetail',					params = {						id: this.id,					}				this.$http(url, params, 'GET').then(res => {					uni.hideLoading();					var data = res.data					// 处理 undefined和null转为空白字符串					for (const key in data) {						data[key] = this.$praseStrEmpty(data[key])					}					this.detailData = data;					uni.setNavigationBarTitle({					    title: this.detailData.title					});					console.log()					if (this.detailData.contents) {						var replaceStr = "application/x-shockwave-flash"					    this.detailData.contents=this.detailData.contents.replace(new RegExp(replaceStr,'gm'),'video/webm')//(/''/g,"video/webm")					    this.detailData.contents=this.detailData.contents.replace(/<embed([\s\w"-=\/\.:;]+)/ig, '<embed style="width: 100%;height:500px;" $1');					}					 if (this.detailData.contents) {						this.detailData.contents = this.detailData.contents.replace(								/<p([\s\w"=\/\.:;]+)((?:(style="[^"]+")))/ig, '<p')							.replace(/<p>/ig, '<p style="font-size: 15px; line-height: 25px;">')							.replace(/<img([\s\w"-=\/\.:;]+)((?:(height="[^"]+")))/ig, '<img$1')							.replace(/<img([\s\w"-=\/\.:;]+)((?:(width="[^"]+")))/ig, '<img$1')							.replace(/<img([\s\w"-=\/\.:;]+)((?:(style="[^"]+")))/ig, '<img$1')							.replace(/<img([\s\w"-=\/\.:;]+)((?:(alt="[^"]+")))/ig, '<img$1')							.replace(/<img([\s\w"-=\/\.:;]+)/ig, '<img style="width: 100%;" $1');													this.detailData.contents = this.detailData.contents.replace(								/<p([\s\w"=\/\.:;]+)((?:(style="[^"]+")))/ig, '<p')							.replace(/<p>/ig, '<p style="font-size: 15px; line-height: 25px;">')							.replace(/<iframe([\s\w"-=\/\.:;]+)((?:(width="[^"]+")))/ig, '<iframe$1')							.replace(/<iframe([\s\w"-=\/\.:;]+)((?:(style="[^"]+")))/ig, '<iframe$1')							.replace(/<iframe([\s\w"-=\/\.:;]+)((?:(alt="[^"]+")))/ig, '<iframe$1')							.replace(/<iframe([\s\w"-=\/\.:;]+)/ig, '<iframe style="width: 100%;height:500px;" $1');					}					this.itemArr = this.detailData.fileList                     console.log(this.itemArr)				})			},						// }		}	}</script><style scoped>	.top{		width: 1200px;		margin: 0 auto;		display: flex;		padding: 30px 0;		font-size: 14px;	}	.content2{		font-family: PingFangSC-Regular, PingFang SC;background: #FFFFFF;		min-height: 100vh;	}	.htmlBox{		width: 720px;		margin: 0 auto;	}	.topline{		padding-right: 10px;		cursor: pointer;		color: #3C3C3C;	}	.topjt{		color: #AAAAAA;		padding-right: 10px;	}	.htmlTitle{		font-size: 24px;		font-weight: 500;		color: #3C3C3C;		line-height: 33px;		font-family: PingFangSC-Medium, PingFang SC;	}	.time{		font-size: 14px;		padding-top: 16px;		color: #999999;		line-height: 20px;		border-bottom: 1px solid #EEEEEE;		padding-bottom: 19px;	}	.html{		padding-top: 18px;	}	.fileIcon{		width: 14px;		height: 14px;		margin-top: 4px;		margin-right: 4px;	}	.itemArrLeft{		display: flex;	}	.itemArrLine{		display: flex;		justify-content: space-between;		padding: 16px 0;				color: #333333;		line-height: 22px;		font-size: 16px;		width: 720px;	}	.itemArrLineBottom{		border-bottom: 1px solid #EEEEEE;	}	.itemArr{		width: 686px;		margin: 0 auto;		margin-top: 30px;		border-radius: 6px;		border: 1px solid #EEEEEE;		padding: 0 16px;			}	.dloadbtn{		display: block;		width: 68px;		height: 28px;		background: #3F90F7;		border-radius: 6px;		color: #FFFFFF;		text-align: center;		line-height:28px ;		font-size: 14px;		text-decoration:none;	}	.lbel{		width: 720px;		margin: 0 auto;		margin-top: 30px;		padding-bottom: 30px;	}	.topName{		width: 84px;		height: 24px;		background: rgba(63, 144, 247, 0.1);		border-radius: 14px;		font-size: 14px;		color: #3F90F7;		line-height: 24px;		text-align: center;		cursor: pointer;	}	.fileName{		text-decoration:underline;		color: #3F90F7;	}	.c999{		color: #999999;	}</style>
 |