1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <template>
- <view class="detail main-bg">
- <view class="title font-thirty font-color3">
- {{list.noticeTitle}}
- </view>
- <view class="time font-twenty-four font-color4">
- <span class="padding">创建时间: {{list.createTime}}</span><span>创建人: {{list.createBy}}</span>
- </view>
- <image class="header-img" src="/static/img.png"></image>
- <!-- <view class="content">{{list.content}}</view> -->
- <view style="width:100%; overflow: hidden;">
- <rich-text :nodes="noticeContent"></rich-text>
- </view>
- </view>
- </template>
- <script>
- import server from "@/api/index";
- export default {
- data() {
- return {
- id: null,
- noticeContent: null,
- list:{},
- }
- },
- onLoad(e) {
- console.log(e);
- this.id = e.id;
- this.getListFn();
- },
- methods: {
- 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(/<br[^>]*\/>/gi, '');
- newContent = newContent.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display:block;margin-top:0;margin-bottom:0;"');
- return newContent;
- },
- getListFn(){
- let that = this;
- server.getNewsInfo(this.id).then(res =>{
- if(res){
- this.list = res;
- console.log('res.noticeContent', res.noticeContent)
- this.noticeContent = this.formatRichText(res.noticeContent);
- console.log("999", this.noticeContent)
- }else{
- this.list={
- url: '',
- noticeTitle: '',
- createTime: '',
- createBy: '',
- noticeContent: ''
- }
- }
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .detail{
- width: 100%;
- padding: 30rpx;
- min-height: 100vh;
- height: auto;
- .title{
- letter-spacing: 2rpx;
- font-weight: 550;
- }
- .time{
- height: 93rpx;
- line-height: 93rpx;
- .padding{
- padding-right: 30rpx;
- }
- }
- .header-img{
- width: 100%;
- height: 360rpx;
- margin-bottom: 30rpx;
- border-radius: 24rpx;
- }
- }
- </style>
|