|
@@ -114,6 +114,7 @@ register = function () {
|
114
|
114
|
const imagePreview = $('.photo__img');
|
115
|
115
|
// console.log(fileInput.id)
|
116
|
116
|
|
|
117
|
+ var templeteHelper = new photoHelper();
|
117
|
118
|
|
118
|
119
|
fileInputs.forEach((fileInput)=> {
|
119
|
120
|
// 當選擇圖片後,顯示圖片的預覽
|
|
@@ -123,25 +124,44 @@ register = function () {
|
123
|
124
|
const selectedFile = fileInput.files[0];
|
124
|
125
|
|
125
|
126
|
if(selectedFile) {
|
126
|
|
- const reader = new FileReader();
|
127
|
|
- reader.onload = function(e) {
|
128
|
|
- // 移除 data:image/jpeg;base64,
|
129
|
|
- // customBase64Data = e.target.result.split(",")[1];
|
130
|
|
-
|
131
|
|
- customBase64Data = e.target.result;
|
132
|
|
- finalase64Data = customBase64Data;
|
133
|
|
- // console.log(e.target)
|
134
|
|
- const img = new Image();
|
135
|
|
- img.src = e.target.result;
|
136
|
|
- imagePreview.html("");
|
137
|
|
- imagePreview.append(img);
|
138
|
|
-
|
139
|
|
- // console.log(finalase64Data)
|
|
127
|
+
|
|
128
|
+ if(fileInput.id == 'fileInput1') {
|
|
129
|
+ templeteHelper.loadFile('#fileInput1',function (_photoData) {
|
|
130
|
+ console.log('fileInput1 has loaded.');
|
|
131
|
+ templateData = _photoData;
|
|
132
|
+
|
|
133
|
+ finalase64Data = templateData;
|
|
134
|
+ console.log(finalase64Data)
|
|
135
|
+
|
|
136
|
+ const img = new Image();
|
|
137
|
+ img.src = templateData;
|
|
138
|
+ imagePreview.html("");
|
|
139
|
+ imagePreview.append(img);
|
|
140
|
+ // $('.templete_output').attr('src', templateData);
|
|
141
|
+ });
|
140
|
142
|
}
|
141
|
|
- reader.readAsDataURL(selectedFile);
|
|
143
|
+
|
|
144
|
+ if(fileInput.id == 'fileInput2') {
|
|
145
|
+ templeteHelper.loadFile('#fileInput2',function (_photoData) {
|
|
146
|
+ console.log('fileInput2 has loaded.');
|
|
147
|
+ templateData = _photoData;
|
|
148
|
+
|
|
149
|
+ finalase64Data = templateData;
|
|
150
|
+ console.log(finalase64Data)
|
|
151
|
+
|
|
152
|
+ const img = new Image();
|
|
153
|
+ img.src = templateData;
|
|
154
|
+ imagePreview.html("");
|
|
155
|
+ imagePreview.append(img);
|
|
156
|
+ // $('.templete_output').attr('src', templateData);
|
|
157
|
+ });
|
|
158
|
+ }
|
|
159
|
+
|
|
160
|
+
|
142
|
161
|
}else {
|
143
|
162
|
LinePicHandler(linePicUrl);
|
144
|
163
|
}
|
|
164
|
+
|
145
|
165
|
if(fileInput.id == 'fileInput2') {
|
146
|
166
|
setTimeout(()=>{
|
147
|
167
|
console.log(finalase64Data)
|
|
@@ -151,6 +171,43 @@ register = function () {
|
151
|
171
|
}
|
152
|
172
|
});
|
153
|
173
|
});
|
|
174
|
+
|
|
175
|
+ // fileInputs.forEach((fileInput)=> {
|
|
176
|
+ // // 當選擇圖片後,顯示圖片的預覽
|
|
177
|
+ // fileInput.addEventListener("change", function(e){
|
|
178
|
+ // console.log(fileInput.id)
|
|
179
|
+
|
|
180
|
+ // const selectedFile = fileInput.files[0];
|
|
181
|
+
|
|
182
|
+ // if(selectedFile) {
|
|
183
|
+ // const reader = new FileReader();
|
|
184
|
+ // reader.onload = function(e) {
|
|
185
|
+ // // 移除 data:image/jpeg;base64,
|
|
186
|
+ // // customBase64Data = e.target.result.split(",")[1];
|
|
187
|
+
|
|
188
|
+ // customBase64Data = e.target.result;
|
|
189
|
+ // finalase64Data = customBase64Data;
|
|
190
|
+ // // console.log(e.target)
|
|
191
|
+ // const img = new Image();
|
|
192
|
+ // img.src = e.target.result;
|
|
193
|
+ // imagePreview.html("");
|
|
194
|
+ // imagePreview.append(img);
|
|
195
|
+
|
|
196
|
+ // // console.log(finalase64Data)
|
|
197
|
+ // }
|
|
198
|
+ // reader.readAsDataURL(selectedFile);
|
|
199
|
+ // }else {
|
|
200
|
+ // LinePicHandler(linePicUrl);
|
|
201
|
+ // }
|
|
202
|
+ // if(fileInput.id == 'fileInput2') {
|
|
203
|
+ // setTimeout(()=>{
|
|
204
|
+ // console.log(finalase64Data)
|
|
205
|
+ // sendBase64DataToApi(finalase64Data);
|
|
206
|
+ // }, 200);
|
|
207
|
+
|
|
208
|
+ // }
|
|
209
|
+ // });
|
|
210
|
+ // });
|
154
|
211
|
}
|
155
|
212
|
|
156
|
213
|
// 送出圖片
|