captcha-api.js 994 Bytes
/**
 * Created by TaoHuang on 2016/12/12.
 */

'use strict';

const apiUrl = global.yoho.config.domains.service;

const PAGE = 'pc';

module.exports = class extends global.yoho.BaseModel {
    constructor(ctx) {
        super(ctx);
    }

    gen(id) {
        if (id) {
            return Promise.resolve({
                code: 200,
                data: {
                    url: `${apiUrl}passport/img-check.jpg?udid=${id}&fromPage=${PAGE}`
                }
            });
        } else {
            return Promise.reject({
                code: 400,
                message: '生成二维码失败,请重新刷新!'
            });
        }
    }

    check(id, captcha) {
        return this.get({
            data: {
                method: 'app.verified.graphic',
                udid: id,
                fromPage: PAGE,
                degrees: captcha
            }
        });
    }

    try() {
        return this.get({
            url: 'smart/way'
        });
    }
};