hookehuyr

解决方案自适应样式优化

1 <!-- 1 <!--
2 * @Date: 2024-09-29 15:49:27 2 * @Date: 2024-09-29 15:49:27
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2024-10-16 18:55:21 4 + * @LastEditTime: 2024-10-21 14:43:11
5 * @FilePath: /hager/src/views/solution/detail.vue 5 * @FilePath: /hager/src/views/solution/detail.vue
6 * @Description: 文件描述 6 * @Description: 文件描述
7 --> 7 -->
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
18 </div> 18 </div>
19 </div> 19 </div>
20 </hager-box> 20 </hager-box>
21 - <hager-box class="box-n"> 21 + <hager-box v-if="!is_xs" class="box-n">
22 <el-row :gutter="0"> 22 <el-row :gutter="0">
23 <el-col :span="12" style="height: 25rem;"> 23 <el-col :span="12" style="height: 25rem;">
24 <el-carousel height="25rem" :interval="8000" style="border-radius: 5px;"> 24 <el-carousel height="25rem" :interval="8000" style="border-radius: 5px;">
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
27 </el-carousel-item> 27 </el-carousel-item>
28 </el-carousel> 28 </el-carousel>
29 </el-col> 29 </el-col>
30 - <el-col class="brief-introduction" :span="12"> 30 + <el-col :span="12" class="brief-introduction">
31 <div class="intro-box"> 31 <div class="intro-box">
32 <hager-h1 title="学校解决方案" sub="Electronic solutions"></hager-h1> 32 <hager-h1 title="学校解决方案" sub="Electronic solutions"></hager-h1>
33 <p style="margin: 2rem 0;">淨於电气开乐驾能民电峰决方案,提供安全。可靠。摄作友好。易于堆护的电力划! 1h14. n53 X0(009121 3098. 228 41324849 56MeD 换至备用电源,保障救学和生活的连续性。</p> 33 <p style="margin: 2rem 0;">淨於电气开乐驾能民电峰决方案,提供安全。可靠。摄作友好。易于堆护的电力划! 1h14. n53 X0(009121 3098. 228 41324849 56MeD 换至备用电源,保障救学和生活的连续性。</p>
...@@ -36,24 +36,67 @@ ...@@ -36,24 +36,67 @@
36 </el-col> 36 </el-col>
37 </el-row> 37 </el-row>
38 </hager-box> 38 </hager-box>
39 + <div v-else>
40 + <div style="height: 25rem; margin-top: 2rem;">
41 + <el-carousel height="25rem" :interval="8000" style="border-radius: 5px;">
42 + <el-carousel-item v-for="(item, index) in banner_list" :key="index" class="carousel-img">
43 + <el-image @click="onClickImg(item.src)" style="width: 100%; height: 100%;" fit="fill" :src="item.src"></el-image>
44 + </el-carousel-item>
45 + </el-carousel>
46 + </div>
47 + <div class="brief-introduction xs">
48 + <div class="intro-box xs">
49 + <hager-h1 title="学校解决方案" sub="Electronic solutions"></hager-h1>
50 + <p style="margin: 2rem 0;">淨於电气开乐驾能民电峰决方案,提供安全。可靠。摄作友好。易于堆护的电力划! 1h14. n53 X0(009121 3098. 228 41324849 56MeD 换至备用电源,保障救学和生活的连续性。</p>
51 + <i class="el-icon-right"></i>
52 + </div>
53 + </div>
54 + </div>
39 <hager-box class="box-2n"> 55 <hager-box class="box-2n">
40 <hager-h1 title="成功案例" sub="Success Cases" style="margin: 2rem 0;"></hager-h1> 56 <hager-h1 title="成功案例" sub="Success Cases" style="margin: 2rem 0;"></hager-h1>
41 - <div class="hager-success-cases"> 57 + <div v-if="!is_xs">
42 - <div class="card" v-for="(item, index) in success_data_list" :key="index"> 58 + <div class="hager-success-cases">
43 - <img :src="item.img" alt="学校图片" class="card-image"> 59 + <div class="card" v-for="(item, index) in success_data_list" :key="index">
44 - <div class="card-content"> 60 + <img :src="item.img" alt="学校图片" class="card-image">
45 - <h3>{{ item.title }}</h3> 61 + <div class="card-content">
46 - <p>{{ item.sub }}</p> 62 + <h3>{{ item.title }}</h3>
47 - <i class="el-icon-right"></i> 63 + <p>{{ item.sub }}</p>
64 + <i class="el-icon-right"></i>
65 + </div>
48 </div> 66 </div>
49 </div> 67 </div>
68 + <div style="display: flex; justify-content: center; margin-top: 2rem;">
69 + <hager-more></hager-more>
70 + </div>
50 </div> 71 </div>
51 - <div style="display: flex; justify-content: center; margin-top: 2rem;"> 72 + <div v-else>
52 - <hager-more></hager-more> 73 + <swiper ref="mySuccessSwiper" class="swiper" :options="swiperOption" @slideChange="onSuccessSlideChange">
74 + <swiper-slide v-for="(item, index) in success_data_list" :key="index">
75 + <div class="hager-success-cases xs">
76 + <div class="card">
77 + <img :src="item.img" alt="学校图片" class="card-image">
78 + <div class="card-content">
79 + <h3>{{ item.title }}</h3>
80 + <p class="clamp-text">{{ item.sub }}</p>
81 + <i class="el-icon-right"></i>
82 + </div>
83 + </div>
84 + </div>
85 + </swiper-slide>
86 + </swiper>
87 + <div v-if="success_data_list.length > SuccessSlidesPerView || is_xs" class="hager-product-center-more xs">
88 + <hager-more></hager-more>
89 + <div class="xs-control">
90 + <div>
91 + <i :class="['el-icon-arrow-left', activeSuccessIndex === 0 ? 'disabled' : '']" @click="prevSuccessBtn()"></i>
92 + <i :class="['el-icon-arrow-right', reach_success_end ? 'disabled' : '']" @click="nextSuccessBtn()"></i>
93 + </div>
94 + </div>
95 + </div>
53 </div> 96 </div>
54 </hager-box> 97 </hager-box>
55 <hager-box class="box-n"> 98 <hager-box class="box-n">
56 - <hager-h1 title="使用产品" sub="Our advantages" style="margin: 2rem 0;"></hager-h1> 99 + <hager-h1 title="使用产品" sub="Products" style="margin: 2rem 0;"></hager-h1>
57 <swiper ref="myProductSwiper" class="swiper" :options="swiperOption" @slideChange="onProductSlideChange"> 100 <swiper ref="myProductSwiper" class="swiper" :options="swiperOption" @slideChange="onProductSlideChange">
58 <swiper-slide v-for="(item, index) in product_list" :key="index"> 101 <swiper-slide v-for="(item, index) in product_list" :key="index">
59 <div class="card-box" @click="goToProduct(item)"> 102 <div class="card-box" @click="goToProduct(item)">
...@@ -65,8 +108,8 @@ ...@@ -65,8 +108,8 @@
65 </div> 108 </div>
66 </swiper-slide> 109 </swiper-slide>
67 </swiper> 110 </swiper>
68 - <div class="hager-product-center-more"> 111 + <div v-if="product_list.length > productSlidesPerView || is_xs" class="hager-product-center-more">
69 - <hager-more></hager-more> 112 + <!-- <hager-more></hager-more> -->
70 <div class="xs-control"> 113 <div class="xs-control">
71 <div> 114 <div>
72 <i :class="['el-icon-arrow-left', activeProductIndex === 0 ? 'disabled' : '']" @click="prevProductBtn()"></i> 115 <i :class="['el-icon-arrow-left', activeProductIndex === 0 ? 'disabled' : '']" @click="prevProductBtn()"></i>
...@@ -86,6 +129,7 @@ import hagerH1 from '@/components/common/hagerH1.vue'; ...@@ -86,6 +129,7 @@ import hagerH1 from '@/components/common/hagerH1.vue';
86 import hagerMore from '@/components/hagerMore.vue'; 129 import hagerMore from '@/components/hagerMore.vue';
87 import hagerHCarousel from '@/components/hagerHCarousel.vue'; 130 import hagerHCarousel from '@/components/hagerHCarousel.vue';
88 import hagerService from '@/components/common/hagerService.vue'; 131 import hagerService from '@/components/common/hagerService.vue';
132 +import $ from 'jquery';
89 133
90 export default { 134 export default {
91 components: { hagerBox, hagerH1, hagerMore, hagerHCarousel, hagerService }, 135 components: { hagerBox, hagerH1, hagerMore, hagerHCarousel, hagerService },
...@@ -105,27 +149,27 @@ export default { ...@@ -105,27 +149,27 @@ export default {
105 success_data_list: [{ 149 success_data_list: [{
106 title: '厦门翔城中小学', 150 title: '厦门翔城中小学',
107 sub: '占地面积约43811.99平方米,总建筑面积约32188.83平方米,规模48个教学班,可提供2400个优质初中学位。翔城中学是翔安第一所拥有游泳馆的中学。', 151 sub: '占地面积约43811.99平方米,总建筑面积约32188.83平方米,规模48个教学班,可提供2400个优质初中学位。翔城中学是翔安第一所拥有游泳馆的中学。',
108 - img: 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg', 152 + img: 'https://cdn.ipadbiz.cn/hager/img/WX20241021-135715@2x.png',
109 }, { 153 }, {
110 title: '厦门翔城中小学', 154 title: '厦门翔城中小学',
111 sub: '占地面积约43811.99平方米,总建筑面积约32188.83平方米,规模48个教学班,可提供2400个优质初中学位。翔城中学是翔安第一所拥有游泳馆的中学。', 155 sub: '占地面积约43811.99平方米,总建筑面积约32188.83平方米,规模48个教学班,可提供2400个优质初中学位。翔城中学是翔安第一所拥有游泳馆的中学。',
112 - img: 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg', 156 + img: 'https://cdn.ipadbiz.cn/hager/img/WX20241021-135715@2x.png',
113 }, { 157 }, {
114 title: '厦门翔城中小学', 158 title: '厦门翔城中小学',
115 sub: '占地面积约43811.99平方米,总建筑面积约32188.83平方米,规模48个教学班,可提供2400个优质初中学位。翔城中学是翔安第一所拥有游泳馆的中学。', 159 sub: '占地面积约43811.99平方米,总建筑面积约32188.83平方米,规模48个教学班,可提供2400个优质初中学位。翔城中学是翔安第一所拥有游泳馆的中学。',
116 - img: 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg', 160 + img: 'https://cdn.ipadbiz.cn/hager/img/WX20241021-135715@2x.png',
117 }, { 161 }, {
118 title: '厦门翔城中小学', 162 title: '厦门翔城中小学',
119 sub: '占地面积约43811.99平方米,总建筑面积约32188.83平方米,规模48个教学班,可提供2400个优质初中学位。翔城中学是翔安第一所拥有游泳馆的中学。', 163 sub: '占地面积约43811.99平方米,总建筑面积约32188.83平方米,规模48个教学班,可提供2400个优质初中学位。翔城中学是翔安第一所拥有游泳馆的中学。',
120 - img: 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg', 164 + img: 'https://cdn.ipadbiz.cn/hager/img/WX20241021-135715@2x.png',
121 }, { 165 }, {
122 title: '厦门翔城中小学', 166 title: '厦门翔城中小学',
123 sub: '占地面积约43811.99平方米,总建筑面积约32188.83平方米,规模48个教学班,可提供2400个优质初中学位。翔城中学是翔安第一所拥有游泳馆的中学。', 167 sub: '占地面积约43811.99平方米,总建筑面积约32188.83平方米,规模48个教学班,可提供2400个优质初中学位。翔城中学是翔安第一所拥有游泳馆的中学。',
124 - img: 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg', 168 + img: 'https://cdn.ipadbiz.cn/hager/img/WX20241021-135715@2x.png',
125 }, { 169 }, {
126 title: '厦门翔城中小学', 170 title: '厦门翔城中小学',
127 sub: '占地面积约43811.99平方米,总建筑面积约32188.83平方米,规模48个教学班,可提供2400个优质初中学位。翔城中学是翔安第一所拥有游泳馆的中学。', 171 sub: '占地面积约43811.99平方米,总建筑面积约32188.83平方米,规模48个教学班,可提供2400个优质初中学位。翔城中学是翔安第一所拥有游泳馆的中学。',
128 - img: 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg', 172 + img: 'https://cdn.ipadbiz.cn/hager/img/WX20241021-135715@2x.png',
129 }], 173 }],
130 product_list: [{ 174 product_list: [{
131 src: 'https://cdn.ipadbiz.cn/hager/img/KNX%E6%99%BA%E8%83%BD%E6%8E%A7%E5%88%B6%E6%A8%A1%E5%9D%97@2x.png', 175 src: 'https://cdn.ipadbiz.cn/hager/img/KNX%E6%99%BA%E8%83%BD%E6%8E%A7%E5%88%B6%E6%A8%A1%E5%9D%97@2x.png',
...@@ -172,13 +216,41 @@ export default { ...@@ -172,13 +216,41 @@ export default {
172 } 216 }
173 } 217 }
174 }, 218 },
175 - activeSolutionIndex: 0, 219 + activeSuccessIndex: 0,
176 activeProductIndex: 0, 220 activeProductIndex: 0,
221 + reach_success_end: false,
177 reach_product_end: false, 222 reach_product_end: false,
223 + SuccessSlidesPerView: 4,
224 + productSlidesPerView: 4,
178 } 225 }
179 }, 226 },
180 mounted () { 227 mounted () {
228 + this.$nextTick(() => {
229 + this.$refs.myProductSwiper.$swiper?.on('breakpoint', (swiper) => {
230 + // breakpoint时 显示的条数
231 + this.productSlidesPerView = swiper.slidesPerView
232 + });
181 233
234 + function clampText(element, lines) {
235 + var $element = $(element);
236 + var lineHeight = parseFloat($element.css('line-height')); // 获取行高
237 + var maxHeight = lineHeight * lines; // 计算三行的最大高度
238 +
239 + // 如果内容高度超过三行,进行截断
240 + if ($element.height() > maxHeight) {
241 + var originalText = $element.text(); // 获取原始文本
242 + var truncatedText = originalText;
243 +
244 + // 逐字截断文本,直到高度小于或等于三行
245 + while ($element.height() > maxHeight) {
246 + truncatedText = truncatedText.slice(0, -1); // 每次去掉最后一个字符
247 + $element.text(truncatedText + '...'); // 添加省略号
248 + }
249 + }
250 + }
251 +
252 + clampText('.clamp-text', 3); // 限制显示三行文本
253 + });
182 }, 254 },
183 methods: { 255 methods: {
184 onClickImg (item) { 256 onClickImg (item) {
...@@ -192,6 +264,12 @@ export default { ...@@ -192,6 +264,12 @@ export default {
192 prevProductBtn () { 264 prevProductBtn () {
193 this.$refs.myProductSwiper.$swiper.slidePrev(); 265 this.$refs.myProductSwiper.$swiper.slidePrev();
194 }, 266 },
267 + nextSuccessBtn () {
268 + this.$refs.mySuccessSwiper.$swiper.slideNext();
269 + },
270 + prevSuccessBtn () {
271 + this.$refs.mySuccessSwiper.$swiper.slidePrev();
272 + },
195 nextProductBtn () { 273 nextProductBtn () {
196 this.$refs.myProductSwiper.$swiper.slideNext(); 274 this.$refs.myProductSwiper.$swiper.slideNext();
197 }, 275 },
...@@ -205,6 +283,17 @@ export default { ...@@ -205,6 +283,17 @@ export default {
205 this.reach_product_end = false; 283 this.reach_product_end = false;
206 } 284 }
207 }, 285 },
286 + onSuccessSlideChange () {
287 + this.activeSuccessIndex = this.$refs.mySuccessSwiper.$swiper.activeIndex;
288 + const isEnd = this.$refs.mySuccessSwiper.$swiper.isEnd;
289 + console.warn(isEnd);
290 +
291 + if (isEnd) {
292 + this.reach_success_end = true;
293 + } else {
294 + this.reach_success_end = false;
295 + }
296 + },
208 } 297 }
209 } 298 }
210 </script> 299 </script>
...@@ -230,8 +319,14 @@ export default { ...@@ -230,8 +319,14 @@ export default {
230 .brief-introduction { 319 .brief-introduction {
231 background-color: #FFF; 320 background-color: #FFF;
232 height: 25rem; 321 height: 25rem;
322 + &.xs {
323 + height: auto;
324 + }
233 .intro-box { 325 .intro-box {
234 padding: 3rem; 326 padding: 3rem;
327 + &.xs {
328 + padding: 2rem;
329 + }
235 i { 330 i {
236 color: @primary-color; 331 color: @primary-color;
237 font-size: 1.5rem; 332 font-size: 1.5rem;
...@@ -240,40 +335,20 @@ export default { ...@@ -240,40 +335,20 @@ export default {
240 } 335 }
241 .hager-success-cases { 336 .hager-success-cases {
242 margin-top: 2rem; 337 margin-top: 2rem;
243 - // display: grid;
244 - // grid-template-columns: repeat(3, 1fr); /* 一行显示4个 */
245 - // gap: 1.5rem; /* 每个项目之间的间距 */
246 display: flex; 338 display: flex;
247 flex-wrap: wrap; 339 flex-wrap: wrap;
248 justify-content: space-between; /* 确保子元素之间的空间被均匀分配 */ 340 justify-content: space-between; /* 确保子元素之间的空间被均匀分配 */
249 - // .case-item { 341 + &.xs {
250 - // position: relative; 342 + display: block;
251 - // height: 12rem; 343 + }
252 - // padding: 1.5rem;
253 - // text-align: center;
254 - // color: #FFF;
255 - // border-radius: 8px;
256 - // background-image: url('https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg');
257 - // background-size: cover;
258 - // background-position: top center;
259 - // transition: transform 0.3s ease-in-out;
260 - // &:hover {
261 - // transform: scale(1.05);
262 - // box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
263 - // cursor: pointer;
264 - // }
265 - // }
266 .card { 344 .card {
267 - // margin: 0.5rem;
268 flex: 0 0 32.33%; /* 宽度为 1/3 */ 345 flex: 0 0 32.33%; /* 宽度为 1/3 */
269 margin-bottom: 1rem; /* 在元素之间添加间距 */ 346 margin-bottom: 1rem; /* 在元素之间添加间距 */
270 box-sizing: border-box; /* 防止 padding 或 margin 影响宽度 */ 347 box-sizing: border-box; /* 防止 padding 或 margin 影响宽度 */
271 - // width: 300px;
272 border-radius: 10px; 348 border-radius: 10px;
273 box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); 349 box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
274 overflow: hidden; 350 overflow: hidden;
275 background-color: #fff; 351 background-color: #fff;
276 - // margin: 0;
277 transition: transform 0.3s ease-in-out; 352 transition: transform 0.3s ease-in-out;
278 &:hover { 353 &:hover {
279 transform: scale(1.05); 354 transform: scale(1.05);
...@@ -347,7 +422,7 @@ export default { ...@@ -347,7 +422,7 @@ export default {
347 } 422 }
348 } 423 }
349 .card-title { 424 .card-title {
350 - color: @secondary-color; 425 + color: @text-color;
351 font-weight: bold; 426 font-weight: bold;
352 margin: 1rem 0; 427 margin: 1rem 0;
353 &:hover { 428 &:hover {
...@@ -356,6 +431,5 @@ export default { ...@@ -356,6 +431,5 @@ export default {
356 } 431 }
357 } 432 }
358 } 433 }
359 -
360 } 434 }
361 </style> 435 </style>
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
31 <div class="card-content"> 31 <div class="card-content">
32 <div class="card-title"> 32 <div class="card-title">
33 <span>{{ x.title }}</span> 33 <span>{{ x.title }}</span>
34 - <i class="el-icon-right"></i> 34 + <i class="el-icon-right" style="color: #00ABE5;"></i>
35 </div> 35 </div>
36 <p class="card-sub">{{ x.sub }}</p> 36 <p class="card-sub">{{ x.sub }}</p>
37 </div> 37 </div>
...@@ -82,35 +82,35 @@ export default { ...@@ -82,35 +82,35 @@ export default {
82 data () { 82 data () {
83 return { 83 return {
84 solution_list: [{ 84 solution_list: [{
85 - src: 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg', 85 + src: 'https://cdn.ipadbiz.cn/hager/img/WX20241021-110827@2x.png',
86 title: '1住宅解决方案', 86 title: '1住宅解决方案',
87 sub: 'Residential Solution Case' 87 sub: 'Residential Solution Case'
88 }, { 88 }, {
89 - src: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg', 89 + src: 'https://cdn.ipadbiz.cn/hager/img/WX20241021-110827@2x.png',
90 title: '2住宅解决方案', 90 title: '2住宅解决方案',
91 sub: 'Residential Solution Case' 91 sub: 'Residential Solution Case'
92 }, { 92 }, {
93 - src: 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg', 93 + src: 'https://cdn.ipadbiz.cn/hager/img/WX20241021-110827@2x.png',
94 title: '3住宅解决方案', 94 title: '3住宅解决方案',
95 sub: 'Residential Solution Case' 95 sub: 'Residential Solution Case'
96 }, { 96 }, {
97 - src: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg', 97 + src: 'https://cdn.ipadbiz.cn/hager/img/WX20241021-110827@2x.png',
98 title: '4住宅解决方案', 98 title: '4住宅解决方案',
99 sub: 'Residential Solution Case' 99 sub: 'Residential Solution Case'
100 }, { 100 }, {
101 - src: 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg', 101 + src: 'https://cdn.ipadbiz.cn/hager/img/WX20241021-110827@2x.png',
102 title: '1住宅解决方案', 102 title: '1住宅解决方案',
103 sub: 'Residential Solution Case' 103 sub: 'Residential Solution Case'
104 }, { 104 }, {
105 - src: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg', 105 + src: 'https://cdn.ipadbiz.cn/hager/img/WX20241021-110827@2x.png',
106 title: '2住宅解决方案', 106 title: '2住宅解决方案',
107 sub: 'Residential Solution Case' 107 sub: 'Residential Solution Case'
108 }, { 108 }, {
109 - src: 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg', 109 + src: 'https://cdn.ipadbiz.cn/hager/img/WX20241021-110827@2x.png',
110 title: '3住宅解决方案', 110 title: '3住宅解决方案',
111 sub: 'Residential Solution Case' 111 sub: 'Residential Solution Case'
112 }, { 112 }, {
113 - src: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg', 113 + src: 'https://cdn.ipadbiz.cn/hager/img/WX20241021-110827@2x.png',
114 title: '4住宅解决方案', 114 title: '4住宅解决方案',
115 sub: 'Residential Solution Case' 115 sub: 'Residential Solution Case'
116 }], 116 }],
......