Showing
7 changed files
with
398 additions
and
68 deletions
assets/README.md
0 → 100644
1 | +存放生成的HTML文件等 |
@@ -19,14 +19,16 @@ class LoginData | @@ -19,14 +19,16 @@ class LoginData | ||
19 | /** | 19 | /** |
20 | * 登录 | 20 | * 登录 |
21 | * | 21 | * |
22 | + * @param string $area 地区编号 | ||
22 | * @param string $profile 邮箱或手机号 | 23 | * @param string $profile 邮箱或手机号 |
23 | * @param string $password 密码 | 24 | * @param string $password 密码 |
24 | * @return array | 25 | * @return array |
25 | */ | 26 | */ |
26 | - public static function signin($profile, $password) | 27 | + public static function signin($area, $profile, $password) |
27 | { | 28 | { |
28 | $param = Yohobuy::param(); | 29 | $param = Yohobuy::param(); |
29 | $param['method'] = 'app.passport.signin'; | 30 | $param['method'] = 'app.passport.signin'; |
31 | + $param['area'] = $area; | ||
30 | $param['profile'] = $profile; | 32 | $param['profile'] = $profile; |
31 | $param['password'] = $password; | 33 | $param['password'] = $password; |
32 | 34 |
@@ -33,7 +33,7 @@ class Helpers | @@ -33,7 +33,7 @@ class Helpers | ||
33 | if (!isset($productData['product_skn'])) { | 33 | if (!isset($productData['product_skn'])) { |
34 | return false; | 34 | return false; |
35 | } | 35 | } |
36 | - | 36 | + |
37 | // 市场价和售价一样,则不显示市场价 | 37 | // 市场价和售价一样,则不显示市场价 |
38 | if (intval($productData['market_price']) === intval($productData['sales_price'])) { | 38 | if (intval($productData['market_price']) === intval($productData['sales_price'])) { |
39 | $productData['market_price'] = false; | 39 | $productData['market_price'] = false; |
@@ -57,10 +57,10 @@ class Helpers | @@ -57,10 +57,10 @@ class Helpers | ||
57 | $result['tags']['yearEnd'] = isset($productData['year-end']) && $productData['year-end'] === 'Y'; // 年末 | 57 | $result['tags']['yearEnd'] = isset($productData['year-end']) && $productData['year-end'] === 'Y'; // 年末 |
58 | $result['tags']['isReNew'] = false; // 再到着 | 58 | $result['tags']['isReNew'] = false; // 再到着 |
59 | $result['tags']['isNewFestival'] = false; // 新品节 | 59 | $result['tags']['isNewFestival'] = false; // 新品节 |
60 | - | 60 | + |
61 | return $result; | 61 | return $result; |
62 | } | 62 | } |
63 | - | 63 | + |
64 | /** | 64 | /** |
65 | * 生成公开的TOKEN凭证 | 65 | * 生成公开的TOKEN凭证 |
66 | * | 66 | * |
@@ -69,9 +69,9 @@ class Helpers | @@ -69,9 +69,9 @@ class Helpers | ||
69 | */ | 69 | */ |
70 | public static function makeToken($string) | 70 | public static function makeToken($string) |
71 | { | 71 | { |
72 | - return md5(md5($string.'#@!@#')); | 72 | + return md5(md5($string . '#@!@#')); |
73 | } | 73 | } |
74 | - | 74 | + |
75 | /** | 75 | /** |
76 | * 验证TOKEN凭证 | 76 | * 验证TOKEN凭证 |
77 | * | 77 | * |
@@ -83,9 +83,131 @@ class Helpers | @@ -83,9 +83,131 @@ class Helpers | ||
83 | { | 83 | { |
84 | if ($token === self::makeToken($string)) { | 84 | if ($token === self::makeToken($string)) { |
85 | return true; | 85 | return true; |
86 | - } else { | 86 | + } |
87 | + else { | ||
88 | + return false; | ||
89 | + } | ||
90 | + } | ||
91 | + | ||
92 | + /** | ||
93 | + * 验证手机是否合法 | ||
94 | + * | ||
95 | + * @param int $mobile | ||
96 | + * @return boolean | ||
97 | + */ | ||
98 | + public static function verifyMobile($mobile) | ||
99 | + { | ||
100 | + if (empty($mobile)) { | ||
101 | + return false; | ||
102 | + } | ||
103 | + return (bool) preg_match('/^1[3|4|5|8|7][0-9]{9}$/', trim($mobile)); | ||
104 | + } | ||
105 | + | ||
106 | + /** | ||
107 | + * 验证密码是否合法 | ||
108 | + * | ||
109 | + * @param int $password | ||
110 | + * @return boolean | ||
111 | + */ | ||
112 | + public static function verifyPassword($password) | ||
113 | + { | ||
114 | + if (empty($password)) { | ||
87 | return false; | 115 | return false; |
88 | } | 116 | } |
117 | + return (bool) preg_match('/^([a-zA-Z0-9\-\+_!@\#$%\^&\*\(\)\:\;\.=\[\]\\\',\?]){6,20}$/', trim($password)); | ||
89 | } | 118 | } |
90 | - | ||
91 | -} | ||
119 | + | ||
120 | + /** | ||
121 | + * 验证邮箱是否合法 | ||
122 | + * | ||
123 | + * @param string $email | ||
124 | + * @return boolean | ||
125 | + */ | ||
126 | + public static function verifyEmail($email) | ||
127 | + { | ||
128 | + if (empty($email)) { | ||
129 | + return false; | ||
130 | + } | ||
131 | + return !!filter_var($email, FILTER_VALIDATE_EMAIL); | ||
132 | + } | ||
133 | + | ||
134 | + /** | ||
135 | + * 验证国际手机号是否合法 | ||
136 | + * | ||
137 | + * @param string $areaMobile | ||
138 | + * @return boolean | ||
139 | + */ | ||
140 | + public static function verifyAreaMobile($areaMobile) | ||
141 | + { | ||
142 | + if (empty($areaMobile)) { | ||
143 | + return false; | ||
144 | + } | ||
145 | + if (!strpos($areaMobile, '-')) { | ||
146 | + return self::areaMobielVerify($areaMobile); | ||
147 | + } else { | ||
148 | + $mobileData = explode('-', $areaMobile); | ||
149 | + if (count($mobileData) != 2) { | ||
150 | + return false; | ||
151 | + } | ||
152 | + } | ||
153 | + return self::areaMobielVerify($mobileData[1], $mobileData[0]); | ||
154 | + } | ||
155 | + | ||
156 | + /** | ||
157 | + * 各国手机号规则 | ||
158 | + */ | ||
159 | + private static function areaMobielVerify($mobile, $area = 86) | ||
160 | + { | ||
161 | + $verify = array( | ||
162 | + 86 => array( | ||
163 | + 'name' => '中国', | ||
164 | + 'match' => (bool) preg_match('/^1[3|4|5|8|7][0-9]{9}$/', trim($mobile)), | ||
165 | + ), | ||
166 | + 852 => array( | ||
167 | + 'name' => '中国香港', | ||
168 | + 'match' => (bool) preg_match('/^[9|6|5][0-9]{7}$/', trim($mobile)), | ||
169 | + ), | ||
170 | + 853 => array( | ||
171 | + 'name' => '中国澳门', | ||
172 | + 'match' => (bool) preg_match('/^[0-9]{8}$/', trim($mobile)), | ||
173 | + ), | ||
174 | + 886 => array( | ||
175 | + 'name' => '中国台湾', | ||
176 | + 'match' => (bool) preg_match('/^[0-9]{10}$/', trim($mobile)), | ||
177 | + ), | ||
178 | + 65 => array( | ||
179 | + 'name' => '新加坡', | ||
180 | + 'match' => (bool) preg_match('/^[9|8][0-9]{7}$/', trim($mobile)), | ||
181 | + ), | ||
182 | + 60 => array( | ||
183 | + 'name' => '马来西亚', | ||
184 | + 'match' => (bool) preg_match('/^1[1|2|3|4|6|7|9][0-9]{8}$/', trim($mobile)), | ||
185 | + ), | ||
186 | + 1 => array( | ||
187 | + 'name' => '加拿大&美国', | ||
188 | + 'match' => (bool) preg_match('/^[0-9]{10}$/', trim($mobile)), | ||
189 | + ), | ||
190 | + 82 => array( | ||
191 | + 'name' => '韩国', | ||
192 | + 'match' => (bool) preg_match('/^01[0-9]{9}$/', trim($mobile)), | ||
193 | + ), | ||
194 | + 44 => array( | ||
195 | + 'name' => '英国', | ||
196 | + 'match' => (bool) preg_match('/^7[7|8|9][0-9]{8}$/', trim($mobile)), | ||
197 | + ), | ||
198 | + 81 => array( | ||
199 | + 'name' => '日本', | ||
200 | + 'match' => (bool) preg_match('/^0[9|8|7][0-9]{9}$/', trim($mobile)), | ||
201 | + ), | ||
202 | + 61 => array( | ||
203 | + 'name' => '澳大利亚', | ||
204 | + 'match' => (bool) preg_match('/^[0-9]{11}$/', trim($mobile)), | ||
205 | + ), | ||
206 | + ); | ||
207 | + if (isset($verify[$area])) { | ||
208 | + return $verify[$area]['match']; | ||
209 | + } | ||
210 | + return false; | ||
211 | + } | ||
212 | + | ||
213 | +} |
script/nginx/conf/vhosts/yohobuy.rls.conf
0 → 100644
1 | +server | ||
2 | +{ | ||
3 | + listen 80; | ||
4 | + server_name wap.yohobuy.com; | ||
5 | + | ||
6 | + #access_log /Data/logs/access.wap.yohobuy.com.log combined; | ||
7 | + error_log /Data/logs/error.wap.yohobuy.com.log warn; | ||
8 | + | ||
9 | + root /Data/PE/yohobuy/yohobuy/m.yohobuy.com/public; | ||
10 | + | ||
11 | + location ~* \.html$ { | ||
12 | + root /Data/PE/yohobuy/assets; | ||
13 | + if (!-f $request_filename){ | ||
14 | + root /Data/PE/yohobuy/yohobuy/m.yohobuy.com/public; | ||
15 | + rewrite ^/(.+)$ /index.php?$1& last; | ||
16 | + } | ||
17 | + expires 7d; | ||
18 | + } | ||
19 | + | ||
20 | + location / { | ||
21 | + index index.php; | ||
22 | + if (!-f $request_filename){ | ||
23 | + rewrite ^/(.+)$ /index.php?$1& last; | ||
24 | + } | ||
25 | + } | ||
26 | + | ||
27 | + location ~* \.(ico|woff)$ { | ||
28 | + expires 7d; | ||
29 | + } | ||
30 | + | ||
31 | + location = /crossdomain.xml { | ||
32 | + expires 7d; | ||
33 | + } | ||
34 | + | ||
35 | + location ~ .*\.php?$ { | ||
36 | + fastcgi_pass 127.0.0.1:9000; | ||
37 | + fastcgi_index index.php; | ||
38 | + #fastcgi_param PATH_INFO $fastcgi_script_name; | ||
39 | + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | ||
40 | + include fastcgi_params; | ||
41 | + } | ||
42 | + | ||
43 | + error_page 403 = http://wap.yohobuy.com; | ||
44 | + error_page 404 = http://wap.yohobuy.com/error.html; | ||
45 | +} | ||
46 | + | ||
47 | +server | ||
48 | +{ | ||
49 | + listen 80; | ||
50 | + server_name static.wap.yohobuy.com; | ||
51 | + | ||
52 | + #access_log /Data/logs/access.static.wap.yohobuy.com.log combined; | ||
53 | + #error_log /Data/logs/error.static.wap.yohobuy.com.log warn; | ||
54 | + | ||
55 | + root /Data/PE/yohobuy/static; | ||
56 | + | ||
57 | + location / { | ||
58 | + log_not_found off; | ||
59 | + access_log off; | ||
60 | + expires 30d; | ||
61 | + } | ||
62 | + | ||
63 | + location ~* \.(svg|eot|ttf|woff|otf)$ { | ||
64 | + add_header Access-Control-Allow-Origin *; | ||
65 | + expires 30d; | ||
66 | + } | ||
67 | + | ||
68 | +} |
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | use Action\AbstractAction; | 3 | use Action\AbstractAction; |
4 | -use Plugin\Partner\Factory; | ||
5 | use LibModels\Wap\Passport\LoginData; | 4 | use LibModels\Wap\Passport\LoginData; |
5 | +use LibModels\Wap\Passport\RegData; | ||
6 | +use Plugin\Helpers; | ||
7 | +use Plugin\Partner\Factory; | ||
6 | 8 | ||
9 | +/** | ||
10 | + * 登录的控制器 | ||
11 | + */ | ||
7 | class LoginController extends AbstractAction | 12 | class LoginController extends AbstractAction |
8 | { | 13 | { |
14 | + /** | ||
15 | + * 登录页 | ||
16 | + */ | ||
9 | public function indexAction() | 17 | public function indexAction() |
10 | { | 18 | { |
19 | + $this->setTitle('登录'); | ||
20 | + | ||
11 | $data = array( | 21 | $data = array( |
12 | - 'backUrl' => 'm.yohobuy.com', | 22 | + 'loginIndex' => true, |
23 | + 'backUrl' => '/', | ||
13 | 'showHeaderImg' => true, | 24 | 'showHeaderImg' => true, |
14 | 'isPassportPage' => true, | 25 | 'isPassportPage' => true, |
15 | - 'modulePath' => 'passport/login/login' | 26 | + 'registerUrl' => '/reg.html', |
27 | + 'interationalUrl' => '/login.html', | ||
28 | + 'phoneRetriveUrl' => '', | ||
29 | + 'emailRetriveUrl' => '', | ||
16 | ); | 30 | ); |
17 | 31 | ||
18 | - $this->_view->assign('title', '登录'); | ||
19 | $this->_view->display('index', $data); | 32 | $this->_view->display('index', $data); |
20 | } | 33 | } |
21 | 34 | ||
35 | + /** | ||
36 | + * 国际账号登录页 | ||
37 | + */ | ||
22 | public function interationalAction() | 38 | public function interationalAction() |
23 | { | 39 | { |
24 | - $data = array( | ||
25 | - 'backUrl' => 'm.yohobuy.com', | ||
26 | - 'headerText' => '登录', | ||
27 | - 'isPassportPage' => true, | ||
28 | - 'modulePath' => 'passport/login/interational', | ||
29 | - 'countrys' => array( | ||
30 | - array( | ||
31 | - 'areaCode' => '+86', | ||
32 | - 'selected' => true, | ||
33 | - 'name' => '中国' | ||
34 | - ), | ||
35 | - array( | ||
36 | - 'areaCode' => '+864', | ||
37 | - 'name' => '中国香港' | ||
38 | - ) | ||
39 | - ), | ||
40 | - 'countryCode' => '+86' | ||
41 | - ); | 40 | + $this->setTitle('国际账号登录'); |
41 | + | ||
42 | + $data = array(); | ||
43 | + $data['loginInterational'] = true; | ||
44 | + $data['backUrl'] = '/'; | ||
45 | + $data['headerText'] = '登录'; | ||
46 | + $data['isPassportPage'] = true; | ||
47 | + $data['countryCode'] = '+86'; | ||
48 | + | ||
49 | + // 获取地区数据列表 | ||
50 | + $area = RegData::getAreasData(); | ||
51 | + // 有数据 | ||
52 | + if (!empty($area['data'])) { | ||
53 | + $build = array(); | ||
54 | + foreach ($area['data'] as $value) { | ||
55 | + $build = array(); | ||
56 | + $build['areaCode'] = '+' . $value['area']; | ||
57 | + $build['selected'] = $value['area'] === '86'; | ||
58 | + $build['name'] = $value['name']; | ||
59 | + $data['countrys'][] = $build; | ||
60 | + } | ||
61 | + } | ||
62 | + // 没数据 | ||
63 | + else { | ||
64 | + $data['countrys'][0] = array(); | ||
65 | + $data['countrys'][0]['areaCode'] = '+86'; | ||
66 | + $data['countrys'][0]['selected'] = true; | ||
67 | + $data['countrys'][0]['name'] = '中国'; | ||
68 | + } | ||
42 | 69 | ||
43 | - $this->_view->assign('title', '国际账号登录'); | ||
44 | $this->_view->display('interational', $data); | 70 | $this->_view->display('interational', $data); |
71 | + | ||
72 | + $data = array(); | ||
73 | + $area = array(); | ||
74 | + } | ||
75 | + | ||
76 | + /** | ||
77 | + * 登录操作 | ||
78 | + * | ||
79 | + * @param string area 地区编号, 不需要+号 | ||
80 | + * @param string profile 账号(邮箱或手机号) | ||
81 | + * @param string password 密码 | ||
82 | + * @return json | ||
83 | + */ | ||
84 | + public function authAction() | ||
85 | + { | ||
86 | + $data = array('code' => 400, 'message' => '账号或密码不正确', 'data' => ''); | ||
87 | + | ||
88 | + do { | ||
89 | + /* 判断是不是AJAX请求 */ | ||
90 | + if (!$this->isAjax()) { | ||
91 | + break; | ||
92 | + } | ||
93 | + | ||
94 | + /* 判断参数是否传递 */ | ||
95 | + $area = $this->post('area', '86'); | ||
96 | + $profile = $this->post('profile'); | ||
97 | + $password = $this->post('password'); | ||
98 | + if (!is_numeric($area) || empty($profile) || empty($password)) { | ||
99 | + break; | ||
100 | + } | ||
101 | + | ||
102 | + /* 判断参数是否有效 */ | ||
103 | + $verifyEmail = Helpers::verifyEmail($profile); | ||
104 | + $verifyMobile = ($area === '86') ? Helpers::verifyMobile($profile) | ||
105 | + : Helpers::verifyAreaMobile($profile); | ||
106 | + if (!$verifyEmail && !$verifyMobile) { | ||
107 | + break; | ||
108 | + } | ||
109 | + | ||
110 | + /* 调用登录接口进行登录 */ | ||
111 | + $data = LoginData::signin($area, $profile, $password); | ||
112 | + | ||
113 | + } while (false); | ||
114 | + | ||
115 | + $this->echoJson($data); | ||
45 | } | 116 | } |
46 | - | ||
47 | 117 | ||
48 | /** | 118 | /** |
49 | * 支付宝账号登录:授权页面 | 119 | * 支付宝账号登录:授权页面 |
@@ -17,12 +17,15 @@ class RegController extends AbstractAction | @@ -17,12 +17,15 @@ class RegController extends AbstractAction | ||
17 | $this->setTitle('注册'); | 17 | $this->setTitle('注册'); |
18 | 18 | ||
19 | $data = array(); | 19 | $data = array(); |
20 | + $data['regIndex'] = true; | ||
20 | $data['backUrl'] = '/'; | 21 | $data['backUrl'] = '/'; |
21 | $data['headerText'] = '注册'; | 22 | $data['headerText'] = '注册'; |
22 | $data['isPassportPage'] = true; | 23 | $data['isPassportPage'] = true; |
23 | $data['countrys'] = array(); | 24 | $data['countrys'] = array(); |
24 | 25 | ||
26 | + // 获取地区数据列表 | ||
25 | $area = RegData::getAreasData(); | 27 | $area = RegData::getAreasData(); |
28 | + // 有数据 | ||
26 | if (!empty($area['data'])) { | 29 | if (!empty($area['data'])) { |
27 | $build = array(); | 30 | $build = array(); |
28 | foreach ($area['data'] as $value) { | 31 | foreach ($area['data'] as $value) { |
@@ -32,7 +35,9 @@ class RegController extends AbstractAction | @@ -32,7 +35,9 @@ class RegController extends AbstractAction | ||
32 | $build['name'] = $value['name']; | 35 | $build['name'] = $value['name']; |
33 | $data['countrys'][] = $build; | 36 | $data['countrys'][] = $build; |
34 | } | 37 | } |
35 | - } else { | 38 | + } |
39 | + // 没数据 | ||
40 | + else { | ||
36 | $data['countrys'][0] = array(); | 41 | $data['countrys'][0] = array(); |
37 | $data['countrys'][0]['areaCode'] = '+86'; | 42 | $data['countrys'][0]['areaCode'] = '+86'; |
38 | $data['countrys'][0]['selected'] = true; | 43 | $data['countrys'][0]['selected'] = true; |
@@ -65,11 +70,13 @@ class RegController extends AbstractAction | @@ -65,11 +70,13 @@ class RegController extends AbstractAction | ||
65 | $this->setTitle('注册-验证码'); | 70 | $this->setTitle('注册-验证码'); |
66 | 71 | ||
67 | $data = array(); | 72 | $data = array(); |
73 | + $data['regCode'] = true; | ||
68 | $data['backUrl'] = '/'; | 74 | $data['backUrl'] = '/'; |
69 | $data['headerText'] = '注册'; | 75 | $data['headerText'] = '注册'; |
70 | $data['isPassportPage'] = true; | 76 | $data['isPassportPage'] = true; |
71 | $data['areaCode'] = $area; | 77 | $data['areaCode'] = $area; |
72 | $data['phoneNum'] = $mobile; | 78 | $data['phoneNum'] = $mobile; |
79 | + $data['token'] = $token; | ||
73 | 80 | ||
74 | $this->_view->display('code', $data); | 81 | $this->_view->display('code', $data); |
75 | } | 82 | } |
@@ -83,14 +90,27 @@ class RegController extends AbstractAction | @@ -83,14 +90,27 @@ class RegController extends AbstractAction | ||
83 | */ | 90 | */ |
84 | public function passwordAction() | 91 | public function passwordAction() |
85 | { | 92 | { |
86 | - $data = array( | ||
87 | - 'backUrl' => 'm.yohobuy.com', | ||
88 | - 'headerText' => '注册', | ||
89 | - 'isPassportPage' => true, | ||
90 | - 'modulePath' => 'passport/register/password' | ||
91 | - ); | 93 | + $token = $this->get('token'); |
94 | + $mobile = $this->get('mobile'); | ||
95 | + $area = $this->get('area', '86'); | ||
96 | + | ||
97 | + // 判断是否允许访问, 不允许则跳转到错误页面 | ||
98 | + if (!is_string($token) || !is_numeric($mobile) || !is_numeric($area) | ||
99 | + || !Helpers::verifyToken($mobile, $token)) { | ||
100 | + $this->error(); | ||
101 | + } | ||
102 | + | ||
103 | + $this->setTitle('注册-设置密码'); | ||
104 | + | ||
105 | + $data = array(); | ||
106 | + $data['regPwd'] = true; | ||
107 | + $data['backUrl'] = '/'; | ||
108 | + $data['headerText'] = '注册'; | ||
109 | + $data['isPassportPage'] = true; | ||
110 | + $data['areaCode'] = $area; | ||
111 | + $data['phoneNum'] = $mobile; | ||
112 | + $data['token'] = $token; | ||
92 | 113 | ||
93 | - $this->_view->assign('title', '注册-密码'); | ||
94 | $this->_view->display('password', $data); | 114 | $this->_view->display('password', $data); |
95 | } | 115 | } |
96 | 116 | ||
@@ -99,7 +119,6 @@ class RegController extends AbstractAction | @@ -99,7 +119,6 @@ class RegController extends AbstractAction | ||
99 | * | 119 | * |
100 | * @param string area 地区编号,注意不需要+号 | 120 | * @param string area 地区编号,注意不需要+号 |
101 | * @param string mobile 手机号 | 121 | * @param string mobile 手机号 |
102 | - * @param string token 访问TOKEN凭证 | ||
103 | * @return json | 122 | * @return json |
104 | */ | 123 | */ |
105 | public function verifymobileAction() | 124 | public function verifymobileAction() |
@@ -112,16 +131,10 @@ class RegController extends AbstractAction | @@ -112,16 +131,10 @@ class RegController extends AbstractAction | ||
112 | break; | 131 | break; |
113 | } | 132 | } |
114 | 133 | ||
115 | - $token = $this->post('token'); | ||
116 | $mobile = $this->post('mobile'); | 134 | $mobile = $this->post('mobile'); |
117 | $area = $this->post('area', '86'); | 135 | $area = $this->post('area', '86'); |
118 | /* 判断参数是否合法 */ | 136 | /* 判断参数是否合法 */ |
119 | - if (!is_string($token) || !is_numeric($mobile) || !is_numeric($area)) { | ||
120 | - break; | ||
121 | - } | ||
122 | - | ||
123 | - /* 判断是否允许访问 */ | ||
124 | - if (!Helpers::verifyToken($mobile, $token)) { | 137 | + if (!is_numeric($mobile) || !is_numeric($area)) { |
125 | break; | 138 | break; |
126 | } | 139 | } |
127 | 140 | ||
@@ -133,12 +146,13 @@ class RegController extends AbstractAction | @@ -133,12 +146,13 @@ class RegController extends AbstractAction | ||
133 | 146 | ||
134 | /* 返回跳转到验证页面的链接*/ | 147 | /* 返回跳转到验证页面的链接*/ |
135 | if ($data['code'] == 200) { | 148 | if ($data['code'] == 200) { |
149 | + $token = Helpers::makeToken($mobile); | ||
136 | $data['data'] = '/passport/reg/code?token='.$token.'&mobile='.$mobile.'&area='.$area; | 150 | $data['data'] = '/passport/reg/code?token='.$token.'&mobile='.$mobile.'&area='.$area; |
137 | } | 151 | } |
138 | 152 | ||
139 | } while (false); | 153 | } while (false); |
140 | 154 | ||
141 | - echo $this->echoJson($data); | 155 | + $this->echoJson($data); |
142 | } | 156 | } |
143 | 157 | ||
144 | /** | 158 | /** |
@@ -160,17 +174,11 @@ class RegController extends AbstractAction | @@ -160,17 +174,11 @@ class RegController extends AbstractAction | ||
160 | break; | 174 | break; |
161 | } | 175 | } |
162 | 176 | ||
163 | - $token = $this->post('token'); | ||
164 | $mobile = $this->post('mobile'); | 177 | $mobile = $this->post('mobile'); |
165 | $area = $this->post('area'); | 178 | $area = $this->post('area'); |
166 | $code = $this->post('code'); | 179 | $code = $this->post('code'); |
167 | /* 判断参数是否合法 */ | 180 | /* 判断参数是否合法 */ |
168 | - if (!is_string($token) || !is_numeric($mobile) || !is_numeric($area) || !isset($code)) { | ||
169 | - break; | ||
170 | - } | ||
171 | - | ||
172 | - /* 判断是否允许访问 */ | ||
173 | - if (!Helpers::verifyToken($mobile, $token)) { | 181 | + if (!is_numeric($mobile) || !is_numeric($area) || !isset($code)) { |
174 | break; | 182 | break; |
175 | } | 183 | } |
176 | 184 | ||
@@ -182,12 +190,48 @@ class RegController extends AbstractAction | @@ -182,12 +190,48 @@ class RegController extends AbstractAction | ||
182 | 190 | ||
183 | /* 返回跳转到设置密码的链接*/ | 191 | /* 返回跳转到设置密码的链接*/ |
184 | if ($data['code'] == 200) { | 192 | if ($data['code'] == 200) { |
193 | + $token = Helpers::makeToken($mobile); | ||
185 | $data['data'] = '/passport/reg/password?token='.$token.'&mobile='.$mobile.'&area='.$area; | 194 | $data['data'] = '/passport/reg/password?token='.$token.'&mobile='.$mobile.'&area='.$area; |
186 | } | 195 | } |
187 | 196 | ||
188 | } while (false); | 197 | } while (false); |
189 | 198 | ||
190 | - echo $this->echoJson($data); | 199 | + $this->echoJson($data); |
200 | + } | ||
201 | + | ||
202 | + /** | ||
203 | + * 发送验证码 | ||
204 | + * | ||
205 | + * @param string area 地区编号,注意不需要+号 | ||
206 | + * @param string mobile 手机号 | ||
207 | + * @return json | ||
208 | + */ | ||
209 | + public function sendcodeAction() | ||
210 | + { | ||
211 | + $data = array('code' => 400, 'message' => '参数不正确!', 'data' => ''); | ||
212 | + | ||
213 | + do { | ||
214 | + /* 判断是不是AJAX请求 */ | ||
215 | + if (!$this->isAjax()) { | ||
216 | + break; | ||
217 | + } | ||
218 | + | ||
219 | + $mobile = $this->post('mobile'); | ||
220 | + $area = $this->post('area', '86'); | ||
221 | + /* 判断参数是否合法 */ | ||
222 | + if (!is_numeric($mobile) || !is_numeric($area)) { | ||
223 | + break; | ||
224 | + } | ||
225 | + | ||
226 | + /* 向手机发送注册验证码 */ | ||
227 | + $data = RegData::sendCodeToMobile($area, $mobile); | ||
228 | + if (!isset($data['code'])) { | ||
229 | + break; | ||
230 | + } | ||
231 | + | ||
232 | + } while (false); | ||
233 | + | ||
234 | + $this->echoJson($data); | ||
191 | } | 235 | } |
192 | 236 | ||
193 | /** | 237 | /** |
@@ -201,7 +245,7 @@ class RegController extends AbstractAction | @@ -201,7 +245,7 @@ class RegController extends AbstractAction | ||
201 | */ | 245 | */ |
202 | public function setpasswordAction() | 246 | public function setpasswordAction() |
203 | { | 247 | { |
204 | - $data = array('code' => 400, 'message' => '参数不正确!', 'data' => ''); | 248 | + $data = array('code' => 400, 'message' => '密码格式不正确!', 'data' => ''); |
205 | 249 | ||
206 | do { | 250 | do { |
207 | /* 判断是不是AJAX请求 */ | 251 | /* 判断是不是AJAX请求 */ |
@@ -229,14 +273,14 @@ class RegController extends AbstractAction | @@ -229,14 +273,14 @@ class RegController extends AbstractAction | ||
229 | break; | 273 | break; |
230 | } | 274 | } |
231 | 275 | ||
232 | - /* 返回跳转到设置密码的链接*/ | 276 | + /* 返回跳转到来源页面 */ |
233 | if ($data['code'] == 200) { | 277 | if ($data['code'] == 200) { |
234 | $data['data'] = '/passport/reg/password?token='.$token.'&mobile='.$mobile.'&area='.$area; | 278 | $data['data'] = '/passport/reg/password?token='.$token.'&mobile='.$mobile.'&area='.$area; |
235 | } | 279 | } |
236 | 280 | ||
237 | } while (false); | 281 | } while (false); |
238 | 282 | ||
239 | - echo $this->echoJson($data); | 283 | + $this->echoJson($data); |
240 | } | 284 | } |
241 | 285 | ||
242 | } | 286 | } |
1 | -; default | 1 | +; 默认页 |
2 | routes.index.type = "rewrite" | 2 | routes.index.type = "rewrite" |
3 | routes.index.match = "/index.html$" | 3 | routes.index.match = "/index.html$" |
4 | routes.index.route.module = Index | 4 | routes.index.route.module = Index |
5 | routes.index.route.controller = Index | 5 | routes.index.route.controller = Index |
6 | routes.index.route.action = Index | 6 | routes.index.route.action = Index |
7 | 7 | ||
8 | -; error | ||
9 | -routes.notfound.type = "rewrite" | ||
10 | -routes.notfound.match = "/error.html$" | ||
11 | -routes.notfound.route.module = Index | ||
12 | -routes.notfound.route.controller = Error | ||
13 | -routes.notfound.route.action = Index | ||
8 | +; 错误页 | ||
9 | +routes.error.type = "rewrite" | ||
10 | +routes.error.match = "/error.html$" | ||
11 | +routes.error.route.module = Index | ||
12 | +routes.error.route.controller = Error | ||
13 | +routes.error.route.action = Index | ||
14 | + | ||
15 | +; 注册页 | ||
16 | +routes.reg.type = "rewrite" | ||
17 | +routes.reg.match = "/reg.html$" | ||
18 | +routes.reg.route.module = Passport | ||
19 | +routes.reg.route.controller = Reg | ||
20 | +routes.reg.route.action = Index | ||
21 | + | ||
22 | +; 登录页 | ||
23 | +routes.login.type = "rewrite" | ||
24 | +routes.login.match = "/signin.html$" | ||
25 | +routes.login.route.module = Passport | ||
26 | +routes.login.route.controller = Login | ||
27 | +routes.login.route.action = Index | ||
28 | + | ||
29 | +; 登录页(国际账号) | ||
30 | +routes.interational.type = "rewrite" | ||
31 | +routes.interational.match = "/login.html$" | ||
32 | +routes.interational.route.module = Passport | ||
33 | +routes.interational.route.controller = Login | ||
34 | +routes.interational.route.action = Interational | ||
35 | + | ||
36 | + |
-
Please register or login to post a comment