newsComp2.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <template>
  2. <div>
  3. <!-- 新闻资讯 PC-->
  4. <div class="platform-news-information mta-hidden-xs">
  5. <!-- 新闻资讯 -->
  6. <div class="client-container">
  7. <h4 class="client-title-news">新闻资讯</h4>
  8. <ul>
  9. <li style="font-size: 16px" v-for="(item, index) in curNewsData" :key="index">
  10. <div>
  11. <img :src="item.pic" alt="新闻资讯"/>
  12. <h4 class="new_title" @click="checkInfo(item)">{{ item.title }}</h4>
  13. <span class="new_date">发布时间:{{ item.yyyy }}-{{ item.mmdd }}</span>
  14. <p class="new_des">{{ item.intro }}</p>
  15. </div>
  16. </li>
  17. </ul>
  18. </div>
  19. </div>
  20. <!-- 新闻资讯 手机-->
  21. <div class="client-newsInfo-phone mta-hidden-sm">
  22. <div class="client-container">
  23. <h4 class="client-title-news">新闻资讯</h4>
  24. <el-carousel :interval="5000" type="card" height="300px" indicator-position="none" arrow="never">
  25. <el-carousel-item v-for="(item,index) in curNewsData" @click="checkInfo(item)" :key="index" class="el-row">
  26. <img :src="item.pic" alt="新闻资讯"/>
  27. <div class="newsInfo-card-content">
  28. <a style="display: none" :href="`${baseUrl}/news/${item.code}`"></a>
  29. <h4>{{ item.title }}<i></i></h4>
  30. <span>{{ item.yyyy }}-{{ item.mmdd }}</span>
  31. <p>{{ item.intro }}</p>
  32. </div>
  33. </el-carousel-item>
  34. </el-carousel>
  35. </div>
  36. </div>
  37. </div>
  38. </template>
  39. <script>
  40. import {mapGetters} from "vuex";
  41. export default {
  42. name: "newsComp",
  43. props: {
  44. newsData: {
  45. type: Array,
  46. default: () => ([])
  47. }
  48. },
  49. data() {
  50. return {
  51. checkIsPc: false,
  52. }
  53. },
  54. computed: {
  55. baseUrl() {
  56. return this.getBaseUrl;
  57. },
  58. curNewsData() {
  59. return this.newsData && this.newsData.length<4?this.newsData:this.newsData.slice(0,4)
  60. },
  61. ...mapGetters(['getBaseUrl']),
  62. },
  63. methods: {
  64. isPC() {
  65. const browserWidth = document.documentElement.clientWidth;
  66. if (browserWidth <= 768) {
  67. return false;
  68. } else {
  69. return true;
  70. }
  71. },
  72. checkInfo(data) {
  73. const opt = {
  74. id: data.code,
  75. };
  76. this.$router.push({name: 'news-id', params: opt});
  77. }
  78. },
  79. mounted() {
  80. this.checkIsPc = this.isPC();
  81. }
  82. }
  83. </script>
  84. <style lang="scss" scoped>
  85. .platform-news-information {
  86. overflow: hidden;
  87. h4.client-title-news {
  88. font-size: 30px;
  89. font-weight: 800;
  90. text-align: center;
  91. color: #333;
  92. margin-top: 90px;
  93. margin-bottom: 60px;
  94. }
  95. ul > li {
  96. .new_title {
  97. font-size: 18px;
  98. color: #333;
  99. text-align: left;
  100. font-weight: 800;
  101. margin-bottom: 8px;
  102. }
  103. .new_date {
  104. font-size: 12px;
  105. font-weight: 500;
  106. color: #565656;
  107. position: relative;
  108. margin-bottom: 20px;
  109. &:after {
  110. content: '';
  111. position: absolute;
  112. bottom: -10px;
  113. left: 250px;
  114. width: 60px;
  115. height: 2px;
  116. background: #00B96B;
  117. }
  118. }
  119. .new_des {
  120. height: 96px;
  121. font-size: 14px;
  122. line-height: 24px;
  123. font-weight: 500;
  124. color: #565656;
  125. text-align: justify;
  126. }
  127. }
  128. ul > li > div {
  129. border-bottom: none;
  130. margin-bottom: 66px;
  131. img {
  132. width: 226px;
  133. height: 154px;
  134. }
  135. }
  136. }
  137. .client-newsInfo-phone{
  138. background-color: rgb(238, 238, 238);
  139. padding-top: 20px;
  140. .client-title-news {
  141. text-align: center;
  142. font-weight: 800;
  143. font-size: 18px;
  144. }
  145. // 轮播外层
  146. .el-carousel{
  147. padding: 20px 0 40px;
  148. // card
  149. .el-carousel__item{
  150. width: 80%;left: -15%;color: rgb(16, 16, 16);background: #fff;box-shadow: rgba(0, 0, 0, 0.4) 0px 0px 6px -1px;
  151. img{width: 100%;height: 135px;}
  152. }
  153. // 文字区域
  154. .newsInfo-card-content{
  155. padding: 24px 20px;
  156. h4{
  157. font-size: 14px;
  158. color: #333;
  159. font-weight: 400;
  160. }
  161. span{margin-top: 16px; font-size: 12px; display: block}
  162. p{min-height: 40px;margin-top: 16px; font-size: 12px;
  163. -webkit-line-clamp:4;
  164. text-overflow: ellipsis;
  165. -o-text-overflow: ellipsis;
  166. overflow: hidden;
  167. word-wrap: break-word;
  168. display: -webkit-box;
  169. white-space: normal !important;
  170. -webkit-box-orient: vertical;
  171. }
  172. }
  173. }
  174. }
  175. </style>