one.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  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. </div>
  159. </el-col>
  160. </el-row>
  161. </div>
  162. </template>
  163. <script setup>
  164. import moment from 'moment'
  165. const selectMenu = inject('selectMenu')
  166. // 图片引入
  167. import home from '/images/home.jpg'
  168. import match from '/images/match.jpg'
  169. import match1 from '/images/match_1.jpg'
  170. import match2 from '/images/match_2.jpg'
  171. import match3 from '/images/match_3.jpg'
  172. import match4 from '/images/match_4.jpg'
  173. // 接口
  174. import { NewsStore } from '@/store/api/platform/news'
  175. import { MatchStore } from '@/store/api/platform/match'
  176. const newsStore = NewsStore()
  177. const matchStore = MatchStore()
  178. // 路由
  179. const router = useRouter()
  180. // 加载中
  181. const loading = ref(false)
  182. // 新闻
  183. const newsList = ref([])
  184. // 比赛
  185. const matchList = ref([])
  186. const carouselList = ref([{ url: match1 }, { url: match2 }, { url: match3 }, { url: match4 }])
  187. // 请求
  188. onMounted(async () => {
  189. loading.value = true
  190. await searchNews()
  191. await searchMatch()
  192. loading.value = false
  193. })
  194. const searchNews = async () => {
  195. const info = {
  196. skip: 0,
  197. limit: 4,
  198. is_use: '0',
  199. status: '1'
  200. }
  201. const res = await newsStore.query(info)
  202. if (res.errcode == '0') newsList.value = res.data
  203. }
  204. const searchMatch = async () => {
  205. const info = {
  206. skip: 0,
  207. limit: 6,
  208. is_use: '0',
  209. status: '1'
  210. }
  211. const res = await matchStore.query(info)
  212. if (res.errcode == '0') matchList.value = res.data
  213. }
  214. // 查看详情
  215. const toView = (item, type) => {
  216. if (type == '0') router.push({ path: '/news/detail', query: { id: item.id || item._id } })
  217. else router.push({ path: '/innovation/detail', query: { id: item.id || item._id } })
  218. }
  219. const removeHtmlStyle = (html) => {
  220. let relStyle = /style\s*?=\s*?([‘"])[\s\S]*?\1/g //去除样式
  221. let relTag = /<.+?>/g //去除标签
  222. let relClass = /class\s*?=\s*?([‘"])[\s\S]*?\1/g // 清除类名
  223. let newHtml = ''
  224. if (html) {
  225. newHtml = html.replace(relStyle, '')
  226. newHtml = newHtml.replace(relTag, '')
  227. newHtml = newHtml.replace(relClass, '')
  228. }
  229. return newHtml
  230. }
  231. // 查看更多
  232. const toMore = () => {
  233. router.push({ path: `/five` })
  234. }
  235. </script>
  236. <style scoped lang="scss">
  237. .main {
  238. .home {
  239. position: relative;
  240. .image {
  241. width: 100%;
  242. height: 200px;
  243. }
  244. }
  245. .one {
  246. padding: 25px 0;
  247. .one_1 {
  248. display: flex;
  249. justify-content: space-between;
  250. margin: 0 0 10px 0;
  251. .left {
  252. font-size: $global-font-size-26;
  253. font-family:
  254. PingFangSC-Semibold,
  255. PingFang SC;
  256. font-weight: 600;
  257. color: #111;
  258. line-height: 33px;
  259. }
  260. .right {
  261. text-align: right;
  262. font-size: $global-font-size-16;
  263. font-family:
  264. PingFangSC-Regular,
  265. PingFang SC;
  266. font-weight: 400;
  267. color: #2280ff;
  268. line-height: $global-font-size-16;
  269. display: block;
  270. margin-top: 13px;
  271. margin-right: 34px;
  272. }
  273. .right:hover {
  274. cursor: pointer;
  275. }
  276. }
  277. .one_2 {
  278. display: flex;
  279. justify-content: space-between;
  280. flex-wrap: wrap;
  281. .list {
  282. display: flex;
  283. align-items: center;
  284. padding: 15px;
  285. transition: all 0.3s;
  286. border-bottom: #9d9898 1px dashed;
  287. .left {
  288. font-family: PingFangSC-Regular;
  289. font-size: $global-font-size-14;
  290. color: #2374ff;
  291. line-height: $global-font-size-14;
  292. padding: 0 !important;
  293. .year {
  294. margin-bottom: 2px;
  295. }
  296. .date {
  297. font-size: $global-font-size-24;
  298. line-height: $global-font-size-24;
  299. margin-bottom: 10px;
  300. }
  301. }
  302. .right {
  303. padding: 0 !important;
  304. .name {
  305. font-family: PingFangSC-Medium;
  306. font-size: $global-font-size-18;
  307. color: #121834;
  308. line-height: $global-font-size-18;
  309. font-weight: 700;
  310. margin-bottom: 8px;
  311. }
  312. .content {
  313. font-size: $global-font-size-14;
  314. color: #525a68;
  315. line-height: 19px;
  316. font-weight: 400;
  317. display: -webkit-box;
  318. -webkit-line-clamp: 2;
  319. -webkit-box-orient: vertical;
  320. overflow: hidden;
  321. text-overflow: ellipsis;
  322. margin-top: 8px;
  323. }
  324. }
  325. }
  326. .list:hover {
  327. background: #f0f7ff;
  328. box-shadow: 0 0 16px rgba(205, 205, 205, 0.6);
  329. cursor: pointer;
  330. }
  331. }
  332. }
  333. .oneRight {
  334. padding: 25px 0 0 0 !important;
  335. .carousel {
  336. padding: 0 !important;
  337. margin: 0 0 10px 0;
  338. border-radius: 4px;
  339. :deep(.slick-slide) {
  340. text-align: center;
  341. height: 220px;
  342. background: #364d79;
  343. overflow: hidden;
  344. border-radius: 4px;
  345. }
  346. .image {
  347. width: 100%;
  348. height: 100%;
  349. border-radius: 4px;
  350. }
  351. }
  352. .title {
  353. padding: 0 !important;
  354. display: flex;
  355. align-items: center;
  356. justify-content: space-between;
  357. background: linear-gradient(90deg, #d7e8ff, #fff);
  358. width: 300px;
  359. height: 64px;
  360. padding-left: 21px;
  361. box-sizing: border-box;
  362. margin-bottom: 7px;
  363. .left {
  364. font-size: $global-font-size-22;
  365. font-family:
  366. PingFangSC-Medium,
  367. PingFang SC;
  368. font-weight: 500;
  369. color: #111;
  370. line-height: $global-font-size-20;
  371. }
  372. .right {
  373. text-align: right;
  374. font-size: $global-font-size-16;
  375. font-family:
  376. PingFangSC-Regular,
  377. PingFang SC;
  378. font-weight: 400;
  379. color: #666;
  380. cursor: pointer;
  381. }
  382. }
  383. .content {
  384. padding: 0 !important;
  385. margin: 10px 0 0 0;
  386. .list {
  387. padding: 0 !important;
  388. background: #eff4f9;
  389. width: 100%;
  390. margin: 0 0 10px 0;
  391. border-radius: 4px;
  392. .image {
  393. width: 100%;
  394. height: 150px;
  395. border-radius: 4px 4px 0 0;
  396. }
  397. .name {
  398. padding: 10px;
  399. font-size: $global-font-size-16;
  400. font-family:
  401. PingFangSC-Medium,
  402. PingFang SC;
  403. font-weight: 500;
  404. color: #111;
  405. }
  406. }
  407. }
  408. }
  409. }
  410. </style>