Showing
1 changed file
with
45 additions
and
39 deletions
| 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-17 11:12:56 | 4 | + * @LastEditTime: 2024-10-20 21:33:43 |
| 5 | * @FilePath: /hager/src/views/index.vue | 5 | * @FilePath: /hager/src/views/index.vue |
| 6 | - * @Description: 文件描述 | 6 | + * @Description: 首页 |
| 7 | --> | 7 | --> |
| 8 | <template> | 8 | <template> |
| 9 | <div class="hager-container"> | 9 | <div class="hager-container"> |
| ... | @@ -84,8 +84,9 @@ | ... | @@ -84,8 +84,9 @@ |
| 84 | </div> | 84 | </div> |
| 85 | </hager-box> | 85 | </hager-box> |
| 86 | <hager-box class="box-n"> | 86 | <hager-box class="box-n"> |
| 87 | + <!-- TODO: 待完善, 产品分类跳转,没有更多分类了? --> | ||
| 87 | <hager-h1 title="产品中心" sub="Product"></hager-h1> | 88 | <hager-h1 title="产品中心" sub="Product"></hager-h1> |
| 88 | - <div v-if="!is_xs" class="hager-product-center"> | 89 | + <!-- <div v-if="!is_xs" class="hager-product-center"> |
| 89 | <el-row :gutter="15"> | 90 | <el-row :gutter="15"> |
| 90 | <el-col :span="6" v-for="(item, index) in product_list" :key="index"> | 91 | <el-col :span="6" v-for="(item, index) in product_list" :key="index"> |
| 91 | <div @click ="goToProduct(item)" class="product-item"> | 92 | <div @click ="goToProduct(item)" class="product-item"> |
| ... | @@ -97,17 +98,20 @@ | ... | @@ -97,17 +98,20 @@ |
| 97 | <div class="more-box" style="margin-top: 2rem;"> | 98 | <div class="more-box" style="margin-top: 2rem;"> |
| 98 | <hager-more></hager-more> | 99 | <hager-more></hager-more> |
| 99 | </div> | 100 | </div> |
| 100 | - </div> | 101 | + </div> --> |
| 101 | - <div v-else> | 102 | + <div> |
| 102 | <swiper ref="myProductSwiper" class="swiper" :options="swiperOption" @slideChange="onProductSlideChange"> | 103 | <swiper ref="myProductSwiper" class="swiper" :options="swiperOption" @slideChange="onProductSlideChange"> |
| 103 | <swiper-slide v-for="(item, index) in product_list" :key="index"> | 104 | <swiper-slide v-for="(item, index) in product_list" :key="index"> |
| 104 | <div @click="goToProduct(item)" class="product-item xs"> | 105 | <div @click="goToProduct(item)" class="product-item xs"> |
| 105 | - <div class="img" :style="{ height: '8rem', margin: '1rem', backgroundImage: 'url('+item.src+')' }"></div> | 106 | + <div class="img" :style="{ height: '8rem', backgroundImage: 'url('+item.src+')' }"></div> |
| 106 | <p style="margin: 0.5rem;">{{ item.title }}</p> | 107 | <p style="margin: 0.5rem;">{{ item.title }}</p> |
| 107 | </div> | 108 | </div> |
| 108 | </swiper-slide> | 109 | </swiper-slide> |
| 109 | </swiper> | 110 | </swiper> |
| 110 | - <div class="hager-product-center-more xs"> | 111 | + <div v-if="product_list.length <= productSlidesPerView" class="more-box" style="margin-top: 2rem;"> |
| 112 | + <hager-more></hager-more> | ||
| 113 | + </div> | ||
| 114 | + <div v-else class="hager-product-center-more xs"> | ||
| 111 | <hager-more></hager-more> | 115 | <hager-more></hager-more> |
| 112 | <div class="xs-control"> | 116 | <div class="xs-control"> |
| 113 | <div> | 117 | <div> |
| ... | @@ -217,7 +221,6 @@ export default { | ... | @@ -217,7 +221,6 @@ export default { |
| 217 | content: '11月28-29日,2023汤点文旅住宿节在苏州国际会议酒店隆重开幕,作为酒店整11月28-29日,2023汤点文旅住宿节在苏州国际会议酒店隆重开幕,作为酒店整11月28-29日,2023汤点文旅住宿节在苏州国际会议酒店隆重开幕,作为酒店整11月28-29日,2023汤点文旅住宿节在苏州国际会议酒店隆重开幕,作为酒店整', | 221 | content: '11月28-29日,2023汤点文旅住宿节在苏州国际会议酒店隆重开幕,作为酒店整11月28-29日,2023汤点文旅住宿节在苏州国际会议酒店隆重开幕,作为酒店整11月28-29日,2023汤点文旅住宿节在苏州国际会议酒店隆重开幕,作为酒店整11月28-29日,2023汤点文旅住宿节在苏州国际会议酒店隆重开幕,作为酒店整', |
| 218 | sub: 'o Ehe gy aha oid asto Ehe gy aha oid asto Ehe gy aha oid ast' | 222 | sub: 'o Ehe gy aha oid asto Ehe gy aha oid asto Ehe gy aha oid ast' |
| 219 | }], | 223 | }], |
| 220 | - // is_xs: false, | ||
| 221 | screen_width: 0, | 224 | screen_width: 0, |
| 222 | solution_list: [{ | 225 | solution_list: [{ |
| 223 | src: 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg', | 226 | src: 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg', |
| ... | @@ -239,32 +242,39 @@ export default { | ... | @@ -239,32 +242,39 @@ export default { |
| 239 | title: '4住宅解决方案' | 242 | title: '4住宅解决方案' |
| 240 | }], | 243 | }], |
| 241 | product_list: [{ | 244 | product_list: [{ |
| 242 | - 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', | 245 | + src: 'https://cdn.ipadbiz.cn/hager/img/pp01@2x.png', |
| 243 | - title: 'hw01 空气断路器' | 246 | + title: '配电产品' |
| 247 | + }, { | ||
| 248 | + src: 'https://cdn.ipadbiz.cn/hager/img/pp01@2x.png', | ||
| 249 | + title: '成套产品' | ||
| 244 | }, { | 250 | }, { |
| 245 | - src: 'https://cdn.ipadbiz.cn/hager/img/ats%E8%87%AA%E5%8A%A8%E8%BD%AC%E6%8D%A2%E5%BC%80%E5%85%B3@2x.png', | 251 | + src: 'https://cdn.ipadbiz.cn/hager/img/pp01@2x.png', |
| 246 | - title: 'h3+ 智能塑壳断路器' | 252 | + title: '开关面板' |
| 247 | }, { | 253 | }, { |
| 248 | - src: 'https://cdn.ipadbiz.cn/hager/img/h3+%20%E6%99%BA%E8%83%BD%E5%A1%91%E5%A3%B3%E6%96%AD%E8%B7%AF%E5%99%A8@2x.png', | 254 | + src: 'https://cdn.ipadbiz.cn/hager/img/pp01@2x.png', |
| 249 | - title: 'ats自动转换开关' | 255 | + title: '智能控制' |
| 250 | }, { | 256 | }, { |
| 251 | - src: 'https://cdn.ipadbiz.cn/hager/img/hw+%20%E7%A9%BA%E6%B0%94%E6%96%AD%E8%B7%AF%E5%99%A8@2x.png', | 257 | + src: 'https://cdn.ipadbiz.cn/hager/img/pp01@2x.png', |
| 252 | - title: 'KNX智能控制模块' | 258 | + title: '能源管理' |
| 253 | }], | 259 | }], |
| 254 | swiperOption: { | 260 | swiperOption: { |
| 255 | slidesPerView: 2, | 261 | slidesPerView: 2, |
| 256 | - spaceBetween: 50, | 262 | + spaceBetween: 20, |
| 257 | preventClicks : true, | 263 | preventClicks : true, |
| 258 | slideToClickedSlide: false, | 264 | slideToClickedSlide: false, |
| 259 | touchRatio: 0, | 265 | touchRatio: 0, |
| 260 | breakpoints: { | 266 | breakpoints: { |
| 267 | + 1480: { | ||
| 268 | + slidesPerView: 5, | ||
| 269 | + spaceBetween: 30 | ||
| 270 | + }, | ||
| 261 | 1024: { | 271 | 1024: { |
| 262 | - slidesPerView: 4, | 272 | + slidesPerView: 5, |
| 263 | - spaceBetween: 40 | 273 | + spaceBetween: 30 |
| 264 | }, | 274 | }, |
| 265 | 768: { | 275 | 768: { |
| 266 | slidesPerView: 3, | 276 | slidesPerView: 3, |
| 267 | - spaceBetween: 30 | 277 | + spaceBetween: 20 |
| 268 | }, | 278 | }, |
| 269 | 640: { | 279 | 640: { |
| 270 | slidesPerView: 2, | 280 | slidesPerView: 2, |
| ... | @@ -284,30 +294,21 @@ export default { | ... | @@ -284,30 +294,21 @@ export default { |
| 284 | activeProductIndex: 0, | 294 | activeProductIndex: 0, |
| 285 | reach_solution_end: false, | 295 | reach_solution_end: false, |
| 286 | reach_product_end: false, | 296 | reach_product_end: false, |
| 297 | + productSlidesPerView: 5, | ||
| 287 | } | 298 | } |
| 288 | }, | 299 | }, |
| 289 | async mounted () { | 300 | async mounted () { |
| 290 | - // const container = document.querySelector('.container'); | 301 | + this.$nextTick(() => { |
| 291 | - // const boxes = container.querySelectorAll('.box'); | 302 | + this.$refs.myProductSwiper.$swiper?.on('breakpoint', (swiper) => { |
| 292 | - | 303 | + // breakpoint时 显示的条数 |
| 293 | - // // 如果超过11个项目,设置最后一个为特殊样式 | 304 | + this.productSlidesPerView = swiper.slidesPerView |
| 294 | - // if (boxes.length > 11) { | 305 | + }); |
| 295 | - // boxes[boxes.length - 1].classList.add('other'); | 306 | + }); |
| 296 | - // } | ||
| 297 | - // this.$nextTick(() => { | ||
| 298 | - // console.warn(this.$refs.mySolutionSwiper); | ||
| 299 | - // this.$refs.mySolutionSwiper.$swiper?.on('click', (evt) => { | ||
| 300 | - // // evt.preventDefault(); | ||
| 301 | - // let index = this.$refs.mySolutionSwiper.$swiper.clickedIndex; | ||
| 302 | - // this.goToSolution(this.solution_list[index]); | ||
| 303 | - // }); | ||
| 304 | - // }); | ||
| 305 | }, | 307 | }, |
| 306 | watch: { | 308 | watch: { |
| 307 | // 监听$route对象的变化 | 309 | // 监听$route对象的变化 |
| 308 | $route(to, from) { | 310 | $route(to, from) { |
| 309 | console.log('路由变化了:', to.path); | 311 | console.log('路由变化了:', to.path); |
| 310 | - // 在此处执行你想要的逻辑 | ||
| 311 | } | 312 | } |
| 312 | }, | 313 | }, |
| 313 | methods: { | 314 | methods: { |
| ... | @@ -344,7 +345,10 @@ export default { | ... | @@ -344,7 +345,10 @@ export default { |
| 344 | }, | 345 | }, |
| 345 | goToProduct (v) { | 346 | goToProduct (v) { |
| 346 | this.$router.push({ | 347 | this.$router.push({ |
| 347 | - path: '/product/detail' | 348 | + path: '/product/category', |
| 349 | + query: { | ||
| 350 | + id: v.id | ||
| 351 | + } | ||
| 348 | }); | 352 | }); |
| 349 | }, | 353 | }, |
| 350 | handleScreenWidth(width) { | 354 | handleScreenWidth(width) { |
| ... | @@ -573,10 +577,10 @@ export default { | ... | @@ -573,10 +577,10 @@ export default { |
| 573 | color: #333; | 577 | color: #333; |
| 574 | border-radius: 8px; | 578 | border-radius: 8px; |
| 575 | background-color: #f3f3f3; | 579 | background-color: #f3f3f3; |
| 576 | - // transition: transform 0.3s ease-in-out; | 580 | + transition: transform 0.3s ease-in-out; |
| 577 | &:hover { | 581 | &:hover { |
| 578 | cursor: pointer; | 582 | cursor: pointer; |
| 579 | - // transform: scale(1.05); | 583 | + transform: scale(1.05); |
| 580 | // box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); | 584 | // box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); |
| 581 | } | 585 | } |
| 582 | &.xs { | 586 | &.xs { |
| ... | @@ -592,6 +596,8 @@ export default { | ... | @@ -592,6 +596,8 @@ export default { |
| 592 | background-size: cover; /* 相当于 object-fit: cover */ | 596 | background-size: cover; /* 相当于 object-fit: cover */ |
| 593 | background-position: center; /* 让图片居中 */ | 597 | background-position: center; /* 让图片居中 */ |
| 594 | background-repeat: no-repeat; | 598 | background-repeat: no-repeat; |
| 599 | + border-top-left-radius: 5px; | ||
| 600 | + border-top-right-radius: 5px; | ||
| 595 | } | 601 | } |
| 596 | } | 602 | } |
| 597 | 603 | ... | ... |
-
Please register or login to post a comment