|
@@ -35,6 +35,9 @@ const CommonGetHeaders = {
|
|
|
'Sec-Fetch-Dest': `document`
|
|
'Sec-Fetch-Dest': `document`
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+const W_345API_KEY = 'jhOlNfSd37oJ4aaL1o0G5821rW';
|
|
|
|
|
+const W_345API_URL = 'https://www.345api.cn/api/code/ocr';
|
|
|
|
|
+
|
|
|
if (!lk.isExecComm) {
|
|
if (!lk.isExecComm) {
|
|
|
if (lk.isRequest()) {
|
|
if (lk.isRequest()) {
|
|
|
checkHandleRequest();
|
|
checkHandleRequest();
|
|
@@ -136,24 +139,34 @@ async function checkTryExploreAll() {
|
|
|
await checkLogin(userLst[0]);
|
|
await checkLogin(userLst[0]);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-async function checkLogin(phone, password) {
|
|
|
|
|
|
|
+async function checkLogin(accountData) {
|
|
|
|
|
+ let phone = accountData.phone;
|
|
|
|
|
+ let password = accountData.password;
|
|
|
|
|
+ lk.log(`开始登录搜索检查:${phone}----${password}`);
|
|
|
|
|
+
|
|
|
let userInfo = getPrivData(phone, 'UserData');
|
|
let userInfo = getPrivData(phone, 'UserData');
|
|
|
let isSucc = false;
|
|
let isSucc = false;
|
|
|
- await loadIndex();
|
|
|
|
|
|
|
+ // await loadIndex();
|
|
|
if (userInfo.phone && userInfo.password && userInfo.token) {
|
|
if (userInfo.phone && userInfo.password && userInfo.token) {
|
|
|
- let ret = await doExplore(userInfo.phone, userInfo.password, userInfo.token);
|
|
|
|
|
- if (ret) {
|
|
|
|
|
- isSucc = true;
|
|
|
|
|
|
|
+ let isNeddExplore = await checkNeedExplore(userInfo.phone, userInfo.password, userInfo.token);
|
|
|
|
|
+ if (isNeddExplore) {
|
|
|
|
|
+ let exploreData = await doExplore(userInfo.phone, userInfo.password, userInfo.token);
|
|
|
|
|
+ if (exploreData) {
|
|
|
|
|
+ isSucc = true;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
let base64ImgData = await getVerifyCodeImg();
|
|
let base64ImgData = await getVerifyCodeImg();
|
|
|
- let codeNum = await autoVerifyCode(base64ImgData);
|
|
|
|
|
- if (codeNum) {
|
|
|
|
|
- userInfo = await doLogin(phone, password, codeNum);
|
|
|
|
|
- if (userInfo) {
|
|
|
|
|
- let ret = await doExplore(userInfo.phone, userInfo.password, userInfo.token);
|
|
|
|
|
- if (ret) {
|
|
|
|
|
- isSucc = true;
|
|
|
|
|
|
|
+ let codeStr = await tryAutoVerifyCode(base64ImgData);
|
|
|
|
|
+ if (codeStr) {
|
|
|
|
|
+ userInfo = await doLogin(phone, password, codeStr);
|
|
|
|
|
+ let isNeddExplore = await checkNeedExplore(userInfo.phone, userInfo.password, userInfo.token);
|
|
|
|
|
+ if (isNeddExplore) {
|
|
|
|
|
+ if (userInfo) {
|
|
|
|
|
+ let exploreData = await doExplore(userInfo.phone, userInfo.password, userInfo.token);
|
|
|
|
|
+ if (exploreData) {
|
|
|
|
|
+ isSucc = true;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -161,6 +174,15 @@ async function checkLogin(phone, password) {
|
|
|
return isSucc;
|
|
return isSucc;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+async function checkNeedExplore(phone, password, token) {
|
|
|
|
|
+ let data = await getParadropData(phone, password, token);
|
|
|
|
|
+ let orderData = data.paradrop_order_data;
|
|
|
|
|
+ if (orderData && orderData.start_time && orderData.end_time) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ return true;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
function loadIndex() {
|
|
function loadIndex() {
|
|
|
return new Promise((resolve, _reject) => {
|
|
return new Promise((resolve, _reject) => {
|
|
|
try {
|
|
try {
|
|
@@ -210,22 +232,8 @@ function loadIndex() {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-function string2Hex(tmp) {
|
|
|
|
|
- let str = '';
|
|
|
|
|
- for (let i = 0; i < tmp.length; i++) {
|
|
|
|
|
- str += tmp[i].charCodeAt(0).toString(16);
|
|
|
|
|
- }
|
|
|
|
|
- return str;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
function base64encode(bytes) {
|
|
function base64encode(bytes) {
|
|
|
let CryptoJS = createCryptoJS();
|
|
let CryptoJS = createCryptoJS();
|
|
|
- // let hexStr = string2Hex(str);
|
|
|
|
|
- // let data = CryptoJS.enc.Utf8.parse(hexStr);
|
|
|
|
|
- // let base64Data = CryptoJS.enc.Base64.stringify(data);
|
|
|
|
|
- lk.log(typeof (bytes));
|
|
|
|
|
- lk.log(JSON.stringify(bytes));
|
|
|
|
|
-
|
|
|
|
|
let data = CryptoJS.lib.WordArray.create(bytes);
|
|
let data = CryptoJS.lib.WordArray.create(bytes);
|
|
|
let base64Data = CryptoJS.enc.Base64.stringify(data);
|
|
let base64Data = CryptoJS.enc.Base64.stringify(data);
|
|
|
return 'data:image/png;base64,' + base64Data;
|
|
return 'data:image/png;base64,' + base64Data;
|
|
@@ -255,7 +263,7 @@ async function getVerifyCodeImg() {
|
|
|
lk.log(`获取验证码图片结果`);
|
|
lk.log(`获取验证码图片结果`);
|
|
|
if (_response.status == 200) {
|
|
if (_response.status == 200) {
|
|
|
ret = base64encode(_response.bodyBytes);
|
|
ret = base64encode(_response.bodyBytes);
|
|
|
- lk.log(ret);
|
|
|
|
|
|
|
+ // lk.log(ret);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
} catch (e) {
|
|
} catch (e) {
|
|
@@ -274,8 +282,55 @@ async function getVerifyCodeImg() {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-async function autoVerifyCode(base64Data) {
|
|
|
|
|
- return;
|
|
|
|
|
|
|
+async function tryAutoVerifyCode(base64Data) {
|
|
|
|
|
+ return doVerifyCodeBy345Api(base64Data);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+async function doVerifyCodeBy345Api(base64Data) {
|
|
|
|
|
+ return new Promise((resolve, _reject) => {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const headers = CommonHeaders;
|
|
|
|
|
+ let reqData = {
|
|
|
|
|
+ key: W_345API_KEY,
|
|
|
|
|
+ data: base64Data,
|
|
|
|
|
+ }
|
|
|
|
|
+ let payLoad = JSON.stringify(reqData);
|
|
|
|
|
+ let url = {
|
|
|
|
|
+ url: `${W_345API_URL}`,
|
|
|
|
|
+ headers: headers,
|
|
|
|
|
+ body: payLoad,
|
|
|
|
|
+ };
|
|
|
|
|
+ lk.log(`开始请求345api验证码识别`);
|
|
|
|
|
+ lk.post(url, async (error, _response, data) => {
|
|
|
|
|
+ let ret;
|
|
|
|
|
+ try {
|
|
|
|
|
+ if (error) {
|
|
|
|
|
+ lk.log(`验证码识别发生错误`);
|
|
|
|
|
+ lk.execFail();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ let info = JSON.parse(data);
|
|
|
|
|
+ lk.log(data);
|
|
|
|
|
+ if (info.code == 200 && info.data) {
|
|
|
|
|
+ ret = info.data.code_data;
|
|
|
|
|
+ lk.log(`验证码识别成功:${info.data.code_data},耗时:${data.require_date}`);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ lk.log(`验证码识别失败,响应:${data}`);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ lk.log(`验证码识别发生错误`);
|
|
|
|
|
+ lk.logErr(e);
|
|
|
|
|
+ lk.execFail();
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ resolve(ret);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ lk.log(`验证码识别发生错误`);
|
|
|
|
|
+ lk.logErr(e);
|
|
|
|
|
+ resolve();
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
async function doLogin(phone, password, verifyCode) {
|
|
async function doLogin(phone, password, verifyCode) {
|