mix-public 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/{resource → customMethod}/imageFormat.js +30 -0
- package/customMethod/originalFileSelect.js +17 -0
- package/customMethod/publicLogic.js +47 -0
- package/{resource → main}/mixappfunc.js +425 -449
- package/mixRender.js +1 -1
- package/package.json +1 -1
- package/pageRender/getInfo.js +1 -1
- package/resource/jsQR.js +8 -0
- /package/{resource → customMethod}/cookie.js +0 -0
- /package/{resource → customMethod}/http.js +0 -0
package/README.md
CHANGED
|
@@ -168,3 +168,33 @@ export async function formatImage(imgPath, formatConfig){
|
|
|
168
168
|
}
|
|
169
169
|
})
|
|
170
170
|
}
|
|
171
|
+
|
|
172
|
+
export function scanQrcode(imgPath){
|
|
173
|
+
return new Promise((resolve, reject) => {
|
|
174
|
+
getImgFile(imgPath).then(file=>{
|
|
175
|
+
const reader = new FileReader();
|
|
176
|
+
reader.onload = function(event) {
|
|
177
|
+
const img = new Image();
|
|
178
|
+
img.onload = function() {
|
|
179
|
+
const canvas = document.createElement('canvas');
|
|
180
|
+
const ctx = canvas.getContext('2d');
|
|
181
|
+
canvas.width = img.width;
|
|
182
|
+
canvas.height = img.height;
|
|
183
|
+
ctx.drawImage(img, 0, 0);
|
|
184
|
+
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
|
185
|
+
const code = jsQR(imageData.data, imageData.width, imageData.height);
|
|
186
|
+
if (code) {
|
|
187
|
+
resolve(code.data)
|
|
188
|
+
} else {
|
|
189
|
+
resolve("")
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
img.onerror = function (event) {
|
|
193
|
+
reject(event)
|
|
194
|
+
};
|
|
195
|
+
img.src = event.target.result;
|
|
196
|
+
};
|
|
197
|
+
reader.readAsDataURL(file);
|
|
198
|
+
})
|
|
199
|
+
})
|
|
200
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export default function (callback){
|
|
2
|
+
let $upload
|
|
3
|
+
$upload = document.createElement("input")
|
|
4
|
+
$upload.id = new Date().getTime()
|
|
5
|
+
$upload.type = "file"
|
|
6
|
+
$upload.style.display = "none"
|
|
7
|
+
var body = document.querySelector("body")
|
|
8
|
+
body.appendChild($upload)
|
|
9
|
+
$upload.addEventListener("change", function (evt) {
|
|
10
|
+
var files = evt.target.files
|
|
11
|
+
if (files.length > 0) {
|
|
12
|
+
callback(files[0])
|
|
13
|
+
}
|
|
14
|
+
$upload.value = "" //清空 input value
|
|
15
|
+
})
|
|
16
|
+
$upload.click()
|
|
17
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export const returnMethod = (op) => {
|
|
2
|
+
var isWeb = op.isWeb || false;
|
|
3
|
+
var isAndroid = op.isAndroid || false;
|
|
4
|
+
var isIOS = op.isIOS || false;
|
|
5
|
+
var webMethod = op.webMethod || false;
|
|
6
|
+
var callBackMethod = op.callBackMethod || false;
|
|
7
|
+
var params = op.params || {};
|
|
8
|
+
var methodName = op.methodName || "";
|
|
9
|
+
var callBackMethodName = "MIX_APP_" + methodName
|
|
10
|
+
params.MethodName = callBackMethodName
|
|
11
|
+
callMethod({
|
|
12
|
+
isWeb,
|
|
13
|
+
isAndroid,
|
|
14
|
+
isIOS,
|
|
15
|
+
methodName,
|
|
16
|
+
webMethod: ()=>{webMethod().then(data=>{window[callBackMethodName](data)})},
|
|
17
|
+
params
|
|
18
|
+
})
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
window[callBackMethodName] = (data)=>{
|
|
21
|
+
callBackMethod && data ? callBackMethod(data,resolve) : resolve()
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
export const callMethod = (op) => {
|
|
26
|
+
var isWeb = op.isWeb;
|
|
27
|
+
var isAndroid = op.isAndroid;
|
|
28
|
+
var isIOS = op.isIOS;
|
|
29
|
+
var webMethod = op.webMethod;
|
|
30
|
+
var params = op.params || {};
|
|
31
|
+
var methodName = op.methodName;
|
|
32
|
+
for (var key in params) {
|
|
33
|
+
if (!Object.hasOwn(params, key)) continue;
|
|
34
|
+
params[key] = params[key].toString();
|
|
35
|
+
}
|
|
36
|
+
if (isWeb) {
|
|
37
|
+
webMethod && webMethod();
|
|
38
|
+
} else {
|
|
39
|
+
if (isAndroid) {
|
|
40
|
+
Func[methodName](JSON.stringify(row));
|
|
41
|
+
} else if (isIOS) {
|
|
42
|
+
window.webkit.messageHandlers[methodName].postMessage(
|
|
43
|
+
JSON.stringify(row)
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|