PageMessage.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. <template>
  2. <div class="topNews">
  3. <div class="newsTitle">今日头条</div>
  4. <div class="newsContent">
  5. <div class="newsScrollWrapper">
  6. <div class="newsItem">
  7. <a href="#">十四届全国人大常委会第十九次会议举行第二次全体会议 审议执法检查报告、专项工作报告等 赵乐际出席会议</a>
  8. </div>
  9. <div class="newsItem">
  10. <a href="#">最高检调研组在四川调研</a>
  11. </div>
  12. <div class="newsItem">
  13. <a href="#">辽宁高院深入学习贯彻中央经济工作会议精神</a>
  14. </div>
  15. <div class="newsItem">
  16. <a href="#">省检察院召开党组(扩大)会议 传达学习中央经济工作会议精神</a>
  17. </div>
  18. <!-- 重复一遍,实现无缝滚动 -->
  19. <div class="newsItem">
  20. <a href="#">十四届全国人大常委会第十九次会议举行第二次全体会议 审议执法检查报告、专项工作报告等 赵乐际出席会议</a>
  21. </div>
  22. <div class="newsItem">
  23. <a href="#">最高检调研组在四川调研</a>
  24. </div>
  25. <div class="newsItem">
  26. <a href="#">辽宁高院深入学习贯彻中央经济工作会议精神</a>
  27. </div>
  28. <div class="newsItem">
  29. <a href="#">省检察院召开党组(扩大)会议 传达学习中央经济工作会议精神</a>
  30. </div>
  31. </div>
  32. </div>
  33. </div>
  34. </template>
  35. <script setup>
  36. //0.加载必备依赖 start ---------------------------------------->
  37. import { ref, onMounted } from "vue"
  38. const nuxtApp = useNuxtApp();
  39. const axios = nuxtApp.$axios;
  40. const getLinkPathDetail = (item) => {
  41. if (item.islink == 1) {
  42. return `${item.linkurl}`;
  43. } else {
  44. return `/${item.pinyin}/${item.id}.html`;
  45. }
  46. }
  47. //0.加载必备依赖 end ---------------------------------------->
  48. //1.获得板块数据 start ---------------------------------------->
  49. //大标题
  50. const headlinelist = ref([])
  51. //大标题下面的二级内容
  52. const headlinelist1 = ref([])
  53. async function getModelData1() {
  54. const mkdata = await requestDataPromise('/web/getWebsiteArticlett', {
  55. method: 'GET',
  56. query: {
  57. 'imgnum': 0,
  58. 'textnum': 3,
  59. 'level': 1,
  60. 'placeid': 0,
  61. 'id': ''
  62. },
  63. });
  64. if (mkdata.code == 200) {
  65. for (let index in mkdata.data.text) {
  66. if (index < 1) {
  67. headlinelist.value.push(mkdata.data.text[index])
  68. } else {
  69. headlinelist1.value.push(mkdata.data.text[index])
  70. }
  71. }
  72. } else {
  73. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  74. console.log("错误位置:设置大标题")
  75. console.log("后端错误反馈:", mkdata.message)
  76. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  77. }
  78. }
  79. getModelData1()
  80. const hotNewsList = ref("")
  81. async function getModelData3() {
  82. const mkdata = await requestDataPromise('/web/getWebsiteArticlett', {
  83. method: 'GET',
  84. query: {
  85. 'imgnum': 0,
  86. 'textnum': 8,
  87. 'level': 6,
  88. 'placeid': 0,
  89. 'id': ''
  90. },
  91. });
  92. if (mkdata.code == 200) {
  93. hotNewsList.value = mkdata.data.text;
  94. } else {
  95. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  96. // console.log("错误位置:获取首页今日热点")
  97. // console.log("后端错误反馈:", mkdata.message)
  98. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  99. }
  100. }
  101. getModelData3()
  102. //1.获得板块数据 end ---------------------------------------->
  103. </script>
  104. <style lang="less" scoped>
  105. // >1400px
  106. @media screen and (min-width: 1401px) {
  107. .topNews {
  108. width: 1400PX;
  109. height: 40PX;
  110. overflow: hidden;
  111. border: dashed 1PX #eed0d0;
  112. margin: 20PX auto;
  113. position: relative;
  114. padding-top: 4PX;
  115. box-sizing: border-box;
  116. .newsTitle {
  117. position: absolute;
  118. top: 5PX;
  119. left: -2PX;
  120. width: 91PX;
  121. height: 29PX;
  122. line-height: 29PX;
  123. background: url("../../public/index/titleIcon.jpg") no-repeat center center;
  124. color: #fff;
  125. font-size: 16PX;
  126. padding-left: 13PX;
  127. box-sizing: border-box;
  128. }
  129. .newsContent {
  130. width: 1250PX;
  131. height: 32PX;
  132. line-height: 32PX;
  133. box-sizing: border-box;
  134. font-size: 15PX;
  135. color: #000;
  136. position: relative;
  137. overflow: hidden;
  138. margin-left: 120PX;
  139. .newsScrollWrapper {
  140. position: absolute;
  141. display: flex;
  142. /* 让新闻条目横向排列 */
  143. white-space: nowrap;
  144. animation: scroll 60s linear infinite;
  145. left: 0;
  146. top: 0;
  147. .newsItem {
  148. text-align: center;
  149. white-space: nowrap;
  150. /* 单条新闻不换行 */
  151. margin-right: 20PX;
  152. /* 新闻之间的间距,可调整 */
  153. flex-shrink: 0;
  154. /* 关键:防止新闻条目被挤压变形 */
  155. a {
  156. display: inline-block;
  157. color: #333;
  158. padding: 0 10PX;
  159. box-sizing: border-box;
  160. }
  161. a:hover {
  162. color: #f00;
  163. /* 可选:鼠标悬停变色 */
  164. }
  165. }
  166. }
  167. @keyframes scroll {
  168. 0% {
  169. transform: translateX(0);
  170. /* 初始位置 */
  171. }
  172. 100% {
  173. transform: translateX(-50%);
  174. /* 滚动到第二份列表的起始位置,刚好衔接 */
  175. }
  176. }
  177. }
  178. .newsContent:hover .newsScrollWrapper {
  179. animation-play-state: paused;
  180. }
  181. }
  182. }
  183. // 801px-1400px
  184. @media screen and (min-width: 801px) and (max-width: 1400px) {
  185. .topNews {
  186. width: 100%;
  187. height: 40PX;
  188. overflow: hidden;
  189. border: dashed 1PX #eed0d0;
  190. margin: 20PX auto;
  191. position: relative;
  192. padding-top: 4PX;
  193. box-sizing: border-box;
  194. .newsTitle {
  195. position: absolute;
  196. top: 5PX;
  197. left: -2PX;
  198. width: 91PX;
  199. height: 29PX;
  200. line-height: 29PX;
  201. background: url("../../public/index/titleIcon.jpg") no-repeat center center;
  202. color: #fff;
  203. font-size: 16PX;
  204. padding-left: 13PX;
  205. box-sizing: border-box;
  206. }
  207. .newsContent {
  208. width: 88%;
  209. height: 32PX;
  210. line-height: 32PX;
  211. box-sizing: border-box;
  212. font-size: 15PX;
  213. color: #000;
  214. position: relative;
  215. overflow: hidden;
  216. margin-left: 120PX;
  217. .newsScrollWrapper {
  218. position: absolute;
  219. display: flex;
  220. /* 让新闻条目横向排列 */
  221. white-space: nowrap;
  222. animation: scroll 60s linear infinite;
  223. left: 0;
  224. top: 0;
  225. .newsItem {
  226. text-align: center;
  227. white-space: nowrap;
  228. /* 单条新闻不换行 */
  229. margin-right: 20PX;
  230. /* 新闻之间的间距,可调整 */
  231. flex-shrink: 0;
  232. /* 关键:防止新闻条目被挤压变形 */
  233. a {
  234. display: inline-block;
  235. color: #333;
  236. padding: 0 10PX;
  237. box-sizing: border-box;
  238. }
  239. a:hover {
  240. color: #f00;
  241. /* 可选:鼠标悬停变色 */
  242. }
  243. }
  244. }
  245. @keyframes scroll {
  246. 0% {
  247. transform: translateX(0);
  248. /* 初始位置 */
  249. }
  250. 100% {
  251. transform: translateX(-50%);
  252. /* 滚动到第二份列表的起始位置,刚好衔接 */
  253. }
  254. }
  255. }
  256. .newsContent:hover .newsScrollWrapper {
  257. animation-play-state: paused;
  258. }
  259. }
  260. }
  261. // <=800px
  262. @media screen and (max-width: 800px) {
  263. .topNews {
  264. display: none;
  265. }
  266. }
  267. </style>