newsComp.vue 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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-newsInfo-phone mta-hidden-sm">
  30. <h4 class="client-title">新闻资讯</h4>
  31. <el-carousel :interval="5000" type="card" height="300px" indicator-position="none" arrow="never">
  32. <el-carousel-item v-for="(item,index) in newsData" @click="checkInfo(item)" :key="index" class="el-row">
  33. <img :src="item.pic" alt="新闻资讯"/>
  34. <div class="newsInfo-card-content">
  35. <a style="display: none" :href="`${baseUrl}/news/${item.code}`"></a>
  36. <h4>{{ item.title }}<i></i></h4>
  37. <span>{{ item.yyyy }}-{{ item.mmdd }}</span>
  38. <p>{{ item.intro }}</p>
  39. </div>
  40. </el-carousel-item>
  41. </el-carousel>
  42. </div>
  43. </div>
  44. </template>
  45. <script>
  46. import {mapGetters} from "vuex";
  47. export default {
  48. name: "newsComp",
  49. props: {
  50. newsData: {
  51. type: Array,
  52. default: () => ([])
  53. }
  54. },
  55. data() {
  56. return {
  57. checkIsPc: false,
  58. }
  59. },
  60. computed: {
  61. baseUrl() {
  62. return this.getBaseUrl;
  63. },
  64. ...mapGetters(['getBaseUrl']),
  65. },
  66. methods: {
  67. isPC() {
  68. const browserWidth = document.documentElement.clientWidth;
  69. if (browserWidth <= 768) {
  70. return false;
  71. } else {
  72. return true;
  73. }
  74. },
  75. checkInfo(data) {
  76. const opt = {
  77. id: data.code,
  78. };
  79. this.$router.push({name: 'news-id', params: opt});
  80. }
  81. },
  82. mounted() {
  83. this.checkIsPc = this.isPC();
  84. }
  85. }
  86. </script>
  87. <style scoped>
  88. </style>