diff --git "a/app/providers/\351\237\263\346\202\246\345\217\260.js" "b/app/providers/\351\237\263\346\202\246\345\217\260.js" new file mode 100644 index 0000000..0e77747 --- /dev/null +++ "b/app/providers/\351\237\263\346\202\246\345\217\260.js" @@ -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 }); + } +};