海南旅游项目 前端仓库
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.

72 lines
2.2 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. <template>
  2. <view class="lf-m-l-32 lf-m-r-32">
  3. <view>
  4. <view class="lf-font-32 lf-color-333 lf-m-t-30 lf-m-b-20">
  5. {{title_content.title}}
  6. </view>
  7. <view class="lf-flex lf-m-b-24">
  8. <view class="lf-color-999 lf-font-24" v-if="title_content.updated_at">
  9. 发布于<text class="lf-m-l-10">{{title_content.updated_at}}</text>
  10. </view>
  11. <view class="lf-color-999 lf-font-24 lf-m-l-30" v-if="title_content.author">
  12. 作者<text class="lf-m-l-10">{{title_content.author}}</text>
  13. </view>
  14. </view>
  15. </view>
  16. <rich-text :nodes="formatRichText(content)" v-if="$isRight(content)"></rich-text>
  17. <lf-nocontent v-else></lf-nocontent>
  18. <!-- 回到顶部 -->
  19. <u-back-top :scroll-top="pageScrollTop" :custom-style="{background: 'rgba(51, 51 51, 0.3)'}"></u-back-top>
  20. </view>
  21. </template>
  22. <script>
  23. export default {
  24. data(){
  25. return {
  26. content: '',
  27. news_id: 0,
  28. title_content: ''
  29. }
  30. },
  31. onLoad(e){
  32. this.news_id = e.news_id
  33. if(this.news_id) {
  34. this.getData();
  35. }
  36. },
  37. methods: {
  38. // 富文本处理
  39. formatRichText(richText){
  40. if(richText != null){
  41. let newRichText= richText.replace(/<img[^>]*>/gi, function(match, capture){
  42. match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, '');
  43. match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, '');
  44. match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, '');
  45. return match;
  46. });
  47. newRichText = newRichText.replace(/style="[^"]+"/gi,function(match, capture){
  48. match = match.replace(/width:[^;]+;/gi, 'width:100%;').replace(/width:[^;]+;/gi, 'width:100%;');
  49. return match;
  50. });
  51. newRichText = newRichText.replace(/<br[^>]*\/>/gi, '');
  52. newRichText = newRichText.replace(/\<img/gi, '<img style="width:100%;height:auto;display:block;margin:10px 0;"');
  53. return newRichText;
  54. }else{
  55. return null;
  56. }
  57. },
  58. getData(){
  59. this.$http(this.API.API_MESSAGEDETAILS,{id: this.news_id}).then(res => {
  60. this.content = res.data?.content;
  61. this.title_content = res.data
  62. console.log(this.content)
  63. })
  64. }
  65. }
  66. }
  67. </script>
  68. <style lang="scss" scoped="scoped">
  69. </style>