Showing
5 changed files
with
175 additions
and
5 deletions
static/js/passport/bind/bind.js
0 → 100644
1 | +/** | ||
2 | + * 注册 | ||
3 | + * @author: xuqi<qi.xu@yoho.cn> | ||
4 | + * @date: 2015/10/8 | ||
5 | + */ | ||
6 | +var $ = require('jquery'); | ||
7 | + | ||
8 | +var $phoneNum = $('#phone-num'), | ||
9 | + $countrySelect = $('#country-select'), | ||
10 | + $areaCode = $('#area-code'), | ||
11 | + $openId = $('#openId'), | ||
12 | + $sourceType = $('#sourceType'), | ||
13 | + $btnNext = $('#btn-next'); | ||
14 | + | ||
15 | +var api = require('../api'), | ||
16 | + tip = require('../../plugin/tip'), | ||
17 | + dialog = require('../../me/dialog'); | ||
18 | + | ||
19 | +var trim = $.trim; | ||
20 | +var showErrTip = tip.show; | ||
21 | + | ||
22 | +api.selectCssHack($('#country-select')); | ||
23 | + | ||
24 | +api.bindClearEvt(); | ||
25 | + | ||
26 | +$phoneNum.bind('input', function() { | ||
27 | + if (trim($phoneNum.val()) === '') { | ||
28 | + $btnNext.addClass('disable'); | ||
29 | + } else { | ||
30 | + $btnNext.removeClass('disable'); | ||
31 | + } | ||
32 | +}); | ||
33 | + | ||
34 | +$countrySelect.change(function() { | ||
35 | + $areaCode.text($countrySelect.val()); | ||
36 | +}); | ||
37 | + | ||
38 | +$btnNext.on('touchstart', function() { | ||
39 | + var pn = trim($phoneNum.val()), | ||
40 | + openId = trim($openId.val()), | ||
41 | + sourceType = trim($sourceType.val()), | ||
42 | + areaCode = $countrySelect.val(); | ||
43 | + | ||
44 | + if ($btnNext.hasClass('disable')) { | ||
45 | + return; | ||
46 | + } | ||
47 | + | ||
48 | + if (api.phoneRegx[areaCode].test(pn)) { | ||
49 | + $.ajax({ | ||
50 | + url: '/passport/bind/bindCheck', | ||
51 | + type: 'POST', | ||
52 | + data: { | ||
53 | + areaCode: areaCode.replace('+', ''), | ||
54 | + mobile: pn, | ||
55 | + openId: openId, | ||
56 | + sourceType: sourceType | ||
57 | + }, | ||
58 | + success: function(res) { | ||
59 | + console.log(res); | ||
60 | + | ||
61 | + //res : { | ||
62 | + // code: 'xxx', | ||
63 | + // data: { | ||
64 | + // isReg: 0, | ||
65 | + // next: 'xxxx' | ||
66 | + // }, | ||
67 | + // message: 'xxxx', | ||
68 | + //} | ||
69 | + | ||
70 | + | ||
71 | + if (res.code === 200) { | ||
72 | + if (res.data.isReg === 1) { | ||
73 | + dialog.showDialog({ | ||
74 | + dialogText: '该手机号已注册过有货\n' + pn +',确定绑定吗?', | ||
75 | + hasFooter: { | ||
76 | + leftBtnText: '更换号码', | ||
77 | + rightBtnText: '继续绑定' | ||
78 | + } | ||
79 | + }, function() { | ||
80 | + location.href = res.data.next; | ||
81 | + }); | ||
82 | + } else { | ||
83 | + location.href = res.data.next; | ||
84 | + } | ||
85 | + } else { | ||
86 | + showErrTip(res.message); | ||
87 | + } | ||
88 | + } | ||
89 | + }); | ||
90 | + } else { | ||
91 | + showErrTip('手机号格式不正确,请重新输入'); | ||
92 | + } | ||
93 | +}); |
static/js/passport/bind/code.js
0 → 100644
static/js/passport/bind/password.js
0 → 100644
1 | +/** | ||
2 | + * 注册-密码 | ||
3 | + * @author: xuqi<qi.xu@yoho.cn> | ||
4 | + * @date: 2015/10/8 | ||
5 | + */ | ||
6 | +var $ = require('jquery'); | ||
7 | + | ||
8 | +var $pwd = $('#pwd'), | ||
9 | + $btnSure = $('#btn-sure'); | ||
10 | + | ||
11 | +var api = require('../api'); | ||
12 | +var tip = require('../../plugin/tip'); | ||
13 | + | ||
14 | +var trim = $.trim; | ||
15 | +var showErrTip = tip.show; | ||
16 | + | ||
17 | +api.bindEyesEvt({ | ||
18 | + status: 'open' //默认眼睛打开 | ||
19 | +}); | ||
20 | + | ||
21 | +$pwd.bind('input', function() { | ||
22 | + if (trim($pwd.val()) === '') { | ||
23 | + $btnSure.addClass('disable'); | ||
24 | + } else { | ||
25 | + $btnSure.removeClass('disable'); | ||
26 | + } | ||
27 | +}); | ||
28 | + | ||
29 | +$btnSure.on('touchstart', function() { | ||
30 | + var pwd = trim($pwd.val()); | ||
31 | + | ||
32 | + if ($btnSure.hasClass('disable')) { | ||
33 | + return; | ||
34 | + } | ||
35 | + | ||
36 | + if (api.pwdValidate(pwd) === false) { | ||
37 | + showErrTip('密码6-20位,请重新输入'); | ||
38 | + } else { | ||
39 | + $.ajax({ | ||
40 | + type: 'POST', | ||
41 | + url: '/passport/reg/setpassword', | ||
42 | + data: { | ||
43 | + password: pwd, | ||
44 | + phoneNum: $('#phone-num').val(), | ||
45 | + areaCode: $('#area-code').val(), | ||
46 | + token: $('#token').val() | ||
47 | + }, | ||
48 | + success: function(data) { | ||
49 | + var res; | ||
50 | + | ||
51 | + if (data.code === 200) { | ||
52 | + res = data.data; | ||
53 | + showErrTip('注册成功'); | ||
54 | + | ||
55 | + $.ajax({ | ||
56 | + url: res.session, | ||
57 | + dataType: 'jsonp' | ||
58 | + }); | ||
59 | + | ||
60 | + //1000ms后跳转页面 | ||
61 | + setTimeout(function() { | ||
62 | + location.href = res.href; | ||
63 | + }, 1000); | ||
64 | + } else { | ||
65 | + showErrTip(data.message); | ||
66 | + } | ||
67 | + } | ||
68 | + }); | ||
69 | + } | ||
70 | +}); |
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | */ | 5 | */ |
6 | var $ = require('jquery'); | 6 | var $ = require('jquery'); |
7 | 7 | ||
8 | -module.exports = function(useInRegister) { | 8 | +module.exports = function(useInRegister, useForBind) { |
9 | var $captcha = $('#captcha'), | 9 | var $captcha = $('#captcha'), |
10 | $btnNext = $('#btn-next'), | 10 | $btnNext = $('#btn-next'), |
11 | $captchaTip = $('#captcha-tip'), | 11 | $captchaTip = $('#captcha-tip'), |
@@ -52,7 +52,7 @@ module.exports = function(useInRegister) { | @@ -52,7 +52,7 @@ module.exports = function(useInRegister) { | ||
52 | 52 | ||
53 | $.ajax({ | 53 | $.ajax({ |
54 | type: 'POST', | 54 | type: 'POST', |
55 | - url: '/passport/' + urlMid + '/sendcode', | 55 | + url: useForBind ? '/passport/bind/sendBindMsg' : '/passport/' + urlMid + '/sendcode', |
56 | data: { | 56 | data: { |
57 | phoneNum: phoneNum, | 57 | phoneNum: phoneNum, |
58 | areaCode: areaCode | 58 | areaCode: areaCode |
@@ -77,7 +77,7 @@ module.exports = function(useInRegister) { | @@ -77,7 +77,7 @@ module.exports = function(useInRegister) { | ||
77 | 77 | ||
78 | $.ajax({ | 78 | $.ajax({ |
79 | type: 'POST', | 79 | type: 'POST', |
80 | - url: '/passport/' + urlMid + '/verifycode', | 80 | + url: useForBind ? '/passport/bind/sendBindMsg' : '/passport/' + urlMid + '/verifycode', |
81 | data: { | 81 | data: { |
82 | phoneNum: phoneNum, | 82 | phoneNum: phoneNum, |
83 | areaCode: areaCode, | 83 | areaCode: areaCode, |
@@ -97,4 +97,4 @@ module.exports = function(useInRegister) { | @@ -97,4 +97,4 @@ module.exports = function(useInRegister) { | ||
97 | }); | 97 | }); |
98 | 98 | ||
99 | countDown(); | 99 | countDown(); |
100 | -}; | ||
100 | +}; |
-
Please register or login to post a comment