scanner: Upload 3 frames
This commit is contained in:
parent
9f0a24e4d9
commit
cd8d3527c7
@ -1,7 +1,7 @@
|
|||||||
// pages/camera.js
|
// pages/camera.js
|
||||||
//
|
//
|
||||||
import {
|
import {
|
||||||
upload_image_data_url,
|
upload_image_data_urls,
|
||||||
check_auto_torch,
|
check_auto_torch,
|
||||||
} from '../../upload.js'
|
} from '../../upload.js'
|
||||||
|
|
||||||
@ -87,6 +87,7 @@ Page({
|
|||||||
},
|
},
|
||||||
|
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
|
this.image_data_urls = [];
|
||||||
console.log("camera page load", options);
|
console.log("camera page load", options);
|
||||||
this.setData({
|
this.setData({
|
||||||
ai_chat_mode: options.ai_chat_mode,
|
ai_chat_mode: options.ai_chat_mode,
|
||||||
@ -145,7 +146,11 @@ Page({
|
|||||||
const image_data = msg.image_data;
|
const image_data = msg.image_data;
|
||||||
var uca = new Uint8ClampedArray(image_data.data);
|
var uca = new Uint8ClampedArray(image_data.data);
|
||||||
var data_url = data_url_from_frame(image_data.width, image_data.height, uca);
|
var data_url = data_url_from_frame(image_data.width, image_data.height, uca);
|
||||||
this.submit_image(data_url, res.qrcode, res.angle);
|
this.image_data_urls.push(data_url);
|
||||||
|
if (this.image_data_urls.length >= 3) {
|
||||||
|
this.submit_image(this.image_data_urls, res.qrcode, res.angle);
|
||||||
|
this.image_data_urls = [];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -231,13 +236,13 @@ Page({
|
|||||||
this.clean_up();
|
this.clean_up();
|
||||||
},
|
},
|
||||||
|
|
||||||
submit_image(data_url, qr_code, angle) {
|
submit_image(data_urls, qr_code, angle) {
|
||||||
this.log("submit image", qr_code, angle);
|
this.log("submit image", qr_code, angle);
|
||||||
this.busy = true;
|
this.busy = true;
|
||||||
var begin = Date.now();
|
var begin = Date.now();
|
||||||
wx.vibrateShort({ type: "heavy", });
|
wx.vibrateShort({ type: "heavy", });
|
||||||
var gd = getApp().globalData;
|
var gd = getApp().globalData;
|
||||||
gd.image_data_url = data_url;
|
gd.image_data_urls = data_urls;
|
||||||
gd.qr_code = qr_code;
|
gd.qr_code = qr_code;
|
||||||
gd.angle = angle;
|
gd.angle = angle;
|
||||||
this.log("uploading image");
|
this.log("uploading image");
|
||||||
@ -279,7 +284,7 @@ Page({
|
|||||||
this.show_verifyfailed();
|
this.show_verifyfailed();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
upload_image_data_url(data_url, success, fail, this.data.logs.join("\n"));
|
upload_image_data_urls(data_urls, success, fail, this.data.logs.join("\n"));
|
||||||
},
|
},
|
||||||
|
|
||||||
show_result_page(serial_code) {
|
show_result_page(serial_code) {
|
||||||
@ -445,10 +450,16 @@ Page({
|
|||||||
});
|
});
|
||||||
this.handle_image_data_url(data_url);
|
this.handle_image_data_url(data_url);
|
||||||
if (this.data.done_checking_auto_torch && result.ok && result.angle >= 0 && result.qrcode.length && is_emblem_qr_pattern(result.qrcode)) {
|
if (this.data.done_checking_auto_torch && result.ok && result.angle >= 0 && result.qrcode.length && is_emblem_qr_pattern(result.qrcode)) {
|
||||||
this.setData({
|
this.image_data_urls.push(data_url);
|
||||||
show_modal: "verifying",
|
if (this.image_data_urls.length >= 3) {
|
||||||
});
|
this.setData({
|
||||||
this.submit_image(data_url, result.qrcode, result.angle);
|
show_modal: "verifying",
|
||||||
|
});
|
||||||
|
this.submit_image(this.image_data_urls, result.qrcode, result.angle);
|
||||||
|
this.image_data_urls = [];
|
||||||
|
} else {
|
||||||
|
this.reset_busy();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (this.data.should_check_auto_torch && is_emblem_qr_pattern(result.qrcode)) {
|
if (this.data.should_check_auto_torch && is_emblem_qr_pattern(result.qrcode)) {
|
||||||
this.start_check_auto_torch(result.qrcode);
|
this.start_check_auto_torch(result.qrcode);
|
||||||
|
|||||||
@ -15,7 +15,7 @@ function make_query(zoom, ai_chat_mode) {
|
|||||||
ret += "&nick_name=" + encodeURIComponent(ui.nickName || "");
|
ret += "&nick_name=" + encodeURIComponent(ui.nickName || "");
|
||||||
ret += "&tenant=" + (gd.tenant_id || "");
|
ret += "&tenant=" + (gd.tenant_id || "");
|
||||||
ret += "&tk=" + Date.now();
|
ret += "&tk=" + Date.now();
|
||||||
if (ai_chat_mode) /
|
if (ai_chat_mode) {
|
||||||
ret += "&ai_chat_mode=" + ai_chat_mode;
|
ret += "&ai_chat_mode=" + ai_chat_mode;
|
||||||
}
|
}
|
||||||
console.log(ret);
|
console.log(ret);
|
||||||
|
|||||||
@ -55,6 +55,6 @@
|
|||||||
],
|
],
|
||||||
"include": []
|
"include": []
|
||||||
},
|
},
|
||||||
"appid": "wx8e174d4fb7ef5fb6",
|
"projectname": "emblem-scanner",
|
||||||
"projectname": "emblem-scanner"
|
"appid": "wx8e174d4fb7ef5fb6"
|
||||||
}
|
}
|
||||||
@ -2,6 +2,13 @@
|
|||||||
"condition": {
|
"condition": {
|
||||||
"miniprogram": {
|
"miniprogram": {
|
||||||
"list": [
|
"list": [
|
||||||
|
{
|
||||||
|
"name": "camera (dev)",
|
||||||
|
"pathName": "pages/camera/camera",
|
||||||
|
"query": "env=dev",
|
||||||
|
"launchMode": "default",
|
||||||
|
"scene": null
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "index-redirect-to-chat",
|
"name": "index-redirect-to-chat",
|
||||||
"pathName": "pages/index/index",
|
"pathName": "pages/index/index",
|
||||||
@ -23,13 +30,6 @@
|
|||||||
"launchMode": "default",
|
"launchMode": "default",
|
||||||
"scene": null
|
"scene": null
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "camera (dev)",
|
|
||||||
"pathName": "pages/camera/camera",
|
|
||||||
"query": "env=dev&debug=1",
|
|
||||||
"launchMode": "default",
|
|
||||||
"scene": null
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "tenant-26",
|
"name": "tenant-26",
|
||||||
"pathName": "pages/index/index",
|
"pathName": "pages/index/index",
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
function upload_image_data_url(image_data_url, success, fail, log) {
|
function upload_image_data_urls(image_data_urls, success, fail, log) {
|
||||||
do_upload(image_data_url, success, fail, log);
|
do_upload(image_data_urls, success, fail, log);
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_auto_torch(qrcode, cb) {
|
function check_auto_torch(qrcode, cb) {
|
||||||
@ -33,7 +33,7 @@ function check_auto_torch(qrcode, cb) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function do_upload(image_data_url, success, fail, log) {
|
function do_upload(image_data_urls, success, fail, log) {
|
||||||
var ui = wx.getStorageSync('userinfo');
|
var ui = wx.getStorageSync('userinfo');
|
||||||
var gd = getApp().globalData;
|
var gd = getApp().globalData;
|
||||||
var fd = {
|
var fd = {
|
||||||
@ -43,7 +43,7 @@ function do_upload(image_data_url, success, fail, log) {
|
|||||||
qrcode: gd.qr_code,
|
qrcode: gd.qr_code,
|
||||||
angle: 0,
|
angle: 0,
|
||||||
phonemodel: gd.phone_model,
|
phonemodel: gd.phone_model,
|
||||||
image_data_url,
|
image_data_urls,
|
||||||
use_roi_verify: 1,
|
use_roi_verify: 1,
|
||||||
log,
|
log,
|
||||||
};
|
};
|
||||||
@ -52,20 +52,20 @@ function do_upload(image_data_url, success, fail, log) {
|
|||||||
fd.token = ci.token;
|
fd.token = ci.token;
|
||||||
}
|
}
|
||||||
var url = gd.server_url + '/api/v1/qr-verify/';
|
var url = gd.server_url + '/api/v1/qr-verify/';
|
||||||
if (gd.debug) {
|
|
||||||
url = "https://themblem.com/api/v1/debug-upload/";
|
|
||||||
}
|
|
||||||
console.log("wx.request", url, fd.qrcode, fd.angle, fd.phonemodel, fd.realip);
|
console.log("wx.request", url, fd.qrcode, fd.angle, fd.phonemodel, fd.realip);
|
||||||
wx.request({
|
wx.request({
|
||||||
url,
|
url,
|
||||||
method: "POST",
|
method: "POST",
|
||||||
data: fd,
|
header: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
data: JSON.stringify(fd),
|
||||||
success,
|
success,
|
||||||
fail,
|
fail,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
upload_image_data_url,
|
upload_image_data_urls,
|
||||||
check_auto_torch,
|
check_auto_torch,
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user