|
|
@@ -52,13 +52,92 @@ const showCanvas = ref(false);
|
|
|
const showMask = ref(true);
|
|
|
const audioPlaying = ref(false);
|
|
|
let audio = null;
|
|
|
+let signatureInstance = null;
|
|
|
+
|
|
|
+// 将触摸事件转换为鼠标事件,以支持触摸屏
|
|
|
+const setupTouchSupport = (canvas) => {
|
|
|
+ // 触摸开始
|
|
|
+ canvas.addEventListener(
|
|
|
+ "touchstart",
|
|
|
+ (e) => {
|
|
|
+ e.preventDefault();
|
|
|
+ const touch = e.touches[0];
|
|
|
+ if (touch) {
|
|
|
+ const mouseEvent = new MouseEvent("mousedown", {
|
|
|
+ clientX: touch.clientX,
|
|
|
+ clientY: touch.clientY,
|
|
|
+ bubbles: true,
|
|
|
+ cancelable: true,
|
|
|
+ buttons: 1,
|
|
|
+ });
|
|
|
+ canvas.dispatchEvent(mouseEvent);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ { passive: false }
|
|
|
+ );
|
|
|
+
|
|
|
+ // 触摸移动
|
|
|
+ canvas.addEventListener(
|
|
|
+ "touchmove",
|
|
|
+ (e) => {
|
|
|
+ e.preventDefault();
|
|
|
+ const touch = e.touches[0];
|
|
|
+ if (touch) {
|
|
|
+ const mouseEvent = new MouseEvent("mousemove", {
|
|
|
+ clientX: touch.clientX,
|
|
|
+ clientY: touch.clientY,
|
|
|
+ bubbles: true,
|
|
|
+ cancelable: true,
|
|
|
+ buttons: 1,
|
|
|
+ });
|
|
|
+ canvas.dispatchEvent(mouseEvent);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ { passive: false }
|
|
|
+ );
|
|
|
+
|
|
|
+ // 触摸结束
|
|
|
+ canvas.addEventListener(
|
|
|
+ "touchend",
|
|
|
+ (e) => {
|
|
|
+ e.preventDefault();
|
|
|
+ const touch = e.changedTouches[0];
|
|
|
+ if (touch) {
|
|
|
+ const mouseEvent = new MouseEvent("mouseup", {
|
|
|
+ clientX: touch.clientX,
|
|
|
+ clientY: touch.clientY,
|
|
|
+ bubbles: true,
|
|
|
+ cancelable: true,
|
|
|
+ });
|
|
|
+ canvas.dispatchEvent(mouseEvent);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ { passive: false }
|
|
|
+ );
|
|
|
+
|
|
|
+ // 触摸取消
|
|
|
+ canvas.addEventListener(
|
|
|
+ "touchcancel",
|
|
|
+ (e) => {
|
|
|
+ e.preventDefault();
|
|
|
+ const mouseEvent = new MouseEvent("mouseup", {
|
|
|
+ bubbles: true,
|
|
|
+ cancelable: true,
|
|
|
+ });
|
|
|
+ canvas.dispatchEvent(mouseEvent);
|
|
|
+ },
|
|
|
+ { passive: false }
|
|
|
+ );
|
|
|
+};
|
|
|
|
|
|
const handleMaskClick = async () => {
|
|
|
showMask.value = false;
|
|
|
await nextTick();
|
|
|
const canvas = document.querySelector(".step4-detail-canvas-content canvas");
|
|
|
if (canvas) {
|
|
|
- new SmoothSignature(canvas);
|
|
|
+ signatureInstance = new SmoothSignature(canvas);
|
|
|
+ // 添加触摸事件支持
|
|
|
+ setupTouchSupport(canvas);
|
|
|
}
|
|
|
|
|
|
if (audio) {
|