Showing
2 changed files
with
60 additions
and
22 deletions
| ... | @@ -6,7 +6,7 @@ | ... | @@ -6,7 +6,7 @@ |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| 8 | <template> | 8 | <template> |
| 9 | - <div :class="['hagerH1', is_xs ? 'xs' : '']"> | 9 | + <div :class="['hagerH1']"> |
| 10 | <p class="h1">{{ title }}</p> | 10 | <p class="h1">{{ title }}</p> |
| 11 | <p class="sub">{{ sub }}</p> | 11 | <p class="sub">{{ sub }}</p> |
| 12 | </div> | 12 | </div> | ... | ... |
| 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-09 16:42:27 | 4 | + * @LastEditTime: 2024-10-09 17:43:10 |
| 5 | * @FilePath: /hager/src/views/index.vue | 5 | * @FilePath: /hager/src/views/index.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -47,25 +47,28 @@ | ... | @@ -47,25 +47,28 @@ |
| 47 | </div> | 47 | </div> |
| 48 | </hager-box> | 48 | </hager-box> |
| 49 | <hager-box class="box-2n" @screen-width="handleScreenWidth"> | 49 | <hager-box class="box-2n" @screen-width="handleScreenWidth"> |
| 50 | - <hager-h1 title="解决方案" sub="Solution" :width="screen_width"></hager-h1> | 50 | + <hager-h1 title="解决方案" sub="Solution"></hager-h1> |
| 51 | <div :class="['hager-solution', is_xs ? 'xs' : '']"> | 51 | <div :class="['hager-solution', is_xs ? 'xs' : '']"> |
| 52 | - <div @click="goToSolution(item)" class="solution-item xs" :style="{ backgroundImage: 'url('+item.src+')' }" v-for="(item, index) in solution_list" :key="index"><p>{{ item.title }}</p></div> | 52 | + <div @click="goToSolution(item)" :class="['solution-item', is_xs ? 'xs' : '']" :style="{ backgroundImage: 'url('+item.src+')' }" v-for="(item, index) in solution_list" :key="index"><p>{{ item.title }}</p></div> |
| 53 | - <div v-if="!is_xs" class="solution-item other">Other解决方案</div> | 53 | + <!-- <div v-if="!is_xs" class="solution-item other">Other解决方案</div> --> |
| 54 | </div> | 54 | </div> |
| 55 | <div class="xs-control" v-if="is_xs"> | 55 | <div class="xs-control" v-if="is_xs"> |
| 56 | - <div><i class="el-icon-arrow-left" @click="prevBtn"></i> <i class="el-icon-arrow-right" @click="nextBtn"></i></div> | 56 | + <div><i class="el-icon-arrow-left" @click="prevBtn(solution_list)"></i> <i class="el-icon-arrow-right" @click="nextBtn(solution_list)"></i></div> |
| 57 | </div> | 57 | </div> |
| 58 | </hager-box> | 58 | </hager-box> |
| 59 | <hager-box class="box-n"> | 59 | <hager-box class="box-n"> |
| 60 | <hager-h1 title="产品中心" sub="Product Center"></hager-h1> | 60 | <hager-h1 title="产品中心" sub="Product Center"></hager-h1> |
| 61 | - <div class="hager-product-center"> | 61 | + <div :class="['hager-product-center', is_xs ? 'xs' : '']"> |
| 62 | - <div v-for="(item, index) in 4" :key="index" class="product-item"> | 62 | + <div v-for="(item, index) in product_list" :key="index" :class="['product-item', is_xs ? 'xs' : '']"> |
| 63 | - <el-image style="width: 14rem; height: 14rem;" src="https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg" fit="fit"></el-image> | 63 | + <el-image style="height: 14rem;" :src="item.src" fit="cover"></el-image> |
| 64 | - <p style="margin-top: 1rem;">atS三型特决井天</p> | 64 | + <p style="margin-top: 1rem;">{{ item.title }}</p> |
| 65 | </div> | 65 | </div> |
| 66 | </div> | 66 | </div> |
| 67 | - <div style="display: flex; justify-content: center; margin-top: 2rem;"> | 67 | + <div :class="['hager-product-center-more', is_xs ? 'xs' : '']"> |
| 68 | <hager-more></hager-more> | 68 | <hager-more></hager-more> |
| 69 | + <div class="xs-control" v-if="is_xs"> | ||
| 70 | + <div><i class="el-icon-arrow-left" @click="prevBtn(product_list)"></i> <i class="el-icon-arrow-right" @click="nextBtn(product_list)"></i></div> | ||
| 71 | + </div> | ||
| 69 | </div> | 72 | </div> |
| 70 | </hager-box> | 73 | </hager-box> |
| 71 | <hager-box class="box-2n"> | 74 | <hager-box class="box-2n"> |
| ... | @@ -147,7 +150,20 @@ export default { | ... | @@ -147,7 +150,20 @@ export default { |
| 147 | }, { | 150 | }, { |
| 148 | src: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg', | 151 | src: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg', |
| 149 | title: '4住宅解决方案' | 152 | title: '4住宅解决方案' |
| 150 | - }] | 153 | + }], |
| 154 | + product_list: [{ | ||
| 155 | + src: 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg', | ||
| 156 | + title: '三型特决井天' | ||
| 157 | + }, { | ||
| 158 | + src: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg', | ||
| 159 | + title: '三型特决井天' | ||
| 160 | + }, { | ||
| 161 | + src: 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg', | ||
| 162 | + title: '三型特决井天' | ||
| 163 | + }, { | ||
| 164 | + src: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg', | ||
| 165 | + title: '三型特决井天' | ||
| 166 | + }], | ||
| 151 | } | 167 | } |
| 152 | }, | 168 | }, |
| 153 | async mounted () { | 169 | async mounted () { |
| ... | @@ -181,13 +197,13 @@ export default { | ... | @@ -181,13 +197,13 @@ export default { |
| 181 | this.is_xs = width < 768; | 197 | this.is_xs = width < 768; |
| 182 | this.screen_width = width; | 198 | this.screen_width = width; |
| 183 | }, | 199 | }, |
| 184 | - prevBtn () { | 200 | + prevBtn (list) { |
| 185 | - const last = this.solution_list.pop(); // 移除最后一个元素 | 201 | + const last = list.pop(); // 移除最后一个元素 |
| 186 | - this.solution_list.unshift(last); // 将最后一个元素添加到数组开头 | 202 | + list.unshift(last); // 将最后一个元素添加到数组开头 |
| 187 | }, | 203 | }, |
| 188 | - nextBtn () { | 204 | + nextBtn (list) { |
| 189 | - const first = this.solution_list.shift(); // 移除第一个元素 | 205 | + const first = list.shift(); // 移除第一个元素 |
| 190 | - this.solution_list.push(first); // 将第一个元素添加到数组末尾 | 206 | + list.push(first); // 将第一个元素添加到数组末尾 |
| 191 | }, | 207 | }, |
| 192 | }, | 208 | }, |
| 193 | } | 209 | } |
| ... | @@ -267,7 +283,7 @@ export default { | ... | @@ -267,7 +283,7 @@ export default { |
| 267 | // transition: transform 0.3s ease-in-out; | 283 | // transition: transform 0.3s ease-in-out; |
| 268 | &:hover { | 284 | &:hover { |
| 269 | // transform: scale(1.05); | 285 | // transform: scale(1.05); |
| 270 | - box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); | 286 | + // box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); |
| 271 | cursor: pointer; | 287 | cursor: pointer; |
| 272 | } | 288 | } |
| 273 | &.other { | 289 | &.other { |
| ... | @@ -342,11 +358,18 @@ export default { | ... | @@ -342,11 +358,18 @@ export default { |
| 342 | } | 358 | } |
| 343 | } | 359 | } |
| 344 | } | 360 | } |
| 361 | + | ||
| 345 | .hager-product-center { | 362 | .hager-product-center { |
| 346 | margin-top: 2rem; | 363 | margin-top: 2rem; |
| 347 | display: grid; | 364 | display: grid; |
| 348 | grid-template-columns: repeat(4, 1fr); /* 一行显示4个 */ | 365 | grid-template-columns: repeat(4, 1fr); /* 一行显示4个 */ |
| 349 | gap: 1.5rem; /* 每个项目之间的间距 */ | 366 | gap: 1.5rem; /* 每个项目之间的间距 */ |
| 367 | + &.xs { | ||
| 368 | + display: flex; | ||
| 369 | + overflow: hidden; /* 超出部分隐藏 */ | ||
| 370 | + width: 100vw; /* 容器宽度适应屏幕 */ | ||
| 371 | + gap: 1rem; | ||
| 372 | + } | ||
| 350 | .product-item { | 373 | .product-item { |
| 351 | height: auto; | 374 | height: auto; |
| 352 | padding: 1.5rem; | 375 | padding: 1.5rem; |
| ... | @@ -354,13 +377,28 @@ export default { | ... | @@ -354,13 +377,28 @@ export default { |
| 354 | color: #333; | 377 | color: #333; |
| 355 | border-radius: 8px; | 378 | border-radius: 8px; |
| 356 | background-color: #f3f3f3; | 379 | background-color: #f3f3f3; |
| 357 | - transition: transform 0.3s ease-in-out; | 380 | + // transition: transform 0.3s ease-in-out; |
| 358 | &:hover { | 381 | &:hover { |
| 359 | cursor: pointer; | 382 | cursor: pointer; |
| 360 | - transform: scale(1.05); | 383 | + // transform: scale(1.05); |
| 361 | - box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); | 384 | + // box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); |
| 385 | + } | ||
| 386 | + &.xs { | ||
| 387 | + flex: 0 0 50vw; /* 每个子元素宽度为屏幕宽度的一半 (显示2个元素) */ | ||
| 388 | + // padding: 0 20px; | ||
| 389 | + // box-sizing: border-box; | ||
| 362 | } | 390 | } |
| 363 | } | 391 | } |
| 364 | } | 392 | } |
| 393 | + | ||
| 394 | + .hager-product-center-more { | ||
| 395 | + display: flex; | ||
| 396 | + justify-content: center; | ||
| 397 | + margin-top: 2rem; | ||
| 398 | + &.xs { | ||
| 399 | + justify-content: space-between; | ||
| 400 | + padding-left: 20%; | ||
| 401 | + } | ||
| 402 | + } | ||
| 365 | } | 403 | } |
| 366 | </style> | 404 | </style> | ... | ... |
-
Please register or login to post a comment