index.vue 8.1 KB

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