72 lines
1.7 KiB
JavaScript
72 lines
1.7 KiB
JavaScript
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) {
|
|
var gd = getApp().globalData;
|
|
var url = gd.server_url + '/api/v1/check-auto-torch/?qrcode=' + encodeURIComponent(qrcode);
|
|
console.log("check_auto_torch:", url);
|
|
const fail = (e) => {
|
|
console.log("failed to check auto torch", e);
|
|
cb(false, null);
|
|
};
|
|
const success = (res) => {
|
|
if (res.statusCode == 200) {
|
|
var resp;
|
|
console.log(res.data);
|
|
if (typeof res.data == "string") {
|
|
resp = JSON.parse(res.data);
|
|
} else {
|
|
resp = res.data;
|
|
}
|
|
cb(resp.enable_auto_torch, resp.camera_sensitivity);
|
|
} else {
|
|
console.log("failed to check auto torch", res.data);
|
|
cb(false, null);
|
|
}
|
|
};
|
|
wx.request({
|
|
url,
|
|
method: "GET",
|
|
success,
|
|
fail,
|
|
});
|
|
}
|
|
|
|
function do_upload(image_data_urls, success, fail, log) {
|
|
var ui = wx.getStorageSync('userinfo');
|
|
var gd = getApp().globalData;
|
|
var fd = {
|
|
emblem_id: ui.emblem_id,
|
|
nick_name: ui.nickName,
|
|
realip: gd.real_ip,
|
|
qrcode: gd.qr_code,
|
|
angle: 0,
|
|
phonemodel: gd.phone_model,
|
|
image_data_urls,
|
|
use_roi_verify: 1,
|
|
log,
|
|
};
|
|
var ci = gd.caller_info;
|
|
if (ci && ci.token) {
|
|
fd.token = ci.token;
|
|
}
|
|
var url = gd.server_url + '/api/v1/qr-verify/';
|
|
console.log("wx.request", url, fd.qrcode, fd.angle, fd.phonemodel, fd.realip);
|
|
wx.request({
|
|
url,
|
|
method: "POST",
|
|
header: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
data: JSON.stringify(fd),
|
|
success,
|
|
fail,
|
|
});
|
|
}
|
|
|
|
module.exports = {
|
|
upload_image_data_urls,
|
|
check_auto_torch,
|
|
};
|