浏览代码

fix photo

Sherry 1年前
父节点
当前提交
e143101110

+ 56
- 0
src/fe/healthpassport/css/all.css 查看文件

@@ -10991,6 +10991,7 @@ button.swiper-pagination-bullet {
10991 10991
   position: relative;
10992 10992
 }
10993 10993
 .photo__img {
10994
+  position: relative;
10994 10995
   width: 16em;
10995 10996
   height: 16em;
10996 10997
   border-radius: 50%;
@@ -11017,6 +11018,61 @@ button.swiper-pagination-bullet {
11017 11018
 .photo .fileInput {
11018 11019
   display: none;
11019 11020
 }
11021
+.photo .load-wrapp {
11022
+  display: none;
11023
+  position: absolute;
11024
+  width: 16em;
11025
+  height: 16em;
11026
+  left: 50%;
11027
+  top: 50%;
11028
+  transform: translate(-50%, -50%);
11029
+  border-radius: 50%;
11030
+  background-color: rgba(255, 255, 255, 0.2);
11031
+  pointer-events: none;
11032
+}
11033
+.photo .load {
11034
+  position: absolute;
11035
+  left: 50%;
11036
+  top: 50%;
11037
+  transform: translate(-50%, -50%);
11038
+  width: 40%;
11039
+  height: 40%;
11040
+}
11041
+.photo .spinner {
11042
+  position: relative;
11043
+  width: 100%;
11044
+  height: 100%;
11045
+  margin: 0 auto;
11046
+  animation: loadingI 2s linear infinite;
11047
+}
11048
+.photo .bubble-1,
11049
+.photo .bubble-2 {
11050
+  position: absolute;
11051
+  top: 0;
11052
+  width: 3em;
11053
+  height: 3em;
11054
+  border-radius: 100%;
11055
+  background-color: #EAF2F8;
11056
+  animation: bounce 2s ease-in-out infinite;
11057
+}
11058
+.photo .bubble-2 {
11059
+  top: auto;
11060
+  bottom: 0;
11061
+  animation-delay: -1s;
11062
+}
11063
+@keyframes loadingI {
11064
+  100% {
11065
+    transform: rotate(360deg);
11066
+  }
11067
+}
11068
+@keyframes bounce {
11069
+  0%, 100% {
11070
+    transform: scale(0);
11071
+  }
11072
+  50% {
11073
+    transform: scale(1);
11074
+  }
11075
+}
11020 11076
 
11021 11077
 .modal .close {
11022 11078
   font-size: 1rem;

+ 1
- 1
src/fe/healthpassport/css/all.css.map
文件差异内容过多而无法显示
查看文件


+ 58
- 0
src/fe/healthpassport/css/component/_userPhoto.scss 查看文件

@@ -2,6 +2,7 @@
2 2
 .photo {
3 3
   position: relative;
4 4
   &__img {
5
+    position: relative;
5 6
     width: 16em;
6 7
     height: 16em;
7 8
     // border: 1px solid red;
@@ -29,4 +30,61 @@
29 30
   .fileInput {
30 31
     display: none;
31 32
   }
33
+  .load-wrapp {
34
+    display: none;
35
+    position: absolute;
36
+    width: 16em;
37
+    height: 16em;
38
+    left: 50%;
39
+    top: 50%;
40
+    transform: translate(-50%, -50%);
41
+    border-radius: 50%;
42
+    background-color: rgba($c-white, 0.2);
43
+    pointer-events: none;
44
+  }
45
+  .load {
46
+      position: absolute;
47
+      left: 50%;
48
+      top: 50%;
49
+      transform: translate(-50%, -50%);
50
+      width: 40%;
51
+      height: 40%;
52
+  }
53
+  .spinner {
54
+      position: relative;
55
+      width: 100%;
56
+      height: 100%;
57
+      margin: 0 auto;
58
+      animation: loadingI 2s linear infinite;
59
+  }
60
+  .bubble-1,
61
+  .bubble-2 {
62
+      position: absolute;
63
+      top: 0;
64
+      width: 3em;
65
+      height: 3em;
66
+      border-radius: 100%;
67
+      background-color: $c-blue-active;
68
+      animation: bounce 2s ease-in-out infinite;
69
+  }
70
+  .bubble-2 {
71
+      top: auto;
72
+      bottom: 0;
73
+      animation-delay: -1s;
74
+  }
75
+  @keyframes loadingI {
76
+      100% {
77
+          transform: rotate(360deg);
78
+      }
79
+  }
80
+
81
+  @keyframes bounce {
82
+      0%,
83
+      100% {
84
+          transform: scale(0);
85
+      }
86
+      50% {
87
+          transform: scale(1);
88
+      }
89
+  }
32 90
 }

+ 8
- 0
src/fe/healthpassport/index.html 查看文件

@@ -43,6 +43,14 @@
43 43
             <div class="form">
44 44
               <div class="form__item form__item-photo photo">
45 45
                 <div class="photo__img"></div>
46
+                <div class="load-wrapp">
47
+                  <div class="load">
48
+                    <div class="spinner">
49
+                      <div class="bubble-1"></div>
50
+                      <div class="bubble-2"></div>
51
+                    </div>
52
+                  </div>
53
+                </div>
46 54
                 <input type="file" id="fileInput1" class="fileInput" accept="image/*">
47 55
                 <div class="photo__icon photo__icon-1">
48 56
                   <img src="./images/solar_camera-linear.png" alt="">

+ 8
- 0
src/fe/healthpassport/js/register.js 查看文件

@@ -121,6 +121,8 @@ register = function () {
121 121
 			fileInput.addEventListener("change", function(e){
122 122
 				console.log(fileInput.id)
123 123
 
124
+				$(".photo .load-wrapp ").show();
125
+
124 126
 				const selectedFile = fileInput.files[0];
125 127
 
126 128
 				if(selectedFile) {
@@ -138,6 +140,8 @@ register = function () {
138 140
 							imagePreview.html("");
139 141
 							imagePreview.append(img);
140 142
 							// $('.templete_output').attr('src', templateData);
143
+
144
+							$(".photo .load-wrapp ").hide();
141 145
 						});
142 146
 					}
143 147
 
@@ -154,14 +158,18 @@ register = function () {
154 158
 							imagePreview.html("");
155 159
 							imagePreview.append(img);
156 160
 							// $('.templete_output').attr('src', templateData);
161
+
162
+							$(".photo .load-wrapp ").hide();
157 163
 						});
158 164
 					}
159 165
 					
160 166
 
161 167
 				}else {
162 168
 					LinePicHandler(linePicUrl);
169
+					$(".photo .load-wrapp ").hide();
163 170
 				}
164 171
 
172
+
165 173
 				if(fileInput.id == 'fileInput2') {
166 174
 					setTimeout(()=>{
167 175
 						console.log(finalase64Data)

+ 11
- 11
src/fe/healthpassport/js/services/index.js 查看文件

@@ -12,14 +12,14 @@ function Service() {
12 12
   function init() {
13 13
     console.log('GameService init')
14 14
 
15
-    return liffInit().then((profile) => {
15
+    // return liffInit().then((profile) => {
16 16
       
17 17
       // // 測試用資料
18
-      // const profile = {
19
-      //   userId: "Ua89aacd560a328ece0fec5584435046f",
20
-      //   displayName: "Tim",
21
-      //   pictureUrl: "https://sprofile.line-scdn.net/0hAvrrYLRRHllfCwoU_RtgJi9bHTN8ekdLdWRZPmJYQGxnPFwLdG5Za29YSTkyb1AGID9XbzoLEmlTGGk_QV3ibVg7QG5mOVANdm5Uug",
22
-      // }
18
+      const profile = {
19
+        userId: "Ua89aacd560a328ece0fec5584435046f",
20
+        displayName: "Tim",
21
+        pictureUrl: "https://sprofile.line-scdn.net/0hAvrrYLRRHllfCwoU_RtgJi9bHTN8ekdLdWRZPmJYQGxnPFwLdG5Za29YSTkyb1AGID9XbzoLEmlTGGk_QV3ibVg7QG5mOVANdm5Uug",
22
+      }
23 23
 
24 24
       m_LineUserId = profile.userId || '';
25 25
       m_LineName = profile.displayName || '';
@@ -29,12 +29,12 @@ function Service() {
29 29
       console.log('lineUserId:', m_LineUserId)
30 30
 
31 31
       // 測試用
32
-      // return Promise.resolve(profile);
32
+      return Promise.resolve(profile);
33 33
 
34
-      return profile;
35
-    }).catch((error) => {
36
-      console.log('[GameService] Liff Init Error \n Name:' + error.name + '\n Message:' + error.message);
37
-    })
34
+    //   return profile;
35
+    // }).catch((error) => {
36
+    //   console.log('[GameService] Liff Init Error \n Name:' + error.name + '\n Message:' + error.message);
37
+    // })
38 38
 
39 39
   }
40 40
 

+ 37
- 4
src/fe/healthpassport/lib/photoHelper.js 查看文件

@@ -19,10 +19,43 @@ var photoHelper = function () {
19 19
     // var file = document.querySelector('input[type=file]').files[0];
20 20
     var file = $(_input)[0].files[0];
21 21
 
22
-    ImageHelper.resizeAndRotateImage(file,maxHeight,function(resizeImageObj){
23
-      // var newImage = new Image();
24
-      // newImage.src = resizeImageObj;
25
-      _callback(resizeImageObj);
22
+    removePicExif(file).then(res => {
23
+      console.log(res)
24
+      file = res;
25
+      ImageHelper.resizeAndRotateImage(file,maxHeight,function(resizeImageObj){
26
+        // var newImage = new Image();
27
+        // newImage.src = resizeImageObj;
28
+        _callback(resizeImageObj);
29
+      });
30
+    });
31
+  }
32
+
33
+  function removePicExif(file) {
34
+    return new Promise((reslove) => {
35
+      if (file) {
36
+        let reader = new FileReader();
37
+        let image = new Image();
38
+        reader.onload = function (ev) {
39
+          image.src = ev.target.result;
40
+          image.onload = function () {
41
+            const ctxWidth = this.width;
42
+            const ctxHeight = this.height;
43
+            const canvas = document.createElement("canvas");
44
+            const ctx = canvas.getContext("2d");
45
+            canvas.width = ctxWidth;
46
+            canvas.height = ctxHeight;
47
+            ctx.drawImage(this, 0, 0, ctxWidth, ctxHeight);
48
+            canvas.toBlob((blob) => {
49
+              const newFile = new File([blob], file.name, {
50
+                type: "image/jpeg",
51
+                lastModified: Date.now(),
52
+              });
53
+              reslove(newFile);
54
+            });
55
+          };
56
+        };
57
+        reader.readAsDataURL(file);
58
+      }
26 59
     });
27 60
   }
28 61