Compare commits

...

6 Commits

Author SHA1 Message Date
853046d633 feat: 服务支持页面竖屏适配
All checks were successful
deploy to server / build-and-deploy (push) Successful in 3m7s
-竖屏是修改支持卡片布局
2025-11-01 16:32:37 +08:00
0996e910d9 feat: 产品筛选器竖屏适配
- 切换到竖屏是产品筛选器改为两行
2025-11-01 16:26:37 +08:00
52048fc2a6 feat: 产品详情页竖屏适配 2025-11-01 16:26:16 +08:00
fc164beaf3 fix: 移除console输出 2025-11-01 16:08:25 +08:00
3b6857637b fix: 调整footer行为 2025-11-01 16:05:59 +08:00
d076088747 feat: 首页竖屏适配
- 首页Carousel高度根据屏幕宽度变化
- 首页推荐栏目卡片数量随屏幕宽度改变
2025-11-01 15:32:15 +08:00
9 changed files with 226 additions and 21 deletions

View File

@ -83,4 +83,10 @@
border-radius: 5px; border-radius: 5px;
font-size: 14px; font-size: 14px;
} }
@media (max-width: 768px) {
.homepage-carousel .el-carousel__item {
height: 50vw;
}
}
</style> </style>

View File

@ -7,19 +7,20 @@
<div v-if="!pending"> <div v-if="!pending">
<el-carousel <el-carousel
class="recommend-carousel" class="recommend-carousel"
height="auto" :height="carouselHeight"
arrow="never" arrow="never"
indicator-position="outside" indicator-position="outside"
:autoplay="false" :autoplay="false"
> >
<el-carousel-item <el-carousel-item
v-for="n in Math.floor(products.length / 3) + 1" v-for="n in pages"
ref="carouselItem"
:key="n" :key="n"
class="recommend-list" class="recommend-list"
> >
<div class="recommend-card-group"> <div class="recommend-card-group">
<el-card <el-card
v-for="(item, index) in products.slice((n - 1) * 3, n * 3)" v-for="(item, index) in pageProducts(n)"
:key="index" :key="index"
class="recommend-card" class="recommend-card"
@click="handleProductCardClick(item.id.toString() || '')" @click="handleProductCardClick(item.id.toString() || '')"
@ -64,9 +65,32 @@
}, },
}); });
const carouselHeight = ref<string>('auto');
const perPage = ref(3);
const carouselItem = ref<HTMLElement | null>(null);
const { getImageUrl } = useDirectusImage(); const { getImageUrl } = useDirectusImage();
const { height } = useElementSize(carouselItem);
const products = computed(() => props.homepageData?.recommendProducts || []); const products = computed(() => props.homepageData?.recommendProducts || []);
const pages = computed(() =>
Math.ceil(products.value.length / perPage.value)
);
const updatePerPage = () => {
const width = window.innerWidth;
if (width < 768) {
perPage.value = 1;
} else if (width < 1024) {
perPage.value = 2;
} else {
perPage.value = 3;
}
};
const pageProducts = (n: number) => {
return products.value.slice((n - 1) * perPage.value, n * perPage.value);
};
const handleProductCardClick = (documentId: string) => { const handleProductCardClick = (documentId: string) => {
// 使用路由导航到产品详情页 // 使用路由导航到产品详情页
@ -76,6 +100,21 @@
router.push(localePath(`/products/${documentId}`)); router.push(localePath(`/products/${documentId}`));
} }
}; };
watch(height, (h) => {
if (h > 0) {
carouselHeight.value = h + 40 + 'px';
}
});
onMounted(() => {
updatePerPage();
window.addEventListener('resize', updatePerPage);
});
onBeforeUnmount(() => {
window.removeEventListener('resize', updatePerPage);
});
</script> </script>
<style scoped> <style scoped>
@ -126,7 +165,7 @@
.recommend-list { .recommend-list {
display: flex; display: flex;
padding: 1rem; padding: 1rem;
height: 400px; height: auto;
} }
.recommend-card-group { .recommend-card-group {
@ -134,7 +173,7 @@
gap: 1rem; gap: 1rem;
width: 100%; width: 100%;
margin: 0 auto; margin: 0 auto;
height: 100%; height: auto;
} }
.recommend-card { .recommend-card {
@ -173,4 +212,16 @@
width: 100%; width: 100%;
border-radius: 4px; border-radius: 4px;
} }
@media (max-width: 1024px) {
.recommend-card {
width: 50%;
}
}
@media (max-width: 768px) {
.recommend-card {
width: 100%;
}
}
</style> </style>

View File

@ -5,19 +5,20 @@
<div v-if="!pending"> <div v-if="!pending">
<el-carousel <el-carousel
class="recommend-carousel" class="recommend-carousel"
height="auto" :height="carouselHeight"
arrow="never" arrow="never"
indicator-position="outside" indicator-position="outside"
:autoplay="false" :autoplay="false"
> >
<el-carousel-item <el-carousel-item
v-for="n in Math.floor(solutions.length / 3) + 1" v-for="n in pages"
ref="carouselItem"
:key="n" :key="n"
class="recommend-list" class="recommend-list"
> >
<div class="recommend-card-group"> <div class="recommend-card-group">
<el-card <el-card
v-for="(item, index) in solutions.slice((n - 1) * 3, n * 3)" v-for="(item, index) in pageSolutions(n)"
:key="index" :key="index"
class="recommend-card" class="recommend-card"
@click="handleSolutionCardClick(item.id.toString() || '')" @click="handleSolutionCardClick(item.id.toString() || '')"
@ -62,11 +63,34 @@
}, },
}); });
const carouselHeight = ref<string>('auto');
const perPage = ref(3);
const carouselItem = ref<HTMLElement | null>(null);
const { getImageUrl } = useDirectusImage(); const { getImageUrl } = useDirectusImage();
const { height } = useElementSize(carouselItem);
const solutions = computed( const solutions = computed(
() => props.homepageData?.recommendSolutions || [] () => props.homepageData?.recommendSolutions || []
); );
const pages = computed(() =>
Math.ceil(solutions.value.length / perPage.value)
);
const updatePerPage = () => {
const width = window.innerWidth;
if (width < 768) {
perPage.value = 1;
} else if (width < 1024) {
perPage.value = 2;
} else {
perPage.value = 3;
}
};
const pageSolutions = (n: number) => {
return solutions.value.slice((n - 1) * perPage.value, n * perPage.value);
};
const handleSolutionCardClick = (documentId: string) => { const handleSolutionCardClick = (documentId: string) => {
// 使用路由导航到产品详情页 // 使用路由导航到产品详情页
@ -76,6 +100,21 @@
router.push(localePath(`/solutions/${documentId}`)); router.push(localePath(`/solutions/${documentId}`));
} }
}; };
watch(height, (h) => {
if (h > 0) {
carouselHeight.value = h + 40 + 'px';
}
});
onMounted(() => {
updatePerPage();
window.addEventListener('resize', updatePerPage);
});
onBeforeUnmount(() => {
window.removeEventListener('resize', updatePerPage);
});
</script> </script>
<style scoped> <style scoped>
@ -126,7 +165,7 @@
.recommend-list { .recommend-list {
display: flex; display: flex;
padding: 1rem; padding: 1rem;
height: 400px; height: auto;
} }
.recommend-card-group { .recommend-card-group {
@ -134,7 +173,7 @@
gap: 1rem; gap: 1rem;
width: 100%; width: 100%;
margin: 0 auto; margin: 0 auto;
height: 100%; height: auto;
} }
.recommend-card { .recommend-card {
@ -173,4 +212,16 @@
width: 100%; width: 100%;
border-radius: 4px; border-radius: 4px;
} }
@media (max-width: 1024px) {
.recommend-card {
width: 50%;
}
}
@media (max-width: 768px) {
.recommend-card {
width: 100%;
}
}
</style> </style>

View File

@ -42,4 +42,11 @@
color: var(--el-text-color-primary); color: var(--el-text-color-primary);
margin: 0; margin: 0;
} }
@media (max-width: 768px) {
.product-tabs ::v-deep(.el-tabs__nav) {
float: none;
min-width: 100%;
}
}
</style> </style>

View File

@ -10,7 +10,7 @@
<el-carousel <el-carousel
v-else v-else
class="product-carousel" class="product-carousel"
height="500px" height="auto"
:autoplay="false" :autoplay="false"
:loop="false" :loop="false"
arrow="always" arrow="always"
@ -18,8 +18,9 @@
<el-carousel-item <el-carousel-item
v-for="(item, index) in product.images || []" v-for="(item, index) in product.images || []"
:key="index" :key="index"
class="product-carousel-item"
> >
<div class="product-carousel-item"> <div>
<el-image <el-image
:src="getImageUrl(item.image || '')" :src="getImageUrl(item.image || '')"
:alt="product.name" :alt="product.name"
@ -59,6 +60,10 @@
gap: 3rem; gap: 3rem;
} }
.product-carousel-item {
height: 500px;
}
.product-image .el-image { .product-image .el-image {
position: relative; position: relative;
width: 100%; width: 100%;
@ -99,4 +104,23 @@
line-height: 1.6; line-height: 1.6;
margin-bottom: 2rem; margin-bottom: 2rem;
} }
@media (max-width: 768px) {
.product-header {
grid-template-columns: 1fr;
}
.product-carousel-item {
height: 300px;
}
.product-image .el-image {
height: 300px;
}
.product-info h1 {
font-size: 1.5rem;
margin-top: 0;
}
}
</style> </style>

View File

@ -1,6 +1,6 @@
<template> <template>
<footer class="jinshen-footer"> <footer class="jinshen-footer">
<div class="footer-container"> <div class="footer-container hide-on-mobile">
<!-- Logo 和公司信息 --> <!-- Logo 和公司信息 -->
<div class="footer-section"> <div class="footer-section">
<div class="footer-logo"> <div class="footer-logo">
@ -250,6 +250,10 @@
/* 响应式设计 */ /* 响应式设计 */
@media (max-width: 768px) { @media (max-width: 768px) {
.hide-on-mobile {
display: none;
}
.footer-container { .footer-container {
grid-template-columns: 1fr; grid-template-columns: 1fr;
padding: 1.5rem 1rem; padding: 1.5rem 1rem;

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="question-category"> <div class="question-category">
<el-row :gutter="12"> <el-row class="hide-on-mobile" :gutter="12">
<el-col :span="8"> <el-col :span="8">
<span class="select-label">产品分类</span> <span class="select-label">产品分类</span>
<el-select <el-select
@ -43,6 +43,48 @@
/> />
</el-col> </el-col>
</el-row> </el-row>
<el-row class="display-on-mobile" :gutter="12">
<el-col :span="12">
<span class="select-label">产品分类</span>
<el-select
v-model="model.selectedType"
placeholder="选择产品类型"
clearable
>
<el-option
v-for="type in productTypeOptions"
:key="type.id"
:label="type.name"
:value="type.id"
/>
</el-select>
</el-col>
<el-col :span="12">
<span class="select-label">产品系列</span>
<el-select
v-model="model.selectedProduct"
placeholder="选择系列产品"
clearable
>
<el-option
v-for="product in productOptions"
:key="product.id"
:label="product.name"
:value="product.id"
/>
</el-select>
</el-col>
</el-row>
<el-row class="display-on-mobile">
<span class="select-label">关键词</span>
<el-input
v-model="model.keyword"
placeholder="输入关键词..."
clearable
:prefix-icon="Search"
/>
</el-row>
</div> </div>
</template> </template>
@ -82,4 +124,18 @@
height: 40px; height: 40px;
font-size: 0.9rem; font-size: 0.9rem;
} }
.display-on-mobile {
display: none;
}
@media (max-width: 768px) {
.hide-on-mobile {
display: none;
}
.display-on-mobile {
display: flex;
margin-bottom: 1rem;
}
}
</style> </style>

View File

@ -34,10 +34,4 @@
.page-footer { .page-footer {
padding: 0px; padding: 0px;
} }
@media (max-width: 768px) {
.page-footer {
display: none;
}
}
</style> </style>

View File

@ -86,7 +86,8 @@
} }
.card-group { .card-group {
display: flex; display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 50px; gap: 50px;
justify-content: space-around; justify-content: space-around;
margin-bottom: 2rem; margin-bottom: 2rem;
@ -121,4 +122,15 @@
border-radius: 4px; border-radius: 4px;
min-height: 36px; min-height: 36px;
} }
@media (max-width: 768px) {
section {
width: 100%;
}
.card-group {
grid-template-columns: 1fr;
gap: 20px;
}
}
</style> </style>