register-new.js
1.39 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
44
45
46
47
48
49
50
51
52
53
54
55
const $ = require('yoho-jquery');
const $captcha = $('#js-img-check');
const tip = require('plugin/tip');
const showErrTip = tip.show;
const Validate = require('plugin/validata');
const validate = new Validate($captcha, {
useREM: {
rootFontSize: 40,
picWidth: 150
}
});
class RegisterNew {
constructor() {
this.view = {
getVerifyCodeBtn: $('#getVerifyCodeBtn'),
regBtn: $('#regBtn'),
};
this.requested = false;
this.getVerifyCodeBtn.on('click', this.getVerifyCode.bind(this));
}
/**
* 获取验证码
*/
getVerifyCode() {
let params = {};
$.ajax({
url: '/passport/reg/verifymobile',
type: 'POST',
data: params,
success: function(data) {
validate.type === 2 && validate.refresh();
if (data.code === 200) {
location.href = data.data;
} else {
(data.changeCaptcha && validate.type !== 2) && validate.refresh();
showErrTip(data.message);
this.requested = false;
}
},
error: function() {
showErrTip('出错了,请重试');
validate.refresh();
this.requested = false;
}
});
}
}
module.exports = RegisterNew;