Merge branch 'develop' of http://git.dev.yoho.cn/web/yohobuy into feature/web-list
Showing
4 changed files
with
91 additions
and
90 deletions
@@ -160,4 +160,67 @@ class CommonController extends WebAction | @@ -160,4 +160,67 @@ class CommonController extends WebAction | ||
160 | } | 160 | } |
161 | } | 161 | } |
162 | 162 | ||
163 | + /* | ||
164 | + * 简单头部 | ||
165 | + */ | ||
166 | + | ||
167 | + public function getSimpleHeaderAction() | ||
168 | + { | ||
169 | + $result = array(); | ||
170 | + do { | ||
171 | + /* 判断是不是AJAX请求 */ | ||
172 | + if (!$this->isAjax()) { | ||
173 | + break; | ||
174 | + } | ||
175 | + | ||
176 | + //获取用户 | ||
177 | + $uid = $this->getUid(true); | ||
178 | + if (!$uid) { | ||
179 | + $isLogin = false; | ||
180 | + $username = ''; | ||
181 | + } | ||
182 | + else { | ||
183 | + $isLogin = true; | ||
184 | + $username = $this->_uname; | ||
185 | + } | ||
186 | + //拼接简单头部 | ||
187 | + $tool = array( | ||
188 | + 'favorite' => Helpers::url('/home/favorite?t=' . time()), //我的收藏链接 | ||
189 | + 'coupon' => Helpers::url('/home/coupons?t=' . time()), //我的优惠券链接 | ||
190 | + 'order' => Helpers::url('/home/orders?t=' . time()), //订单中心连接 | ||
191 | + 'help' => Helpers::url('/help'), | ||
192 | + ); | ||
193 | + if ($isLogin) { | ||
194 | + $tool+=array( | ||
195 | + 'user' => $username, | ||
196 | + 'userCenter' => Helpers::url('/home?t=' . time()), //用户中心链接 | ||
197 | + 'logout' => Helpers::url('/logout.html?t=' . time()), //退出 | ||
198 | + ); | ||
199 | + } | ||
200 | + else { | ||
201 | + $tool+=array( | ||
202 | + 'login' => Helpers::url('/signin.html'), //登录链接,已登录不传 | ||
203 | + 'register' => Helpers::url('/reg.html'), //注册链接,已登录不传 | ||
204 | + ); | ||
205 | + } | ||
206 | + | ||
207 | + $simpleHeader = array( | ||
208 | + 'user' => $username, | ||
209 | + 'href' => $tool, | ||
210 | + 'logo' => array( | ||
211 | + 'img' => 'http://static.yohobuy.com/newheader/img/logo_e.png', | ||
212 | + 'url' => SITE_MAIN | ||
213 | + ), | ||
214 | + ); | ||
215 | + | ||
216 | + $result = array( | ||
217 | + 'code' => 200, | ||
218 | + 'data' => $simpleHeader | ||
219 | + ); | ||
220 | + } | ||
221 | + while (false); | ||
222 | + | ||
223 | + $this->echoJson($result); | ||
224 | + } | ||
225 | + | ||
163 | } | 226 | } |
@@ -20,26 +20,27 @@ use Plugin\Captcha; | @@ -20,26 +20,27 @@ use Plugin\Captcha; | ||
20 | class PassportModel | 20 | class PassportModel |
21 | { | 21 | { |
22 | 22 | ||
23 | - const REGISTER_LEFT_BANNER_CODE = 'c479ec90120cae7f96e52922b4917064';//注册左边的banner | ||
24 | - const BACK_LFFT_BANNER_CODE = '3bbaf502c447a2ddad60879042e286d8';//找回密码左边的banner | ||
25 | - const SIGNIN_LEFT_BANNER_CODE ='db350894e01e90eac55cd3a13ad77331';//登录页左边的banner | ||
26 | - const AUTOUSERINFO_LEFT_BANNER_CODE ='c62d5da06d843b6ed78d8d27e87fa143';//完善信息页左边的banner | 23 | + const REGISTER_LEFT_BANNER_CODE = 'c479ec90120cae7f96e52922b4917064'; //注册左边的banner |
24 | + const BACK_LFFT_BANNER_CODE = '3bbaf502c447a2ddad60879042e286d8'; //找回密码左边的banner | ||
25 | + const SIGNIN_LEFT_BANNER_CODE = 'db350894e01e90eac55cd3a13ad77331'; //登录页左边的banner | ||
26 | + const AUTOUSERINFO_LEFT_BANNER_CODE = 'c62d5da06d843b6ed78d8d27e87fa143'; //完善信息页左边的banner | ||
27 | const BACK_FIND_SECRET_KEY = '_+@#$%^'; | 27 | const BACK_FIND_SECRET_KEY = '_+@#$%^'; |
28 | 28 | ||
29 | //简单头部 | 29 | //简单头部 |
30 | public static function getSimpleHeader($isLogin, $username = '') | 30 | public static function getSimpleHeader($isLogin, $username = '') |
31 | { | 31 | { |
32 | + //拼接简单头部 | ||
32 | $tool = array( | 33 | $tool = array( |
33 | - 'favoriteHref' => Helpers::url('/home/favorite/index'), //我的收藏链接 | ||
34 | - 'couponHref' => Helpers::url('/home/coupons/index'), //我的优惠券链接 | ||
35 | - 'orderHref' => Helpers::url('/home/orders/index'), //订单中心连接 | 34 | + 'favoriteHref' => Helpers::url('/home/favorite?t=' . time()), //我的收藏链接 |
35 | + 'couponHref' => Helpers::url('/home/coupons?t=' . time()), //我的优惠券链接 | ||
36 | + 'orderHref' => Helpers::url('/home/orders?t=' . time()), //订单中心连接 | ||
36 | 'helpHref' => Helpers::url('/help'), | 37 | 'helpHref' => Helpers::url('/help'), |
37 | ); | 38 | ); |
38 | if ($isLogin) { | 39 | if ($isLogin) { |
39 | $tool+=array( | 40 | $tool+=array( |
40 | 'user' => $username, | 41 | 'user' => $username, |
41 | - 'userCenter' => Helpers::url('/home/index'), //用户中心链接 | ||
42 | - 'logoutHref' => Helpers::url('/passport/signout/index'), //退出 | 42 | + 'userCenter' => Helpers::url('/home?t=' . time()), //用户中心链接 |
43 | + 'logoutHref' => Helpers::url('/logout.html?t=' . time()), //退出 | ||
43 | ); | 44 | ); |
44 | } | 45 | } |
45 | else { | 46 | else { |
@@ -68,13 +69,13 @@ class PassportModel | @@ -68,13 +69,13 @@ class PassportModel | ||
68 | */ | 69 | */ |
69 | public static function getLeftBanner($code) | 70 | public static function getLeftBanner($code) |
70 | { | 71 | { |
71 | - $ret = array('img'=>'','url'=>''); | 72 | + $ret = array('img' => '', 'url' => ''); |
72 | $resource = IndexData::getResourceData($code); | 73 | $resource = IndexData::getResourceData($code); |
73 | - if(isset($resource['data'][0])) | ||
74 | - { | ||
75 | - if($resource['data'][0]['template_name'] == 'single_image') { | 74 | + if (isset($resource['data'][0])) { |
75 | + if ($resource['data'][0]['template_name'] == 'single_image') { | ||
76 | $val = current($resource['data'][0]['data']); | 76 | $val = current($resource['data'][0]['data']); |
77 | - } else if($resource['data'][0]['template_name'] == 'single_name_image') { | 77 | + } |
78 | + else if ($resource['data'][0]['template_name'] == 'single_name_image') { | ||
78 | $val = $resource['data'][0]['data']; | 79 | $val = $resource['data'][0]['data']; |
79 | } | 80 | } |
80 | $ret['img'] = Images::getImageUrl($val['src'], 252, 190); | 81 | $ret['img'] = Images::getImageUrl($val['src'], 252, 190); |
@@ -98,7 +99,7 @@ class PassportModel | @@ -98,7 +99,7 @@ class PassportModel | ||
98 | $verifyCode = strtolower($verifyCode); | 99 | $verifyCode = strtolower($verifyCode); |
99 | $ret = true; | 100 | $ret = true; |
100 | //检测验证码不正确 | 101 | //检测验证码不正确 |
101 | - if($verifyCode != strtolower(Captcha::getFromSession('passport_istration'))) { | 102 | + if ($verifyCode != strtolower(Captcha::getFromSession('passport_istration'))) { |
102 | $ret = false; | 103 | $ret = false; |
103 | } | 104 | } |
104 | return $ret; | 105 | return $ret; |
@@ -111,11 +112,12 @@ class PassportModel | @@ -111,11 +112,12 @@ class PassportModel | ||
111 | * @param string $mobile | 112 | * @param string $mobile |
112 | * @return array | 113 | * @return array |
113 | */ | 114 | */ |
114 | - public static function getUserInfoByMobile($area, $mobile) { | 115 | + public static function getUserInfoByMobile($area, $mobile) |
116 | + { | ||
115 | $ret = array(); | 117 | $ret = array(); |
116 | $data = UserData::getUserInfoByMobile($area, $mobile); | 118 | $data = UserData::getUserInfoByMobile($area, $mobile); |
117 | - if($data['code'] == 200) { | ||
118 | - if(!empty($data['data'])) { | 119 | + if ($data['code'] == 200) { |
120 | + if (!empty($data['data'])) { | ||
119 | $ret = current($data['data']); | 121 | $ret = current($data['data']); |
120 | } | 122 | } |
121 | } | 123 | } |
@@ -128,14 +130,16 @@ class PassportModel | @@ -128,14 +130,16 @@ class PassportModel | ||
128 | * @param string $email | 130 | * @param string $email |
129 | * @return array | 131 | * @return array |
130 | */ | 132 | */ |
131 | - public static function getUserInfoByEmail($email) { | 133 | + public static function getUserInfoByEmail($email) |
134 | + { | ||
132 | $ret = array(); | 135 | $ret = array(); |
133 | $data = UserData::getUserInfoByEmail($email); | 136 | $data = UserData::getUserInfoByEmail($email); |
134 | - if($data['code'] == 200) { | ||
135 | - if(!empty($data['data'])) { | 137 | + if ($data['code'] == 200) { |
138 | + if (!empty($data['data'])) { | ||
136 | $ret = current($data['data']); | 139 | $ret = current($data['data']); |
137 | } | 140 | } |
138 | } | 141 | } |
139 | return $ret; | 142 | return $ret; |
140 | } | 143 | } |
144 | + | ||
141 | } | 145 | } |
@@ -5,6 +5,7 @@ use LibModels\Web\Passport\RegData; | @@ -5,6 +5,7 @@ use LibModels\Web\Passport\RegData; | ||
5 | use LibModels\Web\Passport\LoginData; | 5 | use LibModels\Web\Passport\LoginData; |
6 | use Passport\PassportModel as PassportModel; | 6 | use Passport\PassportModel as PassportModel; |
7 | use Plugin\Helpers; | 7 | use Plugin\Helpers; |
8 | + | ||
8 | class LoginController extends WebAction | 9 | class LoginController extends WebAction |
9 | { | 10 | { |
10 | 11 | ||
@@ -93,7 +94,6 @@ class LoginController extends WebAction | @@ -93,7 +94,6 @@ class LoginController extends WebAction | ||
93 | $account = trim($this->post('account')); | 94 | $account = trim($this->post('account')); |
94 | $password = trim($this->post('password')); | 95 | $password = trim($this->post('password')); |
95 | $isRemember = trim($this->post('isRemember')); | 96 | $isRemember = trim($this->post('isRemember')); |
96 | - $isRemember = false; | ||
97 | if (!is_numeric($area) || empty($account) || empty($password)) { | 97 | if (!is_numeric($area) || empty($account) || empty($password)) { |
98 | break; | 98 | break; |
99 | } | 99 | } |
@@ -119,17 +119,6 @@ class LoginController extends WebAction | @@ -119,17 +119,6 @@ class LoginController extends WebAction | ||
119 | if (!isset($data['code']) || $data['code'] != 200 || !isset($data['data']['uid'])) { | 119 | if (!isset($data['code']) || $data['code'] != 200 || !isset($data['data']['uid'])) { |
120 | break; | 120 | break; |
121 | } | 121 | } |
122 | - //登录成功记录账户信息 | ||
123 | - if ($isRemember) { | ||
124 | - $this->setCookie('account', $this->encrypt($account), time() + 3600 * 24 * 7, '/'); | ||
125 | - $this->setCookie('userInfo', $this->encrypt($password), time() + 3600 * 24 * 7, '/'); | ||
126 | - $this->setCookie('isRemember', $isRemember, time() + 3600 * 24 * 7); | ||
127 | - } | ||
128 | - else { | ||
129 | - $this->setCookie('account', '', -1, '/'); | ||
130 | - $this->setCookie('userInfo', '', -1, '/'); | ||
131 | - $this->setCookie('isRemember', '', -1, '/'); | ||
132 | - } | ||
133 | 122 | ||
134 | $refer = $this->getCookie('refer'); | 123 | $refer = $this->getCookie('refer'); |
135 | if (empty($refer) || strstr($refer, 'signin.html') || strstr($refer, 'passport/login/index')) { | 124 | if (empty($refer) || strstr($refer, 'signin.html') || strstr($refer, 'passport/login/index')) { |
@@ -138,7 +127,7 @@ class LoginController extends WebAction | @@ -138,7 +127,7 @@ class LoginController extends WebAction | ||
138 | else { | 127 | else { |
139 | $refer = rawurldecode($refer); | 128 | $refer = rawurldecode($refer); |
140 | } | 129 | } |
141 | - $data['data']['session'] = Helpers::syncUserSession($data['data']['uid'],$refer); | 130 | + $data['data']['session'] = Helpers::syncUserSession($data['data']['uid'], $refer); |
142 | $data['data']['href'] = $refer; | 131 | $data['data']['href'] = $refer; |
143 | 132 | ||
144 | $token = Helpers::makeToken($data['data']['uid']); | 133 | $token = Helpers::makeToken($data['data']['uid']); |
@@ -172,59 +161,4 @@ class LoginController extends WebAction | @@ -172,59 +161,4 @@ class LoginController extends WebAction | ||
172 | $this->go($refer); | 161 | $this->go($refer); |
173 | } | 162 | } |
174 | 163 | ||
175 | - /* | ||
176 | - * 加密算法 | ||
177 | - */ | ||
178 | - | ||
179 | - private function encrypt($data, $key='yohobuy') | ||
180 | - { | ||
181 | - $key = md5($key); | ||
182 | - $x = 0; | ||
183 | - $str=''; | ||
184 | - $char=''; | ||
185 | - $len = strlen($data); | ||
186 | - $l = strlen($key); | ||
187 | - for ($i = 0; $i < $len; $i++) { | ||
188 | - if ($x == $l) { | ||
189 | - $x = 0; | ||
190 | - } | ||
191 | - $char .= $key{$x}; | ||
192 | - $x++; | ||
193 | - } | ||
194 | - for ($i = 0; $i < $len; $i++) { | ||
195 | - $str .= chr(ord($data{$i}) + (ord($char{$i})) % 256); | ||
196 | - } | ||
197 | - return base64_encode($str); | ||
198 | - } | ||
199 | - | ||
200 | - /* | ||
201 | - * 解密算法 | ||
202 | - */ | ||
203 | - | ||
204 | - private function decrypt($data, $key='yohobuy') | ||
205 | - { | ||
206 | - $key = md5($key); | ||
207 | - $x = 0; | ||
208 | - $str=''; | ||
209 | - $char=''; | ||
210 | - $data = base64_decode($data); | ||
211 | - $len = strlen($data); | ||
212 | - $l = strlen($key); | ||
213 | - for ($i = 0; $i < $len; $i++) { | ||
214 | - if ($x == $l) { | ||
215 | - $x = 0; | ||
216 | - } | ||
217 | - $char .= substr($key, $x, 1); | ||
218 | - $x++; | ||
219 | - } | ||
220 | - for ($i = 0; $i < $len; $i++) { | ||
221 | - if (ord(substr($data, $i, 1)) < ord(substr($char, $i, 1))) { | ||
222 | - $str .= chr((ord(substr($data, $i, 1)) + 256) - ord(substr($char, $i, 1))); | ||
223 | - } | ||
224 | - else { | ||
225 | - $str .= chr(ord(substr($data, $i, 1)) - ord(substr($char, $i, 1))); | ||
226 | - } | ||
227 | - } | ||
228 | - return $str; | ||
229 | - } | ||
230 | } | 164 | } |
@@ -21,7 +21,7 @@ routes.login.route.action = Index | @@ -21,7 +21,7 @@ routes.login.route.action = Index | ||
21 | 21 | ||
22 | ; 登录退出页 | 22 | ; 登录退出页 |
23 | routes.logout.type = "rewrite" | 23 | routes.logout.type = "rewrite" |
24 | -routes.logout.match = "/passport/signout/index" | 24 | +routes.logout.match = "/logout.html" |
25 | routes.logout.route.module = Passport | 25 | routes.logout.route.module = Passport |
26 | routes.logout.route.controller = Login | 26 | routes.logout.route.controller = Login |
27 | routes.logout.route.action = Out | 27 | routes.logout.route.action = Out |
-
Please register or login to post a comment