选位问题修复
This commit is contained in:
parent
1b8b891531
commit
8315e35852
@ -78,9 +78,10 @@ export default {
|
|||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
handleCanvasClick(e) {
|
handleCanvasClick(e) {
|
||||||
if (!this.containerRect) return;
|
if (this.isMoving) {
|
||||||
// 如果是移动操作则忽略点击
|
this.isMoving = false; // 重置移动状态
|
||||||
if (this.isMoving) return;
|
return;
|
||||||
|
}
|
||||||
// 获取dpr
|
// 获取dpr
|
||||||
const dpr = this.$refs.canvasRef.dpr || 1;
|
const dpr = this.$refs.canvasRef.dpr || 1;
|
||||||
|
|
||||||
@ -180,9 +181,12 @@ export default {
|
|||||||
|
|
||||||
initGestureHandler() {
|
initGestureHandler() {
|
||||||
try {
|
try {
|
||||||
this.gestureHandler = new GestureHandler(this, this.transformMatrix, {
|
// this.gestureHandler = new GestureHandler(this, this.transformMatrix, {
|
||||||
container: this.containerRect
|
// container: this.containerRect
|
||||||
});
|
// });
|
||||||
|
this.gestureHandler = new GestureHandler(this, this.transformMatrix, {
|
||||||
|
container: this.containerRect
|
||||||
|
});
|
||||||
// console.log( 'initGestureHandler', this.gestureHandler )
|
// console.log( 'initGestureHandler', this.gestureHandler )
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('手势处理器初始化失败:', e);
|
console.error('手势处理器初始化失败:', e);
|
||||||
@ -262,24 +266,30 @@ export default {
|
|||||||
// 更新触点数量
|
// 更新触点数量
|
||||||
this.touchPoints = event.touches.length;
|
this.touchPoints = event.touches.length;
|
||||||
// 增加移动状态检测
|
// 增加移动状态检测
|
||||||
if (event.type === 'touchstart') {
|
if (event.type === 'touchstart') {
|
||||||
this.lastTouchTime = Date.now();
|
this.isMoving = false; // 重置移动状态
|
||||||
this.touchStartPoint = {
|
} else if (event.type === 'touchmove') {
|
||||||
x: event.touches[0].clientX,
|
this.isMoving = true; // 标记为移动操作
|
||||||
y: event.touches[0].clientY
|
}
|
||||||
};
|
|
||||||
this.isMoving = false; // 重置移动状态
|
// if (event.type === 'touchstart') {
|
||||||
}
|
// this.lastTouchTime = Date.now();
|
||||||
else if (event.type === 'touchmove') {
|
// this.touchStartPoint = {
|
||||||
// 检测移动距离是否超过阈值
|
// x: event.touches[0].clientX,
|
||||||
if (this.touchStartPoint) {
|
// y: event.touches[0].clientY
|
||||||
const dx = Math.abs(event.touches[0].clientX - this.touchStartPoint.x);
|
// };
|
||||||
const dy = Math.abs(event.touches[0].clientY - this.touchStartPoint.y);
|
// this.isMoving = false; // 重置移动状态
|
||||||
if (dx > 5 || dy > 5) {
|
// }
|
||||||
this.isMoving = true;
|
// 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') {
|
// if (event.type === 'touchstart') {
|
||||||
@ -665,14 +675,18 @@ export default {
|
|||||||
y: data.yCoords[index] * seatSize
|
y: data.yCoords[index] * seatSize
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
// 重置变换矩阵
|
||||||
this.transformMatrix = new TransformMatrix();
|
this.transformMatrix = new TransformMatrix();
|
||||||
|
|
||||||
|
// 重新初始化手势处理器
|
||||||
|
await this.getContainerPosition();
|
||||||
|
this.initGestureHandler();
|
||||||
// 自动居中显示座位区域
|
// 自动居中显示座位区域
|
||||||
// 自动居中显示座位区域
|
// 自动居中显示座位区域
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
if (!this.gestureHandler) {
|
// if (!this.gestureHandler) {
|
||||||
this.initGestureHandler();
|
// this.initGestureHandler();
|
||||||
}
|
// }
|
||||||
if (this.seatPositions.length > 0) {
|
if (this.seatPositions.length > 0) {
|
||||||
// 计算座位区域边界
|
// 计算座位区域边界
|
||||||
const xs = this.seatPositions.map(s => s.x);
|
const xs = this.seatPositions.map(s => s.x);
|
||||||
|
@ -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;"}
|
{"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;"}
|
@ -6882,7 +6882,7 @@ function initOnError() {
|
|||||||
function initRuntimeSocketService() {
|
function initRuntimeSocketService() {
|
||||||
const hosts = "127.0.0.1,172.10.0.127";
|
const hosts = "127.0.0.1,172.10.0.127";
|
||||||
const port = "8090";
|
const port = "8090";
|
||||||
const id = "mp-weixin_Mc-x4m";
|
const id = "mp-weixin_pbUakk";
|
||||||
const lazy = typeof swan !== "undefined";
|
const lazy = typeof swan !== "undefined";
|
||||||
let restoreError = lazy ? () => {
|
let restoreError = lazy ? () => {
|
||||||
} : initOnError();
|
} : initOnError();
|
||||||
|
@ -39,10 +39,10 @@ const _sfc_main = {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleCanvasClick(e) {
|
handleCanvasClick(e) {
|
||||||
if (!this.containerRect)
|
if (this.isMoving) {
|
||||||
return;
|
this.isMoving = false;
|
||||||
if (this.isMoving)
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
const dpr = this.$refs.canvasRef.dpr || 1;
|
const dpr = this.$refs.canvasRef.dpr || 1;
|
||||||
const x = (e.detail.x - this.containerRect.left) * dpr;
|
const x = (e.detail.x - this.containerRect.left) * dpr;
|
||||||
const y = (e.detail.y - this.containerRect.top) * dpr;
|
const y = (e.detail.y - this.containerRect.top) * dpr;
|
||||||
@ -65,7 +65,7 @@ const _sfc_main = {
|
|||||||
} else if (this.currentView === "seat") {
|
} else if (this.currentView === "seat") {
|
||||||
const hitSeat = this.$refs.canvasRef.checkSeatHit(x, y);
|
const hitSeat = this.$refs.canvasRef.checkSeatHit(x, y);
|
||||||
if (hitSeat) {
|
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);
|
this.toggleSeatSelection(hitSeat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -112,7 +112,7 @@ const _sfc_main = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} 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));
|
await new Promise((r) => setTimeout(r, 100));
|
||||||
retryCount++;
|
retryCount++;
|
||||||
@ -124,7 +124,7 @@ const _sfc_main = {
|
|||||||
container: this.containerRect
|
container: this.containerRect
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} 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 = {
|
this.gestureHandler = {
|
||||||
catchEvent: this.createGestureFallback(),
|
catchEvent: this.createGestureFallback(),
|
||||||
setScale: (scale) => {
|
setScale: (scale) => {
|
||||||
@ -182,20 +182,9 @@ const _sfc_main = {
|
|||||||
var _a;
|
var _a;
|
||||||
this.touchPoints = event.touches.length;
|
this.touchPoints = event.touches.length;
|
||||||
if (event.type === "touchstart") {
|
if (event.type === "touchstart") {
|
||||||
this.lastTouchTime = Date.now();
|
|
||||||
this.touchStartPoint = {
|
|
||||||
x: event.touches[0].clientX,
|
|
||||||
y: event.touches[0].clientY
|
|
||||||
};
|
|
||||||
this.isMoving = false;
|
this.isMoving = false;
|
||||||
} else if (event.type === "touchmove") {
|
} else if (event.type === "touchmove") {
|
||||||
if (this.touchStartPoint) {
|
this.isMoving = true;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
(_a = this.gestureHandler) == null ? void 0 : _a.catchEvent(event);
|
(_a = this.gestureHandler) == null ? void 0 : _a.catchEvent(event);
|
||||||
if (event.type === "touchend" || event.type === "touchcancel") {
|
if (event.type === "touchend" || event.type === "touchcancel") {
|
||||||
@ -543,7 +532,7 @@ const _sfc_main = {
|
|||||||
};
|
};
|
||||||
this.seatAreas = response.data;
|
this.seatAreas = response.data;
|
||||||
} catch (e) {
|
} 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) {
|
async loadSeatData(areaCode) {
|
||||||
@ -563,10 +552,9 @@ const _sfc_main = {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
this.transformMatrix = new pages_index_transformMatrix.TransformMatrix();
|
this.transformMatrix = new pages_index_transformMatrix.TransformMatrix();
|
||||||
|
await this.getContainerPosition();
|
||||||
|
this.initGestureHandler();
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
if (!this.gestureHandler) {
|
|
||||||
this.initGestureHandler();
|
|
||||||
}
|
|
||||||
if (this.seatPositions.length > 0) {
|
if (this.seatPositions.length > 0) {
|
||||||
const xs = this.seatPositions.map((s) => s.x);
|
const xs = this.seatPositions.map((s) => s.x);
|
||||||
const ys = this.seatPositions.map((s) => s.y);
|
const ys = this.seatPositions.map((s) => s.y);
|
||||||
@ -582,7 +570,7 @@ const _sfc_main = {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} 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" });
|
common_vendor.index.showToast({ title: "加载座位失败", icon: "none" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user