Showing
1 changed file
with
51 additions
and
9 deletions
@@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
3 | use Action\AbstractAction; | 3 | use Action\AbstractAction; |
4 | use LibModels\Wap\Passport\BackData; | 4 | use LibModels\Wap\Passport\BackData; |
5 | use LibModels\Wap\Passport\RegData; | 5 | use LibModels\Wap\Passport\RegData; |
6 | +use Plugin\Helpers; | ||
6 | 7 | ||
7 | /** | 8 | /** |
8 | * 频道选择 | 9 | * 频道选择 |
@@ -31,9 +32,21 @@ class BackController extends AbstractAction | @@ -31,9 +32,21 @@ class BackController extends AbstractAction | ||
31 | */ | 32 | */ |
32 | public function sendemailAction() | 33 | public function sendemailAction() |
33 | { | 34 | { |
34 | - if($this->isAjax()) | 35 | + $result = array('code' => 400, 'message' => '邮箱格式不正确,请重新输入', 'data' => ''); |
36 | + do | ||
35 | { | 37 | { |
38 | + /* 判断是不是AJAX请求 */ | ||
39 | + if (!$this->isAjax()) | ||
40 | + { | ||
41 | + break; | ||
42 | + } | ||
43 | + | ||
36 | $email = $this->post('email', ''); | 44 | $email = $this->post('email', ''); |
45 | + // 判断邮箱是否有效 | ||
46 | + if(!Helpers::verifyEmail($email)) | ||
47 | + { | ||
48 | + break; | ||
49 | + } | ||
37 | 50 | ||
38 | // 发送邮箱验证码 | 51 | // 发送邮箱验证码 |
39 | $result = BackData::sendCodeToEmail($email); | 52 | $result = BackData::sendCodeToEmail($email); |
@@ -42,8 +55,10 @@ class BackController extends AbstractAction | @@ -42,8 +55,10 @@ class BackController extends AbstractAction | ||
42 | $result['data'] = '/passport/back/success?email='.$email; | 55 | $result['data'] = '/passport/back/success?email='.$email; |
43 | } | 56 | } |
44 | 57 | ||
45 | - $this->echoJson($result); | ||
46 | } | 58 | } |
59 | + while (false); | ||
60 | + | ||
61 | + $this->echoJson($result); | ||
47 | } | 62 | } |
48 | 63 | ||
49 | /** | 64 | /** |
@@ -51,15 +66,28 @@ class BackController extends AbstractAction | @@ -51,15 +66,28 @@ class BackController extends AbstractAction | ||
51 | */ | 66 | */ |
52 | public function resendemailAction() | 67 | public function resendemailAction() |
53 | { | 68 | { |
54 | - if($this->isAjax()) | 69 | + $result = array('code' => 400, 'message' => '重发邮件失败'); |
70 | + do | ||
55 | { | 71 | { |
72 | + if(!$this->isAjax()) | ||
73 | + { | ||
74 | + break; | ||
75 | + } | ||
76 | + | ||
56 | $email = $this->get('email', ''); | 77 | $email = $this->get('email', ''); |
57 | 78 | ||
58 | // 发送邮箱验证码 | 79 | // 发送邮箱验证码 |
59 | - $result = BackData::sendCodeToEmail($email); | 80 | + $return = BackData::sendCodeToEmail($email); |
81 | + | ||
82 | + if(!empty($return)) | ||
83 | + { | ||
84 | + $result = $return; | ||
85 | + } | ||
60 | 86 | ||
61 | - $this->echoJson($result); | ||
62 | } | 87 | } |
88 | + while(false); | ||
89 | + | ||
90 | + $this->echoJson($result); | ||
63 | } | 91 | } |
64 | 92 | ||
65 | public function successAction() | 93 | public function successAction() |
@@ -133,20 +161,34 @@ class BackController extends AbstractAction | @@ -133,20 +161,34 @@ class BackController extends AbstractAction | ||
133 | */ | 161 | */ |
134 | public function sendcodeAction() | 162 | public function sendcodeAction() |
135 | { | 163 | { |
136 | - if($this->isAjax()) | 164 | + $result = array('code' => 400, 'message' => '手机号码格式不正确,请重新输入', 'data' => ''); |
165 | + do | ||
137 | { | 166 | { |
167 | + /* 判断是不是AJAX请求 */ | ||
168 | + if (!$this->isAjax()) | ||
169 | + { | ||
170 | + break; | ||
171 | + } | ||
138 | $phoneNum = $this->post('phoneNum', ''); | 172 | $phoneNum = $this->post('phoneNum', ''); |
139 | $areaCode = $this->post('areaCode', 86); | 173 | $areaCode = $this->post('areaCode', 86); |
140 | 174 | ||
175 | + if(!Helpers::verifyMobile($phoneNum)) | ||
176 | + { | ||
177 | + break; | ||
178 | + } | ||
179 | + | ||
141 | // 发送手机验证码 | 180 | // 发送手机验证码 |
142 | - $result = BackData::sendCodeToMobile($phoneNum, $areaCode); | ||
143 | - if($result['code'] === 200) | 181 | + $return = BackData::sendCodeToMobile($phoneNum, $areaCode); |
182 | + if($return && $return['code'] === 200) | ||
144 | { | 183 | { |
184 | + $result = $return; | ||
145 | $result['data'] = '/passport/back/mobilecode?phoneNum='.$phoneNum.'&areaCode='.$areaCode; | 185 | $result['data'] = '/passport/back/mobilecode?phoneNum='.$phoneNum.'&areaCode='.$areaCode; |
146 | } | 186 | } |
147 | 187 | ||
148 | - $this->echoJson($result); | ||
149 | } | 188 | } |
189 | + while (false); | ||
190 | + | ||
191 | + $this->echoJson($result); | ||
150 | } | 192 | } |
151 | 193 | ||
152 | /** | 194 | /** |
-
Please register or login to post a comment