hookehuyr

✨ feat(首页解决方案): 自适应轮播图调整

...@@ -16,9 +16,9 @@ ...@@ -16,9 +16,9 @@
16 "jquery": "^3.7.1", 16 "jquery": "^3.7.1",
17 "mui-player": "^1.8.1", 17 "mui-player": "^1.8.1",
18 "sass": "1.55.0", 18 "sass": "1.55.0",
19 - "swiper": "4", 19 + "swiper": "5",
20 "vue": "2.7.13", 20 "vue": "2.7.13",
21 - "vue-awesome-swiper": "3.1.3", 21 + "vue-awesome-swiper": "4.1.1",
22 "vue-router": "3.6.5" 22 "vue-router": "3.6.5"
23 }, 23 },
24 "devDependencies": { 24 "devDependencies": {
......
1 /* 1 /*
2 * @Date: 2024-08-26 10:12:56 2 * @Date: 2024-08-26 10:12:56
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2024-10-10 20:20:18 4 + * @LastEditTime: 2024-10-11 10:10:31
5 * @FilePath: /hager/src/main.js 5 * @FilePath: /hager/src/main.js
6 * @Description: 文件描述 6 * @Description: 文件描述
7 */ 7 */
...@@ -19,7 +19,7 @@ import 'element-ui/lib/theme-chalk/display.css'; // 基于断点的隐藏类, ...@@ -19,7 +19,7 @@ import 'element-ui/lib/theme-chalk/display.css'; // 基于断点的隐藏类,
19 import CollapseTransition from 'element-ui/lib/transitions/collapse-transition'; 19 import CollapseTransition from 'element-ui/lib/transitions/collapse-transition';
20 20
21 import VueAwesomeSwiper from 'vue-awesome-swiper'; 21 import VueAwesomeSwiper from 'vue-awesome-swiper';
22 -import 'swiper/dist/css/swiper.css'; // 确保引入正确的CSS文件路径 22 +import 'swiper/css/swiper.css'; // 确保引入正确的CSS文件路径
23 23
24 Vue.use(VueRouter); 24 Vue.use(VueRouter);
25 // Vue.use(ElementUI); 25 // Vue.use(ElementUI);
......
1 <!-- 1 <!--
2 * @Date: 2024-08-27 10:06:30 2 * @Date: 2024-08-27 10:06:30
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2024-10-11 10:01:58 4 + * @LastEditTime: 2024-10-11 11:21:43
5 * @FilePath: /hager/src/views/index.vue 5 * @FilePath: /hager/src/views/index.vue
6 * @Description: 文件描述 6 * @Description: 文件描述
7 --> 7 -->
...@@ -49,18 +49,30 @@ ...@@ -49,18 +49,30 @@
49 <hager-box class="box-2n" @screen-width="handleScreenWidth"> 49 <hager-box class="box-2n" @screen-width="handleScreenWidth">
50 <hager-h1 title="解决方案" sub="Solution"></hager-h1> 50 <hager-h1 title="解决方案" sub="Solution"></hager-h1>
51 <div v-if="!is_xs" class="hager-solution"> 51 <div v-if="!is_xs" class="hager-solution">
52 - <div @click="goToSolution(item)" :class="['solution-item']" :style="{ backgroundImage: 'url('+item.src+')' }" v-for="(item, index) in solution_list" :key="index"><p>{{ item.title }}</p></div> 52 + <div
53 - </div> 53 + @click="goToSolution(item)"
54 - <swiper v-else ref="mySwiper" class="swiper" :options="swiperOption"> 54 + class="solution-item"
55 - <swiper-slide
56 - class="solution-item-a"
57 :style="{ backgroundImage: 'url('+item.src+')' }" 55 :style="{ backgroundImage: 'url('+item.src+')' }"
58 v-for="(item, index) in solution_list" :key="index"> 56 v-for="(item, index) in solution_list" :key="index">
59 <p>{{ item.title }}</p> 57 <p>{{ item.title }}</p>
60 - </swiper-slide> 58 + </div>
61 - </swiper> 59 + </div>
62 - <div class="xs-control" v-if="is_xs"> 60 + <div v-else>
63 - <div><i class="el-icon-arrow-left" @click="prevBtn(solution_list)"></i> <i class="el-icon-arrow-right" @click="nextBtn(solution_list)"></i></div> 61 + <swiper ref="mySolutionSwiper" class="swiper" :options="swiperOption">
62 + <swiper-slide
63 + @click.native="goToSolution(item)"
64 + class="solution-item xs"
65 + :style="{ backgroundImage: 'url('+item.src+')' }"
66 + v-for="(item, index) in solution_list" :key="index">
67 + <p>{{ item.title }}</p>
68 + </swiper-slide>
69 + </swiper>
70 + <div class="xs-control">
71 + <div>
72 + <i class="el-icon-arrow-left" @click="prevSolutionBtn()"></i>
73 + <i class="el-icon-arrow-right" @click="nextSolutionBtn()"></i>
74 + </div>
75 + </div>
64 </div> 76 </div>
65 </hager-box> 77 </hager-box>
66 <hager-box class="box-n"> 78 <hager-box class="box-n">
...@@ -191,7 +203,7 @@ export default { ...@@ -191,7 +203,7 @@ export default {
191 title: '三型特决井天' 203 title: '三型特决井天'
192 }], 204 }],
193 swiperOption: { 205 swiperOption: {
194 - slidesPerView: 3, 206 + // slidesPerView: 3,
195 spaceBetween: 50, 207 spaceBetween: 50,
196 preventClicks : false, 208 preventClicks : false,
197 slideToClickedSlide: false, 209 slideToClickedSlide: false,
...@@ -209,8 +221,12 @@ export default { ...@@ -209,8 +221,12 @@ export default {
209 spaceBetween: 20 221 spaceBetween: 20
210 }, 222 },
211 320: { 223 320: {
212 - slidesPerView: 1, 224 + slidesPerView: 2,
213 spaceBetween: 10 225 spaceBetween: 10
226 + },
227 + 160: {
228 + slidesPerView: 1,
229 + spaceBetween: 0
214 } 230 }
215 } 231 }
216 } 232 }
...@@ -244,21 +260,14 @@ export default { ...@@ -244,21 +260,14 @@ export default {
244 }); 260 });
245 }, 261 },
246 handleScreenWidth(width) { 262 handleScreenWidth(width) {
247 - // this.is_xs = width < 768;
248 this.screen_width = width; 263 this.screen_width = width;
249 }, 264 },
250 - prevBtn (list) { 265 + prevSolutionBtn () {
251 - this.$refs.mySwiper.swiper.slidePrev(); 266 + this.$refs.mySolutionSwiper.$swiper.slidePrev();
252 }, 267 },
253 - nextBtn (list) { 268 + nextSolutionBtn () {
254 - this.$refs.mySwiper.swiper.slideNext(); 269 + this.$refs.mySolutionSwiper.$swiper.slideNext();
255 }, 270 },
256 - onSwiper (swiper) {
257 - console.log(swiper);
258 - },
259 - onSlideChange () {
260 - console.log('slide change');
261 - }
262 }, 271 },
263 } 272 }
264 </script> 273 </script>
...@@ -327,65 +336,33 @@ export default { ...@@ -327,65 +336,33 @@ export default {
327 width: calc(100vw - 1rem); /* 容器宽度适应屏幕 */ 336 width: calc(100vw - 1rem); /* 容器宽度适应屏幕 */
328 gap: 1rem; 337 gap: 1rem;
329 } 338 }
330 - .solution-item {
331 - position: relative;
332 - height: 12rem;
333 - padding: 1.5rem;
334 - text-align: center;
335 - color: #FFF;
336 - border-radius: 8px;
337 - // background-image: url('https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg');
338 - background-size: cover;
339 - background-position: center;
340 - // transition: transform 0.3s ease-in-out;
341 - &:hover {
342 - // transform: scale(1.05);
343 - // box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
344 - cursor: pointer;
345 - }
346 - &.other {
347 - display: flex;
348 - background-color: #e0f7ff; /* 特殊的样式 */
349 - color: @secondary-color;
350 - font-weight: bold;
351 - // line-height: 8rem;
352 - background-image: none;
353 - align-items: center;
354 - justify-content: center;
355 - font-size: 1.5rem;
356 - }
357 - p {
358 - position: absolute;
359 - bottom: 0;
360 - left: 0;
361 - right: 0;
362 - height: 2rem;
363 - background-color: rgba(0, 0, 0, 0.2);
364 - line-height: 2rem;
365 - }
366 - &.xs {
367 - flex: 0 0 50vw; /* 每个子元素宽度为屏幕宽度的一半 (显示2个元素) */
368 - // padding: 0 20px;
369 - // box-sizing: border-box;
370 - }
371 - }
372 } 339 }
373 - .solution-item-a { 340 + .solution-item {
374 position: relative; 341 position: relative;
375 height: 12rem; 342 height: 12rem;
376 - // padding: 1.5rem; 343 + padding: 1.5rem;
377 text-align: center; 344 text-align: center;
378 color: #FFF; 345 color: #FFF;
379 border-radius: 8px; 346 border-radius: 8px;
380 - // background-image: url('https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg');
381 background-size: cover; 347 background-size: cover;
382 background-position: center; 348 background-position: center;
383 - // transition: transform 0.3s ease-in-out; 349 + transition: transform 0.3s ease-in-out;
384 &:hover { 350 &:hover {
385 // transform: scale(1.05); 351 // transform: scale(1.05);
386 // box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); 352 // box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
387 cursor: pointer; 353 cursor: pointer;
388 } 354 }
355 + &.other {
356 + display: flex;
357 + background-color: #e0f7ff; /* 特殊的样式 */
358 + color: @secondary-color;
359 + font-weight: bold;
360 + // line-height: 8rem;
361 + background-image: none;
362 + align-items: center;
363 + justify-content: center;
364 + font-size: 1.5rem;
365 + }
389 p { 366 p {
390 position: absolute; 367 position: absolute;
391 bottom: 0; 368 bottom: 0;
...@@ -394,6 +371,12 @@ export default { ...@@ -394,6 +371,12 @@ export default {
394 height: 2rem; 371 height: 2rem;
395 background-color: rgba(0, 0, 0, 0.2); 372 background-color: rgba(0, 0, 0, 0.2);
396 line-height: 2rem; 373 line-height: 2rem;
374 + border-bottom-left-radius: 8px;
375 + border-bottom-right-radius: 8px;
376 + }
377 + &.xs {
378 + padding: 0;
379 + margin-top: 1rem;
397 } 380 }
398 } 381 }
399 .xs-control { 382 .xs-control {
......
...@@ -1552,7 +1552,7 @@ delayed-stream@~1.0.0: ...@@ -1552,7 +1552,7 @@ delayed-stream@~1.0.0:
1552 resolved "https://mirrors.cloud.tencent.com/npm/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" 1552 resolved "https://mirrors.cloud.tencent.com/npm/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619"
1553 integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ== 1553 integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==
1554 1554
1555 -dom7@^2.1.3: 1555 +dom7@^2.1.5:
1556 version "2.1.5" 1556 version "2.1.5"
1557 resolved "https://mirrors.cloud.tencent.com/npm/dom7/-/dom7-2.1.5.tgz#a79411017800b31d8400070cdaebbfc92c1f6377" 1557 resolved "https://mirrors.cloud.tencent.com/npm/dom7/-/dom7-2.1.5.tgz#a79411017800b31d8400070cdaebbfc92c1f6377"
1558 integrity sha512-xnhwVgyOh3eD++/XGtH+5qBwYTgCm0aW91GFgPJ3XG+jlsRLyJivnbP0QmUBFhI+Oaz9FV0s7cxgXHezwOEBYA== 1558 integrity sha512-xnhwVgyOh3eD++/XGtH+5qBwYTgCm0aW91GFgPJ3XG+jlsRLyJivnbP0QmUBFhI+Oaz9FV0s7cxgXHezwOEBYA==
...@@ -2007,11 +2007,6 @@ normalize-wheel@^1.0.1: ...@@ -2007,11 +2007,6 @@ normalize-wheel@^1.0.1:
2007 resolved "https://mirrors.cloud.tencent.com/npm/normalize-wheel/-/normalize-wheel-1.0.1.tgz#aec886affdb045070d856447df62ecf86146ec45" 2007 resolved "https://mirrors.cloud.tencent.com/npm/normalize-wheel/-/normalize-wheel-1.0.1.tgz#aec886affdb045070d856447df62ecf86146ec45"
2008 integrity sha512-1OnlAPZ3zgrk8B91HyRj+eVv+kS5u+Z0SCsak6Xil/kmgEia50ga7zfkumayonZrImffAxPU/5WcyGhzetHNPA== 2008 integrity sha512-1OnlAPZ3zgrk8B91HyRj+eVv+kS5u+Z0SCsak6Xil/kmgEia50ga7zfkumayonZrImffAxPU/5WcyGhzetHNPA==
2009 2009
2010 -object-assign@^4.1.1:
2011 - version "4.1.1"
2012 - resolved "https://mirrors.cloud.tencent.com/npm/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
2013 - integrity sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==
2014 -
2015 object-inspect@^1.13.1: 2010 object-inspect@^1.13.1:
2016 version "1.13.2" 2011 version "1.13.2"
2017 resolved "https://mirrors.cloud.tencent.com/npm/object-inspect/-/object-inspect-1.13.2.tgz#dea0088467fb991e67af4058147a24824a3043ff" 2012 resolved "https://mirrors.cloud.tencent.com/npm/object-inspect/-/object-inspect-1.13.2.tgz#dea0088467fb991e67af4058147a24824a3043ff"
...@@ -2350,11 +2345,6 @@ source-map@^0.6.1, source-map@~0.6.0: ...@@ -2350,11 +2345,6 @@ source-map@^0.6.1, source-map@~0.6.0:
2350 resolved "https://mirrors.cloud.tencent.com/npm/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" 2345 resolved "https://mirrors.cloud.tencent.com/npm/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
2351 integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== 2346 integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==
2352 2347
2353 -ssr-window@^1.0.1:
2354 - version "1.0.1"
2355 - resolved "https://mirrors.cloud.tencent.com/npm/ssr-window/-/ssr-window-1.0.1.tgz#30752a6a4666e7767f0b7e6aa6fc2fdbd0d9b369"
2356 - integrity sha512-dgFqB+f00LJTEgb6UXhx0h+SrG50LJvti2yMKMqAgzfUmUXZrLSv2fjULF7AWGwK25EXu8+smLR3jYsJQChPsg==
2357 -
2358 ssr-window@^2.0.0: 2348 ssr-window@^2.0.0:
2359 version "2.0.0" 2349 version "2.0.0"
2360 resolved "https://mirrors.cloud.tencent.com/npm/ssr-window/-/ssr-window-2.0.0.tgz#98c301aef99523317f8d69618f0010791096efc4" 2350 resolved "https://mirrors.cloud.tencent.com/npm/ssr-window/-/ssr-window-2.0.0.tgz#98c301aef99523317f8d69618f0010791096efc4"
...@@ -2379,13 +2369,13 @@ supports-preserve-symlinks-flag@^1.0.0: ...@@ -2379,13 +2369,13 @@ supports-preserve-symlinks-flag@^1.0.0:
2379 resolved "https://mirrors.cloud.tencent.com/npm/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09" 2369 resolved "https://mirrors.cloud.tencent.com/npm/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09"
2380 integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== 2370 integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==
2381 2371
2382 -swiper@4, swiper@^4.0.7: 2372 +swiper@5:
2383 - version "4.5.1" 2373 + version "5.4.5"
2384 - resolved "https://mirrors.cloud.tencent.com/npm/swiper/-/swiper-4.5.1.tgz#ed43998e780ceb478610079c8d23fd425eca636f" 2374 + resolved "https://mirrors.cloud.tencent.com/npm/swiper/-/swiper-5.4.5.tgz#a350f654bf68426dbb651793824925512d223c0f"
2385 - integrity sha512-se6I7PWWu950NAMXXT+ENtF/6SVb8mPyO+bTfNxbQBILSeLqsYp3Ndap+YOA0EczOIUlea274PKejT6gKZDseA== 2375 + integrity sha512-7QjA0XpdOmiMoClfaZ2lYN6ICHcMm72LXiY+NF4fQLFidigameaofvpjEEiTQuw3xm5eksG5hzkaRsjQX57vtA==
2386 dependencies: 2376 dependencies:
2387 - dom7 "^2.1.3" 2377 + dom7 "^2.1.5"
2388 - ssr-window "^1.0.1" 2378 + ssr-window "^2.0.0"
2389 2379
2390 systemjs@^6.15.1: 2380 systemjs@^6.15.1:
2391 version "6.15.1" 2381 version "6.15.1"
...@@ -2495,13 +2485,10 @@ vite@^5.4.1: ...@@ -2495,13 +2485,10 @@ vite@^5.4.1:
2495 optionalDependencies: 2485 optionalDependencies:
2496 fsevents "~2.3.3" 2486 fsevents "~2.3.3"
2497 2487
2498 -vue-awesome-swiper@3.1.3: 2488 +vue-awesome-swiper@4.1.1:
2499 - version "3.1.3" 2489 + version "4.1.1"
2500 - resolved "https://mirrors.cloud.tencent.com/npm/vue-awesome-swiper/-/vue-awesome-swiper-3.1.3.tgz#05500b501ffb3fec9bf7eb9985bcf4ae8360ed9e" 2490 + resolved "https://mirrors.cloud.tencent.com/npm/vue-awesome-swiper/-/vue-awesome-swiper-4.1.1.tgz#8f7ab221ad003021d756b86aa618f429924900fe"
2501 - integrity sha512-E7suzkyApO8vNZbgdEnjSmnpsmQZyRvSVXJ7sey3XYwKPOkLhH3+GnHroBw+5PZIQXvWBwdCeQsPG1xQ1r1Rhg== 2491 + integrity sha512-50um10t6N+lJaORkpwSi1wWuMmBI1sgFc9Znsi5oUykw2cO5DzLaBHcO2JNX21R+Ue4TGoIJDhhxjBHtkFrTEQ==
2502 - dependencies:
2503 - object-assign "^4.1.1"
2504 - swiper "^4.0.7"
2505 2492
2506 vue-router@3.6.5: 2493 vue-router@3.6.5:
2507 version "3.6.5" 2494 version "3.6.5"
......