Skip to content

Commit

Permalink
fix: 修复一些provider没有正确检测是否发送短信成功
Browse files Browse the repository at this point in the history
  • Loading branch information
axetroy committed Dec 3, 2017
1 parent 31873df commit e2c708b
Show file tree
Hide file tree
Showing 48 changed files with 204 additions and 50 deletions.
6 changes: 5 additions & 1 deletion app/providers/ZOL游戏.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ module.exports = class extends Provider {
await page.click('#get-anicode');

// 检验是否发送成功
await page.waitForSelector('#get-anicode.resendphonecode', { timeout: 1000 * 3 });
try {
await page.waitForSelector('#get-anicode.resendphonecode', { timeout: 1000 * 3 });
} catch (err) {
throw null;
}
}
};
14 changes: 9 additions & 5 deletions app/providers/baidu.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,18 @@ module.exports = class extends Provider {
// 如果需要注册
await page.waitForSelector('#TANGRAM__PSP_3__smsRegPromptWrapper', {
timeout: 500,
visible: true,
visible: true
});
await page.click('#TANGRAM__PSP_3__smsRegPromptBtn');
} catch (err) {}

// 检验是否发送成功
await page.waitForSelector('#TANGRAM__PSP_3__smsTimer.pass-item-time-timing', {
timeout: 1000 * 3,
});
try {
// 检验是否发送成功
await page.waitForSelector('#TANGRAM__PSP_3__smsTimer.pass-item-time-timing', {
timeout: 1000 * 3
});
} catch (err) {
throw null;
}
}
};
6 changes: 5 additions & 1 deletion app/providers/qq.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ module.exports = class extends Provider {
await page.click('#send-sms', { button: 'left' });

// 检验是否发送成功
await page.waitForSelector('.send-sms.disabled', { timeout: 1000 * 3 });
try {
await page.waitForSelector('.send-sms.disabled', { timeout: 1000 * 3 });
} catch (err) {
throw null;
}
}
};
8 changes: 6 additions & 2 deletions app/providers/中关村在线.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = class extends Provider {
constructor() {
super();
this.url = `http://service.zol.com.cn/user/siteLogin.php`;
}
}
async resolve(ctx) {
const options = ctx.options;
const page = ctx.page;
Expand All @@ -17,6 +17,10 @@ module.exports = class extends Provider {
await page.click('#get-anicode');

// 检验是否发送成功
await page.waitForSelector('.resendphonecode', { timeout: 1000 * 3 });
try {
await page.waitForSelector('.resendphonecode', { timeout: 1000 * 3 });
} catch (err) {
throw null;
}
}
};
6 changes: 5 additions & 1 deletion app/providers/中国移动.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ module.exports = class extends Provider {
await page.click('#btnGetSmsCode');

// 检验是否发送成功
await page.waitForSelector('.getSmsCode.BtnCode', { timeout: 1000 * 3 });
try {
await page.waitForSelector('.getSmsCode.BtnCode', { timeout: 1000 * 3 });
} catch (err) {
throw null;
}
}
};
6 changes: 5 additions & 1 deletion app/providers/久其格格.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ module.exports = class extends Provider {
await page.click('#chkCodeSendBtn');

// 检验是否发送成功
await page.waitForSelector('#chkCodeSendBtn[disabled]', { timeout: 1000 * 3 });
try {
await page.waitForSelector('#chkCodeSendBtn[disabled]', { timeout: 1000 * 3 });
} catch (err) {
throw null;
}
}
};
14 changes: 7 additions & 7 deletions app/providers/乾贷网短信.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ module.exports = class extends Provider {
// 松开鼠标

// 检验是否发送成功
try {
await page.evaluate(() => {
const display = document.querySelector('.resend.text-send').style.display;
// 倒计时应该会被显示出来
return display !== 'none' && display !== '';
});
} catch (err) {
const isSuccess = await page.evaluate(() => {
const display = document.querySelector('.resend.text-send').style.display;
// 倒计时应该会被显示出来
return display !== 'none' && display !== '';
});

if (isSuccess === false) {
throw null;
}
}
Expand Down
6 changes: 5 additions & 1 deletion app/providers/亚马逊.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ module.exports = class extends Provider {
await page.click('#continue');

// 检验是否发送成功
await page.waitForSelector('#auth-pv-enter-code', { timeout: 1000 * 3 });
try {
await page.waitForSelector('#auth-pv-enter-code', { timeout: 1000 * 3 });
} catch (err) {
throw err;
}
}
};
2 changes: 1 addition & 1 deletion app/providers/人人车.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = class extends Provider {

throw null; // 抛出错误,代表发送失败
} catch (err) {
throw err;
throw null;
}
}
};
7 changes: 6 additions & 1 deletion app/providers/优视.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ module.exports = class extends Provider {

await page.click('#getCodeBtn');

await page.waitForSelector('#getCodeBtn.btn_code', { timeout: 1000 * 5 });
// 检验是否发送成功
try {
await page.waitForSelector('#getCodeBtn.btn_code', { timeout: 1000 * 5 });
} catch (err) {
throw null;
}
}
};
7 changes: 6 additions & 1 deletion app/providers/优酷.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ module.exports = class extends Provider {
await page.type('#repeatPsd', options.password, { delay: 30 });
await page.click('#getMobileCode');

await page.waitForSelector('#getMobileCode[disable]', { timeout: 1000 * 5 });
// 检验是否发生成功
try {
await page.waitForSelector('#getMobileCode[disable]', { timeout: 1000 * 5 });
} catch (err) {
throw null;
}
}
};
2 changes: 2 additions & 0 deletions app/providers/六月游戏.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ module.exports = class extends Provider {
await page.click('#send_sms');

await utils.sleep(1000 * 600);

// TODO:检验是否发送成功
}
};
6 changes: 5 additions & 1 deletion app/providers/千米电商云.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ module.exports = class extends Provider {
await page.click('#send_code');

// 检验是否发送成功
await page.waitForSelector('#send_tip.disabled', { timeout: 1000 * 3 });
try {
await page.waitForSelector('#send_tip.disabled', { timeout: 1000 * 3 });
} catch (err) {
throw null;
}
}
};
2 changes: 2 additions & 0 deletions app/providers/向日葵.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ module.exports = class extends Provider {
await page.type('#mobilebox_name', options.name, { delay: 30 });
await page.type('#mobilebox_phone', options.phone, { delay: 30 });
await page.click('.contact-submit');

// TODO:检验是否发送成功
}
};
6 changes: 5 additions & 1 deletion app/providers/唯品会.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ module.exports = class extends Provider {
await page.click('#J_mobile_verifycode_btn');

// 检验是否发送成功
await page.waitForSelector('#J_mobile_verifycode_btn.ui-btn-disable', { timeout: 1000 * 3 });
try {
await page.waitForSelector('#J_mobile_verifycode_btn.ui-btn-disable', { timeout: 1000 * 3 });
} catch (err) {
throw null;
}
}
};
6 changes: 5 additions & 1 deletion app/providers/喜地.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ module.exports = class extends Provider {
await page.click('.getTelCode');

// 检验是否发送成功
await page.waitForSelector('.getTelCode.notActive', { timeout: 1000 * 3 });
try {
await page.waitForSelector('.getTelCode.notActive', { timeout: 1000 * 3 });
} catch (err) {
throw null;
}
}
};
2 changes: 2 additions & 0 deletions app/providers/嗨厨房.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ module.exports = class extends Provider {

await page.type('input[name="phone"]', options.phone, { delay: 50 });
await page.click('.login-reg-code');

// TODO:检验是否发送成功
}
};
7 changes: 6 additions & 1 deletion app/providers/国美.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ module.exports = class extends Provider {

await page.click('#getVerifyCode');

await page.waitForSelector('#resendSpan', { timeout: 1000 * 3 });
// 检验是否发送成功
try {
await page.waitForSelector('#resendSpan', { timeout: 1000 * 3 });
} catch (err) {
throw null;
}
}
};
7 changes: 6 additions & 1 deletion app/providers/大智慧.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ module.exports = class extends Provider {
await page.type('#mobileUpass', options.password, { delay: 50 });
await page.click('#sendCode');

await page.waitForSelector('#sendCode[disabled]', { timeout: 1000 * 3 });
// 检验是否发送成功
try {
await page.waitForSelector('#sendCode[disabled]', { timeout: 1000 * 3 });
} catch (err) {
throw null;
}
}
};
7 changes: 6 additions & 1 deletion app/providers/小米.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ module.exports = class extends Provider {

await page.click('input[type="submit"]');

await page.waitForSelector('.send-status.disabled', { timeout: 1000 * 3 });
// 检验是否发送成功
try {
await page.waitForSelector('.send-status.disabled', { timeout: 1000 * 3 });
} catch (err) {
throw null;
}
}
};
4 changes: 3 additions & 1 deletion app/providers/工行信用卡.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ module.exports = class extends Provider {
return style.display === 'none';
});

await (isSuccess ? Promise.resolve(true) : Promise.reject(false));
if (isSuccess === false) {
throw null;
}
}
};
7 changes: 6 additions & 1 deletion app/providers/广西社保卡.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ module.exports = class extends Provider {

await page.type('#tel', options.phone, { delay: 50 });
await page.click('#btn');
await page.waitForSelector('.window-alert-img-ok', { timeout: 3000 });

try {
await page.waitForSelector('.window-alert-img-ok', { timeout: 3000 });
} catch (err) {
throw null;
}
}
};
6 changes: 5 additions & 1 deletion app/providers/手拉手商城.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ module.exports = class extends Provider {
await utils.sleep(100);

// 检验是否发送成功
await page.waitForSelector('#button[disabled]');
try {
await page.waitForSelector('#button[disabled]');
} catch (err) {
throw null;
}
}
};
2 changes: 1 addition & 1 deletion app/providers/折800.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ module.exports = class extends Provider {

await utils.sleep(100);

// 检验是否发送成功
// TODO: 检验是否发送成功
}
};
6 changes: 5 additions & 1 deletion app/providers/支付宝.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ module.exports = class extends Provider {
btn.click();
});

await page.waitForSelector('#J-resend-mobile button[disabled]', { timeout: 1000 * 3 });
try {
await page.waitForSelector('#J-resend-mobile button[disabled]', { timeout: 1000 * 3 });
} catch (err) {
throw null;
}
}
};
2 changes: 2 additions & 0 deletions app/providers/日报网.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@ module.exports = class extends Provider {
await page.type('#repass', options.password, { delay: 50 });
await utils.sleep(500);
await page.click('a.send');

// TODO: 检测是否发送成功
}
};
2 changes: 2 additions & 0 deletions app/providers/淘宝.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,7 @@ module.exports = class extends Provider {

await utils.sleep(500);
await page.click('#J_BtnMobileForm');

// TODO: 检测是否发送成功
}
};
6 changes: 5 additions & 1 deletion app/providers/熊猫直播.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ module.exports = class extends Provider {
// 松开鼠标

// 检验是否发送成功
await page.waitForSelector('.ruc-send-auth-code-btn.button-disable', { timeout: 1000 * 3 });
try {
await page.waitForSelector('.ruc-send-auth-code-btn.button-disable', { timeout: 1000 * 3 });
} catch (err) {
throw null;
}
}
};
2 changes: 2 additions & 0 deletions app/providers/爱奇艺.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ module.exports = class extends Provider {
await page.type('input[data-regbox="name"]', options.phone, { delay: 50 });
await utils.sleep(1000 * 2);
await page.click('[rseat="prgd_smsbtn"]');

// TODO: 检测是否发送成功
}
};
6 changes: 5 additions & 1 deletion app/providers/爱拍原创.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ module.exports = class extends Provider {
await page.click('#msg');

// 检验是否发送成功
await page.waitForSelector('.msg_disabled', { timeout: 1000 * 3 });
try {
await page.waitForSelector('.msg_disabled', { timeout: 1000 * 3 });
} catch (err) {
throw null;
}
}
};
7 changes: 6 additions & 1 deletion app/providers/牛竞猜.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ module.exports = class extends Provider {
await page.type('input[name="phone"]', options.phone, { delay: 50 });
await page.type('input.phoneVerify', '1234', { delay: 50 });
await page.click('.phoneVerifyBtn');
await page.waitForSelector('.phoneVerifyBtn.disabled', { timeout: 1000 * 3 });

try {
await page.waitForSelector('.phoneVerifyBtn.disabled', { timeout: 1000 * 3 });
} catch (err) {
throw null;
}
}
};
8 changes: 7 additions & 1 deletion app/providers/猎聘.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ module.exports = class extends Provider {
await page.type('.register-box [name="user_pwd"]', options.password, { delay: 50 });
await page.click('.register-box .btn-phone-code');

await page.waitForSelector('.register-box .btn-phone-code.btn-disabled', { timeout: 1000 * 3 });
try {
await page.waitForSelector('.register-box .btn-phone-code.btn-disabled', {
timeout: 1000 * 3
});
} catch (err) {
throw null;
}
}
};
Loading

0 comments on commit e2c708b

Please sign in to comment.