123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316 |
- <template>
- <div id="index">
- <el-row>
- <el-col :span="24" class="main animate__animated animate__backInRight">
- <el-col :span="24" class="brain">
- <el-image class="image" :src="brain" fit="fill" />
- </el-col>
- <div class="w_1200">
- <el-col :span="24" class="two">
- <el-col :span="18" class="left">
- <el-col
- :span="24"
- class="list"
- v-for="(item, index) in list"
- :key="index"
- @click="toView(item)"
- >
- <el-col :span="6" class="left">
- <el-image
- class="image"
- v-if="item.logo && item.logo.length > 0"
- :src="item.logo[0].url"
- fit="fill"
- />
- <el-image class="image" v-else :src="new_4" fit="fill" />
- </el-col>
- <el-col :span="17" class="right">
- <el-col :span="24" class="right_1 textOver">
- {{ item.title || '暂无标题' }}
- </el-col>
- <el-col :span="24" class="right_2 textMore">
- <div v-html="removeHtmlStyle(item.content)"></div>
- </el-col>
- <el-col :span="24" class="right_3">
- {{ item.time || '暂无' }}
- </el-col>
- </el-col>
- </el-col>
- </el-col>
- <el-col :span="5" class="right">
- <el-col :span="24" class="title">
- <el-col :span="24" class="left">成果展示 </el-col>
- <el-col :span="24" class="right" @click="toMore(0)"> 查看更多</el-col>
- </el-col>
- <el-col :span="24" class="content">
- <a-timeline>
- <a-timeline-item
- v-for="(item, index) in achievementList"
- :key="index"
- @click="toCommon(item, '/achievement/detail')"
- >
- <div class="name">{{ item.name }}</div>
- <div class="time">{{ item.time }}</div>
- </a-timeline-item>
- </a-timeline>
- </el-col>
- <el-col :span="24" class="title">
- <el-col :span="24" class="left">项目精选 </el-col>
- <el-col :span="24" class="right" @click="toMore(1)"> 查看更多</el-col>
- </el-col>
- <el-col :span="24" class="content">
- <a-timeline>
- <a-timeline-item
- v-for="(item, index) in projectList"
- :key="index"
- @click="toCommon(item, '/project/detail')"
- >
- <div class="name">{{ item.name }}</div>
- <div class="time">{{ item.time }}</div>
- </a-timeline-item>
- </a-timeline>
- </el-col>
- </el-col>
- </el-col>
- <el-col :span="24" class="thr">
- <el-pagination
- background
- layout="total, prev, pager, next"
- :page-sizes="[10, 20, 50, 100, 200]"
- :total="total"
- :page-size="limit"
- v-model:current-page="currentPage"
- @current-change="changePage"
- @size-change="sizeChange"
- >
- </el-pagination>
- </el-col>
- </div>
- </el-col>
- </el-row>
- </div>
- </template>
- <script setup>
- // 接口
- import { NewsStore } from '@/store/api/platform/news'
- import { AchievementStore } from '@/store/api/platform/achievement'
- import { ProjectStore } from '@/store/api/platform/project'
- const store = NewsStore()
- const projectStore = ProjectStore()
- const achievementStore = AchievementStore()
- // 路由
- const router = useRouter()
- // 图片引入
- import brain from '@/assets/home.jpg'
- import new_4 from '@/assets/new_4.png'
- // 加载中
- const loading = ref(false)
- // 列表
- const list = ref([])
- let skip = 0
- let limit = inject('limit')
- const total = ref(0)
- const achievementList = ref([])
- const projectList = ref([])
- // 请求
- onMounted(async () => {
- loading.value = true
- await searchOther()
- await search({ skip, limit })
- loading.value = false
- })
- const searchOther = async () => {
- const info = {
- skip: 0,
- limit: 6,
- status: '1',
- is_use: '0'
- }
- let res
- res = await achievementStore.query(info)
- if (res.errcode == '0') achievementList.value = res.data
- res = await projectStore.query(info)
- if (res.errcode == '0') projectList.value = res.data
- }
- const search = async (query = { skip: 0, limit }) => {
- const info = {
- skip: query.skip,
- limit: query.limit,
- status: '1',
- is_use: '0'
- }
- const res = await store.query(info)
- if (res.errcode == '0') {
- list.value = res.data
- total.value = res.total
- }
- }
- // 查看
- const toView = (item) => {
- router.push({ path: `/news/detail`, query: { id: item.id || item._id } })
- }
- // 查看更多
- const toMore = (type) => {
- if (type == '0') router.push({ path: `/achievement` })
- else router.push({ path: `/project` })
- }
- // 详情
- const toCommon = (item, route) => {
- router.push({ path: route, query: { id: item._id || item.id } })
- }
- const removeHtmlStyle = (html) => {
- let relStyle = /style\s*?=\s*?([‘"])[\s\S]*?\1/g //去除样式
- let relTag = /<.+?>/g //去除标签
- let relClass = /class\s*?=\s*?([‘"])[\s\S]*?\1/g // 清除类名
- let newHtml = ''
- if (html) {
- newHtml = html.replace(relStyle, '')
- newHtml = newHtml.replace(relTag, '')
- newHtml = newHtml.replace(relClass, '')
- }
- return newHtml
- }
- const currentPage = ref(1)
- // 分页
- const changePage = (page = currentPage.value) => {
- search({ skip: (page - 1) * limit, limit: limit })
- }
- const sizeChange = (limits) => {
- limit = limits
- currentPage.value = 1
- search({ skip: 0, limit: limit })
- }
- </script>
- <style lang="scss" scoped>
- .main {
- background: rgb(248, 248, 248);
- .brain {
- .image {
- width: 100%;
- height: 200px;
- }
- }
- .two {
- display: flex;
- width: 100%;
- margin: 10px 0 0 0;
- padding: 10px;
- background-color: #fff;
- border-radius: 10px;
- .left {
- .list {
- display: flex;
- align-items: center;
- margin-bottom: 30px;
- .left {
- .image {
- width: 216px;
- height: 144px;
- }
- }
- .right {
- margin: 0 0 0 10px;
- .right_1 {
- height: 24px;
- font-size: 18px;
- font-family:
- PingFangSC-Medium,
- PingFang SC;
- font-weight: 500;
- color: #111;
- display: block;
- line-height: 24px;
- margin-bottom: 20px;
- }
- .right_2 {
- margin-bottom: 20px;
- height: 48px;
- overflow: hidden;
- font-size: 14px;
- font-family:
- PingFangSC-Regular,
- PingFang SC;
- font-weight: 400;
- color: #999;
- line-height: 24px;
- }
- .right_3 {
- font-size: 12px;
- font-family:
- PingFangSC-Regular,
- PingFang SC;
- font-weight: 400;
- color: #999;
- line-height: 12px;
- }
- .right_1:hover {
- color: #2374ff;
- }
- }
- }
- }
- .right {
- .title {
- display: flex;
- align-items: center;
- justify-content: space-between;
- background: linear-gradient(90deg, #d7e8ff, #fff);
- width: 300px;
- height: 64px;
- padding-left: 21px;
- padding-right: 5px;
- box-sizing: border-box;
- margin-bottom: 7px;
- .left {
- font-size: 24px;
- font-family:
- PingFangSC-Medium,
- PingFang SC;
- font-weight: 500;
- color: #111;
- line-height: 24px;
- }
- .right {
- font-size: 14px;
- font-family:
- PingFangSC-Regular,
- PingFang SC;
- font-weight: 400;
- color: #666;
- }
- }
- .content {
- margin: 10px 0 0 0;
- .name {
- max-height: 48px;
- font-size: 14px;
- font-family:
- PingFangSC-Medium,
- PingFang SC;
- font-weight: 500;
- color: #111;
- line-height: 24px;
- display: block;
- }
- .time {
- margin-top: 8px;
- font-size: 12px;
- font-family:
- PingFangSC-Medium,
- PingFang SC;
- font-weight: 500;
- color: #999;
- line-height: 17px;
- }
- }
- }
- }
- .thr {
- display: flex;
- flex-direction: row-reverse;
- padding: 20px;
- }
- }
- </style>
|