|
|
@@ -155,17 +155,22 @@ async function checkLogin(accountData) {
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- let base64ImgData = await getVerifyCodeImg();
|
|
|
- let codeStr = await tryAutoRecognizeCaptcha('ddddocr', base64ImgData);
|
|
|
- if (codeStr) {
|
|
|
- userInfo = await doLogin(phone, password, codeStr);
|
|
|
- if (userInfo) {
|
|
|
- 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;
|
|
|
+ let tryCount = 10;
|
|
|
+ for (let i = 0; i < tryCount; i++) {
|
|
|
+ let codeStr = await checkGetVerifyCodeImgNum();
|
|
|
+ if (codeStr) {
|
|
|
+ lk.log(`尝试第${i + 1}次...`);
|
|
|
+ userInfo = await doLogin(phone, password, codeStr);
|
|
|
+ if (userInfo) {
|
|
|
+ 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;
|
|
|
+ }
|
|
|
}
|
|
|
+ break;
|
|
|
+ } else {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -281,8 +286,21 @@ async function getVerifyCodeImg() {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+async function checkGetVerifyCodeImgNum() {
|
|
|
+ let maxCount = 10;
|
|
|
+ let retCode;
|
|
|
+ for (let i = 0; i < maxCount; i++) {
|
|
|
+ let base64ImgData = await getVerifyCodeImg();
|
|
|
+ let codeStr = await tryAutoRecognizeCaptcha('ddddocr', base64ImgData);
|
|
|
+ if (codeStr && codeStr.length == 4) {
|
|
|
+ retCode = codeStr;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return retCode;
|
|
|
+}
|
|
|
+
|
|
|
async function tryAutoRecognizeCaptcha(typeStr, base64Data) {
|
|
|
- lk.log('data:image/png;base64,' + base64Data);
|
|
|
switch (typeStr) {
|
|
|
case 'baidu':
|
|
|
let accessToken = await getBDAccessToken();
|