百色农校
This commit is contained in:
75
components/Index/HotNewsCarousel.vue
Normal file
75
components/Index/HotNewsCarousel.vue
Normal file
@@ -0,0 +1,75 @@
|
||||
<template>
|
||||
<div class="lg:my-3 my-0 relative">
|
||||
<el-carousel :height="flashHeight + 'px'" indicator-position="none">
|
||||
<el-carousel-item v-for="(item,index) in list" :key="index">
|
||||
<nuxt-link :to="`/detail/${item.articleId}.html`" class="item flex justify-center items-center">
|
||||
<img :src="`${FILE_SERVER}${item.image}`" class="w-[500px] h-[380px]" />
|
||||
<div class="absolute bottom-3 z-100 text-white font-bold px-4 line-clamp-1 text-sm lg:text-lg">{{ item.title }}</div>
|
||||
</nuxt-link>
|
||||
</el-carousel-item>
|
||||
</el-carousel>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type {CompanyParam} from "~/api/system/company/model";
|
||||
import {pageCmsArticle} from "~/api/cms/cmsArticle";
|
||||
import type {CmsArticle} from "~/api/cms/cmsArticle/model";
|
||||
import {FILE_SERVER} from "~/config";
|
||||
|
||||
const isMobile = useIsMobile();
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
config?: any;
|
||||
list?: any[];
|
||||
disabled?: boolean;
|
||||
title?: string;
|
||||
comments?: string;
|
||||
}>(),
|
||||
{
|
||||
title: '卡片标题',
|
||||
comments: '卡片描述'
|
||||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
}>();
|
||||
|
||||
const list = ref<CmsArticle[]>([]);
|
||||
const flashHeight = ref<number>(372)
|
||||
|
||||
// 搜索表单
|
||||
const where = reactive<CompanyParam>({
|
||||
keywords: ''
|
||||
});
|
||||
|
||||
// 请求数据
|
||||
const reload = async () => {
|
||||
pageCmsArticle({
|
||||
recommend: 1,
|
||||
limit: 5,
|
||||
lang: getLang()
|
||||
}).then(res => {
|
||||
list.value = res?.list || [];
|
||||
})
|
||||
if(isMobile.value){
|
||||
flashHeight.value = 260;
|
||||
}
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.config,
|
||||
() => {
|
||||
reload();
|
||||
},
|
||||
{immediate: true}
|
||||
);
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.hidden-sm-and-up .el-carousel{
|
||||
height: 160px;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user