百色农校完成
This commit is contained in:
85
components/Index/Carousel2.vue
Normal file
85
components/Index/Carousel2.vue
Normal file
@@ -0,0 +1,85 @@
|
||||
<template>
|
||||
<div v-if="list" style="margin-top: 210px;" class="w-full bg-white mb-3 hidden-sm-and-down">
|
||||
<el-carousel id="flash1" :height="flashHeight + 'px'" :interval="2000">
|
||||
<el-carousel-item v-for="(item,index) in list" :key="index">
|
||||
<div class="item relative flex justify-center items-center">
|
||||
<el-image :src="`${FILE_SERVER}${item.image}`" fit="fill" class="w-full" :style="`height: 300px;`" />
|
||||
<!-- fit: '' | 'fill' | 'contain' | 'cover' | 'none' | 'scale-down'-->
|
||||
</div>
|
||||
</el-carousel-item>
|
||||
</el-carousel>
|
||||
</div>
|
||||
|
||||
<!-- 移动端 -->
|
||||
<!-- <div class="sm:hidden w-full bg-white mt-[38px] mb-3 hidden-sm-and-up" v-if="ad">-->
|
||||
<!-- <el-carousel indicator-position="none" height="200">-->
|
||||
<!-- <el-carousel-item v-for="(item,index) in ad?.imageList" :key="index">-->
|
||||
<!-- <el-image :src="item.url" />-->
|
||||
<!-- </el-carousel-item>-->
|
||||
<!-- </el-carousel>-->
|
||||
<!-- </div>-->
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type {CompanyParam} from "~/api/system/company/model";
|
||||
import type {CmsAd} from "~/api/cms/cmsAd/model";
|
||||
import {getCmsAd, pageCmsAd} from "~/api/cms/cmsAd";
|
||||
import {pageCmsArticle} from "~/api/cms/cmsArticle";
|
||||
import type {CmsArticle} from "~/api/cms/cmsArticle/model";
|
||||
import {FILE_SERVER} from "~/config";
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
config?: any;
|
||||
list?: any[];
|
||||
disabled?: boolean;
|
||||
title?: string;
|
||||
comments?: string;
|
||||
}>(),
|
||||
{
|
||||
title: '卡片标题',
|
||||
comments: '卡片描述'
|
||||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
}>();
|
||||
|
||||
const isMobile = useIsMobile();
|
||||
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