HotNews.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. 'imgnum': 2,
  51. 'textnum': 4,
  52. 'placeid':0,
  53. 'level': 4,
  54. 'id': 0,
  55. },
  56. });
  57. if(mkdata.code == 200){
  58. hotNewsListdata1.value = mkdata.data.img;
  59. hotNewsListdata2.value = mkdata.data.text;
  60. }else{
  61. console.log("错误位置:获取最新资讯")
  62. }
  63. }
  64. getPageData();
  65. </script>
  66. <style lang="less" scoped>
  67. .hotList {
  68. height: 405px;
  69. }
  70. .title {
  71. width: 100px;
  72. font-family: Microsoft YaHei, Microsoft YaHei;
  73. font-weight: bold;
  74. font-size: 22px;
  75. color: #489D97;
  76. margin: 10px 0 20px;
  77. position: relative;
  78. border-left: #489D97 5px solid;
  79. padding-left: 15px;
  80. }
  81. .hotList_photo_text {
  82. width: 270px;
  83. .hotList_photo_text1 {
  84. display: flex;
  85. img {
  86. float: left;
  87. width: 120px;
  88. height: 80px;
  89. margin-right: 10px;
  90. }
  91. .hotlist_text {
  92. float: left;
  93. width: 126px;
  94. height: 76px;
  95. display: -webkit-box;
  96. -webkit-box-orient: vertical;
  97. -webkit-line-clamp: 3;
  98. overflow: hidden;
  99. text-overflow: ellipsis;
  100. word-break: break-all;
  101. font-weight: 400;
  102. font-size: 18px;
  103. color: #333333;
  104. }
  105. }
  106. .hotList_photo_text1:first-child {
  107. margin-bottom: 20px;
  108. }
  109. .hotList_photo_text1:hover {
  110. .hotlist_text {
  111. color: #489d97;
  112. }
  113. }
  114. }
  115. // 文字
  116. .message {
  117. width: 270px;
  118. margin-top: 20px;
  119. .messageList {
  120. width: 270px;
  121. white-space: nowrap;
  122. /* 禁止换行 */
  123. overflow: hidden;
  124. /* 隐藏超出部分 */
  125. text-overflow: ellipsis;
  126. /* 超出部分显示省略号 */
  127. font-family: Microsoft YaHei, Microsoft YaHei;
  128. font-weight: 400;
  129. font-size: 18px;
  130. color: #333333;
  131. margin-bottom: 20px;
  132. a {
  133. color: #333333;
  134. }
  135. em{
  136. display: inline-block;
  137. width: 8px;
  138. height: 8px;
  139. background-color: #D9D9D9 ;
  140. border-radius: 50%;
  141. vertical-align: middle;
  142. margin-right: 10px;
  143. }
  144. }
  145. >li:hover>a {
  146. color: #489d97;
  147. }
  148. }
  149. </style>