Authored by Rock Zhang

修改一些接口数据格式“

@@ -8,10 +8,6 @@ use Hood\Core\Security\AuthCode; @@ -8,10 +8,6 @@ use Hood\Core\Security\AuthCode;
8 */ 8 */
9 class BackController extends AbstractAction 9 class BackController extends AbstractAction
10 { 10 {
11 - public function indexAction()  
12 - {  
13 - echo '密码找回';  
14 - }  
15 11
16 public function emailAction() 12 public function emailAction()
17 { 13 {
@@ -33,11 +29,30 @@ class BackController extends AbstractAction @@ -33,11 +29,30 @@ class BackController extends AbstractAction
33 { 29 {
34 if($this->isAjax()) 30 if($this->isAjax())
35 { 31 {
  32 + $email = $this->post('email', '');
  33 +
  34 + // 发送邮箱验证码
  35 + $result = BackData::sendCodeToEmail($email);
  36 + if($result['code'] === 200)
  37 + {
  38 + $result['data'] = '/passport/back/success?email='.$email;
  39 + }
  40 +
  41 + $this->echoJson($result);
  42 + }
  43 + }
  44 +
  45 + /**
  46 + * 重新发送邮箱验证码
  47 + */
  48 + public function resendemailAction()
  49 + {
  50 + if($this->isAjax())
  51 + {
36 $email = $this->get('email', ''); 52 $email = $this->get('email', '');
37 53
38 // 发送邮箱验证码 54 // 发送邮箱验证码
39 $result = BackData::sendCodeToEmail($email); 55 $result = BackData::sendCodeToEmail($email);
40 - $result['data'] = '/passport/back/success';  
41 56
42 $this->echoJson($result); 57 $this->echoJson($result);
43 } 58 }
@@ -45,13 +60,18 @@ class BackController extends AbstractAction @@ -45,13 +60,18 @@ class BackController extends AbstractAction
45 60
46 public function successAction() 61 public function successAction()
47 { 62 {
  63 + $email = $this->get('email', '');
  64 + // 获取到邮箱域名
  65 + $pattern = "/^([0-9A-Za-z\\-_\\.]+)@([0-9a-z]+\\.[a-z]{2,3}(\\.[a-z]{2})?)$/i";
  66 + $domain_name = 'http://mail.'.preg_replace( $pattern ,"$2", $email );
  67 +
48 $data = array( 68 $data = array(
49 - 'backUrl' => 'm.yohobuy.com', 69 + 'backUrl' => '/passport/back/email',
50 'headerText' => '找回密码', 70 'headerText' => '找回密码',
51 'isPassportPage' => true, 71 'isPassportPage' => true,
52 'backEmailSuccess' => true, 72 'backEmailSuccess' => true,
53 - 'goEmail' => '',  
54 - 'resendUrl' => '' 73 + 'goEmail' => $domain_name,
  74 + 'resendUrl' => '/passport/back/resendemail?email='.$email
55 ); 75 );
56 76
57 $this->_view->assign('title', 'YOHO!有货'); 77 $this->_view->assign('title', 'YOHO!有货');
@@ -67,12 +87,12 @@ class BackController extends AbstractAction @@ -67,12 +87,12 @@ class BackController extends AbstractAction
67 { 87 {
68 if($this->isAjax()) 88 if($this->isAjax())
69 { 89 {
70 - $pwd = $this->get('pwd', '');  
71 - $code = $this->get('code', ''); 90 + $pwd = $this->post('password', '');
  91 + $code = $this->post('code', '');
72 92
73 $data = BackData::modifyPasswordByEmail($pwd, $code); 93 $data = BackData::modifyPasswordByEmail($pwd, $code);
74 94
75 - $this->returnJson(200, '成功', '');// 前端不需要判断结果 95 + $this->echoJson($data);// 前端不需要判断结果
76 } 96 }
77 } 97 }
78 98
@@ -106,7 +126,7 @@ class BackController extends AbstractAction @@ -106,7 +126,7 @@ class BackController extends AbstractAction
106 });*/ 126 });*/
107 127
108 $data = array( 128 $data = array(
109 - 'backUrl' => '/passport/back/login', 129 + 'backUrl' => '/passport/login/index',
110 'headerText' => '找回密码', 130 'headerText' => '找回密码',
111 'isPassportPage' => true, 131 'isPassportPage' => true,
112 'backMobile' => true, 132 'backMobile' => true,
@@ -121,17 +141,17 @@ class BackController extends AbstractAction @@ -121,17 +141,17 @@ class BackController extends AbstractAction
121 /** 141 /**
122 * 发送手机验证码 142 * 发送手机验证码
123 */ 143 */
124 - public function mobilecodeSendAction() 144 + public function sendcodeAction()
125 { 145 {
126 if($this->isAjax()) 146 if($this->isAjax())
127 { 147 {
128 - $mobile = $this->get('mobile', '');  
129 - $area = $this->get('area', 86); 148 + $mobile = $this->post('mobile', '');
  149 + $area = $this->post('area', 86);
130 150
131 // 发送手机验证码 151 // 发送手机验证码
132 $result = BackData::sendCodeToMobile($mobile, $area); 152 $result = BackData::sendCodeToMobile($mobile, $area);
133 153
134 - $this->returnJson($result['code'], $result['message'], $result['data']); 154 + $this->echoJson($result);
135 } 155 }
136 } 156 }
137 157
@@ -158,32 +178,40 @@ class BackController extends AbstractAction @@ -158,32 +178,40 @@ class BackController extends AbstractAction
158 * 178 *
159 * @return array 校验手机验证码的结果(token) 179 * @return array 校验手机验证码的结果(token)
160 */ 180 */
161 - public function mobilecodeValidateAction() 181 + public function verifycodeAction()
162 { 182 {
163 if($this->isAjax()) 183 if($this->isAjax())
164 { 184 {
165 - $mobile = $this->get('mobile', '');  
166 - $code = $this->get('code', '');  
167 - $area = $this->get('area', 86); 185 + $mobile = $this->post('mobile', '');
  186 + $code = $this->post('code', '');
  187 + $area = $this->post('area', 86);
168 188
169 // 校验手机验证码 189 // 校验手机验证码
170 $result = BackData::validateMobileCode($mobile, $code, $area); 190 $result = BackData::validateMobileCode($mobile, $code, $area);
171 191
172 - $this->returnJson($result['code'], $result['message'], $result['data']); 192 + $this->echoJson($result);
173 } 193 }
174 } 194 }
175 195
176 public function passwordAction() 196 public function passwordAction()
177 { 197 {
178 $mobile = $this->get('mobile', ''); 198 $mobile = $this->get('mobile', '');
  199 + // 手机验证令牌
179 $token = $this->get('token', ''); 200 $token = $this->get('token', '');
180 $area = $this->get('area', 86); 201 $area = $this->get('area', 86);
  202 +
  203 + // 邮箱验证码
  204 + $code = $this->get('code', '');
181 205
182 $data = array( 206 $data = array(
183 - 'backUrl' => '/passport/back/login', 207 + 'backUrl' => '/passport/login/index',
184 'headerText' => '找回密码', 208 'headerText' => '找回密码',
185 'isPassportPage' => true, 209 'isPassportPage' => true,
186 'backNewPwd' => true, 210 'backNewPwd' => true,
  211 + 'mobile' => $mobile,
  212 + 'token' => $token,
  213 + 'areaCode' => $area,
  214 + 'code' => $code
187 ); 215 );
188 216
189 $this->_view->assign('title', 'YOHO!有货'); 217 $this->_view->assign('title', 'YOHO!有货');
@@ -199,15 +227,15 @@ class BackController extends AbstractAction @@ -199,15 +227,15 @@ class BackController extends AbstractAction
199 { 227 {
200 if($this->isAjax()) 228 if($this->isAjax())
201 { 229 {
202 - $mobile = $this->get('mobile', '');  
203 - $token = $this->get('token', '');  
204 - $newpwd = $this->get('newpwd', 86);  
205 - $area = $this->get('area', 86); 230 + $mobile = $this->post('mobile', '');
  231 + $token = $this->post('token', '');
  232 + $newpwd = $this->post('password', '');
  233 + $area = $this->post('area', 86);
206 234
207 // 根据手机验证码修改密码 235 // 根据手机验证码修改密码
208 $result = BackData::modifyPasswordByMobile($mobile, $token, $newpwd, $area); 236 $result = BackData::modifyPasswordByMobile($mobile, $token, $newpwd, $area);
209 237
210 - $this->returnJson($result['code'], $result['message'], $result['data']); 238 + $this->echoJson($result);
211 } 239 }
212 } 240 }
213 } 241 }