natasha 1 year ago
parent
commit
dd8485567f

+ 1 - 1
src/components/Adult/Preview.vue

@@ -1103,7 +1103,7 @@ export default {
   },
   // 生命周期 - 创建完成(可以访问当前this实例)
   created() {
-    console.log("2023-10-20");
+    console.log("2023-10-21");
   },
   // 生命周期 - 挂载完成(可以访问DOM元素)
   mounted() {

+ 19 - 0
src/components/Adult/preview/components/FreeWriteQP.vue

@@ -96,6 +96,11 @@ export default {
         this.hasDrew = true;
         this.lastLoc = this.window2Canvas(e.clientX, e.clientY);
       };
+      this.canvas.ontouchstart = (e) => {
+        this.isMouseDown = true;
+        this.hasDrew = true;
+        this.lastLoc = this.window2Canvas(e.touches[0].clientX, e.touches[0].clientY);
+      };
       this.canvas.onmouseout = (e) => {
         this.isMouseDown = false;
       };
@@ -107,12 +112,26 @@ export default {
           this.lastLoc = Object.assign({}, curLoc); // U know what I mean.
         }
       };
+      this.canvas.ontouchmove = (e) => {
+        if (this.isMouseDown) {
+          let curLoc = this.window2Canvas(e.touches[0].clientX, e.touches[0].clientY); // 获得当前坐标
+          this.draw(this.context, this.lastLoc, curLoc);
+          this.history.push([this.lastLoc, curLoc]);
+          this.lastLoc = Object.assign({}, curLoc); // U know what I mean.
+        }
+      };
       this.canvas.onmouseup = (e) => {
         this.isMouseDown = false;
         if (history.length) {
           localStorage.setItem("history", JSON.stringify(this.history));
         }
       };
+      this.canvas.onTouchend = (e) => {
+        this.isMouseDown = false;
+        if (history.length) {
+          localStorage.setItem("history", JSON.stringify(this.history));
+        }
+      };
     },
     window2Canvas(x, y) {
       let bbox = this.canvas.getBoundingClientRect();

+ 1 - 1
src/components/Adult/preview/components/Freewrite.vue

@@ -8,7 +8,7 @@
         "
         class="character-target-div"
       >
-        <vueEsign
+        <FreeWriteQP
           :bgColor.sync="bgColor"
           :height="height"
           :isCrop="isCrop"

+ 1 - 1
src/components/Adult/preview/components/FreewriteLettle.vue

@@ -19,7 +19,7 @@
         <template v-if="!hasPlay && data && data.strokes_image_url">
           <img class="img" :src="data.strokes_image_url" alt="" />
         </template>
-        <vueEsign
+        <FreeWriteQP
           :bgColor.sync="bgColor"
           :height="height"
           :isCrop="isCrop"