2.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <div class="newsBox">
  3. <div class="listNewsTitle" v-if="skinId==1">
  4. 最新资讯
  5. </div>
  6. <div class="listNewsTitle_skin2" v-if="skinId==2">
  7. <span>最新资讯</span>
  8. </div>
  9. <div class="newsContent">
  10. <div v-for="item in component_style1_News1Array" class="newsContentImg">
  11. <NuxtLink
  12. :href="getLinkPathDetail(item)"
  13. :title="item.title"
  14. :target="item.islink == 1 ? '_blank' : '_self'"
  15. >
  16. <div>{{ item.title }}</div>
  17. <img :src="item.imgurl" />
  18. </NuxtLink>
  19. </div>
  20. <div v-for="item in component_style1_News2Array" class="newsContentText">
  21. <NuxtLink
  22. :href="getLinkPathDetail(item)"
  23. :title="item.title"
  24. :target="item.islink == 1 ? '_blank' : '_self'"
  25. >
  26. {{ item.title }}
  27. </NuxtLink>
  28. </div>
  29. </div>
  30. </div>
  31. </template>
  32. <script setup>
  33. //引入vue
  34. import {ref} from 'vue';
  35. //获得新闻数据
  36. const props = defineProps({
  37. //templateData:Array,//新闻数据
  38. skinId:String,//皮肤id
  39. });
  40. const component_style1_News1Array = ref([]);
  41. const component_style1_News2Array = ref([]);
  42. // component_style1_News1Array.value = props.templateData.img.slice(0,2);
  43. // component_style1_News2Array.value = props.templateData.text.slice(0,4);
  44. //最新资讯数据 start ---------------------------------------->
  45. async function getPageData() {
  46. const mkdata = await requestDataPromise('/web/getWebsiteArticlett', {
  47. method: 'GET',
  48. query: {
  49. 'imgnum': 4,
  50. 'textnum': 4,
  51. 'level': 4,
  52. 'id': 0,
  53. 'placeid': 0,
  54. },
  55. });
  56. if(mkdata.code == 200){
  57. component_style1_News1Array.value = mkdata.data.img.slice(0, 2);
  58. component_style1_News2Array.value = mkdata.data.text.slice(0, 4);
  59. }
  60. }
  61. getPageData();
  62. </script>
  63. <style lang="less" scoped>
  64. .newsBox {
  65. .listNewsTitle {
  66. font-size:22px;
  67. font-weight:bold;
  68. height: 40px;
  69. line-height: 25px;
  70. border-bottom: 2px solid #004564;
  71. color:#004564;
  72. margin-bottom: 20px;
  73. box-sizing: border-box;
  74. }
  75. .listNewsTitle_skin2 {
  76. font-size:22px;
  77. font-weight:bold;
  78. height: 40px;
  79. line-height: 25px;
  80. border-bottom: 2px solid #A91B33;
  81. color:#A91B33;
  82. margin-bottom: 20px;
  83. box-sizing: border-box;
  84. span {
  85. color:#A91B33;
  86. height: 30px;
  87. line-height: 30px;
  88. border-left: 3px solid #A91B33;
  89. padding-left: 12px;
  90. }
  91. }
  92. .newsContent {
  93. .newsContentImg {
  94. a {
  95. display: block;
  96. display: flex;
  97. align-items: center;
  98. justify-content: center;
  99. margin-bottom: 20px;
  100. font-size:18px;
  101. div {
  102. overflow: hidden;
  103. display: -webkit-box;
  104. -webkit-line-clamp: 3;
  105. -webkit-box-orient: vertical;
  106. text-overflow: ellipsis;
  107. color:#333333;
  108. }
  109. }
  110. img {
  111. display: block;
  112. margin-left: 10px;
  113. width: 120px;
  114. height: 80px;
  115. }
  116. }
  117. .newsContentText {
  118. font-size:18px;
  119. color:#333333;
  120. margin-bottom: 20px;
  121. overflow: hidden;
  122. white-space: nowrap;
  123. text-overflow: ellipsis;
  124. a {
  125. color:#333333;
  126. }
  127. }
  128. }
  129. }
  130. </style>