HotNews.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <template>
  2. <div class="hotList">
  3. <div class="title">
  4. 最新资讯
  5. <em></em>
  6. </div>
  7. <div class="top111">
  8. <div class="hotList_photo_text" v-for="(item, index) in hotNewsListImg" :key="index">
  9. <NuxtLink :to="item.linkurl" v-if="item.islink == 1" :title="item.title">
  10. <img :src="item.imgurl" alt="">
  11. <span class="jingxuan">精选</span>
  12. <div class="hotlist_text">{{ item.title }}</div>
  13. </NuxtLink>
  14. <NuxtLink :to="`/${item.pinyin}/${item.id}.html`" v-if="item.islink == 0" :title="item.title">
  15. <img :src="item.imgurl" alt="">
  16. <span class="jingxuan">精选</span>
  17. <div class="hotlist_text">{{ item.title }}</div>
  18. </NuxtLink>
  19. </div>
  20. </div>
  21. <ul class="message">
  22. <li class="messageList" v-for="(item, index) in hotNewsList" :key="index">
  23. <NuxtLink :to="item.linkurl" v-if="item.islink == 1" :title="item.title">{{ item.title }}</NuxtLink>
  24. <NuxtLink :to="`/${item.pinyin}/${item.id}.html`" v-if="item.islink == 0" :title="item.title">
  25. {{ item.title }}
  26. </NuxtLink>
  27. </li>
  28. </ul>
  29. </div>
  30. </template>
  31. <script setup>
  32. const hotNewsList = ref([])
  33. async function getPageData() {
  34. const mkdata = await requestDataPromise('/web/getWebsiteArticlett', {
  35. method: 'GET',
  36. query: {
  37. 'imgnum':0,
  38. 'textnum': 5,
  39. 'level': 4,
  40. 'id': 0,
  41. 'placeid':0,
  42. },
  43. });
  44. if (mkdata.code == 200) {
  45. hotNewsList.value = mkdata.data.text;
  46. } else {
  47. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  48. console.log("错误位置:获取最新资讯")
  49. console.log("后端错误反馈:", mkdata.message)
  50. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  51. }
  52. }
  53. getPageData();
  54. const hotNewsListImg = ref([])
  55. async function getPageData1() {
  56. const mkdata = await requestDataPromise('/web/getWebsiteArticlett', {
  57. method: 'GET',
  58. query: {
  59. 'imgnum':1,
  60. 'textnum': 0,
  61. 'level': 4,
  62. 'id': 0,
  63. 'placeid':0,
  64. },
  65. });
  66. if (mkdata.code == 200) {
  67. hotNewsListImg.value = mkdata.data.img;
  68. } else {
  69. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  70. console.log("错误位置:获取最新资讯")
  71. console.log("后端错误反馈:", mkdata.message)
  72. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  73. }
  74. }
  75. getPageData1();
  76. </script>
  77. <style lang="less" scoped>
  78. .title {
  79. width: 100px;
  80. height: 40px;
  81. line-height: 40px;
  82. font-family: Microsoft YaHei, Microsoft YaHei;
  83. font-weight: 400;
  84. margin: 10px 0;
  85. font-size: 20px;
  86. color: #333333;
  87. position: relative;
  88. em {
  89. display: inline-block;
  90. width: 8px;
  91. height: 8px;
  92. border-radius: 4px;
  93. background-color: #a01c0e;
  94. position: absolute;
  95. top: 6px;
  96. right: 8px;
  97. }
  98. }
  99. .top111 {
  100. width: 350px;
  101. height: 280px;
  102. position: relative;
  103. .hotList_photo_text {
  104. width: 350px;
  105. height: 280px;
  106. position: relative;
  107. img {
  108. width: 350px;
  109. height: 230px;
  110. }
  111. .jingxuan {
  112. display: inline-block;
  113. width: 50px;
  114. height: 26px;
  115. background-color: #a01c0e;
  116. color: #fff;
  117. text-align: center;
  118. line-height: 26px;
  119. position: absolute;
  120. top: 0px;
  121. right: 10px;
  122. }
  123. .hotlist_text {
  124. width: 350px;
  125. height: 40px;
  126. line-height: 40px;
  127. white-space: nowrap;
  128. overflow: hidden;
  129. text-overflow: ellipsis;
  130. font-family: Microsoft YaHei, Microsoft YaHei;
  131. font-weight: bold;
  132. font-size: 18px;
  133. color: #333333;
  134. margin-top: 8px;
  135. }
  136. }
  137. }
  138. .message {
  139. width: 350px;
  140. margin-top: 30px;
  141. .messageList {
  142. width: 350px;
  143. white-space: nowrap;
  144. /* 禁止换行 */
  145. overflow: hidden;
  146. /* 隐藏超出部分 */
  147. text-overflow: ellipsis;
  148. /* 超出部分显示省略号 */
  149. font-family: Microsoft YaHei, Microsoft YaHei;
  150. font-weight: 400;
  151. font-size: 18px;
  152. color: #333333;
  153. margin-bottom: 25px;
  154. a {
  155. color: #333333;
  156. }
  157. }
  158. .messageList:first-child {
  159. font-weight: bold;
  160. }
  161. >li:hover>a {
  162. color: #a01c0e;
  163. }
  164. }
  165. </style>