Authored by xuqi

zepto ajax

@@ -16,12 +16,13 @@ $resend.on('touchstart', function(e) { @@ -16,12 +16,13 @@ $resend.on('touchstart', function(e) {
16 16
17 $.ajax({ 17 $.ajax({
18 url: $resend.data('url'), 18 url: $resend.data('url'),
19 - type: 'GET'  
20 - }).then(function(data) {  
21 - if (data.code === 200) {  
22 - showErrTip(data.message);  
23 - } else {  
24 - showErrTip(data.message); 19 + type: 'GET',
  20 + success: function(data) {
  21 + if (data.code === 200) {
  22 + showErrTip(data.message);
  23 + } else {
  24 + showErrTip(data.message);
  25 + }
25 } 26 }
26 }); 27 });
27 }); 28 });
@@ -37,12 +37,13 @@ $btnSure.on('touchstart', function() { @@ -37,12 +37,13 @@ $btnSure.on('touchstart', function() {
37 type: 'POST', 37 type: 'POST',
38 data: { 38 data: {
39 email: email 39 email: email
40 - }  
41 - }).then(function(data) {  
42 - if (data.code === 200) {  
43 - location.href = data.data;  
44 - } else {  
45 - showErrTip(data.message); 40 + },
  41 + success: function(data) {
  42 + if (data.code === 200) {
  43 + location.href = data.data;
  44 + } else {
  45 + showErrTip(data.message);
  46 + }
46 } 47 }
47 }); 48 });
48 } else { 49 } else {
@@ -45,12 +45,13 @@ $btnNext.on('touchstart', function() { @@ -45,12 +45,13 @@ $btnNext.on('touchstart', function() {
45 data: { 45 data: {
46 area: country.split('+')[1], 46 area: country.split('+')[1],
47 mobile: pn 47 mobile: pn
48 - }  
49 - }).then(function(data) {  
50 - if (data.code === 200) {  
51 - location.href = '/passport/back/code';  
52 - } else {  
53 - showErrTip(data.message); 48 + },
  49 + success: function(data) {
  50 + if (data.code === 200) {
  51 + location.href = '/passport/back/code';
  52 + } else {
  53 + showErrTip(data.message);
  54 + }
54 } 55 }
55 }); 56 });
56 } else { 57 } else {
@@ -37,17 +37,18 @@ $btnOk.on('touchstart', function() { @@ -37,17 +37,18 @@ $btnOk.on('touchstart', function() {
37 url: '/passport/back/update', 37 url: '/passport/back/update',
38 data: { 38 data: {
39 password: pwd 39 password: pwd
40 - }  
41 - }).then(function(data) {  
42 - if (data.code === 200) {  
43 - showErrTip('密码修改成功');  
44 -  
45 - //1000ms后跳转页面  
46 - setTimeout(function() {  
47 - location.href = '/';  
48 - }, 1000);  
49 - } else {  
50 - showErrTip(data.message); 40 + },
  41 + success: function(data) {
  42 + if (data.code === 200) {
  43 + showErrTip('密码修改成功');
  44 +
  45 + //1000ms后跳转页面
  46 + setTimeout(function() {
  47 + location.href = '/';
  48 + }, 1000);
  49 + } else {
  50 + showErrTip(data.message);
  51 + }
51 } 52 }
52 }); 53 });
53 } else { 54 } else {
@@ -50,15 +50,16 @@ module.exports = function(useInRegister) { @@ -50,15 +50,16 @@ module.exports = function(useInRegister) {
50 50
51 $.ajax({ 51 $.ajax({
52 type: 'POST', 52 type: 'POST',
53 - url: '/passport/' + urlMid + '/sendPhone'  
54 - }).then(function (data) {  
55 - if (data.code === 200) {  
56 - $captchaTip.text('重发验证码 (60秒)').addClass('disable');  
57 - countDown();  
58 - } else { 53 + url: '/passport/' + urlMid + '/sendPhone',
  54 + success: function(data) {
  55 + if (data.code === 200) {
  56 + $captchaTip.text('重发验证码 (60秒)').addClass('disable');
  57 + countDown();
  58 + } else {
59 59
60 - //验证码不正确,显示提示  
61 - showErrTip(data.message); 60 + //验证码不正确,显示提示
  61 + showErrTip(data.message);
  62 + }
62 } 63 }
63 }); 64 });
64 }); 65 });
@@ -73,14 +74,15 @@ module.exports = function(useInRegister) { @@ -73,14 +74,15 @@ module.exports = function(useInRegister) {
73 url: '/passport/' + urlMid + '/verifycode', 74 url: '/passport/' + urlMid + '/verifycode',
74 data: { 75 data: {
75 verifyCode: trim($captcha.val()) 76 verifyCode: trim($captcha.val())
76 - }  
77 - }).then(function (data) {  
78 - if (data.code === 200) {  
79 - location.href = data.data;  
80 - } else { 77 + },
  78 + success: function(data) {
  79 + if (data.code === 200) {
  80 + location.href = data.data;
  81 + } else {
81 82
82 - //验证码不正确,显示提示  
83 - showErrTip(data.message); 83 + //验证码不正确,显示提示
  84 + showErrTip(data.message);
  85 + }
84 } 86 }
85 }); 87 });
86 }); 88 });
@@ -81,20 +81,22 @@ $loginBtn.on('touchstart', function() { @@ -81,20 +81,22 @@ $loginBtn.on('touchstart', function() {
81 area: country.split('+')[1], 81 area: country.split('+')[1],
82 account: pn, 82 account: pn,
83 pwd: pwd 83 pwd: pwd
  84 + },
  85 + success: function(data) {
  86 + if (data.code === 200) {
  87 + showErrTip('登录成功');
  88 +
  89 + //1000ms后跳转页面
  90 + setTimeout(function() {
  91 + location.href = data.data;
  92 + }, 1000);
  93 + } else {
  94 + showErrTip(data.message);
  95 + }
  96 + },
  97 + error: function() {
  98 + showErrTip('网络断开连接啦~');
84 } 99 }
85 - }).then(function(data) {  
86 - if (data.code === 200) {  
87 - showErrTip('登录成功');  
88 -  
89 - //1000ms后跳转页面  
90 - setTimeout(function() {  
91 - location.href = data.data;  
92 - }, 1000);  
93 - } else {  
94 - showErrTip(data.message);  
95 - }  
96 - }, function() {  
97 - showErrTip('网络断开连接啦~');  
98 }); 100 });
99 } else { 101 } else {
100 showErrTip('账号或密码有错误,请重新输入'); 102 showErrTip('账号或密码有错误,请重新输入');
@@ -84,20 +84,22 @@ $loginBtn.on('touchstart', function() { @@ -84,20 +84,22 @@ $loginBtn.on('touchstart', function() {
84 data: { 84 data: {
85 account: acc, 85 account: acc,
86 pwd: pwd 86 pwd: pwd
  87 + },
  88 + success: function(data) {
  89 + if (data.code === 200) {
  90 + showErrTip('登录成功');
  91 +
  92 + //1s后跳转页面
  93 + setTimeout(function() {
  94 + location.href = data.data;
  95 + }, 1000);
  96 + } else {
  97 + showErrTip(data.message);
  98 + }
  99 + },
  100 + error: function() {
  101 + showErrTip('网络断开连接啦~');
87 } 102 }
88 - }).then(function(data) {  
89 - if (data.code === 200) {  
90 - showErrTip('登录成功');  
91 -  
92 - //1s后跳转页面  
93 - setTimeout(function() {  
94 - location.href = data.data;  
95 - }, 1000);  
96 - } else {  
97 - showErrTip(data.message);  
98 - }  
99 - }, function() {  
100 - showErrTip('网络断开连接啦~');  
101 }); 103 });
102 } else { 104 } else {
103 showErrTip('账号或密码有错误,请重新输入'); 105 showErrTip('账号或密码有错误,请重新输入');
@@ -39,23 +39,24 @@ $btnSure.on('touchstart', function() { @@ -39,23 +39,24 @@ $btnSure.on('touchstart', function() {
39 url: '/passport/register/regmobile', 39 url: '/passport/register/regmobile',
40 data: { 40 data: {
41 password: pwd 41 password: pwd
42 - }  
43 - }).then(function(data) {  
44 - if (data.code === 200) {  
45 - showErrTip('注册成功');  
46 -  
47 - //1000ms后跳转页面  
48 - setTimeout(function() {  
49 - location.href = data.data;  
50 - }, 1000);  
51 - } else {  
52 - if (data.code === 401 || data.code === 404 || data.code === 505) {  
53 - showErrTip(data.message);  
54 - } else {  
55 - showErrTip(data.message); 42 + },
  43 + success: function(data) {
  44 + if (data.code === 200) {
  45 + showErrTip('注册成功');
  46 +
  47 + //1000ms后跳转页面
56 setTimeout(function() { 48 setTimeout(function() {
57 location.href = data.data; 49 location.href = data.data;
58 }, 1000); 50 }, 1000);
  51 + } else {
  52 + if (data.code === 401 || data.code === 404 || data.code === 505) {
  53 + showErrTip(data.message);
  54 + } else {
  55 + showErrTip(data.message);
  56 + setTimeout(function() {
  57 + location.href = data.data;
  58 + }, 1000);
  59 + }
59 } 60 }
60 } 61 }
61 }); 62 });
@@ -45,12 +45,13 @@ $btnNext.on('touchstart', function() { @@ -45,12 +45,13 @@ $btnNext.on('touchstart', function() {
45 data: { 45 data: {
46 area: country.split('+')[1], 46 area: country.split('+')[1],
47 profile: pn 47 profile: pn
48 - }  
49 - }).then(function(data) {  
50 - if (data.code === 200) {  
51 - location.href = '/passport/register/code';  
52 - } else {  
53 - showErrTip(data.message); 48 + },
  49 + success: function(data) {
  50 + if (data.code === 200) {
  51 + location.href = '/passport/register/code';
  52 + } else {
  53 + showErrTip(data.message);
  54 + }
54 } 55 }
55 }); 56 });
56 } else { 57 } else {