index.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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="brain">
  6. <el-image class="image" :src="brain" fit="fill" />
  7. </el-col>
  8. <div class="w_1200">
  9. <el-col :span="24" class="two">
  10. <el-col :span="18" class="left">
  11. <el-col
  12. :span="24"
  13. class="list"
  14. v-for="(item, index) in list"
  15. :key="index"
  16. @click="toView(item)"
  17. >
  18. <el-col :span="6" class="left">
  19. <el-image
  20. class="image"
  21. v-if="item.logo && item.logo.length > 0"
  22. :src="item.logo[0].url"
  23. fit="fill"
  24. />
  25. <el-image class="image" v-else :src="new_4" fit="fill" />
  26. </el-col>
  27. <el-col :span="17" class="right">
  28. <el-col :span="24" class="right_1 textOver">
  29. {{ item.title || '暂无标题' }}
  30. </el-col>
  31. <el-col :span="24" class="right_2 textMore">
  32. <div v-html="removeHtmlStyle(item.content)"></div>
  33. </el-col>
  34. <el-col :span="24" class="right_3">
  35. {{ item.time || '暂无' }}
  36. </el-col>
  37. </el-col>
  38. </el-col>
  39. </el-col>
  40. <el-col :span="5" class="right">
  41. <el-col :span="24" class="title">
  42. <el-col :span="24" class="left">成果展示 </el-col>
  43. <el-col :span="24" class="right" @click="toMore(0)"> 查看更多</el-col>
  44. </el-col>
  45. <el-col :span="24" class="content">
  46. <a-timeline>
  47. <a-timeline-item
  48. v-for="(item, index) in achievementList"
  49. :key="index"
  50. @click="toCommon(item, '/achievement/detail')"
  51. >
  52. <div class="name">{{ item.name }}</div>
  53. <div class="time">{{ item.time }}</div>
  54. </a-timeline-item>
  55. </a-timeline>
  56. </el-col>
  57. <el-col :span="24" class="title">
  58. <el-col :span="24" class="left">项目精选 </el-col>
  59. <el-col :span="24" class="right" @click="toMore(1)"> 查看更多</el-col>
  60. </el-col>
  61. <el-col :span="24" class="content">
  62. <a-timeline>
  63. <a-timeline-item
  64. v-for="(item, index) in projectList"
  65. :key="index"
  66. @click="toCommon(item, '/project/detail')"
  67. >
  68. <div class="name">{{ item.name }}</div>
  69. <div class="time">{{ item.time }}</div>
  70. </a-timeline-item>
  71. </a-timeline>
  72. </el-col>
  73. </el-col>
  74. </el-col>
  75. <el-col :span="24" class="thr">
  76. <el-pagination
  77. background
  78. layout="total, prev, pager, next"
  79. :page-sizes="[10, 20, 50, 100, 200]"
  80. :total="total"
  81. :page-size="limit"
  82. v-model:current-page="currentPage"
  83. @current-change="changePage"
  84. @size-change="sizeChange"
  85. >
  86. </el-pagination>
  87. </el-col>
  88. </div>
  89. </el-col>
  90. </el-row>
  91. </div>
  92. </template>
  93. <script setup>
  94. // 接口
  95. import { NewsStore } from '@/store/api/platform/news'
  96. import { AchievementStore } from '@/store/api/platform/achievement'
  97. import { ProjectStore } from '@/store/api/platform/project'
  98. const store = NewsStore()
  99. const projectStore = ProjectStore()
  100. const achievementStore = AchievementStore()
  101. // 路由
  102. const router = useRouter()
  103. // 图片引入
  104. import brain from '@/assets/home.jpg'
  105. import new_4 from '@/assets/new_4.png'
  106. // 加载中
  107. const loading = ref(false)
  108. // 列表
  109. const list = ref([])
  110. let skip = 0
  111. let limit = inject('limit')
  112. const total = ref(0)
  113. const achievementList = ref([])
  114. const projectList = ref([])
  115. // 请求
  116. onMounted(async () => {
  117. loading.value = true
  118. await searchOther()
  119. await search({ skip, limit })
  120. loading.value = false
  121. })
  122. const searchOther = async () => {
  123. const info = {
  124. skip: 0,
  125. limit: 6,
  126. status: '1',
  127. is_use: '0'
  128. }
  129. let res
  130. res = await achievementStore.query(info)
  131. if (res.errcode == '0') achievementList.value = res.data
  132. res = await projectStore.query(info)
  133. if (res.errcode == '0') projectList.value = res.data
  134. }
  135. const search = async (query = { skip: 0, limit }) => {
  136. const info = {
  137. skip: query.skip,
  138. limit: query.limit,
  139. status: '1',
  140. is_use: '0'
  141. }
  142. const res = await store.query(info)
  143. if (res.errcode == '0') {
  144. list.value = res.data
  145. total.value = res.total
  146. }
  147. }
  148. // 查看
  149. const toView = (item) => {
  150. router.push({ path: `/news/detail`, query: { id: item.id || item._id } })
  151. }
  152. // 查看更多
  153. const toMore = (type) => {
  154. if (type == '0') router.push({ path: `/achievement` })
  155. else router.push({ path: `/project` })
  156. }
  157. // 详情
  158. const toCommon = (item, route) => {
  159. router.push({ path: route, query: { id: item._id || item.id } })
  160. }
  161. const removeHtmlStyle = (html) => {
  162. let relStyle = /style\s*?=\s*?([‘"])[\s\S]*?\1/g //去除样式
  163. let relTag = /<.+?>/g //去除标签
  164. let relClass = /class\s*?=\s*?([‘"])[\s\S]*?\1/g // 清除类名
  165. let newHtml = ''
  166. if (html) {
  167. newHtml = html.replace(relStyle, '')
  168. newHtml = newHtml.replace(relTag, '')
  169. newHtml = newHtml.replace(relClass, '')
  170. }
  171. return newHtml
  172. }
  173. const currentPage = ref(1)
  174. // 分页
  175. const changePage = (page = currentPage.value) => {
  176. search({ skip: (page - 1) * limit, limit: limit })
  177. }
  178. const sizeChange = (limits) => {
  179. limit = limits
  180. currentPage.value = 1
  181. search({ skip: 0, limit: limit })
  182. }
  183. </script>
  184. <style lang="scss" scoped>
  185. .main {
  186. background: rgb(248, 248, 248);
  187. .brain {
  188. .image {
  189. width: 100%;
  190. height: 200px;
  191. }
  192. }
  193. .two {
  194. display: flex;
  195. width: 100%;
  196. margin: 10px 0 0 0;
  197. padding: 10px;
  198. background-color: #fff;
  199. border-radius: 10px;
  200. .left {
  201. .list {
  202. display: flex;
  203. align-items: center;
  204. margin-bottom: 30px;
  205. .left {
  206. .image {
  207. width: 216px;
  208. height: 144px;
  209. }
  210. }
  211. .right {
  212. margin: 0 0 0 10px;
  213. .right_1 {
  214. height: 24px;
  215. font-size: 18px;
  216. font-family:
  217. PingFangSC-Medium,
  218. PingFang SC;
  219. font-weight: 500;
  220. color: #111;
  221. display: block;
  222. line-height: 24px;
  223. margin-bottom: 20px;
  224. }
  225. .right_2 {
  226. margin-bottom: 20px;
  227. height: 48px;
  228. overflow: hidden;
  229. font-size: 14px;
  230. font-family:
  231. PingFangSC-Regular,
  232. PingFang SC;
  233. font-weight: 400;
  234. color: #999;
  235. line-height: 24px;
  236. }
  237. .right_3 {
  238. font-size: 12px;
  239. font-family:
  240. PingFangSC-Regular,
  241. PingFang SC;
  242. font-weight: 400;
  243. color: #999;
  244. line-height: 12px;
  245. }
  246. .right_1:hover {
  247. color: #2374ff;
  248. }
  249. }
  250. }
  251. }
  252. .right {
  253. .title {
  254. display: flex;
  255. align-items: center;
  256. justify-content: space-between;
  257. background: linear-gradient(90deg, #d7e8ff, #fff);
  258. width: 300px;
  259. height: 64px;
  260. padding-left: 21px;
  261. padding-right: 5px;
  262. box-sizing: border-box;
  263. margin-bottom: 7px;
  264. .left {
  265. font-size: 24px;
  266. font-family:
  267. PingFangSC-Medium,
  268. PingFang SC;
  269. font-weight: 500;
  270. color: #111;
  271. line-height: 24px;
  272. }
  273. .right {
  274. font-size: 14px;
  275. font-family:
  276. PingFangSC-Regular,
  277. PingFang SC;
  278. font-weight: 400;
  279. color: #666;
  280. }
  281. }
  282. .content {
  283. margin: 10px 0 0 0;
  284. .name {
  285. max-height: 48px;
  286. font-size: 14px;
  287. font-family:
  288. PingFangSC-Medium,
  289. PingFang SC;
  290. font-weight: 500;
  291. color: #111;
  292. line-height: 24px;
  293. display: block;
  294. }
  295. .time {
  296. margin-top: 8px;
  297. font-size: 12px;
  298. font-family:
  299. PingFangSC-Medium,
  300. PingFang SC;
  301. font-weight: 500;
  302. color: #999;
  303. line-height: 17px;
  304. }
  305. }
  306. }
  307. }
  308. .thr {
  309. display: flex;
  310. flex-direction: row-reverse;
  311. padding: 20px;
  312. }
  313. }
  314. </style>