金诚优选前端代码
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

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 v-if="$isRight(title_content)">
  3. <lf-nav :spreadOut="true" :showIcon="true" bgColor="#F8F8F8" title="文章详情"></lf-nav>
  4. <view style="height: 30rpx;"></view>
  5. <view class="lf-m-l-32 lf-m-r-32">
  6. <view>
  7. <view class="lf-font-36 lf-color-222 lf-m-b-20 lf-font-bold">
  8. {{title_content.article.title}}
  9. </view>
  10. <view class="lf-flex lf-m-b-24">
  11. <view class="lf-font-28" style="color: #2D6361;">
  12. {{title_content.article.author}}
  13. </view>
  14. <view class="lf-color-777 lf-font-28 lf-m-l-25">
  15. {{title_content.article.created_at}}
  16. </view>
  17. </view>
  18. </view>
  19. <rich-text :nodes="formatRichText(content)" v-if="content"></rich-text>
  20. <!-- <lf-nocontent v-else></lf-nocontent> -->
  21. <!-- 回到顶部 -->
  22. <u-back-top :scroll-top="pageScrollTop" :custom-style="{background: 'rgba(51, 51 51, 0.3)'}"></u-back-top>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. export default {
  28. data(){
  29. return {
  30. content: '',
  31. notice_id: 0,
  32. title_content: ''
  33. }
  34. },
  35. onLoad(e){
  36. this.notice_id = e.notice_id;
  37. if(this.notice_id) {
  38. this.getData();
  39. }
  40. },
  41. methods: {
  42. // 富文本处理
  43. formatRichText(richText){
  44. if(richText != null){
  45. let newRichText= richText.replace(/<img[^>]*>/gi, function(match, capture){
  46. match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, '');
  47. match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, '');
  48. match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, '');
  49. return match;
  50. });
  51. newRichText = newRichText.replace(/style="[^"]+"/gi,function(match, capture){
  52. match = match.replace(/width:[^;]+;/gi, 'width:100%;').replace(/width:[^;]+;/gi, 'width:100%;');
  53. return match;
  54. });
  55. newRichText = newRichText.replace(/<br[^>]*\/>/gi, '');
  56. newRichText = newRichText.replace(/\<img/gi, '<img style="width:100%;height:auto;display:block;margin:10px 0;"');
  57. return newRichText;
  58. }else{
  59. return null;
  60. }
  61. },
  62. getData(){
  63. this.$http.get({
  64. api: '/api/article/detail/'+this.notice_id
  65. }).then(res => {
  66. this.content = res.data.data?.article.article_detail;
  67. this.title_content = res.data.data
  68. console.log(res.data)
  69. });
  70. }
  71. }
  72. }
  73. </script>
  74. <style>
  75. </style>