HotNews.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. 'level': 4,
  53. 'id': 0,
  54. 'placeid': 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. .title {
  68. width: 100px;
  69. font-family: Microsoft YaHei, Microsoft YaHei;
  70. font-weight: bold;
  71. font-size: 22px;
  72. color: #255590;
  73. margin: 10px 0 20px;
  74. position: relative;
  75. border-left: #255590 5px solid;
  76. padding-left: 15px;
  77. }
  78. .hotList_photo_text {
  79. width: 270px;
  80. .hotList_photo_text1 {
  81. display: flex;
  82. img {
  83. float: left;
  84. width: 120px;
  85. height: 80px;
  86. margin-right: 10px;
  87. }
  88. .hotlist_text {
  89. float: left;
  90. width: 126px;
  91. height: 75px;
  92. display: -webkit-box;
  93. -webkit-box-orient: vertical;
  94. -webkit-line-clamp: 3;
  95. overflow: hidden;
  96. text-overflow: ellipsis;
  97. word-break: break-all;
  98. font-weight: 400;
  99. font-size: 18px;
  100. color: #333333;
  101. // padding-top: 3px;
  102. }
  103. }
  104. .hotList_photo_text1:first-child {
  105. margin-bottom: 20px;
  106. }
  107. .hotList_photo_text1:hover {
  108. .hotlist_text {
  109. color: #255590;
  110. }
  111. }
  112. }
  113. // 文字
  114. .message {
  115. width: 270px;
  116. margin-top: 20px;
  117. .messageList {
  118. width: 270px;
  119. white-space: nowrap;
  120. /* 禁止换行 */
  121. overflow: hidden;
  122. /* 隐藏超出部分 */
  123. text-overflow: ellipsis;
  124. /* 超出部分显示省略号 */
  125. font-family: Microsoft YaHei, Microsoft YaHei;
  126. font-weight: 400;
  127. font-size: 18px;
  128. color: #333333;
  129. margin-bottom: 20px;
  130. a {
  131. color: #333333;
  132. }
  133. em{
  134. display: inline-block;
  135. width: 8px;
  136. height: 8px;
  137. background-color: #D9D9D9 ;
  138. border-radius: 50%;
  139. vertical-align: middle;
  140. margin-right: 10px;
  141. }
  142. }
  143. >li:hover>a {
  144. color: #255590;
  145. }
  146. }
  147. </style>