newsComp2.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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 newsData" :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-container">
  22. <div class="client-newsInfo-phone mta-hidden-sm">
  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 newsData" @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. ...mapGetters(['getBaseUrl']),
  59. },
  60. methods: {
  61. isPC() {
  62. const browserWidth = document.documentElement.clientWidth;
  63. if (browserWidth <= 768) {
  64. return false;
  65. } else {
  66. return true;
  67. }
  68. },
  69. checkInfo(data) {
  70. const opt = {
  71. id: data.code,
  72. };
  73. this.$router.push({name: 'news-id', params: opt});
  74. }
  75. },
  76. mounted() {
  77. this.checkIsPc = this.isPC();
  78. }
  79. }
  80. </script>
  81. <style lang="scss" scoped>
  82. .platform-news-information {
  83. overflow: hidden;
  84. h4.client-title-news {
  85. font-size: 30px;
  86. font-weight: 800;
  87. text-align: center;
  88. color: #333;
  89. margin-top: 100px;
  90. margin-bottom: 80px;
  91. }
  92. ul {
  93. margin-bottom: 100px;
  94. }
  95. ul > li {
  96. .new_title {
  97. font-size: 18px;
  98. color: #333;
  99. text-align: left;
  100. font-weight: 800;
  101. }
  102. .new_date {
  103. font-size: 12px;
  104. font-weight: 500;
  105. color: #565656;
  106. position: relative;
  107. margin-bottom: 20px;
  108. &:after {
  109. content: '';
  110. position: absolute;
  111. bottom: -8px;
  112. left: 250px;
  113. width: 60px;
  114. height: 3px;
  115. background: #00B96B;
  116. }
  117. }
  118. .new_des {
  119. font-size: 14px;
  120. font-weight: 500;
  121. color: #565656;
  122. }
  123. }
  124. ul > li > div {
  125. border-bottom: none;
  126. margin-bottom: 66px;
  127. img {
  128. width: 226px;
  129. height: 152px;
  130. }
  131. }
  132. }
  133. .client-newsInfo-phone{
  134. background-color: rgb(238, 238, 238);
  135. .client-title-news {
  136. text-align: center;
  137. font-weight: 800;
  138. font-size: 18px;
  139. }
  140. // 轮播外层
  141. .el-carousel{
  142. padding: 20px 0 40px;
  143. // card
  144. .el-carousel__item{
  145. width: 80%;left: -15%;color: rgb(16, 16, 16);background: #fff;box-shadow: rgba(0, 0, 0, 0.4) 0px 0px 6px -1px;
  146. img{width: 100%;height: 135px;}
  147. }
  148. // 文字区域
  149. .newsInfo-card-content{
  150. padding: 24px 20px;
  151. h4{
  152. font-size: 14px;
  153. color: #333;
  154. font-weight: 400;
  155. }
  156. span{margin-top: 16px; font-size: 12px; display: block}
  157. p{min-height: 48px;margin-top: 16px; font-size: 12px;
  158. -webkit-line-clamp:3;
  159. text-overflow: ellipsis;
  160. -o-text-overflow: ellipsis;
  161. overflow: hidden;
  162. word-wrap: break-word;
  163. display: -webkit-box;
  164. white-space: normal !important;
  165. -webkit-box-orient: vertical;
  166. }
  167. }
  168. }
  169. }
  170. </style>