one.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  1. <template>
  2. <div id="index">
  3. <el-row>
  4. <el-col :span="24" class="main animate__animated animate__backInRight">
  5. <el-col :span="24" class="home">
  6. <el-image class="image" :src="home" fit="fill" />
  7. </el-col>
  8. <div class="w_1200" v-loading="loading">
  9. <el-row :gutter="20">
  10. <el-col :span="18" class="oneLeft">
  11. <el-col :span="24" class="one">
  12. <el-col :span="24" class="one_1">
  13. <el-col :span="12" class="left">政策信息</el-col>
  14. <el-col :span="12" class="right" @click="selectMenu('brain')"
  15. >查看政策信息</el-col
  16. >
  17. </el-col>
  18. <el-col :span="24" class="one_2">
  19. <el-col
  20. :span="24"
  21. class="list"
  22. v-for="(item, index) in newsList"
  23. :key="index"
  24. @click="toView(item, '0')"
  25. >
  26. <el-col :span="2" class="left">
  27. <div class="year" v-if="item.time">
  28. {{ moment(item.time).format('YYYY') }}
  29. </div>
  30. <div class="date" v-if="item.time">
  31. {{ moment(item.time).format('MM-DD') }}
  32. </div>
  33. </el-col>
  34. <el-col :span="22" class="right">
  35. <el-col :span="24" class="name textOver">
  36. <el-tooltip effect="dark" :content="item.title" placement="top">
  37. {{ item.title || '暂无标题' }}
  38. </el-tooltip>
  39. </el-col>
  40. <el-col :span="24" class="content">
  41. <div v-html="removeHtmlStyle(item.content)"></div>
  42. </el-col>
  43. </el-col>
  44. </el-col>
  45. </el-col>
  46. </el-col>
  47. <el-col :span="24" class="one">
  48. <el-col :span="24" class="one_1">
  49. <el-col :span="12" class="left">新闻通知</el-col>
  50. <el-col :span="12" class="right" @click="selectMenu('brain')"
  51. >查看新闻通知</el-col
  52. >
  53. </el-col>
  54. <el-col :span="24" class="one_2">
  55. <el-col
  56. :span="24"
  57. class="list"
  58. v-for="(item, index) in newsList"
  59. :key="index"
  60. @click="toView(item, '0')"
  61. >
  62. <el-col :span="2" class="left">
  63. <div class="year" v-if="item.time">
  64. {{ moment(item.time).format('YYYY') }}
  65. </div>
  66. <div class="date" v-if="item.time">
  67. {{ moment(item.time).format('MM-DD') }}
  68. </div>
  69. </el-col>
  70. <el-col :span="22" class="right">
  71. <el-col :span="24" class="name textOver">
  72. <el-tooltip effect="dark" :content="item.title" placement="top">
  73. {{ item.title || '暂无标题' }}
  74. </el-tooltip>
  75. </el-col>
  76. <el-col :span="24" class="content">
  77. <div v-html="removeHtmlStyle(item.content)"></div>
  78. </el-col>
  79. </el-col>
  80. </el-col>
  81. </el-col>
  82. </el-col>
  83. <el-col :span="24" class="one">
  84. <el-col :span="24" class="one_1">
  85. <el-col :span="12" class="left">工作动态</el-col>
  86. <el-col :span="12" class="right" @click="selectMenu('brain')"
  87. >查看工作动态</el-col
  88. >
  89. </el-col>
  90. <el-col :span="24" class="one_2">
  91. <el-col
  92. :span="24"
  93. class="list"
  94. v-for="(item, index) in newsList"
  95. :key="index"
  96. @click="toView(item, '0')"
  97. >
  98. <el-col :span="2" class="left">
  99. <div class="year" v-if="item.time">
  100. {{ moment(item.time).format('YYYY') }}
  101. </div>
  102. <div class="date" v-if="item.time">
  103. {{ moment(item.time).format('MM-DD') }}
  104. </div>
  105. </el-col>
  106. <el-col :span="22" class="right">
  107. <el-col :span="24" class="name textOver">
  108. <el-tooltip effect="dark" :content="item.title" placement="top">
  109. {{ item.title || '暂无标题' }}
  110. </el-tooltip>
  111. </el-col>
  112. <el-col :span="24" class="content">
  113. <div v-html="removeHtmlStyle(item.content)"></div>
  114. </el-col>
  115. </el-col>
  116. </el-col>
  117. </el-col>
  118. </el-col>
  119. </el-col>
  120. <el-col :span="6" class="oneRight">
  121. <el-col :span="24" class="carousel">
  122. <a-carousel autoplay>
  123. <el-image
  124. v-for="(item, index) in carouselList"
  125. :key="index"
  126. class="image"
  127. :src="item.url"
  128. fit="fill"
  129. />
  130. </a-carousel>
  131. </el-col>
  132. <el-col :span="24" class="title">
  133. <el-col :span="16" class="left">赛事推广 </el-col>
  134. <el-col :span="8" class="right" @click="toMore"> 查看更多</el-col>
  135. </el-col>
  136. <el-col :span="24" class="content">
  137. <el-col
  138. :span="24"
  139. v-for="(item, index) in matchList"
  140. :key="index"
  141. @click="toView(item, '1')"
  142. class="list"
  143. >
  144. <el-image
  145. v-if="item.file && item.file.length > 0"
  146. class="image"
  147. :src="item.file[0].url"
  148. fit="cover"
  149. />
  150. <el-image v-else class="image" :src="match" fit="fill" />
  151. <div class="name">
  152. {{ item.name }}
  153. </div>
  154. </el-col>
  155. </el-col>
  156. </el-col>
  157. </el-row>
  158. <el-row :gutter="20" class="type">
  159. <el-col :span="8" class="list" v-for="(item, index) in typeList" :key="index">
  160. <div class="list_1">
  161. <div class="title">{{ item.title }}</div>
  162. </div>
  163. <div
  164. class="list_2"
  165. v-for="(tag, indexx) in item.list"
  166. :key="indexx"
  167. @click="toLink(tag)"
  168. >
  169. {{ tag.name }}
  170. </div>
  171. </el-col>
  172. </el-row>
  173. </div>
  174. </el-col>
  175. </el-row>
  176. </div>
  177. </template>
  178. <script setup>
  179. import moment from 'moment'
  180. const selectMenu = inject('selectMenu')
  181. // 图片引入
  182. import home from '/images/home.jpg'
  183. import match from '/images/match.jpg'
  184. import match1 from '/images/match_1.jpg'
  185. import match2 from '/images/match_2.jpg'
  186. import match3 from '/images/match_3.jpg'
  187. import match4 from '/images/match_4.jpg'
  188. // 接口
  189. import { NewsStore } from '@/store/api/platform/news'
  190. import { MatchStore } from '@/store/api/platform/match'
  191. const newsStore = NewsStore()
  192. const matchStore = MatchStore()
  193. // 路由
  194. const router = useRouter()
  195. // 加载中
  196. const loading = ref(false)
  197. // 新闻
  198. const newsList = ref([])
  199. // 比赛
  200. const matchList = ref([])
  201. // 分类
  202. const typeList = ref([
  203. {
  204. title: '热门高校',
  205. list: [
  206. { name: '吉林省人民政府', href: 'https://www.jl.gov.cn/' },
  207. { name: '长春市人民政府', href: 'http://www.changchun.gov.cn/' },
  208. { name: '吉林省工信厅', href: 'http://gxt.jl.gov.cn/' },
  209. { name: '吉林省国资委', href: 'http://gzw.jl.gov.cn/' },
  210. { name: '吉林省财政厅', href: 'http://czt.jl.gov.cn/' },
  211. { name: '吉林省金融监管局', href: 'http://jr.jl.gov.cn/' }
  212. ]
  213. },
  214. {
  215. title: '政府部门',
  216. list: [
  217. { name: '吉林省人民政府', href: 'https://www.jl.gov.cn/' },
  218. { name: '长春市人民政府', href: 'http://www.changchun.gov.cn/' },
  219. { name: '吉林省工信厅', href: 'http://gxt.jl.gov.cn/' },
  220. { name: '吉林省国资委', href: 'http://gzw.jl.gov.cn/' },
  221. { name: '吉林省财政厅', href: 'http://czt.jl.gov.cn/' },
  222. { name: '吉林省金融监管局', href: 'http://jr.jl.gov.cn/' }
  223. ]
  224. },
  225. {
  226. title: '科研机构',
  227. list: [
  228. { name: '吉林省人民政府', href: 'https://www.jl.gov.cn/' },
  229. { name: '长春市人民政府', href: 'http://www.changchun.gov.cn/' },
  230. { name: '吉林省工信厅', href: 'http://gxt.jl.gov.cn/' },
  231. { name: '吉林省国资委', href: 'http://gzw.jl.gov.cn/' },
  232. { name: '吉林省财政厅', href: 'http://czt.jl.gov.cn/' },
  233. { name: '吉林省金融监管局', href: 'http://jr.jl.gov.cn/' }
  234. ]
  235. }
  236. ])
  237. const carouselList = ref([{ url: match1 }, { url: match2 }, { url: match3 }, { url: match4 }])
  238. // 请求
  239. onMounted(async () => {
  240. loading.value = true
  241. await searchNews()
  242. await searchMatch()
  243. loading.value = false
  244. })
  245. const searchNews = async () => {
  246. const info = {
  247. skip: 0,
  248. limit: 4,
  249. is_use: '0',
  250. status: '1'
  251. }
  252. const res = await newsStore.query(info)
  253. if (res.errcode == '0') newsList.value = res.data
  254. }
  255. const searchMatch = async () => {
  256. const info = {
  257. skip: 0,
  258. limit: 6,
  259. is_use: '0',
  260. status: '1'
  261. }
  262. const res = await matchStore.query(info)
  263. if (res.errcode == '0') matchList.value = res.data
  264. }
  265. // 查看详情
  266. const toView = (item, type) => {
  267. if (type == '0') router.push({ path: '/news/detail', query: { id: item.id || item._id } })
  268. else router.push({ path: '/innovation/detail', query: { id: item.id || item._id } })
  269. }
  270. const removeHtmlStyle = (html) => {
  271. let relStyle = /style\s*?=\s*?([‘"])[\s\S]*?\1/g //去除样式
  272. let relTag = /<.+?>/g //去除标签
  273. let relClass = /class\s*?=\s*?([‘"])[\s\S]*?\1/g // 清除类名
  274. let newHtml = ''
  275. if (html) {
  276. newHtml = html.replace(relStyle, '')
  277. newHtml = newHtml.replace(relTag, '')
  278. newHtml = newHtml.replace(relClass, '')
  279. }
  280. return newHtml
  281. }
  282. const toLink = (item) => {
  283. window.open(item.href, '_blank') // 在新标签页中打开URL
  284. }
  285. // 查看更多
  286. const toMore = () => {
  287. router.push({ path: `/five` })
  288. }
  289. </script>
  290. <style scoped lang="scss">
  291. .main {
  292. .home {
  293. position: relative;
  294. .image {
  295. width: 100%;
  296. height: 200px;
  297. }
  298. }
  299. .one {
  300. padding: 25px 0;
  301. .one_1 {
  302. display: flex;
  303. justify-content: space-between;
  304. margin: 0 0 10px 0;
  305. .left {
  306. font-size: $global-font-size-26;
  307. font-family:
  308. PingFangSC-Semibold,
  309. PingFang SC;
  310. font-weight: 600;
  311. color: #111;
  312. line-height: 33px;
  313. }
  314. .right {
  315. text-align: right;
  316. font-size: $global-font-size-18;
  317. font-family:
  318. PingFangSC-Regular,
  319. PingFang SC;
  320. font-weight: 400;
  321. color: #2280ff;
  322. line-height: $global-font-size-16;
  323. display: block;
  324. margin-top: 13px;
  325. margin-right: 34px;
  326. }
  327. .right:hover {
  328. cursor: pointer;
  329. }
  330. }
  331. .one_2 {
  332. display: flex;
  333. justify-content: space-between;
  334. flex-wrap: wrap;
  335. .list {
  336. display: flex;
  337. align-items: center;
  338. padding: 15px;
  339. transition: all 0.3s;
  340. border-bottom: #9d9898 1px dashed;
  341. .left {
  342. font-family: PingFangSC-Regular;
  343. font-size: $global-font-size-14;
  344. color: #2374ff;
  345. line-height: $global-font-size-14;
  346. padding: 0 !important;
  347. .year {
  348. margin-bottom: 2px;
  349. }
  350. .date {
  351. font-size: $global-font-size-24;
  352. line-height: $global-font-size-24;
  353. margin-bottom: 10px;
  354. }
  355. }
  356. .right {
  357. padding: 0 !important;
  358. .name {
  359. font-family: PingFangSC-Medium;
  360. font-size: $global-font-size-18;
  361. color: #121834;
  362. line-height: $global-font-size-18;
  363. font-weight: 700;
  364. margin-bottom: 8px;
  365. }
  366. .content {
  367. font-size: $global-font-size-14;
  368. color: #525a68;
  369. line-height: 19px;
  370. font-weight: 400;
  371. display: -webkit-box;
  372. -webkit-line-clamp: 2;
  373. -webkit-box-orient: vertical;
  374. overflow: hidden;
  375. text-overflow: ellipsis;
  376. margin-top: 8px;
  377. }
  378. }
  379. }
  380. .list:hover {
  381. background: #f0f7ff;
  382. box-shadow: 0 0 16px rgba(205, 205, 205, 0.6);
  383. cursor: pointer;
  384. }
  385. }
  386. }
  387. .oneRight {
  388. padding: 25px 0 0 0 !important;
  389. .carousel {
  390. padding: 0 !important;
  391. margin: 0 0 10px 0;
  392. border-radius: 4px;
  393. :deep(.slick-slide) {
  394. text-align: center;
  395. height: 220px;
  396. background: #364d79;
  397. overflow: hidden;
  398. border-radius: 4px;
  399. }
  400. .image {
  401. width: 100%;
  402. height: 100%;
  403. border-radius: 4px;
  404. }
  405. }
  406. .title {
  407. padding: 0 !important;
  408. display: flex;
  409. align-items: center;
  410. justify-content: space-between;
  411. background: linear-gradient(90deg, #d7e8ff, #fff);
  412. width: 300px;
  413. height: 64px;
  414. padding-left: 21px;
  415. box-sizing: border-box;
  416. margin-bottom: 7px;
  417. .left {
  418. font-size: $global-font-size-22;
  419. font-family:
  420. PingFangSC-Medium,
  421. PingFang SC;
  422. font-weight: 500;
  423. color: #111;
  424. line-height: $global-font-size-20;
  425. }
  426. .right {
  427. text-align: right;
  428. font-size: $global-font-size-16;
  429. font-family:
  430. PingFangSC-Regular,
  431. PingFang SC;
  432. font-weight: 400;
  433. color: #666;
  434. cursor: pointer;
  435. }
  436. }
  437. .content {
  438. padding: 0 !important;
  439. margin: 10px 0 0 0;
  440. .list {
  441. padding: 0 !important;
  442. background: #eff4f9;
  443. width: 100%;
  444. margin: 0 0 10px 0;
  445. border-radius: 4px;
  446. .image {
  447. width: 100%;
  448. height: 150px;
  449. border-radius: 4px 4px 0 0;
  450. }
  451. .name {
  452. padding: 10px;
  453. font-size: $global-font-size-18;
  454. font-family:
  455. PingFangSC-Medium,
  456. PingFang SC;
  457. font-weight: 500;
  458. color: #111;
  459. }
  460. }
  461. }
  462. }
  463. .type {
  464. margin: 10px 0;
  465. .list {
  466. .list_1 {
  467. margin: 0 0 20px 0;
  468. .title {
  469. font-size: $global-font-size-20;
  470. font-weight: 600;
  471. text-align: center;
  472. color: #252f49;
  473. }
  474. .title::before {
  475. content: '';
  476. position: absolute;
  477. transform: translateY(-50%);
  478. top: 12px;
  479. margin-left: -100px;
  480. width: 80px;
  481. height: 1px;
  482. border-bottom: 1px #252f49 solid;
  483. }
  484. .title::after {
  485. content: '';
  486. position: absolute;
  487. transform: translateY(-50%);
  488. top: 12px;
  489. margin-left: 30px;
  490. width: 80px;
  491. height: 1px;
  492. border-bottom: 1px #252f49 solid;
  493. }
  494. }
  495. .list_2 {
  496. font-size: $global-font-size-18;
  497. margin: 8px;
  498. padding: 5px;
  499. text-align: center;
  500. border: 1px #ebe2e2 solid;
  501. border-radius: 4px;
  502. }
  503. .list_2:hover {
  504. background: #2280ff;
  505. color: #ffffff;
  506. }
  507. }
  508. }
  509. }
  510. </style>