index.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <div class="l_layout">
  3. <div class="article" v-for="article in news" :key="article.id">
  4. <img :src="article.cover" alt="">
  5. <div>
  6. <h2>{{article.title}}</h2>
  7. <span>
  8. <template v-if="article.origin">来源:{{article.origin}} &nbsp;|&nbsp;</template>
  9. {{new Date(Number(article.date)).format('yyyy-MM-dd')}} 发表
  10. </span>
  11. <p ref="brief">{{article.brief}}</p>
  12. <a :href="!article.outer_link ? ('#/information/news/' + article.id) : article.outer_link">阅读全文>></a>
  13. </div>
  14. </div>
  15. </div>
  16. </template>
  17. <script>
  18. export default {
  19. data () {
  20. return {news: []}
  21. },
  22. methods: {
  23. getContent (content) {
  24. let text = content
  25. .replace(/<(style|script|iframe)[^>]*?>[\s\S]+?<\/\1\s*>/gi, '')
  26. .replace(/<[^>]+?>/g, '')
  27. .replace(/\s+/g, ' ')
  28. .replace(/ /g, ' ')
  29. .replace(/&[^>]+?;/g, ' ')
  30. .replace(/>/g, ' ')
  31. return text.substr(0, 320)
  32. }
  33. },
  34. async mounted () {
  35. this.testDom = document.createElement('div')
  36. let result = (await this.$http.get('/news', {params: {page: 0, limit: 100}})).data.content
  37. this.news = result.data
  38. }
  39. }
  40. </script>
  41. <style scoped>
  42. .l_layout {
  43. max-width: 1400px;
  44. padding: 0 20px;
  45. margin: 40px auto 80px;
  46. }
  47. .article {
  48. padding-bottom: 30px;
  49. border-bottom: 1px solid #eeeeee;
  50. margin-bottom: 30px;
  51. }
  52. .article img {
  53. width: 100%;
  54. display: block;
  55. }
  56. .article .div {
  57. margin-top: 15px;
  58. }
  59. .article h2 {
  60. font-size: 14px;
  61. color: #000000;
  62. margin-top: 18px;
  63. }
  64. .article p,
  65. .article span {
  66. font-size: 12px;
  67. color: #989898;
  68. line-height: 22px;
  69. margin-top: 10px;
  70. }
  71. .article span,
  72. .article a {
  73. display: block;
  74. }
  75. .article a {
  76. margin-top: 10px;
  77. color: #00b4ed;
  78. }
  79. @media screen and (min-width: 700px) {
  80. .article {
  81. display: flex;
  82. /* padding-right: calc(100% - 330px); */
  83. position: relative;
  84. padding-bottom: 40px;
  85. margin-bottom: 40px;
  86. align-items: flex-start;
  87. }
  88. .article img {
  89. margin-right: 30px;
  90. width: 300px;
  91. height: auto;
  92. align-self: flex-start;
  93. }
  94. .article div {
  95. flex: 1;
  96. /* position: absolute;
  97. left: 330px;
  98. right: 0;
  99. top: 0;
  100. bottom: 40px; */
  101. display: flex;
  102. flex-direction: column;
  103. align-self: stretch
  104. }
  105. .article h2,
  106. .article a,
  107. .article span {
  108. flex: 0 0 auto;
  109. }
  110. .article p {
  111. /* height: 88px; */
  112. flex: 0 0 auto;
  113. overflow: hidden;
  114. }
  115. .article h2 {
  116. font-size: 18px;
  117. margin-top: 0;
  118. }
  119. .article a,
  120. .article span,
  121. .article p {
  122. margin-top: 20px;
  123. font-size: 14px;
  124. }
  125. .article a {
  126. justify-self: end;
  127. }
  128. }
  129. </style>