HotNews.vue 3.7 KB

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