Showing
4 changed files
with
116 additions
and
5 deletions
| ... | @@ -25,6 +25,7 @@ | ... | @@ -25,6 +25,7 @@ |
| 25 | "element-ui": "^2.15.14", | 25 | "element-ui": "^2.15.14", |
| 26 | "jquery": "^3.7.1", | 26 | "jquery": "^3.7.1", |
| 27 | "mui-player": "^1.8.1", | 27 | "mui-player": "^1.8.1", |
| 28 | + "object-fit-images": "^3.2.4", | ||
| 28 | "sass": "1.55.0", | 29 | "sass": "1.55.0", |
| 29 | "swiper": "5", | 30 | "swiper": "5", |
| 30 | "vue": "2.7.13", | 31 | "vue": "2.7.13", | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2024-09-27 19:49:03 | 2 | * @Date: 2024-09-27 19:49:03 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2024-10-28 15:47:54 | 4 | + * @LastEditTime: 2024-11-01 08:20:35 |
| 5 | * @FilePath: /hager/src/components/hagerCarousel.vue | 5 | * @FilePath: /hager/src/components/hagerCarousel.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -34,8 +34,54 @@ | ... | @@ -34,8 +34,54 @@ |
| 34 | <el-col :span="20"> | 34 | <el-col :span="20"> |
| 35 | <!-- 右边大图区域 --> | 35 | <!-- 右边大图区域 --> |
| 36 | <div class="main-image" :class="{ 'fade-out': isTransitioning, 'fade-in': !isTransitioning }" :style="{ backgroundImage: `url(${images[selectedImage]})`}"> | 36 | <div class="main-image" :class="{ 'fade-out': isTransitioning, 'fade-in': !isTransitioning }" :style="{ backgroundImage: `url(${images[selectedImage]})`}"> |
| 37 | - <!-- <img :src="images[selectedImage]" alt="main image"> --> | ||
| 38 | </div> | 37 | </div> |
| 38 | + <!--<div class="ImageMagnifier"> | ||
| 39 | + <div @mouseover="handOver" @mousemove.stop="handMove" @mouseout="handOut"> | ||
| 40 | + <div ref="img" class="main-image" :class="{ 'fade-out': isTransitioning, 'fade-in': !isTransitioning }" :style="{ backgroundImage: `url(${images[selectedImage]})`}"></div> | ||
| 41 | + <!~~ 放大效果 ~~> | ||
| 42 | + <!~~ 遮罩层 ~~> | ||
| 43 | + <div | ||
| 44 | + v-show="showMask" | ||
| 45 | + class="magnifier-box" | ||
| 46 | + :style="{ | ||
| 47 | + width: magnifierConfigs.width + 'px', | ||
| 48 | + height: magnifierConfigs.height + 'px', | ||
| 49 | + opacity:magnifierConfigs.opacity, | ||
| 50 | + top:magnifierConfigs.top+ 'px', | ||
| 51 | + left:magnifierConfigs.left+ 'px', | ||
| 52 | + }" | ||
| 53 | + /> | ||
| 54 | + <!~~ 放大图 ~~> | ||
| 55 | + <div | ||
| 56 | + v-show="showMask" | ||
| 57 | + class="big-box" | ||
| 58 | + :style="{ | ||
| 59 | + width: bigConfigs.width + 'px', | ||
| 60 | + height: bigConfigs.height + 'px', | ||
| 61 | + top:bigConfigs.top+'px', | ||
| 62 | + left:bigConfigs.left+'px' | ||
| 63 | + }" | ||
| 64 | + > | ||
| 65 | + <div | ||
| 66 | + class="image" | ||
| 67 | + :style="{ | ||
| 68 | + width: bigConfigs.width + 'px', | ||
| 69 | + height: bigConfigs.height + 'px', | ||
| 70 | + transform: bigImageConfigs.transformImage | ||
| 71 | + }" | ||
| 72 | + > | ||
| 73 | + <img | ||
| 74 | + :style="{ | ||
| 75 | + width: bigImageConfigs.width + 'px', | ||
| 76 | + height:bigImageConfigs.height+'px' | ||
| 77 | + }" | ||
| 78 | + :src="images[selectedImage]" | ||
| 79 | + alt="图片不见了" | ||
| 80 | + > | ||
| 81 | + </div> | ||
| 82 | + </div> | ||
| 83 | + </div> | ||
| 84 | + </div>--> | ||
| 39 | </el-col> | 85 | </el-col> |
| 40 | </el-row> | 86 | </el-row> |
| 41 | 87 | ||
| ... | @@ -61,6 +107,26 @@ export default { | ... | @@ -61,6 +107,26 @@ export default { |
| 61 | startIndex: 0, // 当前显示的缩略图起始索引 | 107 | startIndex: 0, // 当前显示的缩略图起始索引 |
| 62 | thumbnailsToShow: 3, // 每次显示4个缩略图 | 108 | thumbnailsToShow: 3, // 每次显示4个缩略图 |
| 63 | isTransitioning: false, // 控制大图的切换动画 | 109 | isTransitioning: false, // 控制大图的切换动画 |
| 110 | + // 配置 | ||
| 111 | + magnifierConfigs: { // 遮罩层 | ||
| 112 | + width: 80, | ||
| 113 | + height: 80, | ||
| 114 | + opacity: 0.3, | ||
| 115 | + top: 0, | ||
| 116 | + left: 0 | ||
| 117 | + }, | ||
| 118 | + bigConfigs: { // 放大的盒子 | ||
| 119 | + width: 200, | ||
| 120 | + height: 200, | ||
| 121 | + top: 0, | ||
| 122 | + left: 0 | ||
| 123 | + }, | ||
| 124 | + bigImageConfigs: { // 放大图片 | ||
| 125 | + width: 500, | ||
| 126 | + height: 400, | ||
| 127 | + transformImage: 'translate(0px, 0px)' | ||
| 128 | + }, | ||
| 129 | + showMask: false | ||
| 64 | }; | 130 | }; |
| 65 | }, | 131 | }, |
| 66 | mounted() {}, | 132 | mounted() {}, |
| ... | @@ -120,6 +186,26 @@ export default { | ... | @@ -120,6 +186,26 @@ export default { |
| 120 | this.startIndex -= 3; | 186 | this.startIndex -= 3; |
| 121 | this.selectImage(this.startIndex); | 187 | this.selectImage(this.startIndex); |
| 122 | } | 188 | } |
| 189 | + }, | ||
| 190 | + handOver() { | ||
| 191 | + this.showMask = true | ||
| 192 | + }, | ||
| 193 | + handMove(event) { | ||
| 194 | + // this.showMask = true | ||
| 195 | + const rect = this.$refs.img.getBoundingClientRect() | ||
| 196 | + // 确定遮罩层坐标 | ||
| 197 | + const maskY = event.clientY - rect.top - this.magnifierConfigs.height / 2 | ||
| 198 | + this.magnifierConfigs.top = maskY | ||
| 199 | + const maskX = event.clientX - rect.left - this.magnifierConfigs.width / 2 | ||
| 200 | + this.magnifierConfigs.left = maskX | ||
| 201 | + // 确定放大图坐标 | ||
| 202 | + this.bigConfigs.top = event.clientY - rect.top - this.bigConfigs.height / 2 | ||
| 203 | + this.bigConfigs.left = event.clientX - rect.left + this.magnifierConfigs.width / 2 | ||
| 204 | + // 确定图像 | ||
| 205 | + this.bigImageConfigs.transformImage = `translate(-${maskX * 2}px,-${maskY * 2}px)` | ||
| 206 | + }, | ||
| 207 | + handOut() { | ||
| 208 | + this.showMask = false | ||
| 123 | } | 209 | } |
| 124 | }, | 210 | }, |
| 125 | }; | 211 | }; |
| ... | @@ -208,5 +294,24 @@ export default { | ... | @@ -208,5 +294,24 @@ export default { |
| 208 | display: flex; | 294 | display: flex; |
| 209 | flex-direction: column; | 295 | flex-direction: column; |
| 210 | } | 296 | } |
| 297 | + | ||
| 298 | + | ||
| 299 | + .ImageMagnifier{ | ||
| 300 | + position: relative; | ||
| 301 | + .magnifier-box{ | ||
| 302 | + background-color: rgb(16, 101, 186); | ||
| 303 | + position: absolute; | ||
| 304 | + z-index: 999; | ||
| 305 | + pointer-events: none; /* 让子元素在事件上透明 */ | ||
| 306 | + } | ||
| 307 | + .big-box{ | ||
| 308 | + background-color: #fff; | ||
| 309 | + // border: 1px solid black; | ||
| 310 | + position: absolute; | ||
| 311 | + overflow: hidden; | ||
| 312 | + z-index: 999; | ||
| 313 | + pointer-events: none; /* 让子元素在事件上透明 */ | ||
| 314 | + } | ||
| 315 | + } | ||
| 211 | } | 316 | } |
| 212 | </style> | 317 | </style> | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2024-09-29 14:26:41 | 2 | * @Date: 2024-09-29 14:26:41 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2024-10-31 14:16:25 | 4 | + * @LastEditTime: 2024-11-01 08:15:53 |
| 5 | * @FilePath: /hager/src/views/product/detail.vue | 5 | * @FilePath: /hager/src/views/product/detail.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -19,10 +19,10 @@ | ... | @@ -19,10 +19,10 @@ |
| 19 | </hager-box> | 19 | </hager-box> |
| 20 | <hager-box v-if="is_enable" class="box-n"> | 20 | <hager-box v-if="is_enable" class="box-n"> |
| 21 | <el-row v-if="!is_xs" :gutter="10" style="margin-bottom: 3rem;"> | 21 | <el-row v-if="!is_xs" :gutter="10" style="margin-bottom: 3rem;"> |
| 22 | - <el-col :span="8"> | 22 | + <el-col :span="7"> |
| 23 | <hager-carousel :images="info_images"></hager-carousel> | 23 | <hager-carousel :images="info_images"></hager-carousel> |
| 24 | </el-col> | 24 | </el-col> |
| 25 | - <el-col :span="16"> | 25 | + <el-col :span="17"> |
| 26 | <div class="product-detail-info"> | 26 | <div class="product-detail-info"> |
| 27 | <div class="product-title" style="">{{ info.product_name }}</div> | 27 | <div class="product-title" style="">{{ info.product_name }}</div> |
| 28 | <div class="product-sub" style="margin: 1rem 0 2rem;" v-html="info.post_excerpt"></div> | 28 | <div class="product-sub" style="margin: 1rem 0 2rem;" v-html="info.post_excerpt"></div> | ... | ... |
| ... | @@ -2007,6 +2007,11 @@ normalize-wheel@^1.0.1: | ... | @@ -2007,6 +2007,11 @@ 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-fit-images@^3.2.4: | ||
| 2011 | + version "3.2.4" | ||
| 2012 | + resolved "https://mirrors.cloud.tencent.com/npm/object-fit-images/-/object-fit-images-3.2.4.tgz#6c299d38fdf207746e5d2d46c2877f6f25d15b52" | ||
| 2013 | + integrity sha512-G+7LzpYfTfqUyrZlfrou/PLLLAPNC52FTy5y1CBywX+1/FkxIloOyQXBmZ3Zxa2AWO+lMF0JTuvqbr7G5e5CWg== | ||
| 2014 | + | ||
| 2010 | object-inspect@^1.13.1: | 2015 | object-inspect@^1.13.1: |
| 2011 | version "1.13.2" | 2016 | version "1.13.2" |
| 2012 | resolved "https://mirrors.cloud.tencent.com/npm/object-inspect/-/object-inspect-1.13.2.tgz#dea0088467fb991e67af4058147a24824a3043ff" | 2017 | resolved "https://mirrors.cloud.tencent.com/npm/object-inspect/-/object-inspect-1.13.2.tgz#dea0088467fb991e67af4058147a24824a3043ff" | ... | ... |
-
Please register or login to post a comment