课程说明
This commit is contained in:
@@ -2,20 +2,22 @@
|
||||
<view>
|
||||
<!-- 公共组件-每个页面必须引入 -->
|
||||
<public-module></public-module>
|
||||
<z-nav-bar title="消息详情"></z-nav-bar>
|
||||
<z-nav-bar title="新闻详情"></z-nav-bar>
|
||||
<view class="box">
|
||||
<view class="title">
|
||||
{{news.title}}
|
||||
</view>
|
||||
<view class="content" v-html="news.content"></view>
|
||||
<!-- <view class="content" v-html="news.content"></view> -->
|
||||
<rich-text v-if="news.content" class="content"
|
||||
:nodes="formatRichText(news.content)"></rich-text>
|
||||
</view>
|
||||
|
||||
<music-play :playData="playData"></music-play>
|
||||
<web-view v-if="urlVisible" :webview-styles="webviewStyles" :src="surl"></web-view>
|
||||
<!-- <music-play :playData="playData"></music-play> -->
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import musicPlay from '@/components/music.vue'
|
||||
// import musicPlay from '@/components/music.vue'
|
||||
import $http from '@/config/requestConfig.js';
|
||||
var clear;
|
||||
import {
|
||||
@@ -25,18 +27,28 @@
|
||||
data() {
|
||||
return {
|
||||
playData: {},
|
||||
newsId: null,
|
||||
newsObj: null,
|
||||
news: {
|
||||
content: '',
|
||||
title: ''
|
||||
}
|
||||
},
|
||||
urlVisible:false,
|
||||
surl:'',
|
||||
type:null,
|
||||
webviewStyles: {
|
||||
progress: {
|
||||
color: '#FF3333'
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
//第一次加载
|
||||
onLoad(e) {
|
||||
// 隐藏原生的tabbar
|
||||
uni.hideTabBar();
|
||||
this.newsId = e.newsid
|
||||
this.newsId = e.newsId
|
||||
this.type = e.type
|
||||
this.surl = e.url
|
||||
console.log(e, '------')
|
||||
},
|
||||
computed: {
|
||||
@@ -46,11 +58,19 @@
|
||||
onShow() {
|
||||
// 隐藏原生的tabbar
|
||||
uni.hideTabBar();
|
||||
this.getData();
|
||||
if(this.type == 1 && this.surl != ''){
|
||||
// this.surl = this.newsObj.url
|
||||
this.urlVisible = true
|
||||
this.news = {}
|
||||
}else{
|
||||
this.getData();
|
||||
this.urlVisible = false
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
components: {
|
||||
musicPlay
|
||||
// musicPlay
|
||||
},
|
||||
//方法
|
||||
methods: {
|
||||
@@ -65,7 +85,28 @@
|
||||
}).catch(e => {
|
||||
console.log(e, '获取新闻详情报错')
|
||||
});
|
||||
}
|
||||
},
|
||||
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(/<img[^>]*>/gi, function(match, capture) {
|
||||
// match = match.replace(/<img[^>]*>/gi, "@click='1111'").replace(/<img[^>]*>/gi, "@click='1111'");
|
||||
// return match;
|
||||
// });
|
||||
newContent = newContent.replace(/<br[^>]*\/>/gi, '');
|
||||
newContent = newContent.replace(/\<img/gi,
|
||||
'<img style="max-width:100%;height:auto;display:inline-block;margin:10rpx auto;"');
|
||||
return newContent;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@@ -73,7 +114,7 @@
|
||||
@import '@/style/mixin.scss';
|
||||
|
||||
.box {
|
||||
background-color: #fff;
|
||||
background-color: #fff;
|
||||
@include pleft_right(10px);
|
||||
min-height: calc(100vh - 270rpx);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user