diff --git a/app.wxss b/app.wxss index d1a1e47..770f3de 100644 --- a/app.wxss +++ b/app.wxss @@ -1,44 +1,4 @@ /**app.wxss**/ -/* 隐藏全局滚动条 - 全面覆盖 */ -::-webkit-scrollbar, -*::-webkit-scrollbar { - display: none !important; - width: 0 !important; - height: 0 !important; - color: transparent !important; - background: transparent !important; -} - -/* 隐藏所有可滚动元素的滚动条 */ -page, -view, -scroll-view, -textarea, -picker-view, -::-webkit-scrollbar-track, -::-webkit-scrollbar-thumb, -::-webkit-scrollbar-button, -::-webkit-scrollbar-corner { - -webkit-overflow-scrolling: touch; - overflow-scrolling: touch; - scrollbar-width: none !important; - -ms-overflow-style: none !important; - -webkit-scrollbar: none !important; -} - -/* 确保页面级滚动条隐藏 */ -page { - overflow: auto !important; - scrollbar-width: none !important; - -ms-overflow-style: none !important; -} - -/* 针对iOS设备的特殊处理 */ -@media screen and (max-width: 768px) { - ::-webkit-scrollbar { - display: none !important; - } -} .container { display: flex; flex-direction: column; diff --git a/pages/goods-detail/goods-detail.js b/pages/goods-detail/goods-detail.js index 39bae10..fa07b9d 100644 --- a/pages/goods-detail/goods-detail.js +++ b/pages/goods-detail/goods-detail.js @@ -81,9 +81,9 @@ Page({ productId: productIdStr, name: product.productName, price: product.price, - minOrder: product.quantity, + minOrder: product.minOrder || product.quantity, yolk: product.yolk, - spec: product.specification, + spec: product.spec || product.specification, region: product.region, contact_phone: product.contact_phone || product.contactPhone, product_contact: product.product_contact || product.contactName, @@ -169,9 +169,9 @@ Page({ productId: productIdStr, name: product.productName, price: product.price, - minOrder: product.quantity, + minOrder: product.minOrder || product.quantity, yolk: product.yolk, - spec: product.specification, + spec: product.spec || product.specification, region: product.region, contact_phone: product.contact_phone || product.contactPhone, product_contact: product.product_contact || product.contactName, @@ -222,24 +222,30 @@ Page({ this.setData({ showImagePreview: true, previewImageUrls: urls, - previewImageIndex: index || 0, - // 重置图片缩放状态 - scale: 1, - offsetX: 0, - offsetY: 0, - isScaling: false + previewImageIndex: parseInt(index || 0) }); + this.resetZoom(); }, // 关闭图片预览 closeImagePreview() { this.setData({ - showImagePreview: false, - // 重置图片缩放状态 + showImagePreview: false + }); + this.resetZoom(); + }, + + // 重置缩放状态 + resetZoom() { + this.setData({ scale: 1, offsetX: 0, offsetY: 0, - isScaling: false + lastScale: 1, + startDistance: 0, + isScaling: false, + initialTouch: null, + lastTapTime: 0 }); }, @@ -247,74 +253,78 @@ Page({ onPreviewImageChange(e) { console.log('图片预览切换:', e); this.setData({ - previewImageIndex: e.detail.current, - // 重置当前图片的缩放状态 - scale: 1, - offsetX: 0, - offsetY: 0, - isScaling: false + previewImageIndex: e.detail.current }); + // 切换图片时重置缩放状态 + this.resetZoom(); }, - // 处理图片点击事件(双击放大/缩小) + // 处理图片点击事件(单击/双击判断) handleImageTap(e) { console.log('图片点击事件:', e); - const now = Date.now(); - const DOUBLE_TAP_DELAY = 300; + const currentTime = Date.now(); + const lastTapTime = this.data.lastTapTime || 0; - // 检查是否为双击 - if (now - this.lastTapTime < DOUBLE_TAP_DELAY) { + // 判断是否为双击(300ms内连续点击) + if (currentTime - lastTapTime < 300) { // 双击事件 - if (this.doubleTapTimer) { - clearTimeout(this.doubleTapTimer); + if (this.data.doubleTapTimer) { + clearTimeout(this.data.doubleTapTimer); } - // 切换缩放状态 + // 切换放大/缩小状态 const newScale = this.data.scale === 1 ? 2 : 1; this.setData({ scale: newScale, - isScaling: false + lastScale: newScale, + offsetX: 0, + offsetY: 0, + lastTapTime: 0 // 重置双击状态 }); } else { - // 单击事件,设置双击计时器 - if (this.doubleTapTimer) { - clearTimeout(this.doubleTapTimer); + // 单击事件,设置延迟来检测是否会成为双击 + if (this.data.doubleTapTimer) { + clearTimeout(this.data.doubleTapTimer); } - this.doubleTapTimer = setTimeout(() => { - // 单击后300毫秒内没有第二次点击,视为单击 - // 可以在这里添加单击事件的处理逻辑 - }, DOUBLE_TAP_DELAY); + this.setData({ + lastTapTime: currentTime, + doubleTapTimer: setTimeout(() => { + // 确认是单击,关闭图片预览 + this.closeImagePreview(); + }, 300) + }); } - - this.lastTapTime = now; }, // 计算两点之间的距离 - getDistance(point1, point2) { - const dx = point2.clientX - point1.clientX; - const dy = point2.clientY - point1.clientY; + calculateDistance(touch1, touch2) { + const dx = touch2.clientX - touch1.clientX; + const dy = touch2.clientY - touch1.clientY; return Math.sqrt(dx * dx + dy * dy); }, // 处理触摸开始事件 handleTouchStart(e) { console.log('触摸开始事件:', e); - if (e.touches.length === 2) { - // 双指触摸,计算初始距离 - this.setData({ - startDistance: this.getDistance(e.touches[0], e.touches[1]), - lastScale: this.data.scale, - isScaling: true - }); - } else if (e.touches.length === 1) { - // 单指触摸,记录初始位置 + const touches = e.touches; + + if (touches.length === 1) { + // 单指:准备拖动 this.setData({ initialTouch: { - x: e.touches[0].clientX, - y: e.touches[0].clientY + x: touches[0].clientX, + y: touches[0].clientY } }); + } else if (touches.length === 2) { + // 双指:记录起始距离,准备缩放 + const distance = this.calculateDistance(touches[0], touches[1]); + this.setData({ + startDistance: distance, + isScaling: true, + lastScale: this.data.scale + }); } }, @@ -351,7 +361,7 @@ Page({ }); } else if (touches.length === 2) { // 双指缩放 - const currentDistance = this.getDistance(touches[0], touches[1]); + const currentDistance = this.calculateDistance(touches[0], touches[1]); const scale = (currentDistance / this.data.startDistance) * this.data.lastScale; // 限制缩放范围在0.5倍到3倍之间 @@ -367,22 +377,11 @@ Page({ // 处理触摸结束事件 handleTouchEnd(e) { console.log('触摸结束事件:', e); - if (e.touches.length === 0) { - // 触摸结束,更新最后缩放比例 - this.setData({ - lastScale: this.data.scale, - isScaling: false, - initialTouch: null - }); - } else if (e.touches.length === 1) { - // 单指触摸结束,保留初始触摸点 - this.setData({ - initialTouch: { - x: e.touches[0].clientX, - y: e.touches[0].clientY - } - }); - } + this.setData({ + isScaling: false, + lastScale: this.data.scale, + initialTouch: null + }); }, // 拨打电话 diff --git a/pages/seller/index.wxml b/pages/seller/index.wxml index 00b8f9f..c48864c 100644 --- a/pages/seller/index.wxml +++ b/pages/seller/index.wxml @@ -55,58 +55,72 @@ - - - - - - - - - + + + + + + + + + + + + + + 暂无图片 - - - - - - - - - - - - {{(item.currentImageIndex || 0) + 1}}/{{item.imageUrls.length}} - + + + {{(item.currentImageIndex || 0) + 1}}/{{item.imageUrls.length}} + - - - - {{item.name}} - 已上架 + + + + {{item.name}} + 已上架 + + + + 蛋黄: + {{item.yolk || '无'}} + + + 规格: + {{item.spec || '无'}} + + + 件数: + {{item.minOrder}}件 + + + 斤重: + {{item.grossWeight || ''}}斤 + + + 地区: + {{item.region || '未设置'}} + + + 创建时间: + {{item.formattedCreatedAt}} - 蛋黄: {{item.yolk || '无'}} - 规格: {{item.spec || '无'}} - 件数: {{item.minOrder}}件 - 斤重: {{item.grossWeight || ''}}斤 - 地区: {{item.region || '未设置'}} - 创建时间: {{item.formattedCreatedAt}} - +