正在显示
1 个修改的文件
包含
6 行增加
和
30 行删除
@@ -370,36 +370,7 @@ class LoginController extends HomeBaseController | @@ -370,36 +370,7 @@ class LoginController extends HomeBaseController | ||
370 | if(!isset($json_arr['access_token'])&&empty($json_arr['access_token'])){ | 370 | if(!isset($json_arr['access_token'])&&empty($json_arr['access_token'])){ |
371 | $this->redirect('/portal/login/thirdLogin'); | 371 | $this->redirect('/portal/login/thirdLogin'); |
372 | } | 372 | } |
373 | - $token = $json_arr['access_token']; | ||
374 | - $openid = $json_arr['openid']; | ||
375 | - //通过access_token获取用户信息 | ||
376 | - $url1 = 'https://api.weixin.qq.com/sns/userinfo?access_token='.$token.'&openid='.$openid.'&lang=zh_CN'; | ||
377 | - $res1 = $this->http_get($url1); | ||
378 | - $info = json_decode($res1,true); | ||
379 | - //查询该微信用户是否存在 | ||
380 | - $where = ['wb_id'=>$info['unionid'],'source'=>'微信']; | ||
381 | - $user = $this->findThird($where); | ||
382 | - //获取微博id,昵称,头像 | ||
383 | - $userModel = new UserModel(); | ||
384 | - $ip = get_client_ip(); | ||
385 | - $users['last_login_time'] = time(); | ||
386 | - $users['last_login_ip'] = $ip; | ||
387 | - if($user){ | ||
388 | - $users['user_nickname'] = $info['nickname']; | ||
389 | - $users['avatar'] = $info['headimgurl']; | ||
390 | - $userModel->where(['wb_id'=>$info['openid'],'source'=>'微信'])->update($users); | ||
391 | - }else{ | ||
392 | - $users['wb_id'] = $info['unionid']; | ||
393 | - $users['user_nickname'] = $info['nickname']; | ||
394 | - $users['avatar'] = $info['headimgurl']; | ||
395 | - $users['source'] = '微信'; | ||
396 | - $users['user_type'] = 2; | ||
397 | - $users['create_time'] = time(); | ||
398 | - $userModel->create($users); | ||
399 | - } | ||
400 | - $userInfo = $this->findThird($where); | ||
401 | - cmf_update_current_user($userInfo); | ||
402 | - $this->redirect('/'); | 373 | + $this->getWxInfo($json_arr); |
403 | } | 374 | } |
404 | 375 | ||
405 | //第三方微信移动端网页登录 | 376 | //第三方微信移动端网页登录 |
@@ -412,6 +383,11 @@ class LoginController extends HomeBaseController | @@ -412,6 +383,11 @@ class LoginController extends HomeBaseController | ||
412 | //用户登录 | 383 | //用户登录 |
413 | $this->redirect('/portal/login/login'); | 384 | $this->redirect('/portal/login/login'); |
414 | } | 385 | } |
386 | + $this->getWxInfo($json_arr); | ||
387 | + } | ||
388 | + | ||
389 | + //获取第三方扫码,移动端微信授权之后的头像,昵称 | ||
390 | + public function getWxInfo($json_arr){ | ||
415 | $token = $json_arr['access_token']; | 391 | $token = $json_arr['access_token']; |
416 | $openid = $json_arr['openid']; | 392 | $openid = $json_arr['openid']; |
417 | //通过access_token获取用户信息 | 393 | //通过access_token获取用户信息 |
-
请 注册 或 登录 后发表评论