imgcheck.js 891 Bytes
'use strict';
const _ = require('lodash');
let captchaData = require('../data/captcha.json');

// let api = global.yoho.API;
/**
 *  获取图形旋转验证码
 *  @return Promise
*     {
 *    "alg": "SALT_MD5",
 *    "code": 200,
 *    "data":
 *    {
 *        "degrees":
 *        [
 *            90,
 *            270,
 *            90,
 *            0
 *        ],
 *        "verifiedGraphicCode": "http://img11.static.yhbimg.com/yhb-img01/2016/12/09/09/011c1ef761ab6f0cdb9fbd116f409a6e52.png"
 *    },
 *    "md5": "25d3e6b030a142c32d246322e6884080",
 *    "message": "操作成功"
 *}
 */
exports.gen = () => {
    // let params = {
    //     method: 'web.register.getVerifiedGraphicCode'
    // };

    // return api.get('', params);

    let random = _.random(0, captchaData.length);

    return Promise.resolve({
        code: 200,
        data: captchaData[random]
    });
};