Browse Source

文章详情

master
Enzo 4 years ago
parent
commit
8ac41fc494
  1. 44
      pages/article/details.vue

44
pages/article/details.vue

@ -1,22 +1,22 @@
<template> <template>
<view>
<view v-if="$isRight(title_content)">
<lf-nav :spreadOut="true" :showIcon="true" bgColor="#F8F8F8" title="文章详情"></lf-nav> <lf-nav :spreadOut="true" :showIcon="true" bgColor="#F8F8F8" title="文章详情"></lf-nav>
<view style="height: 30rpx;"></view> <view style="height: 30rpx;"></view>
<view class="lf-m-l-32 lf-m-r-32"> <view class="lf-m-l-32 lf-m-r-32">
<view> <view>
<view class="lf-font-36 lf-color-222 lf-m-b-20 lf-font-bold"> <view class="lf-font-36 lf-color-222 lf-m-b-20 lf-font-bold">
苦等一年阳澄湖大闸蟹又肥了让你安心吃螃蟹的文章也来了
{{title_content.article.title}}
</view> </view>
<view class="lf-flex lf-m-b-24"> <view class="lf-flex lf-m-b-24">
<view class="lf-font-28" style="color: #2D6361;"> <view class="lf-font-28" style="color: #2D6361;">
金诚优选线上商城
{{title_content.article.author}}
</view> </view>
<view class="lf-color-777 lf-font-28 lf-m-l-25"> <view class="lf-color-777 lf-font-28 lf-m-l-25">
2021.09.01 16:28:22
{{title_content.article.created_at}}
</view> </view>
</view> </view>
</view> </view>
<rich-text :nodes="content" v-if="content"></rich-text>
<rich-text :nodes="formatRichText(content)" v-if="content"></rich-text>
<!-- <lf-nocontent v-else></lf-nocontent> --> <!-- <lf-nocontent v-else></lf-nocontent> -->
<!-- 回到顶部 --> <!-- 回到顶部 -->
<u-back-top :scroll-top="pageScrollTop" :custom-style="{background: 'rgba(51, 51 51, 0.3)'}"></u-back-top> <u-back-top :scroll-top="pageScrollTop" :custom-style="{background: 'rgba(51, 51 51, 0.3)'}"></u-back-top>
@ -36,15 +36,39 @@
onLoad(e){ onLoad(e){
this.notice_id = e.notice_id; this.notice_id = e.notice_id;
if(this.notice_id) { if(this.notice_id) {
// this.getData();
this.getData();
} }
}, },
methods: { 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(){ getData(){
this.$http(this.API.API_NOTICEDETAILS,{id:this.notice_id}).then(res => {
this.content = res.data?.content;
this.title_content = res.data
})
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)
});
} }
} }
} }

Loading…
Cancel
Save