HotNews.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <div class="hotList">
  3. <h1 class="title">
  4. 最新资讯
  5. </h1>
  6. <div class="hotList_photo_text">
  7. <div class="hotList_photo_text1" v-for="(item, index) in hotNewsListdata1" :key="index">
  8. <NuxtLink
  9. :href="getLinkPathDetail(item)"
  10. :title="item.title"
  11. :key="item.id"
  12. :target="item.islink == 1 ? '_blank' : '_self'"
  13. >
  14. <img :src="item.imgurl" :alt="item.title">
  15. <span class="hotlist_text">{{ item.title }}</span>
  16. </NuxtLink>
  17. </div>
  18. </div>
  19. <ul class="message">
  20. <li class="messageList" v-for="(item, index) in hotNewsListdata2" :key="index">
  21. <em></em>
  22. <NuxtLink
  23. :href="getLinkPathDetail(item)"
  24. :title="item.title"
  25. :key="item.id"
  26. :target="item.islink == 1 ? '_blank' : '_self'"
  27. >
  28. {{ item.title }}
  29. </NuxtLink>
  30. </li>
  31. </ul>
  32. </div>
  33. </template>
  34. <script setup>
  35. const getLinkPathDetail = (item) => {
  36. if (item.islink == 1) {
  37. return `${item.linkurl}`;
  38. } else {
  39. //return `/${item.aLIas_pinyin}/${item.id}`;
  40. //return `/newsDetail/${item.id}`
  41. return `/${item.pinyin}/${item.id}.html`;
  42. }
  43. }
  44. const hotNewsListdata1 = ref([])
  45. const hotNewsListdata2 = ref([])
  46. async function getPageData() {
  47. const mkdata = await requestDataPromise('/web/getWebsiteArticlett', {
  48. method: 'GET',
  49. query: {
  50. 'pageSize':6,
  51. 'level': 4,
  52. 'id': 0,
  53. },
  54. });
  55. if(mkdata.code == 200){
  56. hotNewsListdata1.value = mkdata.data.slice(0, 2);
  57. hotNewsListdata2.value = mkdata.data.slice(2, 6);
  58. }else{
  59. console.log("错误位置:获取最新资讯")
  60. }
  61. }
  62. getPageData();
  63. </script>
  64. <style lang="less" scoped>
  65. .title {
  66. width: 100px;
  67. font-family: Microsoft YaHei, Microsoft YaHei;
  68. font-weight: bold;
  69. font-size: 22px;
  70. color: #255590;
  71. margin: 10px 0 20px;
  72. position: relative;
  73. border-left: #255590 5px solid;
  74. padding-left: 15px;
  75. }
  76. .hotList_photo_text {
  77. width: 270px;
  78. .hotList_photo_text1 {
  79. display: flex;
  80. img {
  81. float: left;
  82. width: 120px;
  83. height: 80px;
  84. margin-right: 10px;
  85. }
  86. .hotlist_text {
  87. float: left;
  88. width: 126px;
  89. height: 72px;
  90. display: -webkit-box;
  91. -webkit-box-orient: vertical;
  92. -webkit-line-clamp: 3;
  93. overflow: hidden;
  94. text-overflow: ellipsis;
  95. word-break: break-all;
  96. font-weight: 400;
  97. font-size: 18px;
  98. color: #333333;
  99. padding-top: 3px;
  100. }
  101. }
  102. .hotList_photo_text1:first-child {
  103. margin-bottom: 20px;
  104. }
  105. .hotList_photo_text1:hover {
  106. .hotlist_text {
  107. color: #255590;
  108. }
  109. }
  110. }
  111. // 文字
  112. .message {
  113. width: 270px;
  114. margin-top: 20px;
  115. .messageList {
  116. width: 270px;
  117. white-space: nowrap;
  118. /* 禁止换行 */
  119. overflow: hidden;
  120. /* 隐藏超出部分 */
  121. text-overflow: ellipsis;
  122. /* 超出部分显示省略号 */
  123. font-family: Microsoft YaHei, Microsoft YaHei;
  124. font-weight: 400;
  125. font-size: 18px;
  126. color: #333333;
  127. margin-bottom: 20px;
  128. a {
  129. color: #333333;
  130. }
  131. em{
  132. display: inline-block;
  133. width: 8px;
  134. height: 8px;
  135. background-color: #D9D9D9 ;
  136. border-radius: 50%;
  137. vertical-align: middle;
  138. margin-right: 10px;
  139. }
  140. }
  141. >li:hover>a {
  142. color: #255590;
  143. }
  144. }
  145. </style>