imgcheck.js 1.08 KB
'use strict';
const PAGE = 'H5';
const logger = global.yoho.logger;
const serviceAPI = global.yoho.ServiceAPI.ApiUrl;
const config = global.yoho.config;

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

    /**
     * 获取图片
     */
    gen(udid) {
        logger.info(`get verifiedGraphicCode: ${serviceAPI}passport/img-check.jpg?udid=${udid}&fromPage=${PAGE}`);
        return Promise.resolve({
            code: 200,
            data: {
                verifiedGraphicCode: `${serviceAPI}passport/img-check.jpg?udid=${udid}&fromPage=${PAGE}&client_type=${config.app}` // eslint-disable-line
            }
        });
    }

    /**
     * 校验
     */
    check(udid, captcha) {
        return this.get({
            data: {
                method: 'app.verified.graphic',
                udid: udid,
                fromPage: PAGE,
                degrees: captcha
            }
        }).then(result => {
            logger.info(`app.verified.graphic result: ${JSON.stringify(result)}`);
            return result;
        });
    }
};