Quellcode durchsuchen

处理图片相关问题

seimin vor 11 Monaten
Ursprung
Commit
a0b82efb94
3 geänderte Dateien mit 33 neuen und 3 gelöschten Zeilen
  1. 1 1
      manifest.json
  2. 21 2
      pages/assign/assign.vue
  3. 11 0
      share/useUploadFile.js

+ 1 - 1
manifest.json

@@ -62,7 +62,7 @@
62 62
         "devServer" : {
63 63
             "proxy" : {
64 64
                 "/service" : {
65
-                    "target" : "http://192.168.4.105", //请求的目标域名
65
+                    "target" : "http://192.168.3.111", //请求的目标域名
66 66
                     "changeOrigin" : true, //是否跨域
67 67
                     "secure" : false
68 68
                 }

+ 21 - 2
pages/assign/assign.vue

@@ -700,15 +700,17 @@
700 700
       });
701 701
       return;
702 702
     }
703
+    console.log(dataInfo)
703 704
     console.log(dataInfo.handlerImgList)
705
+    console.log(dataInfo.incidentData.repairImgList)
704 706
     
705 707
     uni.showLoading({
706 708
       title: "加载中",
707 709
       mask: true,
708 710
     });
709 711
     
710
-    if(dataInfo.handlerImgList.length || dataInfo.incidentData.repairImgList.length){
711
-      // 有图片
712
+    if(dataInfo.handlerImgList.length){
713
+      // 有处理图片
712 714
       let handlerOrder$ = handlerOrder();
713 715
       let requestList = [handlerOrder$];
714 716
       Promise.all(requestList).then(resList => {
@@ -724,6 +726,23 @@
724 726
           });
725 727
         }
726 728
       })
729
+    }else if(dataInfo.incidentData.repairImgList.length){
730
+      // 有报修图片,无处理图片
731
+      let handlerOrder$ = handlerOrder();
732
+      let requestList = [handlerOrder$];
733
+      Promise.all(requestList).then(resList => {
734
+        uni.hideLoading();
735
+        console.log(resList);
736
+        if(resList[0].state == 200){
737
+          dataInfo.incidentId = resList[0].data.id;
738
+          handlerImgSuccessNew();
739
+        }else{
740
+          uni.showToast({
741
+            icon: 'none',
742
+            title: resList[0].msg || '请求数据失败!'
743
+          });
744
+        }
745
+      })
727 746
     }else{
728 747
       // 没有图片
729 748
       let handlerOrder$ = handlerOrder();

+ 11 - 0
share/useUploadFile.js

@@ -11,6 +11,16 @@ export function useUploadFile() {
11 11
     })
12 12
   }
13 13
   /**
14
+   * 图片加载完成
15
+   */
16
+  const newImage = (img) => {
17
+    return new Promise((resolve,reject) => {
18
+      img.onload = () => {
19
+        resolve()
20
+      }
21
+    })
22
+  }
23
+  /**
14 24
    * 上传图片
15 25
    */
16 26
   const uploadFile = async (imgObj, type, incidentId) => {
@@ -24,6 +34,7 @@ export function useUploadFile() {
24 34
     let ctx = canvas.getContext('2d')
25 35
     canvas.width = canvasWidth
26 36
     canvas.height = canvasHeight
37
+    await newImage(img)
27 38
     ctx.drawImage(img, 0, 0, canvasWidth, canvasHeight)
28 39
     
29 40
     const fileSrc = await toBlob(canvas, imgObj)