Showing
1 changed file
with
43 additions
and
14 deletions
@@ -9,6 +9,7 @@ use Configs\ChannelConfig; | @@ -9,6 +9,7 @@ use Configs\ChannelConfig; | ||
9 | use WebPlugin\Images; | 9 | use WebPlugin\Images; |
10 | use WebPlugin\Captcha; | 10 | use WebPlugin\Captcha; |
11 | use WebPlugin\Cache; | 11 | use WebPlugin\Cache; |
12 | +use WebPlugin\Helpers; | ||
12 | 13 | ||
13 | /** | 14 | /** |
14 | * web登录注册等相关数据构建 | 15 | * web登录注册等相关数据构建 |
@@ -28,7 +29,6 @@ class PassportModel | @@ -28,7 +29,6 @@ class PassportModel | ||
28 | const AUTOUSERINFO_LEFT_BANNER_CODE = 'c62d5da06d843b6ed78d8d27e87fa143'; //完善信息页左边的banner | 29 | const AUTOUSERINFO_LEFT_BANNER_CODE = 'c62d5da06d843b6ed78d8d27e87fa143'; //完善信息页左边的banner |
29 | const BACK_FIND_SECRET_KEY = '_+@#$%^'; | 30 | const BACK_FIND_SECRET_KEY = '_+@#$%^'; |
30 | 31 | ||
31 | - | ||
32 | /** | 32 | /** |
33 | * 获取左侧banner | 33 | * 获取左侧banner |
34 | * | 34 | * |
@@ -98,13 +98,13 @@ class PassportModel | @@ -98,13 +98,13 @@ class PassportModel | ||
98 | */ | 98 | */ |
99 | public static function getUserInfoByMobile($area, $mobile) | 99 | public static function getUserInfoByMobile($area, $mobile) |
100 | { | 100 | { |
101 | - $key = WebCacheConfig::KEY_PASSPORT_USER_DATA.'_'.$area.'_'.$mobile; | 101 | + $key = WebCacheConfig::KEY_PASSPORT_USER_DATA . '_' . $area . '_' . $mobile; |
102 | $ret = Cache::get($key); | 102 | $ret = Cache::get($key); |
103 | - if(empty($ret)) { | 103 | + if (empty($ret)) { |
104 | $data = UserData::getUserInfoByMobile($area, $mobile); | 104 | $data = UserData::getUserInfoByMobile($area, $mobile); |
105 | if ($data['code'] == 200) { | 105 | if ($data['code'] == 200) { |
106 | if (!empty($data['data'])) { | 106 | if (!empty($data['data'])) { |
107 | - $ret = current($data['data']); | 107 | + $ret = $data['data']; |
108 | Cache::set($key, $ret, 600); | 108 | Cache::set($key, $ret, 600); |
109 | } | 109 | } |
110 | } | 110 | } |
@@ -120,13 +120,13 @@ class PassportModel | @@ -120,13 +120,13 @@ class PassportModel | ||
120 | */ | 120 | */ |
121 | public static function getUserInfoByEmail($email) | 121 | public static function getUserInfoByEmail($email) |
122 | { | 122 | { |
123 | - $key = WebCacheConfig::KEY_PASSPORT_USER_DATA.'_'.$email; | 123 | + $key = WebCacheConfig::KEY_PASSPORT_USER_DATA . '_' . $email; |
124 | $ret = Cache::get($key); | 124 | $ret = Cache::get($key); |
125 | - if(empty($ret)) { | 125 | + if (empty($ret)) { |
126 | $data = UserData::getUserInfoByEmail($email); | 126 | $data = UserData::getUserInfoByEmail($email); |
127 | if ($data['code'] == 200) { | 127 | if ($data['code'] == 200) { |
128 | if (!empty($data['data'])) { | 128 | if (!empty($data['data'])) { |
129 | - $ret = current($data['data']); | 129 | + $ret = $data['data']; |
130 | Cache::set($key, $ret, 600); | 130 | Cache::set($key, $ret, 600); |
131 | } | 131 | } |
132 | } | 132 | } |
@@ -141,15 +141,15 @@ class PassportModel | @@ -141,15 +141,15 @@ class PassportModel | ||
141 | public static function emailBindCheck($email) | 141 | public static function emailBindCheck($email) |
142 | { | 142 | { |
143 | $ret = false; | 143 | $ret = false; |
144 | - $key = WebCacheConfig::KEY_PASSPORT_USER_DATA.'_bind_'.$email; | 144 | + $key = WebCacheConfig::KEY_PASSPORT_USER_DATA . '_bind_' . $email; |
145 | $userInfo = Cache::get($key); | 145 | $userInfo = Cache::get($key); |
146 | - if(empty($userInfo)) { | 146 | + if (empty($userInfo)) { |
147 | $userInfo = UserData::getUserInfoByEmail($email); | 147 | $userInfo = UserData::getUserInfoByEmail($email); |
148 | - if($userInfo['code'] == 200 && !empty($userInfo['data'])) { | 148 | + if ($userInfo['code'] == 200 && !empty($userInfo['data'])) { |
149 | Cache::set($key, $userInfo, 600); | 149 | Cache::set($key, $userInfo, 600); |
150 | } | 150 | } |
151 | } | 151 | } |
152 | - $user = isset($userInfo['data']) ? current($userInfo['data']) : ''; | 152 | + $user = isset($userInfo['data']) ? $userInfo['data'] : ''; |
153 | if (isset($user['mobile']) && !$user['mobile']) { | 153 | if (isset($user['mobile']) && !$user['mobile']) { |
154 | $ret = true; | 154 | $ret = true; |
155 | } | 155 | } |
@@ -161,15 +161,44 @@ class PassportModel | @@ -161,15 +161,44 @@ class PassportModel | ||
161 | */ | 161 | */ |
162 | public static function redirectHome($url) | 162 | public static function redirectHome($url) |
163 | { | 163 | { |
164 | - $ret=false; | 164 | + $ret = false; |
165 | $keyArr = ChannelConfig::$loginUrlKeys; | 165 | $keyArr = ChannelConfig::$loginUrlKeys; |
166 | foreach ($keyArr as $key) { | 166 | foreach ($keyArr as $key) { |
167 | - if(strstr($url, $key)){ | ||
168 | - $ret=true; | 167 | + if (strstr($url, $key)) { |
168 | + $ret = true; | ||
169 | break; | 169 | break; |
170 | } | 170 | } |
171 | } | 171 | } |
172 | return $ret; | 172 | return $ret; |
173 | } | 173 | } |
174 | 174 | ||
175 | + /** | ||
176 | + * 第三方登录 根据手机号获取用户相关信息 | ||
177 | + */ | ||
178 | + public static function getUserInfo($area, $mobile) | ||
179 | + { | ||
180 | + $userInfo = UserData::getUserInfoByMobile($area, $mobile); | ||
181 | + $user = array('username' => '', 'headImg' => '', 'bindLogin' => ''); | ||
182 | + $userTmp = array(); | ||
183 | + if (isset($userInfo['data'])) { | ||
184 | + $userTmp = $userInfo['data']; | ||
185 | + } | ||
186 | + if ($userTmp) { | ||
187 | + //*号临时处理 | ||
188 | + $profileName = isset($userTmp['profile_name']) ? trim($userTmp['profile_name']) : ''; | ||
189 | + if (!$profileName) { | ||
190 | + $profileName = $mobile; | ||
191 | + } | ||
192 | + if ((strlen($profileName) == 11 && !strpos('*', $profileName)) || (strpos($profileName, "-") && !strpos('*', $profileName))) { | ||
193 | + $profileName = substr_replace($profileName, '****', 3, 4); | ||
194 | + } | ||
195 | + $user = array( | ||
196 | + 'username' => $profileName, | ||
197 | + 'headImg' => (isset($userTmp['head_ico']) && !empty($userTmp['head_ico'])) ? Images::getImageUrl($userTmp['head_ico'], 100, 100, 2, 'yhb-head') : ChannelConfig::$headDefaultImgIco, | ||
198 | + 'bindLogin' => Helpers::url('/signin.html', array('bindMobile' => $mobile, 'bindArea' => $area)), | ||
199 | + ); | ||
200 | + } | ||
201 | + return $user; | ||
202 | + } | ||
203 | + | ||
175 | } | 204 | } |
-
Please register or login to post a comment