Skip to content

Commit

Permalink
feat: 增加音悦台provider
Browse files Browse the repository at this point in the history
  • Loading branch information
axetroy committed Nov 26, 2017
1 parent 2d1484a commit 9885d72
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions app/providers/音悦台.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const Provider = require('../provider');
const utils = require('../utils');

module.exports = class extends Provider {
constructor() {
super();
this.url = `http://shop.yinyuetai.com/`;
}
async resolve(ctx) {
const options = ctx.options;
const page = ctx.page;

await page.click('.J_login');

// 等待注册框弹出
await page.waitForSelector('.login-register', { timeout: 1000 * 3 });

// 检验是否发送成功
await page.evaluate(() => {
const buttons = document.querySelectorAll('.login-tab>a');
const loginIndex = [].slice.call(buttons).findIndex(btn => btn.innerText === '注册');
const loginButton = buttons[loginIndex];
if (!loginButton) {
throw null;
} else {
loginButton.click();
}
});

await utils.sleep(500);

await page.type('#register-form input[name="mobile"]', options.phone, { delay: 100 });

await page.click('.login-get-code');

// 检验是否发送成功
await page.waitForSelector('.login-code-disable', { timeout: 1000 * 3 });
}
};

0 comments on commit 9885d72

Please sign in to comment.