newsComp.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <div>
  3. <!-- 新闻资讯 PC-->
  4. <div class="client-news-information mta-hidden-xs">
  5. <h4 class="client-title">麦塔资讯</h4>
  6. <div class="client-container">
  7. <div class="industry-information-box">
  8. <div class="industry-information-left">
  9. <img :src="newsData[0].pic" alt="麦塔资讯"/>
  10. <h4 @click="checkInfo(newsData[0])">{{ newsData[0].title }}<i></i></h4>
  11. <div><b>{{ newsData[0].yyyy }}</b><span>{{ newsData[0].mmdd }}</span></div>
  12. <p>{{ newsData[0].intro }}</p>
  13. </div>
  14. <div class="industry-information-right">
  15. <ul>
  16. <li v-for="(item, index) in newsData" v-if="index >= 1">
  17. <h4 @click="checkInfo(item)">
  18. <a style="display: none" :href="`${baseUrl}/news/${item.code}`"></a>
  19. <span>{{ item.yyyy }}</span>{{ item.title }}
  20. </h4>
  21. <p><span>{{ item.mmdd }}</span>{{ item.intro }}</p>
  22. </li>
  23. </ul>
  24. </div>
  25. </div>
  26. </div>
  27. </div>
  28. <!-- 新闻资讯 手机-->
  29. <div class="client-container">
  30. <div class="client-newsInfo-phone mta-hidden-sm">
  31. <h4 class="client-title">新闻资讯</h4>
  32. <el-carousel :interval="5000" type="card" height="300px" indicator-position="none" arrow="never">
  33. <el-carousel-item v-for="(item,index) in newsData" @click="checkInfo(item)" :key="index" class="el-row">
  34. <img :src="item.pic" alt="新闻资讯"/>
  35. <div class="newsInfo-card-content">
  36. <a style="display: none" :href="`${baseUrl}/news/${item.code}`"></a>
  37. <h4>{{ item.title }}<i></i></h4>
  38. <span>{{ item.yyyy }}-{{ item.mmdd }}</span>
  39. <p>{{ item.intro }}</p>
  40. </div>
  41. </el-carousel-item>
  42. </el-carousel>
  43. </div>
  44. </div>
  45. </div>
  46. </template>
  47. <script>
  48. import {mapGetters} from "vuex";
  49. export default {
  50. name: "newsComp",
  51. props: {
  52. newsData: {
  53. type: Array,
  54. default: () => ([])
  55. }
  56. },
  57. data() {
  58. return {
  59. checkIsPc: false,
  60. }
  61. },
  62. computed: {
  63. baseUrl() {
  64. return this.getBaseUrl;
  65. },
  66. ...mapGetters(['getBaseUrl']),
  67. },
  68. methods: {
  69. isPC() {
  70. const browserWidth = document.documentElement.clientWidth;
  71. if (browserWidth <= 768) {
  72. return false;
  73. } else {
  74. return true;
  75. }
  76. },
  77. checkInfo(data) {
  78. const opt = {
  79. id: data.code,
  80. };
  81. this.$router.push({name: 'news-id', params: opt});
  82. }
  83. },
  84. mounted() {
  85. this.checkIsPc = this.isPC();
  86. }
  87. }
  88. </script>
  89. <style lang="scss" scoped>
  90. .client-news-information {
  91. background: #fafafa;
  92. .client-title {
  93. font-size: 30px;
  94. font-weight: 800;
  95. color: #333;
  96. margin-top: 60px;
  97. margin-bottom: 70px;
  98. }
  99. .industry-information-left {
  100. img {
  101. width: 605px;
  102. height: 180px;
  103. }
  104. }
  105. }
  106. </style>