From 8315e35852d60e260dc1795a30707335d2a3e364 Mon Sep 17 00:00:00 2001 From: sunmeng Date: Thu, 21 Aug 2025 17:55:57 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=89=E4=BD=8D=E9=97=AE=E9=A2=98=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index/gesture-canvas-page.vue | 70 +++++++++++-------- .../pages/index/gesture-canvas-page.js.map | 2 +- unpackage/dist/dev/mp-weixin/common/vendor.js | 2 +- .../pages/index/gesture-canvas-page.js | 34 +++------ 4 files changed, 55 insertions(+), 53 deletions(-) diff --git a/pages/index/gesture-canvas-page.vue b/pages/index/gesture-canvas-page.vue index b7e3379..17d6ac0 100644 --- a/pages/index/gesture-canvas-page.vue +++ b/pages/index/gesture-canvas-page.vue @@ -78,9 +78,10 @@ export default { methods: { handleCanvasClick(e) { - if (!this.containerRect) return; - // 如果是移动操作则忽略点击 - if (this.isMoving) return; + if (this.isMoving) { + this.isMoving = false; // 重置移动状态 + return; + } // 获取dpr const dpr = this.$refs.canvasRef.dpr || 1; @@ -180,9 +181,12 @@ export default { initGestureHandler() { try { - this.gestureHandler = new GestureHandler(this, this.transformMatrix, { - container: this.containerRect - }); + // this.gestureHandler = new GestureHandler(this, this.transformMatrix, { + // container: this.containerRect + // }); + this.gestureHandler = new GestureHandler(this, this.transformMatrix, { + container: this.containerRect + }); // console.log( 'initGestureHandler', this.gestureHandler ) } catch (e) { console.error('手势处理器初始化失败:', e); @@ -262,24 +266,30 @@ export default { // 更新触点数量 this.touchPoints = event.touches.length; // 增加移动状态检测 - if (event.type === 'touchstart') { - this.lastTouchTime = Date.now(); - this.touchStartPoint = { - x: event.touches[0].clientX, - y: event.touches[0].clientY - }; - this.isMoving = false; // 重置移动状态 - } - else if (event.type === 'touchmove') { - // 检测移动距离是否超过阈值 - if (this.touchStartPoint) { - const dx = Math.abs(event.touches[0].clientX - this.touchStartPoint.x); - const dy = Math.abs(event.touches[0].clientY - this.touchStartPoint.y); - if (dx > 5 || dy > 5) { - this.isMoving = true; - } - } - } + if (event.type === 'touchstart') { + this.isMoving = false; // 重置移动状态 + } else if (event.type === 'touchmove') { + this.isMoving = true; // 标记为移动操作 + } + + // if (event.type === 'touchstart') { + // this.lastTouchTime = Date.now(); + // this.touchStartPoint = { + // x: event.touches[0].clientX, + // y: event.touches[0].clientY + // }; + // this.isMoving = false; // 重置移动状态 + // } + // else if (event.type === 'touchmove') { + // // 检测移动距离是否超过阈值 + // if (this.touchStartPoint) { + // const dx = Math.abs(event.touches[0].clientX - this.touchStartPoint.x); + // const dy = Math.abs(event.touches[0].clientY - this.touchStartPoint.y); + // if (dx > 5 || dy > 5) { + // this.isMoving = true; + // } + // } + // } // 仅在触摸开始时重置状态 // if (event.type === 'touchstart') { @@ -665,14 +675,18 @@ export default { y: data.yCoords[index] * seatSize }; }); + // 重置变换矩阵 this.transformMatrix = new TransformMatrix(); - + + // 重新初始化手势处理器 + await this.getContainerPosition(); + this.initGestureHandler(); // 自动居中显示座位区域 // 自动居中显示座位区域 this.$nextTick(() => { - if (!this.gestureHandler) { - this.initGestureHandler(); - } + // if (!this.gestureHandler) { + // this.initGestureHandler(); + // } if (this.seatPositions.length > 0) { // 计算座位区域边界 const xs = this.seatPositions.map(s => s.x); diff --git a/unpackage/dist/dev/.sourcemap/mp-weixin/pages/index/gesture-canvas-page.js.map b/unpackage/dist/dev/.sourcemap/mp-weixin/pages/index/gesture-canvas-page.js.map index ce0312c..38e3f11 100644 --- a/unpackage/dist/dev/.sourcemap/mp-weixin/pages/index/gesture-canvas-page.js.map +++ b/unpackage/dist/dev/.sourcemap/mp-weixin/pages/index/gesture-canvas-page.js.map @@ -1 +1 @@ -{"version":3,"file":"gesture-canvas-page.js","sources":["pages/index/gesture-canvas-page.vue?type=page"],"sourcesContent":["import MiniProgramPage from '/Users/sunmeng/Desktop/wx/canvas/pages/index/gesture-canvas-page.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"} \ No newline at end of file +{"version":3,"file":"gesture-canvas-page.js","sources":["pages/index/gesture-canvas-page.vue?type=page"],"sourcesContent":["import MiniProgramPage from '/Users/sunmeng/Desktop/wx/canvas/pages/index/gesture-canvas-page.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"} \ No newline at end of file diff --git a/unpackage/dist/dev/mp-weixin/common/vendor.js b/unpackage/dist/dev/mp-weixin/common/vendor.js index fe48fd7..7d9db74 100644 --- a/unpackage/dist/dev/mp-weixin/common/vendor.js +++ b/unpackage/dist/dev/mp-weixin/common/vendor.js @@ -6882,7 +6882,7 @@ function initOnError() { function initRuntimeSocketService() { const hosts = "127.0.0.1,172.10.0.127"; const port = "8090"; - const id = "mp-weixin_Mc-x4m"; + const id = "mp-weixin_pbUakk"; const lazy = typeof swan !== "undefined"; let restoreError = lazy ? () => { } : initOnError(); diff --git a/unpackage/dist/dev/mp-weixin/pages/index/gesture-canvas-page.js b/unpackage/dist/dev/mp-weixin/pages/index/gesture-canvas-page.js index 7c2c888..3ab91a3 100644 --- a/unpackage/dist/dev/mp-weixin/pages/index/gesture-canvas-page.js +++ b/unpackage/dist/dev/mp-weixin/pages/index/gesture-canvas-page.js @@ -39,10 +39,10 @@ const _sfc_main = { }, methods: { handleCanvasClick(e) { - if (!this.containerRect) - return; - if (this.isMoving) + if (this.isMoving) { + this.isMoving = false; return; + } const dpr = this.$refs.canvasRef.dpr || 1; const x = (e.detail.x - this.containerRect.left) * dpr; const y = (e.detail.y - this.containerRect.top) * dpr; @@ -65,7 +65,7 @@ const _sfc_main = { } else if (this.currentView === "seat") { const hitSeat = this.$refs.canvasRef.checkSeatHit(x, y); if (hitSeat) { - common_vendor.index.__f__("log", "at pages/index/gesture-canvas-page.vue:112", "选中座位:", hitSeat); + common_vendor.index.__f__("log", "at pages/index/gesture-canvas-page.vue:113", "选中座位:", hitSeat); this.toggleSeatSelection(hitSeat); } } @@ -112,7 +112,7 @@ const _sfc_main = { return; } } catch (e) { - common_vendor.index.__f__("error", "at pages/index/gesture-canvas-page.vue:172", "获取容器位置失败:", e); + common_vendor.index.__f__("error", "at pages/index/gesture-canvas-page.vue:173", "获取容器位置失败:", e); } await new Promise((r) => setTimeout(r, 100)); retryCount++; @@ -124,7 +124,7 @@ const _sfc_main = { container: this.containerRect }); } catch (e) { - common_vendor.index.__f__("error", "at pages/index/gesture-canvas-page.vue:188", "手势处理器初始化失败:", e); + common_vendor.index.__f__("error", "at pages/index/gesture-canvas-page.vue:192", "手势处理器初始化失败:", e); this.gestureHandler = { catchEvent: this.createGestureFallback(), setScale: (scale) => { @@ -182,20 +182,9 @@ const _sfc_main = { var _a; this.touchPoints = event.touches.length; if (event.type === "touchstart") { - this.lastTouchTime = Date.now(); - this.touchStartPoint = { - x: event.touches[0].clientX, - y: event.touches[0].clientY - }; this.isMoving = false; } else if (event.type === "touchmove") { - if (this.touchStartPoint) { - const dx = Math.abs(event.touches[0].clientX - this.touchStartPoint.x); - const dy = Math.abs(event.touches[0].clientY - this.touchStartPoint.y); - if (dx > 5 || dy > 5) { - this.isMoving = true; - } - } + this.isMoving = true; } (_a = this.gestureHandler) == null ? void 0 : _a.catchEvent(event); if (event.type === "touchend" || event.type === "touchcancel") { @@ -543,7 +532,7 @@ const _sfc_main = { }; this.seatAreas = response.data; } catch (e) { - common_vendor.index.__f__("error", "at pages/index/gesture-canvas-page.vue:647", "加载区域数据失败:", e); + common_vendor.index.__f__("error", "at pages/index/gesture-canvas-page.vue:657", "加载区域数据失败:", e); } }, async loadSeatData(areaCode) { @@ -563,10 +552,9 @@ const _sfc_main = { }; }); this.transformMatrix = new pages_index_transformMatrix.TransformMatrix(); + await this.getContainerPosition(); + this.initGestureHandler(); this.$nextTick(() => { - if (!this.gestureHandler) { - this.initGestureHandler(); - } if (this.seatPositions.length > 0) { const xs = this.seatPositions.map((s) => s.x); const ys = this.seatPositions.map((s) => s.y); @@ -582,7 +570,7 @@ const _sfc_main = { } }); } catch (e) { - common_vendor.index.__f__("error", "at pages/index/gesture-canvas-page.vue:705", "加载座位数据失败:", e); + common_vendor.index.__f__("error", "at pages/index/gesture-canvas-page.vue:719", "加载座位数据失败:", e); common_vendor.index.showToast({ title: "加载座位失败", icon: "none" }); } }