HotNews2.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. console.log("获取热点精选", mkdata);
  35. if (mkdata.code == 200) {
  36. for(let item of mkdata.data.img){
  37. if(item.imgurl){
  38. hotNewsList.value.push(item)
  39. if(hotNewsList.value.length == 5){
  40. break;
  41. }
  42. }
  43. }
  44. // hotNewsList.value = mkdata.data;
  45. } else {
  46. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  47. console.log("错误位置:获取热点精选")
  48. console.log("后端错误反馈:", mkdata.message)
  49. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  50. }
  51. }
  52. getPageData();
  53. </script>
  54. <style lang="less" scoped>
  55. .title {
  56. width: 380px;
  57. height: 40px;
  58. line-height: 40px;
  59. border-top: 1px solid #139602;
  60. border-bottom: 1px solid #e7e7e7;
  61. background-color: #fbfbfb;
  62. >h4 {
  63. font-family: Microsoft YaHei, Microsoft YaHei;
  64. font-weight: 400;
  65. margin-left: 20px;
  66. font-size: 20px;
  67. color: #000000;
  68. text-align: left;
  69. font-style: normal;
  70. text-transform: none;
  71. >span {
  72. float: right;
  73. font-family: Microsoft YaHei, Microsoft YaHei;
  74. font-weight: 400;
  75. font-size: 14px;
  76. margin-right: 10px;
  77. color: #999999;
  78. text-align: left;
  79. font-style: normal;
  80. text-transform: none;
  81. }
  82. }
  83. }
  84. .rightList {
  85. height: 556px;
  86. padding-top: 20px;
  87. background-color: #fbfbfb;
  88. >li {
  89. width: 380px;
  90. height: 100px;
  91. margin-bottom: 10px;
  92. margin-left: 15px;
  93. // background-color: #a5caa0;
  94. a {
  95. display: block;
  96. }
  97. >img {
  98. width: 150px;
  99. height: 100px;
  100. border-radius: 4px;
  101. }
  102. p {
  103. float: left;
  104. width: 220px;
  105. height: 100px;
  106. display: -webkit-box;
  107. -webkit-box-orient: vertical;
  108. -webkit-line-clamp: 3;
  109. overflow: hidden;
  110. text-overflow: ellipsis;
  111. word-break: break-all;
  112. font-family: PingFang SC, PingFang SC;
  113. font-weight: 400;
  114. font-size: 16px;
  115. color: #333333;
  116. line-height: 29px;
  117. // border-bottom: 1px solid #e7e7e7;
  118. padding-left: 12px;
  119. padding-right: 10px;
  120. padding-bottom: 10px;
  121. padding-top: 8px;
  122. box-sizing: border-box;
  123. }
  124. }
  125. >li:hover {
  126. p {
  127. //box-shadow: 0 0 16px 1px rgba(0, 0, 0, 0.1);
  128. color: #139602;
  129. }
  130. }
  131. }
  132. .hotNewsImg {
  133. float: left;
  134. width: 150px;
  135. height: 100px;
  136. border-radius: 4px;
  137. }
  138. @media screen and (max-width:800px){/*ipad_phone*/
  139. .rightList > li{overflow:hidden;height:auto;width:100%;display:block;margin:0px auto 11px;}
  140. .rightList > li>a{overflow:hidden;height:auto;width:100%;display:block;}
  141. .hotNewsImg{width:39%;height:26vw;}
  142. .rightList > li p{width:58%; float:right;}
  143. }
  144. </style>