one.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  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="getUrl(item.file)"
  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. const getUrl = (item) => {
  286. if (item) return `${import.meta.env.VITE_APP_HOST}${item[0].uri}`
  287. }
  288. // 查看更多
  289. const toMore = () => {
  290. router.push({ path: `/five` })
  291. }
  292. </script>
  293. <style scoped lang="scss">
  294. .main {
  295. .home {
  296. position: relative;
  297. .image {
  298. width: 100%;
  299. height: 200px;
  300. }
  301. }
  302. .one {
  303. padding: 25px 0;
  304. .one_1 {
  305. display: flex;
  306. justify-content: space-between;
  307. margin: 0 0 10px 0;
  308. .left {
  309. font-size: $global-font-size-26;
  310. font-family:
  311. PingFangSC-Semibold,
  312. PingFang SC;
  313. font-weight: 600;
  314. color: #111;
  315. line-height: 33px;
  316. }
  317. .right {
  318. text-align: right;
  319. font-size: $global-font-size-18;
  320. font-family:
  321. PingFangSC-Regular,
  322. PingFang SC;
  323. font-weight: 400;
  324. color: #2280ff;
  325. line-height: $global-font-size-16;
  326. display: block;
  327. margin-top: 13px;
  328. margin-right: 34px;
  329. }
  330. .right:hover {
  331. cursor: pointer;
  332. }
  333. }
  334. .one_2 {
  335. display: flex;
  336. justify-content: space-between;
  337. flex-wrap: wrap;
  338. .list {
  339. display: flex;
  340. align-items: center;
  341. padding: 15px;
  342. transition: all 0.3s;
  343. border-bottom: #9d9898 1px dashed;
  344. .left {
  345. font-family: PingFangSC-Regular;
  346. font-size: $global-font-size-14;
  347. color: #2374ff;
  348. line-height: $global-font-size-14;
  349. padding: 0 !important;
  350. .year {
  351. margin-bottom: 2px;
  352. }
  353. .date {
  354. font-size: $global-font-size-24;
  355. line-height: $global-font-size-24;
  356. margin-bottom: 10px;
  357. }
  358. }
  359. .right {
  360. padding: 0 !important;
  361. .name {
  362. font-family: PingFangSC-Medium;
  363. font-size: $global-font-size-18;
  364. color: #121834;
  365. line-height: $global-font-size-18;
  366. font-weight: 700;
  367. margin-bottom: 8px;
  368. }
  369. .content {
  370. font-size: $global-font-size-14;
  371. color: #525a68;
  372. line-height: 19px;
  373. font-weight: 400;
  374. display: -webkit-box;
  375. -webkit-line-clamp: 2;
  376. -webkit-box-orient: vertical;
  377. overflow: hidden;
  378. text-overflow: ellipsis;
  379. margin-top: 8px;
  380. }
  381. }
  382. }
  383. .list:hover {
  384. background: #f0f7ff;
  385. box-shadow: 0 0 16px rgba(205, 205, 205, 0.6);
  386. cursor: pointer;
  387. }
  388. }
  389. }
  390. .oneRight {
  391. padding: 25px 0 0 0 !important;
  392. .carousel {
  393. padding: 0 !important;
  394. margin: 0 0 10px 0;
  395. border-radius: 4px;
  396. :deep(.slick-slide) {
  397. text-align: center;
  398. height: 220px;
  399. background: #364d79;
  400. overflow: hidden;
  401. border-radius: 4px;
  402. }
  403. .image {
  404. width: 100%;
  405. height: 100%;
  406. border-radius: 4px;
  407. }
  408. }
  409. .title {
  410. padding: 0 !important;
  411. display: flex;
  412. align-items: center;
  413. justify-content: space-between;
  414. background: linear-gradient(90deg, #d7e8ff, #fff);
  415. width: 300px;
  416. height: 64px;
  417. padding-left: 21px;
  418. box-sizing: border-box;
  419. margin-bottom: 7px;
  420. .left {
  421. font-size: $global-font-size-22;
  422. font-family:
  423. PingFangSC-Medium,
  424. PingFang SC;
  425. font-weight: 500;
  426. color: #111;
  427. line-height: $global-font-size-20;
  428. }
  429. .right {
  430. text-align: right;
  431. font-size: $global-font-size-16;
  432. font-family:
  433. PingFangSC-Regular,
  434. PingFang SC;
  435. font-weight: 400;
  436. color: #666;
  437. cursor: pointer;
  438. }
  439. }
  440. .content {
  441. padding: 0 !important;
  442. margin: 10px 0 0 0;
  443. .list {
  444. padding: 0 !important;
  445. background: #eff4f9;
  446. width: 100%;
  447. margin: 0 0 10px 0;
  448. border-radius: 4px;
  449. .image {
  450. width: 100%;
  451. height: 150px;
  452. border-radius: 4px 4px 0 0;
  453. }
  454. .name {
  455. padding: 10px;
  456. font-size: $global-font-size-18;
  457. font-family:
  458. PingFangSC-Medium,
  459. PingFang SC;
  460. font-weight: 500;
  461. color: #111;
  462. }
  463. }
  464. }
  465. }
  466. .type {
  467. margin: 10px 0;
  468. .list {
  469. .list_1 {
  470. margin: 0 0 20px 0;
  471. .title {
  472. font-size: $global-font-size-20;
  473. font-weight: 600;
  474. text-align: center;
  475. color: #252f49;
  476. }
  477. .title::before {
  478. content: '';
  479. position: absolute;
  480. transform: translateY(-50%);
  481. top: 12px;
  482. margin-left: -100px;
  483. width: 80px;
  484. height: 1px;
  485. border-bottom: 1px #252f49 solid;
  486. }
  487. .title::after {
  488. content: '';
  489. position: absolute;
  490. transform: translateY(-50%);
  491. top: 12px;
  492. margin-left: 30px;
  493. width: 80px;
  494. height: 1px;
  495. border-bottom: 1px #252f49 solid;
  496. }
  497. }
  498. .list_2 {
  499. font-size: $global-font-size-18;
  500. margin: 8px;
  501. padding: 5px;
  502. text-align: center;
  503. border: 1px #ebe2e2 solid;
  504. border-radius: 4px;
  505. }
  506. .list_2:hover {
  507. background: #2280ff;
  508. color: #ffffff;
  509. }
  510. }
  511. }
  512. }
  513. </style>