You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
2.3 KiB
78 lines
2.3 KiB
<template>
|
|
<view v-if="$isRight(title_content)">
|
|
<lf-nav :spreadOut="true" :showIcon="true" bgColor="#F8F8F8" title="文章详情"></lf-nav>
|
|
<view style="height: 30rpx;"></view>
|
|
<view class="lf-m-l-32 lf-m-r-32">
|
|
<view>
|
|
<view class="lf-font-36 lf-color-222 lf-m-b-20 lf-font-bold">
|
|
{{title_content.article.title}}
|
|
</view>
|
|
<view class="lf-flex lf-m-b-24">
|
|
<view class="lf-font-28" style="color: #2D6361;">
|
|
{{title_content.article.author}}
|
|
</view>
|
|
<view class="lf-color-777 lf-font-28 lf-m-l-25">
|
|
{{title_content.article.created_at}}
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<rich-text :nodes="formatRichText(content)" v-if="content"></rich-text>
|
|
<!-- <lf-nocontent v-else></lf-nocontent> -->
|
|
<!-- 回到顶部 -->
|
|
<u-back-top :scroll-top="pageScrollTop" :custom-style="{background: 'rgba(51, 51 51, 0.3)'}"></u-back-top>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data(){
|
|
return {
|
|
content: '',
|
|
notice_id: 0,
|
|
title_content: ''
|
|
}
|
|
},
|
|
onLoad(e){
|
|
this.notice_id = e.notice_id;
|
|
if(this.notice_id) {
|
|
this.getData();
|
|
}
|
|
},
|
|
methods: {
|
|
// 富文本处理
|
|
formatRichText(richText){
|
|
if(richText != null){
|
|
let newRichText= richText.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;
|
|
});
|
|
newRichText = newRichText.replace(/style="[^"]+"/gi,function(match, capture){
|
|
match = match.replace(/width:[^;]+;/gi, 'width:100%;').replace(/width:[^;]+;/gi, 'width:100%;');
|
|
return match;
|
|
});
|
|
newRichText = newRichText.replace(/<br[^>]*\/>/gi, '');
|
|
newRichText = newRichText.replace(/\<img/gi, '<img style="width:100%;height:auto;display:block;margin:10px 0;"');
|
|
return newRichText;
|
|
}else{
|
|
return null;
|
|
}
|
|
},
|
|
getData(){
|
|
this.$http.get({
|
|
api: '/api/article/detail/'+this.notice_id
|
|
}).then(res => {
|
|
this.content = res.data.data?.article.article_detail;
|
|
this.title_content = res.data.data
|
|
|
|
console.log(res.data)
|
|
});
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
</style>
|