130 lines
3.2 KiB
Vue
130 lines
3.2 KiB
Vue
<template>
|
|
|
|
<Banner :layout="layout" />
|
|
|
|
<!-- 主体部分 -->
|
|
<div class="p-5">
|
|
|
|
<div class="m-page">
|
|
<div class="sitemp h-[32px] flex justify-between">
|
|
<h2>
|
|
{{ page.title }}
|
|
</h2>
|
|
</div>
|
|
<div class="content py-3">
|
|
<el-row :gutter="16">
|
|
<el-col :span="24" v-for="(item,index) in list" key="index">
|
|
<div class="cast-item">
|
|
<a :href="mDetail(item)" :title="item.title" class="img"><el-image :fit="`scale-down`" :src="item.image" :alt="item.title" /></a>
|
|
<div class="flex flex-col leading-7">
|
|
<a :href="mDetail(item)" class="text-[16px] font-bold" :title="item.title">{{ item.title }}</a>
|
|
<a :href="mDetail(item)" class="more"><span class="text-gray-400">{{ $t('case.detail') }}>></span></a>
|
|
</div>
|
|
</div>
|
|
</el-col>
|
|
</el-row>
|
|
|
|
<Pagination :total="total" @done="search" />
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
<script setup lang="ts">
|
|
import Banner from "@/components/Banner.vue";
|
|
import {useLayout, usePage} from "~/composables/configState";
|
|
import type {CmsNavigation} from "~/api/cms/cmsNavigation/model";
|
|
import type {CmsArticle, CmsArticleParam} from "~/api/cms/cmsArticle/model";
|
|
import type { ComponentSize } from 'element-plus'
|
|
import {paramsId} from "~/utils/common";
|
|
import {getCmsNavigation, listCmsNavigation} from "~/api/cms/cmsNavigation";
|
|
import {pageCmsArticle} from "~/api/cms/cmsArticle";
|
|
import CmsArticleList from "~/components/CmsArticleList.vue";
|
|
|
|
const route = useRoute();
|
|
|
|
// 页面信息
|
|
const list = ref<CmsArticle[]>([]);
|
|
const i18n = useI18n();
|
|
const category = ref<CmsNavigation[]>([]);
|
|
const total = ref(0);
|
|
|
|
// 获取状态
|
|
const page = usePage();
|
|
const layout = useLayout();
|
|
|
|
// 搜索表单
|
|
const where = reactive<CmsArticleParam>({
|
|
keywords: '',
|
|
page: 1,
|
|
limit: 20,
|
|
status: 0,
|
|
parentId: undefined,
|
|
categoryId: undefined,
|
|
lang: i18n.locale.value
|
|
});
|
|
|
|
|
|
// 加载页面数据
|
|
const reload = async () => {
|
|
await getCmsNavigation(paramsId()).then(data => {
|
|
page.value = data;
|
|
// layout.value = data.design;
|
|
layout.value.banner = data.banner;
|
|
|
|
// seo
|
|
useSeoMeta({
|
|
description: data.comments || data.title,
|
|
keywords: data.title,
|
|
titleTemplate: `${data?.title}` + ' - %s',
|
|
})
|
|
|
|
// 二级栏目分类
|
|
listCmsNavigation({
|
|
parentId: data.parentId == 0 ? data.navigationId : data.parentId
|
|
}).then(navigation => {
|
|
category.value = navigation;
|
|
// 加载文章列表
|
|
if(data.parentId == 0 && category.value.length > 0){
|
|
where.parentId = page.value.navigationId;
|
|
}else {
|
|
where.categoryId = page.value.navigationId;
|
|
}
|
|
pageCmsArticle(where).then(response => {
|
|
if(response){
|
|
total.value = response.count;
|
|
list.value = response.list;
|
|
}
|
|
})
|
|
})
|
|
})
|
|
}
|
|
|
|
/**
|
|
* 搜索
|
|
* @param data
|
|
*/
|
|
const search = (data: CmsArticleParam) => {
|
|
where.page = data.page;
|
|
reload();
|
|
}
|
|
|
|
watch(
|
|
() => route.path,
|
|
() => {
|
|
reload();
|
|
},
|
|
{immediate: true}
|
|
);
|
|
</script>
|
|
<style scoped lang="less">
|
|
.case_listn li{
|
|
max-width: 200px;
|
|
}
|
|
.cast-item{
|
|
border: 1px solid #eeeeee;
|
|
padding: 10px;
|
|
margin-bottom: 10px;
|
|
}
|
|
</style>
|