robot-check.page.js
1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
var $ = require('yoho-jquery'),
Captcha = require('../plugins/captcha'),
qs = require('yoho-qs');
var options = {
checkURI: '/3party/check',
initURI: '/3party/captcha.png',
page: 'robot'
},
baseInfo = {},
captcha;
// 接口风控图形验证码链接
if (window._captchaApiRisk) {
options.refreshURI = '/passport/images-risk.png';
baseInfo.apiRiskValidate = true;
}
captcha = new Captcha('.captcha-wrap', options).init();
// _captchaApiRisk
require('../common');
require('../common/promise');
// 定时监测cookie中refresh_page刷新页面也换验证方式
setInterval(function() {
if (window.cookie('refresh_page') > 0) {
window.setCookie('refresh_page', 0, {
path: '/'
});
window.location.reload();
}
}, 1000);
$('.confirm').on('click', function() {
captcha.check(baseInfo).then(function() {
window.jumpUrl(qs.refer ? decodeURIComponent(qs.refer) : '//www.yohobuy.com');
});
});
captcha.onSuccess(function() {
$('.confirm').trigger('click');
});