Authored by xuqi

link test ajax

@@ -8,7 +8,9 @@ var $ = require('yoho.zepto'); @@ -8,7 +8,9 @@ var $ = require('yoho.zepto');
8 module.exports = function(useInRegister) { 8 module.exports = function(useInRegister) {
9 var $captcha = $('#captcha'), 9 var $captcha = $('#captcha'),
10 $btnNext = $('#btn-next'), 10 $btnNext = $('#btn-next'),
11 - $captchaTip = $('#captcha-tip'); 11 + $captchaTip = $('#captcha-tip'),
  12 + mobile = $('#mobile').val(),
  13 + area = $('#area').val().split('+')[1];
12 14
13 var api = require('./api'); 15 var api = require('./api');
14 var tip = require('../plugin/tip'); 16 var tip = require('../plugin/tip');
@@ -16,7 +18,7 @@ module.exports = function(useInRegister) { @@ -16,7 +18,7 @@ module.exports = function(useInRegister) {
16 var trim = $.trim; 18 var trim = $.trim;
17 var showErrTip = tip.show; 19 var showErrTip = tip.show;
18 20
19 - var urlMid = useInRegister ? 'register' : 'back'; 21 + var urlMid = useInRegister ? 'reg' : 'back';
20 22
21 function countDown() { 23 function countDown() {
22 var count = 59, 24 var count = 59,
@@ -50,7 +52,11 @@ module.exports = function(useInRegister) { @@ -50,7 +52,11 @@ module.exports = function(useInRegister) {
50 52
51 $.ajax({ 53 $.ajax({
52 type: 'POST', 54 type: 'POST',
53 - url: '/passport/' + urlMid + '/sendPhone', 55 + url: '/passport/' + urlMid + '/sendcode',
  56 + data: {
  57 + phoneNum: mobile,
  58 + areaCode: area
  59 + },
54 success: function(data) { 60 success: function(data) {
55 if (data.code === 200) { 61 if (data.code === 200) {
56 $captchaTip.text('重发验证码 (60秒)').addClass('disable'); 62 $captchaTip.text('重发验证码 (60秒)').addClass('disable');
@@ -73,7 +79,10 @@ module.exports = function(useInRegister) { @@ -73,7 +79,10 @@ module.exports = function(useInRegister) {
73 type: 'POST', 79 type: 'POST',
74 url: '/passport/' + urlMid + '/verifycode', 80 url: '/passport/' + urlMid + '/verifycode',
75 data: { 81 data: {
76 - verifyCode: trim($captcha.val()) 82 + mobile: mobile,
  83 + area: area,
  84 + code: trim($captcha.val()),
  85 + token: $('#token').val()
77 }, 86 },
78 success: function(data) { 87 success: function(data) {
79 if (data.code === 200) { 88 if (data.code === 200) {
@@ -36,9 +36,12 @@ $btnSure.on('touchstart', function() { @@ -36,9 +36,12 @@ $btnSure.on('touchstart', function() {
36 } else { 36 } else {
37 $.ajax({ 37 $.ajax({
38 type: 'POST', 38 type: 'POST',
39 - url: '/passport/register/regmobile', 39 + url: '/passport/reg/setpassword',
40 data: { 40 data: {
41 - password: pwd 41 + password: pwd,
  42 + mobile: $('#phone-num').val(),
  43 + area: $('#area-code').val(),
  44 + token: $('#token').val()
42 }, 45 },
43 success: function(data) { 46 success: function(data) {
44 if (data.code === 200) { 47 if (data.code === 200) {
@@ -16,6 +16,8 @@ var tip = require('../../plugin/tip'); @@ -16,6 +16,8 @@ var tip = require('../../plugin/tip');
16 var trim = $.trim; 16 var trim = $.trim;
17 var showErrTip = tip.show; 17 var showErrTip = tip.show;
18 18
  19 +api.selectCssHack($('#country-select'));
  20 +
19 api.bindClearEvt(); 21 api.bindClearEvt();
20 22
21 $phoneNum.bind('input', function() { 23 $phoneNum.bind('input', function() {
@@ -40,15 +42,15 @@ $btnNext.on('touchstart', function() { @@ -40,15 +42,15 @@ $btnNext.on('touchstart', function() {
40 42
41 if (api.phoneRegx[country].test(pn)) { 43 if (api.phoneRegx[country].test(pn)) {
42 $.ajax({ 44 $.ajax({
43 - url: '/passport/register/sendphone', 45 + url: '/passport/reg/verifymobile',
44 type: 'POST', 46 type: 'POST',
45 data: { 47 data: {
46 area: country.split('+')[1], 48 area: country.split('+')[1],
47 - profile: pn 49 + mobile: pn
48 }, 50 },
49 success: function(data) { 51 success: function(data) {
50 if (data.code === 200) { 52 if (data.code === 200) {
51 - location.href = '/passport/register/code'; 53 + location.href = data.data;
52 } else { 54 } else {
53 showErrTip(data.message); 55 showErrTip(data.message);
54 } 56 }
@@ -7,5 +7,8 @@ @@ -7,5 +7,8 @@
7 </div> 7 </div>
8 <span id="btn-sure" class="btn btn-sure disable row">确定</span> 8 <span id="btn-sure" class="btn btn-sure disable row">确定</span>
9 </div> 9 </div>
  10 + <input id="phone-num" type="hidden" value={{phoneNum}}>
  11 + <input id="area-code" type="hidden" value={{areaCode}}>
  12 + <input id="token" type="hidden" value={{token}}>
10 </div> 13 </div>
11 {{> layout/footer}} 14 {{> layout/footer}}
@@ -11,4 +11,7 @@ @@ -11,4 +11,7 @@
11 <div id="captcha-tip" class="captcha-tip disable">重发验证码 (60秒)</div> 11 <div id="captcha-tip" class="captcha-tip disable">重发验证码 (60秒)</div>
12 </div> 12 </div>
13 <span id="btn-next" class="btn btn-next disable row">下一步</span> 13 <span id="btn-next" class="btn btn-next disable row">下一步</span>
  14 + <input id="mobile" type="hidden" value={{phoneNum}}>
  15 + <input id="area" type="hidden" value={{areaCode}}>
  16 + <input id="token" type="hidden" value={{token}}>
14 </div> 17 </div>