Merge branch 'develop' of git.dev.yoho.cn:web/yohobuy into develop
Showing
19 changed files
with
904 additions
and
173 deletions
assets/README.md
0 → 100644
1 | +存放生成的HTML文件等 |
@@ -9,11 +9,11 @@ | @@ -9,11 +9,11 @@ | ||
9 | * @version 1.0 (2015-9-15 11:55:25) | 9 | * @version 1.0 (2015-9-15 11:55:25) |
10 | * @author fei.hong <fei.hong@yoho.cn> | 10 | * @author fei.hong <fei.hong@yoho.cn> |
11 | */ | 11 | */ |
12 | + | ||
12 | namespace Action; | 13 | namespace Action; |
13 | 14 | ||
14 | use Yaf\Controller_Abstract; | 15 | use Yaf\Controller_Abstract; |
15 | use Yaf\Dispatcher; | 16 | use Yaf\Dispatcher; |
16 | - | ||
17 | use Hood\Cache; | 17 | use Hood\Cache; |
18 | 18 | ||
19 | class AbstractAction extends Controller_Abstract | 19 | class AbstractAction extends Controller_Abstract |
@@ -57,7 +57,7 @@ class AbstractAction extends Controller_Abstract | @@ -57,7 +57,7 @@ class AbstractAction extends Controller_Abstract | ||
57 | { | 57 | { |
58 | return $this->_request->getPost($key, $default); | 58 | return $this->_request->getPost($key, $default); |
59 | } | 59 | } |
60 | - | 60 | + |
61 | /** | 61 | /** |
62 | * 使用Memcache缓存 | 62 | * 使用Memcache缓存 |
63 | * | 63 | * |
@@ -67,13 +67,16 @@ class AbstractAction extends Controller_Abstract | @@ -67,13 +67,16 @@ class AbstractAction extends Controller_Abstract | ||
67 | */ | 67 | */ |
68 | protected function memcache($node = null, $childNode = 'hosts') | 68 | protected function memcache($node = null, $childNode = 'hosts') |
69 | { | 69 | { |
70 | + // WINDOWS | ||
70 | if (PATH_SEPARATOR === '\\') { | 71 | if (PATH_SEPARATOR === '\\') { |
71 | return Cache::memcache($node, $childNode); | 72 | return Cache::memcache($node, $childNode); |
72 | - } else { | 73 | + } |
74 | + // LINUX | ||
75 | + else { | ||
73 | return Cache::memcached($node, $childNode); | 76 | return Cache::memcached($node, $childNode); |
74 | } | 77 | } |
75 | } | 78 | } |
76 | - | 79 | + |
77 | /** | 80 | /** |
78 | * 关闭模板自动渲染 | 81 | * 关闭模板自动渲染 |
79 | * | 82 | * |
@@ -83,7 +86,7 @@ class AbstractAction extends Controller_Abstract | @@ -83,7 +86,7 @@ class AbstractAction extends Controller_Abstract | ||
83 | { | 86 | { |
84 | Dispatcher::getInstance()->autoRender(false); | 87 | Dispatcher::getInstance()->autoRender(false); |
85 | } | 88 | } |
86 | - | 89 | + |
87 | /** | 90 | /** |
88 | * 输出JSON数据到浏览器 | 91 | * 输出JSON数据到浏览器 |
89 | * | 92 | * |
@@ -92,14 +95,14 @@ class AbstractAction extends Controller_Abstract | @@ -92,14 +95,14 @@ class AbstractAction extends Controller_Abstract | ||
92 | protected function echoJson($json) | 95 | protected function echoJson($json) |
93 | { | 96 | { |
94 | headers_sent() || header('Content-Type: application/json; charset=utf-8;'); | 97 | headers_sent() || header('Content-Type: application/json; charset=utf-8;'); |
95 | - if(is_array($json)) | ||
96 | - { | 98 | + |
99 | + if (is_array($json)) { | ||
97 | $json = json_encode($json); | 100 | $json = json_encode($json); |
98 | } | 101 | } |
99 | - | 102 | + |
100 | echo $json; | 103 | echo $json; |
101 | } | 104 | } |
102 | - | 105 | + |
103 | /** | 106 | /** |
104 | * 返回JSON数据 | 107 | * 返回JSON数据 |
105 | * | 108 | * |
@@ -116,7 +119,7 @@ class AbstractAction extends Controller_Abstract | @@ -116,7 +119,7 @@ class AbstractAction extends Controller_Abstract | ||
116 | 'data' => $data, | 119 | 'data' => $data, |
117 | )); | 120 | )); |
118 | } | 121 | } |
119 | - | 122 | + |
120 | /** | 123 | /** |
121 | * 判断是不是AJAX请求 | 124 | * 判断是不是AJAX请求 |
122 | * | 125 | * |
@@ -126,15 +129,137 @@ class AbstractAction extends Controller_Abstract | @@ -126,15 +129,137 @@ class AbstractAction extends Controller_Abstract | ||
126 | { | 129 | { |
127 | return $this->_request->isXmlHttpRequest(); | 130 | return $this->_request->isXmlHttpRequest(); |
128 | } | 131 | } |
129 | - | 132 | + |
130 | /** | 133 | /** |
131 | * 跳转到错误页面 | 134 | * 跳转到错误页面 |
132 | */ | 135 | */ |
133 | protected function error() | 136 | protected function error() |
134 | { | 137 | { |
135 | headers_sent() || header('Location: /error.html'); | 138 | headers_sent() || header('Location: /error.html'); |
136 | - | 139 | + |
137 | exit; | 140 | exit; |
138 | } | 141 | } |
139 | 142 | ||
143 | + /** | ||
144 | + * 设置Cookie | ||
145 | + * | ||
146 | + * @param string $name cookie的名字 | ||
147 | + * @param string $value cookie的值 | ||
148 | + * @param integer $expire cookie过期时间 | ||
149 | + * @param integer $path cookie可用的路径 | ||
150 | + * @param string $domain cookie可用域名 | ||
151 | + */ | ||
152 | + protected function setCookie($name, $value, $expire = 0, $path = '/',$domain = 'yohobuy.com') | ||
153 | + { | ||
154 | + setcookie('alipay_redirect', $value, $expire, $path, $domain); | ||
155 | + } | ||
156 | + | ||
157 | + /** | ||
158 | + * 返回Cookie变量 | ||
159 | + * | ||
160 | + * @param string $name cookie名称 | ||
161 | + * @param string $default 未获取到返回的默认值 | ||
162 | + * @return string 获取到的cookie值 | ||
163 | + */ | ||
164 | + protected function getCookie($name, $default = '') | ||
165 | + { | ||
166 | + return $this->request->getCookie($name, $default); | ||
167 | + } | ||
168 | + | ||
169 | + /** | ||
170 | + * 返回顶部软件下载有关数据 | ||
171 | + * @return array 下载有关数据 | ||
172 | + */ | ||
173 | + protected function getHeaderDownload() | ||
174 | + { | ||
175 | + return array( | ||
176 | + 'img' => 'http://img11.static.yhbimg.com/adpic/2015/02/28/18/01d83bfad41c8fca8fd1ad334216d7d733.jpg?imageView/2/w/640/h/480', | ||
177 | + 'url' => 'http://www.baidu.com' | ||
178 | + ); | ||
179 | + } | ||
180 | + | ||
181 | + /* | ||
182 | + * 设置网站SEO的标题 | ||
183 | + * | ||
184 | + * @param string $title 标题 | ||
185 | + * @return void | ||
186 | + */ | ||
187 | + protected function setTitle($title) | ||
188 | + { | ||
189 | + $this->_view->assign('title', $title); | ||
190 | + } | ||
191 | + | ||
192 | + /** | ||
193 | + * 设置网站SEO的关键词 | ||
194 | + * | ||
195 | + * @param string $keywords 关键词,多个之间用","逗号分隔 | ||
196 | + * @return void | ||
197 | + */ | ||
198 | + protected function setKeywords($keywords) | ||
199 | + { | ||
200 | + $this->_view->assign('keywords', $keywords); | ||
201 | + } | ||
202 | + | ||
203 | + /** | ||
204 | + * 设置网站SEO的描述内容 | ||
205 | + * | ||
206 | + * @param string $description 描述内容 | ||
207 | + * @return void | ||
208 | + */ | ||
209 | + protected function setDescription($description) | ||
210 | + { | ||
211 | + $this->_view->assign('description', $description); | ||
212 | + } | ||
213 | + | ||
214 | + /** | ||
215 | + * 设置网站导航头部信息 | ||
216 | + * | ||
217 | + * @param string $backUrl 返回的链接 | ||
218 | + * @param string $title 头部标题 | ||
219 | + * @param string $homeUrl 返回首页的链接 | ||
220 | + * @return void | ||
221 | + */ | ||
222 | + protected function setNavHeader($backUrl, $title, $homeUrl) | ||
223 | + { | ||
224 | + $header = array(); | ||
225 | + | ||
226 | + if (!empty($backUrl)) { | ||
227 | + $header['pageHeader']['navBack'] = $backUrl; | ||
228 | + } | ||
229 | + if (!empty($title)) { | ||
230 | + $header['pageHeader']['navTitle'] = $title; | ||
231 | + } | ||
232 | + if (!empty($homeUrl)) { | ||
233 | + $header['pageHeader']['navHome'] = $homeUrl; | ||
234 | + } | ||
235 | + | ||
236 | + $this->_view->assign('header', $header); | ||
237 | + } | ||
238 | + | ||
239 | + /** | ||
240 | + * 设置网站导航底部信息 | ||
241 | + * | ||
242 | + * @return void | ||
243 | + */ | ||
244 | + protected function setNavFooter() | ||
245 | + { | ||
246 | + $footer = array(); | ||
247 | + | ||
248 | + // 已登录 @todo | ||
249 | + if (false) { | ||
250 | + $footer['pageFooter']['user'] = array(); | ||
251 | + $footer['pageFooter']['user']['name'] = 'goodboy'; // 昵称 | ||
252 | + $footer['pageFooter']['user']['url'] = ''; // 个人中心链接 | ||
253 | + $footer['pageFooter']['user']['signoutUrl'] = ''; // 登出链接 | ||
254 | + } | ||
255 | + // 未登录 | ||
256 | + else { | ||
257 | + $footer['pageFooter'] = array(); | ||
258 | + $footer['pageFooter']['loginUrl'] = ''; // 登录链接 | ||
259 | + $footer['pageFooter']['signupUrl'] = ''; // 注册链接 | ||
260 | + } | ||
261 | + | ||
262 | + $this->_view->assign('footer', $footer); | ||
263 | + } | ||
264 | + | ||
140 | } | 265 | } |
@@ -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; |
@@ -46,31 +46,168 @@ class Helpers | @@ -46,31 +46,168 @@ class Helpers | ||
46 | $result['name'] = $productData['product_name']; | 46 | $result['name'] = $productData['product_name']; |
47 | $result['price'] = $productData['market_price']; | 47 | $result['price'] = $productData['market_price']; |
48 | $result['salePrice'] = $productData['sales_price']; | 48 | $result['salePrice'] = $productData['sales_price']; |
49 | - $result['isFew'] = ($productData['is_soon_sold_out'] === 'Y') ? true : false; | 49 | + $result['isFew'] = ($productData['is_soon_sold_out'] === 'Y'); |
50 | $result['url'] = ''; // @todo | 50 | $result['url'] = ''; // @todo |
51 | - $result['tags'] = array( | ||
52 | - 'isNew' => false, // 新品 | ||
53 | - 'isSale' => false, // 在售 | ||
54 | - 'isLimit' => false, // 限量 | ||
55 | - 'isNewFestival' => false, // 新品节 | ||
56 | - 'isReNew' => false, // 再到着 | ||
57 | - 'isYohood' => false, // YOHOOD | ||
58 | - 'midYear' => false, // 年中 | ||
59 | - 'yearEnd' => false, // 年末 | ||
60 | - ); | ||
61 | - | ||
62 | - foreach ($productData['tags'] as $tag) { | ||
63 | - if ($tag['is_limited'] === 'Y') { | ||
64 | - $result['tags']['isLimit'] = true; | ||
65 | - } elseif ($tag['is_yohood'] === 'Y') { | ||
66 | - $result['tags']['isYohood'] = true; | ||
67 | - } elseif ($tag['is_new'] === 'Y') { | ||
68 | - $result['tags']['isNew'] = true; | 51 | + $result['tags'] = array(); |
52 | + $result['tags']['isNew'] = isset($productData['is_new']) && $productData['is_new'] === 'Y'; // 新品 | ||
53 | + $result['tags']['isSale'] = isset($productData['is_discount']) && $productData['is_discount'] === 'Y'; // 在售 | ||
54 | + $result['tags']['isLimit'] = isset($productData['is_limited']) && $productData['is_limited'] === 'Y'; // 限量 | ||
55 | + $result['tags']['isYohood'] = isset($productData['is_yohood']) && $productData['is_yohood'] === 'Y'; // YOHOOD | ||
56 | + $result['tags']['midYear'] = isset($productData['mid-year']) && $productData['mid-year'] === 'Y'; // 年中 | ||
57 | + $result['tags']['yearEnd'] = isset($productData['year-end']) && $productData['year-end'] === 'Y'; // 年末 | ||
58 | + $result['tags']['isReNew'] = false; // 再到着 | ||
59 | + $result['tags']['isNewFestival'] = false; // 新品节 | ||
60 | + | ||
61 | + return $result; | ||
62 | + } | ||
63 | + | ||
64 | + /** | ||
65 | + * 生成公开的TOKEN凭证 | ||
66 | + * | ||
67 | + * @param string $string 字符串 | ||
68 | + * @return string | ||
69 | + */ | ||
70 | + public static function makeToken($string) | ||
71 | + { | ||
72 | + return md5(md5($string . '#@!@#')); | ||
73 | + } | ||
74 | + | ||
75 | + /** | ||
76 | + * 验证TOKEN凭证 | ||
77 | + * | ||
78 | + * @param string $string 字符串 | ||
79 | + * @param string $token 公开访问TOKEN | ||
80 | + * @return bool | ||
81 | + */ | ||
82 | + public static function verifyToken($string, $token) | ||
83 | + { | ||
84 | + if ($token === self::makeToken($string)) { | ||
85 | + return true; | ||
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)) { | ||
115 | + return false; | ||
116 | + } | ||
117 | + return (bool) preg_match('/^([a-zA-Z0-9\-\+_!@\#$%\^&\*\(\)\:\;\.=\[\]\\\',\?]){6,20}$/', trim($password)); | ||
118 | + } | ||
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; | ||
69 | } | 151 | } |
70 | } | 152 | } |
71 | - | ||
72 | - return $result; | ||
73 | - | 153 | + return self::areaMobielVerify($mobileData[1], $mobileData[0]); |
74 | } | 154 | } |
75 | - | ||
76 | -} | ||
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 | +} |
@@ -14,6 +14,8 @@ var tip = require('../../plugin/tip'); | @@ -14,6 +14,8 @@ var tip = require('../../plugin/tip'); | ||
14 | var trim = $.trim; | 14 | var trim = $.trim; |
15 | var showErrTip = tip.show; | 15 | var showErrTip = tip.show; |
16 | 16 | ||
17 | +var $mobile = $('#mobile'); | ||
18 | + | ||
17 | api.bindEyesEvt(); | 19 | api.bindEyesEvt(); |
18 | 20 | ||
19 | $pwd.bind('input', function() { | 21 | $pwd.bind('input', function() { |
@@ -25,19 +27,45 @@ $pwd.bind('input', function() { | @@ -25,19 +27,45 @@ $pwd.bind('input', function() { | ||
25 | }); | 27 | }); |
26 | 28 | ||
27 | $btnOk.on('touchstart', function() { | 29 | $btnOk.on('touchstart', function() { |
28 | - var pwd = trim($pwd.val()); | 30 | + var pwd = trim($pwd.val()), |
31 | + mobileBack = true, | ||
32 | + setting, | ||
33 | + url; | ||
29 | 34 | ||
30 | if ($btnOk.hasClass('disable')) { | 35 | if ($btnOk.hasClass('disable')) { |
31 | return; | 36 | return; |
32 | } | 37 | } |
33 | 38 | ||
39 | + setting = { | ||
40 | + password: pwd | ||
41 | + }; | ||
42 | + | ||
43 | + if ($mobile.length === 0) { | ||
44 | + mobileBack = false; | ||
45 | + } | ||
46 | + | ||
47 | + if (mobileBack) { | ||
48 | + $.extend(setting, { | ||
49 | + mobile: $mobile.val(), | ||
50 | + areaCode: $('#areaCode').val(), | ||
51 | + token: $('#token').val() | ||
52 | + }); | ||
53 | + | ||
54 | + url = '/passport/back/passwordByMobile'; | ||
55 | + } else { | ||
56 | + $.extend(setting, { | ||
57 | + code: $('#email-code').val() | ||
58 | + }); | ||
59 | + | ||
60 | + url = '/passport/back/passwordByEmail'; | ||
61 | + } | ||
62 | + | ||
63 | + | ||
34 | if (api.pwdValidate(pwd)) { | 64 | if (api.pwdValidate(pwd)) { |
35 | $.ajax({ | 65 | $.ajax({ |
36 | type: 'POST', | 66 | type: 'POST', |
37 | url: '/passport/back/update', | 67 | url: '/passport/back/update', |
38 | - data: { | ||
39 | - password: pwd | ||
40 | - }, | 68 | + data: setting, |
41 | success: function(data) { | 69 | success: function(data) { |
42 | if (data.code === 200) { | 70 | if (data.code === 200) { |
43 | showErrTip('密码修改成功'); | 71 | showErrTip('密码修改成功'); |
@@ -7,5 +7,14 @@ | @@ -7,5 +7,14 @@ | ||
7 | </div> | 7 | </div> |
8 | <span id="btn-ok" class="btn btn-ok disable">完成</span> | 8 | <span id="btn-ok" class="btn btn-ok disable">完成</span> |
9 | </div> | 9 | </div> |
10 | + {{#if mobile}} | ||
11 | + <input id="mobile" type="hidden" value={{mobile}}> | ||
12 | + <input id="area" type="hidden" value={{areaCode}}> | ||
13 | + <input id="token" type="hidden" value={{token}}> | ||
14 | + {{/if}} | ||
15 | + | ||
16 | + {{# code}} | ||
17 | + <input id="email-code" type="hidden" value={{.}}> | ||
18 | + {{/ code}} | ||
10 | </div> | 19 | </div> |
11 | {{> layout/footer}} | 20 | {{> layout/footer}} |
@@ -15,7 +15,6 @@ | @@ -15,7 +15,6 @@ | ||
15 | var docEl = doc.documentElement; | 15 | var docEl = doc.documentElement; |
16 | (function () { | 16 | (function () { |
17 | var clientWidth = docEl.clientWidth; | 17 | var clientWidth = docEl.clientWidth; |
18 | - | ||
19 | if (!clientWidth) { | 18 | if (!clientWidth) { |
20 | return; | 19 | return; |
21 | } | 20 | } |
@@ -380,13 +380,14 @@ class GirlsController extends AbstractAction | @@ -380,13 +380,14 @@ class GirlsController extends AbstractAction | ||
380 | 380 | ||
381 | ), | 381 | ), |
382 | 382 | ||
383 | - | 383 | + // 频道数据 |
384 | + $channelData = Index::getUserChannelData(0, '2,3', '201504091403002'); | ||
384 | 385 | ||
385 | - | ||
386 | - ); | ||
387 | - | ||
388 | - $this->_view->assign('title', '首页'); | ||
389 | - $this->_view->display('index', $data); | 386 | + echo '<pre>'; |
387 | + print_r($channelData); | ||
388 | + | ||
389 | + $this->_view->assign('title', 'YOHO!有货'); | ||
390 | + $this->_view->display('index', $data); | ||
390 | 391 | ||
391 | // // 频道数据 | 392 | // // 频道数据 |
392 | // $channelData = Index::getUserChannelData(0, '2,3', '201504091403002'); | 393 | // $channelData = Index::getUserChannelData(0, '2,3', '201504091403002'); |
@@ -120,7 +120,7 @@ class PlusstarController extends AbstractAction | @@ -120,7 +120,7 @@ class PlusstarController extends AbstractAction | ||
120 | $data['ps']['name'] = $brandInfo['getBrandInfo']['brand_name']; | 120 | $data['ps']['name'] = $brandInfo['getBrandInfo']['brand_name']; |
121 | $data['ps']['isLike'] = $brandInfo['getUidBrandFav']; | 121 | $data['ps']['isLike'] = $brandInfo['getUidBrandFav']; |
122 | $data['ps']['likeUrl'] = "http://guang.m.yohobuy.com/plustar/brandinfo?id=285&openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"http:\/\/guang.m.yohobuy.com\/plustar\/brandinfo","param":{"id":285}},"requesturl":{"url":"\/guang\/api\/v1\/favorite\/togglebrand","param":{"brand_id":"701"}},"priority":"Y"}}"; | 122 | $data['ps']['likeUrl'] = "http://guang.m.yohobuy.com/plustar/brandinfo?id=285&openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"http:\/\/guang.m.yohobuy.com\/plustar\/brandinfo","param":{"id":285}},"requesturl":{"url":"\/guang\/api\/v1\/favorite\/togglebrand","param":{"brand_id":"701"}},"priority":"Y"}}"; |
123 | - $data['ps']['intro'] = empty($brandInfo['brand_intro']) ? '' : strip_tags($brandInfo['brand_intro']); | 123 | + $data['ps']['intro'] = empty($brandInfo['getBrandInfo']['brand_intro']) ? '' : strtr(strip_tags($brandInfo['getBrandInfo']['brand_intro']), 'nbsp;', ' '); |
124 | $data['ps']['newArrival'] = array(); | 124 | $data['ps']['newArrival'] = array(); |
125 | $data['ps']['newArrival']['moreUrl'] = ''; // @todo | 125 | $data['ps']['newArrival']['moreUrl'] = ''; // @todo |
126 | $data['ps']['newArrival']['naList'] = $brandInfo['getNewProduct']; | 126 | $data['ps']['newArrival']['naList'] = $brandInfo['getNewProduct']; |
@@ -8,18 +8,14 @@ use Hood\Core\Security\AuthCode; | @@ -8,18 +8,14 @@ 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 | { |
18 | $data = array( | 14 | $data = array( |
19 | - 'backUrl' => 'm.yohobuy.com', | 15 | + 'backUrl' => '/passport/login/index', |
20 | 'headerText' => '找回密码', | 16 | 'headerText' => '找回密码', |
21 | 'isPassportPage' => true, | 17 | 'isPassportPage' => true, |
22 | - 'modulePath' => 'passport/back/email' | 18 | + 'backEmail' => true |
23 | ); | 19 | ); |
24 | 20 | ||
25 | $this->_view->assign('title', 'YOHO!有货'); | 21 | $this->_view->assign('title', 'YOHO!有货'); |
@@ -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 | - 'modulePath' => 'passport/back/email-success', | ||
53 | - 'goEmail' => '', | ||
54 | - 'resendUrl' => '' | 72 | + 'backEmailSuccess' => true, |
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 | ||
@@ -89,7 +109,7 @@ class BackController extends AbstractAction | @@ -89,7 +109,7 @@ class BackController extends AbstractAction | ||
89 | // 处理地区信息 | 109 | // 处理地区信息 |
90 | foreach ($areas as &$val) { | 110 | foreach ($areas as &$val) { |
91 | $val['areaCode'] = $val['area']; | 111 | $val['areaCode'] = $val['area']; |
92 | - if($val['area'] == 86) | 112 | + if($val['area'] === '86') |
93 | { | 113 | { |
94 | $val['selected'] = true; | 114 | $val['selected'] = true; |
95 | } | 115 | } |
@@ -104,12 +124,12 @@ class BackController extends AbstractAction | @@ -104,12 +124,12 @@ class BackController extends AbstractAction | ||
104 | 124 | ||
105 | return ($a['id'] < $b['id'] ? -1 : 1); | 125 | return ($a['id'] < $b['id'] ? -1 : 1); |
106 | });*/ | 126 | });*/ |
107 | - | 127 | + |
108 | $data = array( | 128 | $data = array( |
109 | - 'backUrl' => 'm.yohobuy.com', | 129 | + 'backUrl' => '/passport/login/index', |
110 | 'headerText' => '找回密码', | 130 | 'headerText' => '找回密码', |
111 | 'isPassportPage' => true, | 131 | 'isPassportPage' => true, |
112 | - 'modulePath' => 'passport/back/mobile', | 132 | + 'backMobile' => true, |
113 | 'countrys' => $areas, | 133 | 'countrys' => $areas, |
114 | 'countryCode' => '+86' | 134 | 'countryCode' => '+86' |
115 | ); | 135 | ); |
@@ -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 | ||
@@ -139,13 +159,13 @@ class BackController extends AbstractAction | @@ -139,13 +159,13 @@ class BackController extends AbstractAction | ||
139 | { | 159 | { |
140 | $mobile = $this->get('mobile', ''); | 160 | $mobile = $this->get('mobile', ''); |
141 | $area = $this->get('area', 86); | 161 | $area = $this->get('area', 86); |
162 | + $areacode = '+'.$area; | ||
142 | 163 | ||
143 | $data = array( | 164 | $data = array( |
144 | - 'backUrl' => 'm.yohobuy.com', | 165 | + 'backUrl' => '/passport/back/mobile', |
145 | 'headerText' => '找回密码', | 166 | 'headerText' => '找回密码', |
146 | 'isPassportPage' => true, | 167 | 'isPassportPage' => true, |
147 | - 'modulePath' => 'passport/back/code', | ||
148 | - 'areaCode' => '+86', | 168 | + 'areaCode' => $areacode, |
149 | 'phoneNum' => $mobile | 169 | 'phoneNum' => $mobile |
150 | ); | 170 | ); |
151 | 171 | ||
@@ -158,41 +178,40 @@ class BackController extends AbstractAction | @@ -158,41 +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' => 'm.yohobuy.com', | 207 | + 'backUrl' => '/passport/login/index', |
184 | 'headerText' => '找回密码', | 208 | 'headerText' => '找回密码', |
185 | 'isPassportPage' => true, | 209 | 'isPassportPage' => true, |
186 | - 'modulePath' => 'passport/back/new-password', | ||
187 | - 'pageHeader' => array( | ||
188 | - 'navBack' => 'm.yohobuy.com', | ||
189 | - 'navHome' => 'm.yohobuy.com', | ||
190 | - 'navTitle' => '上衣' | ||
191 | - ), | ||
192 | - 'pageFooter' => array( | ||
193 | - 'loginUrl' => 'm.yohobuy.com/login.html', | ||
194 | - 'signupUrl' => 'm.yohobuy.com/signup.html' | ||
195 | - ) | 210 | + 'backNewPwd' => true, |
211 | + 'mobile' => $mobile, | ||
212 | + 'token' => $token, | ||
213 | + 'areaCode' => $area, | ||
214 | + 'code' => $code | ||
196 | ); | 215 | ); |
197 | 216 | ||
198 | $this->_view->assign('title', 'YOHO!有货'); | 217 | $this->_view->assign('title', 'YOHO!有货'); |
@@ -208,15 +227,15 @@ class BackController extends AbstractAction | @@ -208,15 +227,15 @@ class BackController extends AbstractAction | ||
208 | { | 227 | { |
209 | if($this->isAjax()) | 228 | if($this->isAjax()) |
210 | { | 229 | { |
211 | - $mobile = $this->get('mobile', ''); | ||
212 | - $token = $this->get('token', ''); | ||
213 | - $newpwd = $this->get('newpwd', 86); | ||
214 | - $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); | ||
215 | 234 | ||
216 | // 根据手机验证码修改密码 | 235 | // 根据手机验证码修改密码 |
217 | $result = BackData::modifyPasswordByMobile($mobile, $token, $newpwd, $area); | 236 | $result = BackData::modifyPasswordByMobile($mobile, $token, $newpwd, $area); |
218 | 237 | ||
219 | - $this->returnJson($result['code'], $result['message'], $result['data']); | 238 | + $this->echoJson($result); |
220 | } | 239 | } |
221 | } | 240 | } |
222 | } | 241 | } |
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 | * 支付宝账号登录:授权页面 |
50 | */ | 120 | */ |
51 | public function alipayAction() | 121 | public function alipayAction() |
52 | { | 122 | { |
123 | + $redirect = $this->_request->getServer('HTTP_REFERER', ''); | ||
124 | + if($redirect != '') | ||
125 | + { | ||
126 | + $this->setCookie('alipay_redirect', $redirect); | ||
127 | + } | ||
53 | Factory::create('alipay')->getAuthorizeUrl(); | 128 | Factory::create('alipay')->getAuthorizeUrl(); |
54 | 129 | ||
55 | exit(); | 130 | exit(); |
@@ -61,6 +136,11 @@ class LoginController extends AbstractAction | @@ -61,6 +136,11 @@ class LoginController extends AbstractAction | ||
61 | */ | 136 | */ |
62 | public function qqAction() | 137 | public function qqAction() |
63 | { | 138 | { |
139 | + $redirect = $this->_request->getServer('HTTP_REFERER', ''); | ||
140 | + if($redirect != '') | ||
141 | + { | ||
142 | + $this->setCookie('qq_redirect', $redirect); | ||
143 | + } | ||
64 | Factory::create('qqconnect')->getAuthorizeUrl(); | 144 | Factory::create('qqconnect')->getAuthorizeUrl(); |
65 | 145 | ||
66 | exit(); | 146 | exit(); |
@@ -72,6 +152,11 @@ class LoginController extends AbstractAction | @@ -72,6 +152,11 @@ class LoginController extends AbstractAction | ||
72 | */ | 152 | */ |
73 | public function sinaAction() | 153 | public function sinaAction() |
74 | { | 154 | { |
155 | + $redirect = $this->_request->getServer('HTTP_REFERER', ''); | ||
156 | + if($redirect != '') | ||
157 | + { | ||
158 | + $this->setCookie('sina_redirect', $redirect); | ||
159 | + } | ||
75 | header('Location:' . Factory::create('sinaweibo')->getAuthorizeUrl()); | 160 | header('Location:' . Factory::create('sinaweibo')->getAuthorizeUrl()); |
76 | 161 | ||
77 | exit(); | 162 | exit(); |
@@ -108,8 +193,11 @@ class LoginController extends AbstractAction | @@ -108,8 +193,11 @@ class LoginController extends AbstractAction | ||
108 | 193 | ||
109 | if($result['code'] == 200) | 194 | if($result['code'] == 200) |
110 | { | 195 | { |
111 | - echo '登陆成功'; | 196 | + $redirect = $this->_request->getCookie('alipay_redirect'); |
197 | + $redirect && $this->redirect($redirect); | ||
112 | } | 198 | } |
199 | + | ||
200 | + $this->redirect('/'); | ||
113 | } | 201 | } |
114 | 202 | ||
115 | /** | 203 | /** |
@@ -121,7 +209,6 @@ class LoginController extends AbstractAction | @@ -121,7 +209,6 @@ class LoginController extends AbstractAction | ||
121 | $access = $qqconnect->getAccessToken(); | 209 | $access = $qqconnect->getAccessToken(); |
122 | /* 获取QQ腾讯用户的详细信息 */ | 210 | /* 获取QQ腾讯用户的详细信息 */ |
123 | $partnerInfo = $qqconnect->getUserInfo($access); | 211 | $partnerInfo = $qqconnect->getUserInfo($access); |
124 | - var_dump($access, $partnerInfo); | ||
125 | 212 | ||
126 | if ($partnerInfo && is_array($partnerInfo)) | 213 | if ($partnerInfo && is_array($partnerInfo)) |
127 | { | 214 | { |
@@ -129,9 +216,12 @@ class LoginController extends AbstractAction | @@ -129,9 +216,12 @@ class LoginController extends AbstractAction | ||
129 | 216 | ||
130 | if($result['code'] == 200) | 217 | if($result['code'] == 200) |
131 | { | 218 | { |
132 | - echo '登陆成功'; | 219 | + $redirect = $this->_request->getCookie('qq_redirect'); |
220 | + $redirect && $this->redirect($redirect); | ||
133 | } | 221 | } |
134 | - } | 222 | + } |
223 | + | ||
224 | + $this->redirect('/'); | ||
135 | } | 225 | } |
136 | 226 | ||
137 | /** | 227 | /** |
@@ -143,7 +233,6 @@ class LoginController extends AbstractAction | @@ -143,7 +233,6 @@ class LoginController extends AbstractAction | ||
143 | $access = $sina->getAccessToken(); | 233 | $access = $sina->getAccessToken(); |
144 | /* 获取QQ腾讯用户的详细信息 */ | 234 | /* 获取QQ腾讯用户的详细信息 */ |
145 | $partnerInfo = $sina->getUserInfo($access); | 235 | $partnerInfo = $sina->getUserInfo($access); |
146 | - var_dump($access, $partnerInfo); | ||
147 | 236 | ||
148 | if ($partnerInfo && is_array($partnerInfo)) | 237 | if ($partnerInfo && is_array($partnerInfo)) |
149 | { | 238 | { |
@@ -151,8 +240,11 @@ class LoginController extends AbstractAction | @@ -151,8 +240,11 @@ class LoginController extends AbstractAction | ||
151 | 240 | ||
152 | if($result['code'] == 200) | 241 | if($result['code'] == 200) |
153 | { | 242 | { |
154 | - echo '登陆成功'; | 243 | + $redirect = $this->_request->getCookie('sina_redirect'); |
244 | + $redirect && $this->redirect($redirect); | ||
155 | } | 245 | } |
156 | - } | 246 | + } |
247 | + | ||
248 | + $this->redirect('/'); | ||
157 | } | 249 | } |
158 | } | 250 | } |
1 | <?php | 1 | <?php |
2 | + | ||
2 | use Action\AbstractAction; | 3 | use Action\AbstractAction; |
4 | +use LibModels\Wap\Passport\RegData; | ||
5 | +use Plugin\Helpers; | ||
3 | 6 | ||
7 | +/** | ||
8 | + * 注册的控制器 | ||
9 | + */ | ||
4 | class RegController extends AbstractAction | 10 | class RegController extends AbstractAction |
5 | { | 11 | { |
12 | + /** | ||
13 | + * 注册页 | ||
14 | + */ | ||
6 | public function indexAction() | 15 | public function indexAction() |
7 | { | 16 | { |
8 | - $data = array( | ||
9 | - 'backUrl' => 'm.yohobuy.com', | ||
10 | - 'headerText' => '注册', | ||
11 | - 'isPassportPage' => true, | ||
12 | - 'modulePath' => 'passport/register/register', | ||
13 | - 'countrys' => array( | ||
14 | - array( | ||
15 | - 'areaCode' => '+86', | ||
16 | - 'selected' => true, | ||
17 | - 'name' => '中国' | ||
18 | - ), | ||
19 | - array( | ||
20 | - 'areaCode' => '+864', | ||
21 | - 'name' => '中国香港' | ||
22 | - ) | ||
23 | - ), | ||
24 | - 'countryCode' => '+86' | ||
25 | - ); | ||
26 | - | ||
27 | - $this->_view->assign('title', '注册'); | 17 | + $this->setTitle('注册'); |
18 | + | ||
19 | + $data = array(); | ||
20 | + $data['regIndex'] = true; | ||
21 | + $data['backUrl'] = '/'; | ||
22 | + $data['headerText'] = '注册'; | ||
23 | + $data['isPassportPage'] = true; | ||
24 | + $data['countrys'] = array(); | ||
25 | + | ||
26 | + // 获取地区数据列表 | ||
27 | + $area = RegData::getAreasData(); | ||
28 | + // 有数据 | ||
29 | + if (!empty($area['data'])) { | ||
30 | + $build = array(); | ||
31 | + foreach ($area['data'] as $value) { | ||
32 | + $build = array(); | ||
33 | + $build['areaCode'] = '+' . $value['area']; | ||
34 | + $build['selected'] = $value['area'] === '86'; | ||
35 | + $build['name'] = $value['name']; | ||
36 | + $data['countrys'][] = $build; | ||
37 | + } | ||
38 | + } | ||
39 | + // 没数据 | ||
40 | + else { | ||
41 | + $data['countrys'][0] = array(); | ||
42 | + $data['countrys'][0]['areaCode'] = '+86'; | ||
43 | + $data['countrys'][0]['selected'] = true; | ||
44 | + $data['countrys'][0]['name'] = '中国'; | ||
45 | + } | ||
28 | $this->_view->display('index', $data); | 46 | $this->_view->display('index', $data); |
47 | + | ||
48 | + $data = array(); | ||
49 | + $area = array(); | ||
29 | } | 50 | } |
30 | 51 | ||
52 | + /** | ||
53 | + * 验证码 | ||
54 | + * | ||
55 | + * @param string area 地区编号 | ||
56 | + * @param string mobile 手机号 | ||
57 | + * @param string token 访问TOKEN凭证 | ||
58 | + */ | ||
31 | public function codeAction() | 59 | public function codeAction() |
32 | { | 60 | { |
33 | - $data = array( | ||
34 | - 'backUrl' => 'm.yohobuy.com', | ||
35 | - 'headerText' => '注册', | ||
36 | - 'isPassportPage' => true, | ||
37 | - 'modulePath' => 'passport/register/code', | ||
38 | - 'areaCode' => '+86', | ||
39 | - 'phoneNum' => '15895869035' | ||
40 | - ); | ||
41 | - | ||
42 | - $this->_view->assign('title', '注册-验证码'); | 61 | + $token = $this->get('token'); |
62 | + $mobile = $this->get('mobile'); | ||
63 | + $area = $this->get('area', '86'); | ||
64 | + | ||
65 | + // 判断是否允许访问, 不允许则跳转到错误页面 | ||
66 | + if (!is_string($token) || !is_numeric($mobile) || !Helpers::verifyToken($mobile, $token)) { | ||
67 | + $this->error(); | ||
68 | + } | ||
69 | + | ||
70 | + $this->setTitle('注册-验证码'); | ||
71 | + | ||
72 | + $data = array(); | ||
73 | + $data['regCode'] = true; | ||
74 | + $data['backUrl'] = '/'; | ||
75 | + $data['headerText'] = '注册'; | ||
76 | + $data['isPassportPage'] = true; | ||
77 | + $data['areaCode'] = $area; | ||
78 | + $data['phoneNum'] = $mobile; | ||
79 | + $data['token'] = $token; | ||
80 | + | ||
43 | $this->_view->display('code', $data); | 81 | $this->_view->display('code', $data); |
44 | } | 82 | } |
45 | 83 | ||
84 | + /** | ||
85 | + * 填写密码页面 | ||
86 | + * | ||
87 | + * @param string area 地区编号 | ||
88 | + * @param string mobile 手机号 | ||
89 | + * @param string token 访问TOKEN凭证 | ||
90 | + */ | ||
46 | public function passwordAction() | 91 | public function passwordAction() |
47 | { | 92 | { |
48 | - $data = array( | ||
49 | - 'backUrl' => 'm.yohobuy.com', | ||
50 | - 'headerText' => '注册', | ||
51 | - 'isPassportPage' => true, | ||
52 | - 'modulePath' => 'passport/register/password' | ||
53 | - ); | ||
54 | - | ||
55 | - $this->_view->assign('title', '注册-密码'); | 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; | ||
113 | + | ||
56 | $this->_view->display('password', $data); | 114 | $this->_view->display('password', $data); |
57 | } | 115 | } |
116 | + | ||
117 | + /** | ||
118 | + * 验证注册的手机号 | ||
119 | + * | ||
120 | + * @param string area 地区编号,注意不需要+号 | ||
121 | + * @param string mobile 手机号 | ||
122 | + * @return json | ||
123 | + */ | ||
124 | + public function verifymobileAction() | ||
125 | + { | ||
126 | + $data = array('code' => 400, 'message' => '参数不正确!', 'data' => ''); | ||
127 | + | ||
128 | + do { | ||
129 | + /* 判断是不是AJAX请求 */ | ||
130 | + if (!$this->isAjax()) { | ||
131 | + break; | ||
132 | + } | ||
133 | + | ||
134 | + $mobile = $this->post('mobile'); | ||
135 | + $area = $this->post('area', '86'); | ||
136 | + /* 判断参数是否合法 */ | ||
137 | + if (!is_numeric($mobile) || !is_numeric($area)) { | ||
138 | + break; | ||
139 | + } | ||
140 | + | ||
141 | + /* 向手机发送注册验证码 */ | ||
142 | + $data = RegData::sendCodeToMobile($area, $mobile); | ||
143 | + if (!isset($data['code'])) { | ||
144 | + break; | ||
145 | + } | ||
146 | + | ||
147 | + /* 返回跳转到验证页面的链接*/ | ||
148 | + if ($data['code'] == 200) { | ||
149 | + $token = Helpers::makeToken($mobile); | ||
150 | + $data['data'] = '/passport/reg/code?token='.$token.'&mobile='.$mobile.'&area='.$area; | ||
151 | + } | ||
152 | + | ||
153 | + } while (false); | ||
154 | + | ||
155 | + $this->echoJson($data); | ||
156 | + } | ||
157 | + | ||
158 | + /** | ||
159 | + * 验证注册的识别码 | ||
160 | + * | ||
161 | + * @param string area 地区编号,注意不需要+号 | ||
162 | + * @param string mobile 手机号 | ||
163 | + * @param string token 访问TOKEN凭证 | ||
164 | + * @param int code 验证码, 手机上收到的 | ||
165 | + * @return json | ||
166 | + */ | ||
167 | + public function verifycodeAction() | ||
168 | + { | ||
169 | + $data = array('code' => 400, 'message' => '参数不正确!', 'data' => ''); | ||
170 | + | ||
171 | + do { | ||
172 | + /* 判断是不是AJAX请求 */ | ||
173 | + if (!$this->isAjax()) { | ||
174 | + break; | ||
175 | + } | ||
176 | + | ||
177 | + $mobile = $this->post('mobile'); | ||
178 | + $area = $this->post('area'); | ||
179 | + $code = $this->post('code'); | ||
180 | + /* 判断参数是否合法 */ | ||
181 | + if (!is_numeric($mobile) || !is_numeric($area) || !isset($code)) { | ||
182 | + break; | ||
183 | + } | ||
184 | + | ||
185 | + /* 验证注册的标识码是否有效 */ | ||
186 | + $data = RegData::validMobileCode($area, $mobile, $code); | ||
187 | + if (!isset($data['code'])) { | ||
188 | + break; | ||
189 | + } | ||
190 | + | ||
191 | + /* 返回跳转到设置密码的链接*/ | ||
192 | + if ($data['code'] == 200) { | ||
193 | + $token = Helpers::makeToken($mobile); | ||
194 | + $data['data'] = '/passport/reg/password?token='.$token.'&mobile='.$mobile.'&area='.$area; | ||
195 | + } | ||
196 | + | ||
197 | + } while (false); | ||
198 | + | ||
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); | ||
235 | + } | ||
236 | + | ||
237 | + /** | ||
238 | + * 设置密码 | ||
239 | + * | ||
240 | + * @param string area 地区编号,注意不需要+号 | ||
241 | + * @param string mobile 手机号 | ||
242 | + * @param string token 访问TOKEN凭证 | ||
243 | + * @param string password 用户设置的密码 | ||
244 | + * @return json | ||
245 | + */ | ||
246 | + public function setpasswordAction() | ||
247 | + { | ||
248 | + $data = array('code' => 400, 'message' => '密码格式不正确!', 'data' => ''); | ||
249 | + | ||
250 | + do { | ||
251 | + /* 判断是不是AJAX请求 */ | ||
252 | + if (!$this->isAjax()) { | ||
253 | + break; | ||
254 | + } | ||
255 | + | ||
256 | + $token = $this->post('token'); | ||
257 | + $mobile = $this->post('mobile'); | ||
258 | + $area = $this->post('area'); | ||
259 | + $password = $this->post('password'); | ||
260 | + /* 判断参数是否合法 */ | ||
261 | + if (!is_string($token) || !is_numeric($mobile) || !is_numeric($area) || !isset($password)) { | ||
262 | + break; | ||
263 | + } | ||
264 | + | ||
265 | + /* 判断是否允许访问 */ | ||
266 | + if (!Helpers::verifyToken($mobile, $token)) { | ||
267 | + break; | ||
268 | + } | ||
269 | + | ||
270 | + /* 验证注册的标识码是否有效 */ | ||
271 | + $data = RegData::regMobile($area, $mobile, $password); | ||
272 | + if (!isset($data['code'])) { | ||
273 | + break; | ||
274 | + } | ||
275 | + | ||
276 | + /* 返回跳转到来源页面 */ | ||
277 | + if ($data['code'] == 200) { | ||
278 | + $data['data'] = '/passport/reg/password?token='.$token.'&mobile='.$mobile.'&area='.$area; | ||
279 | + } | ||
280 | + | ||
281 | + } while (false); | ||
282 | + | ||
283 | + $this->echoJson($data); | ||
284 | + } | ||
285 | + | ||
58 | } | 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