check.page.js 1.05 KB
require('3party/check.page.css');
require('common');

// 图片验证码
let Validate = require('plugin/validata');

let validate = new Validate('#js-img-check', {
    useREM: {
        rootFontSize: 40,
        picWidth: 150
    }
});

validate.init();

$(function() {
    $('.submit').on('click', function() {
        validate.getResults().then((result) => {
            $.ajax({
                method: 'POST',
                url: '/3party/check/submit',
                data: result,
                success: function(ret) {
                    validate.type === 2 && validate.refresh();
                    if (ret.code === 200) {
                        if (window.queryString.refer) {
                            window.location.href = decodeURIComponent(window.queryString.refer);
                        } else {
                            window.location.href = '//m.yohobuy.com';
                        }
                    } else {
                        validate.refresh();
                    }
                }
            });
        });
    });
});