diff --git a/scanner/pages/camera/camera.js b/scanner/pages/camera/camera.js index d202c31..e2fb7c3 100644 --- a/scanner/pages/camera/camera.js +++ b/scanner/pages/camera/camera.js @@ -1,7 +1,7 @@ // pages/camera.js // import { - upload_image_data_url, + upload_image_data_urls, check_auto_torch, } from '../../upload.js' @@ -87,6 +87,7 @@ Page({ }, onLoad(options) { + this.image_data_urls = []; console.log("camera page load", options); this.setData({ ai_chat_mode: options.ai_chat_mode, @@ -145,7 +146,11 @@ Page({ const image_data = msg.image_data; var uca = new Uint8ClampedArray(image_data.data); 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 { @@ -231,13 +236,13 @@ Page({ 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.busy = true; var begin = Date.now(); wx.vibrateShort({ type: "heavy", }); var gd = getApp().globalData; - gd.image_data_url = data_url; + gd.image_data_urls = data_urls; gd.qr_code = qr_code; gd.angle = angle; this.log("uploading image"); @@ -279,7 +284,7 @@ Page({ 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) { @@ -445,10 +450,16 @@ Page({ }); 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)) { - this.setData({ - show_modal: "verifying", - }); - this.submit_image(data_url, result.qrcode, result.angle); + this.image_data_urls.push(data_url); + if (this.image_data_urls.length >= 3) { + this.setData({ + show_modal: "verifying", + }); + this.submit_image(this.image_data_urls, result.qrcode, result.angle); + this.image_data_urls = []; + } else { + this.reset_busy(); + } } else { if (this.data.should_check_auto_torch && is_emblem_qr_pattern(result.qrcode)) { this.start_check_auto_torch(result.qrcode); diff --git a/scanner/pages/camwebview/camwebview.js b/scanner/pages/camwebview/camwebview.js index 07a28bf..d533063 100644 --- a/scanner/pages/camwebview/camwebview.js +++ b/scanner/pages/camwebview/camwebview.js @@ -15,7 +15,7 @@ function make_query(zoom, ai_chat_mode) { ret += "&nick_name=" + encodeURIComponent(ui.nickName || ""); ret += "&tenant=" + (gd.tenant_id || ""); ret += "&tk=" + Date.now(); - if (ai_chat_mode) / + if (ai_chat_mode) { ret += "&ai_chat_mode=" + ai_chat_mode; } console.log(ret); diff --git a/scanner/project.config.json b/scanner/project.config.json index 5fbe02f..43a9118 100644 --- a/scanner/project.config.json +++ b/scanner/project.config.json @@ -55,6 +55,6 @@ ], "include": [] }, - "appid": "wx8e174d4fb7ef5fb6", - "projectname": "emblem-scanner" + "projectname": "emblem-scanner", + "appid": "wx8e174d4fb7ef5fb6" } \ No newline at end of file diff --git a/scanner/project.private.config.json b/scanner/project.private.config.json index 802d02c..3ed19b8 100644 --- a/scanner/project.private.config.json +++ b/scanner/project.private.config.json @@ -2,6 +2,13 @@ "condition": { "miniprogram": { "list": [ + { + "name": "camera (dev)", + "pathName": "pages/camera/camera", + "query": "env=dev", + "launchMode": "default", + "scene": null + }, { "name": "index-redirect-to-chat", "pathName": "pages/index/index", @@ -23,13 +30,6 @@ "launchMode": "default", "scene": null }, - { - "name": "camera (dev)", - "pathName": "pages/camera/camera", - "query": "env=dev&debug=1", - "launchMode": "default", - "scene": null - }, { "name": "tenant-26", "pathName": "pages/index/index", diff --git a/scanner/upload.js b/scanner/upload.js index 48a2b82..7f72598 100644 --- a/scanner/upload.js +++ b/scanner/upload.js @@ -1,5 +1,5 @@ -function upload_image_data_url(image_data_url, success, fail, log) { - do_upload(image_data_url, success, fail, log); +function upload_image_data_urls(image_data_urls, success, fail, log) { + do_upload(image_data_urls, success, fail, log); } 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 gd = getApp().globalData; var fd = { @@ -43,7 +43,7 @@ function do_upload(image_data_url, success, fail, log) { qrcode: gd.qr_code, angle: 0, phonemodel: gd.phone_model, - image_data_url, + image_data_urls, use_roi_verify: 1, log, }; @@ -52,20 +52,20 @@ function do_upload(image_data_url, success, fail, log) { fd.token = ci.token; } 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); wx.request({ url, method: "POST", - data: fd, + header: { + "Content-Type": "application/json", + }, + data: JSON.stringify(fd), success, fail, }); } module.exports = { - upload_image_data_url, + upload_image_data_urls, check_auto_torch, };