Blame view

public/js/3party/check.page.js 1.63 KB
1
require('3party/check.page.css');
2
require('common');
ccbikai(👎🏻🍜) authored
3
yyq authored
4 5
let $ = require('yoho-jquery'),
    Validate = require('plugin/validata');
6
yyq authored
7 8 9 10
let $check = $('#js-img-check');

let baseInfo = {pid: window.queryString.pid};
let validateOptions = {
11 12
    useREM: {
        rootFontSize: 40,
yyq authored
13
        picWidth: 140
14
    }
yyq authored
15 16 17 18 19 20 21 22
};

if ($check.data('riskimg')) {
    validateOptions.imgSrc = '/passport/img-check-risk.jpg';
    baseInfo.apiRiskValidate = true;
}

let validate = new Validate($check, validateOptions);
23
24
validate.init();
25 26

$(function() {
yyq authored
27 28 29 30 31 32 33 34 35 36 37

    // 定时监测cookie中refresh_page刷新页面也换验证方式
    setInterval(function() {
        if (window.cookie('refresh_page') > 0) {
            window.setCookie('refresh_page', 0, {
                path: '/'
            });
            window.location.reload();
        }
    }, 1000);
38
    $('.submit').on('click', function() {
39
        validate.getResults().then((result) => {
yyq authored
40
            $.extend(result, baseInfo);
41
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
            $.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();
                    }
姜枫 authored
57
                }
58
            });
59 60 61
        });
    });
});