HotNews2.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template>
  2. <div class="title">
  3. <h4>
  4. 热点精选
  5. </h4>
  6. </div>
  7. <!-- 列表 -->
  8. <ul class="rightList">
  9. <li v-for="item in hotNewsList">
  10. <NuxtLink :to="item.linkurl" v-show="item.islink == 1" :title="item.title">
  11. <img class="hotNewsImg" :src="item.imgurl">
  12. <p>{{ item.title }}</p>
  13. </NuxtLink>
  14. <NuxtLink :to="`/${item.pinyin}/${item.id}.html`" v-if="item.islink == 0" :title="item.title">
  15. <img class="hotNewsImg" :src="item.imgurl">
  16. <p>{{ item.title }}</p>
  17. </NuxtLink>
  18. </li>
  19. </ul>
  20. </template>
  21. <script setup>
  22. const hotNewsList = ref([])
  23. async function getPageData() {
  24. const mkdata = await requestDataPromise('/web/getWebsiteArticlett', {
  25. method: 'GET',
  26. query: {
  27. 'textnum': 0,
  28. 'imgnum': 5,
  29. 'level': 5,
  30. 'placeid': 0,
  31. 'id': 0
  32. },
  33. });
  34. if (mkdata.code == 200) {
  35. for(let item of mkdata.data.img){
  36. if(item.imgurl){
  37. hotNewsList.value.push(item)
  38. if(hotNewsList.value.length == 5){
  39. break;
  40. }
  41. }
  42. }
  43. // hotNewsList.value = mkdata.data;
  44. } else {
  45. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  46. console.log("错误位置:获取热点精选")
  47. console.log("后端错误反馈:", mkdata.message)
  48. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  49. }
  50. }
  51. getPageData();
  52. </script>
  53. <style lang="less" scoped>
  54. .title {
  55. width: 380px;
  56. height: 40px;
  57. line-height: 40px;
  58. border-top: 1px solid #139602;
  59. border-bottom: 1px solid #e7e7e7;
  60. background-color: #fbfbfb;
  61. >h4 {
  62. font-family: Microsoft YaHei, Microsoft YaHei;
  63. font-weight: 400;
  64. margin-left: 20px;
  65. font-size: 20px;
  66. color: #000000;
  67. text-align: left;
  68. font-style: normal;
  69. text-transform: none;
  70. >span {
  71. float: right;
  72. font-family: Microsoft YaHei, Microsoft YaHei;
  73. font-weight: 400;
  74. font-size: 14px;
  75. margin-right: 10px;
  76. color: #999999;
  77. text-align: left;
  78. font-style: normal;
  79. text-transform: none;
  80. }
  81. }
  82. }
  83. .rightList {
  84. height: 556px;
  85. padding-top: 20px;
  86. background-color: #fbfbfb;
  87. >li {
  88. width: 380px;
  89. height: 100px;
  90. margin-bottom: 10px;
  91. margin-left: 15px;
  92. // background-color: #a5caa0;
  93. a {
  94. display: block;
  95. }
  96. >img {
  97. width: 150px;
  98. height: 100px;
  99. border-radius: 4px;
  100. }
  101. p {
  102. float: left;
  103. width: 220px;
  104. height: 100px;
  105. display: -webkit-box;
  106. -webkit-box-orient: vertical;
  107. -webkit-line-clamp: 3;
  108. overflow: hidden;
  109. text-overflow: ellipsis;
  110. word-break: break-all;
  111. font-family: PingFang SC, PingFang SC;
  112. font-weight: 400;
  113. font-size: 16px;
  114. color: #333333;
  115. line-height: 29px;
  116. // border-bottom: 1px solid #e7e7e7;
  117. padding-left: 12px;
  118. padding-right: 10px;
  119. padding-bottom: 10px;
  120. padding-top: 8px;
  121. box-sizing: border-box;
  122. }
  123. }
  124. >li:hover {
  125. p {
  126. //box-shadow: 0 0 16px 1px rgba(0, 0, 0, 0.1);
  127. color: #139602;
  128. }
  129. }
  130. }
  131. .hotNewsImg {
  132. float: left;
  133. width: 150px;
  134. height: 100px;
  135. border-radius: 4px;
  136. }
  137. </style>