...
|
...
|
@@ -370,36 +370,7 @@ class LoginController extends HomeBaseController |
|
|
if(!isset($json_arr['access_token'])&&empty($json_arr['access_token'])){
|
|
|
$this->redirect('/portal/login/thirdLogin');
|
|
|
}
|
|
|
$token = $json_arr['access_token'];
|
|
|
$openid = $json_arr['openid'];
|
|
|
//通过access_token获取用户信息
|
|
|
$url1 = 'https://api.weixin.qq.com/sns/userinfo?access_token='.$token.'&openid='.$openid.'&lang=zh_CN';
|
|
|
$res1 = $this->http_get($url1);
|
|
|
$info = json_decode($res1,true);
|
|
|
//查询该微信用户是否存在
|
|
|
$where = ['wb_id'=>$info['unionid'],'source'=>'微信'];
|
|
|
$user = $this->findThird($where);
|
|
|
//获取微博id,昵称,头像
|
|
|
$userModel = new UserModel();
|
|
|
$ip = get_client_ip();
|
|
|
$users['last_login_time'] = time();
|
|
|
$users['last_login_ip'] = $ip;
|
|
|
if($user){
|
|
|
$users['user_nickname'] = $info['nickname'];
|
|
|
$users['avatar'] = $info['headimgurl'];
|
|
|
$userModel->where(['wb_id'=>$info['openid'],'source'=>'微信'])->update($users);
|
|
|
}else{
|
|
|
$users['wb_id'] = $info['unionid'];
|
|
|
$users['user_nickname'] = $info['nickname'];
|
|
|
$users['avatar'] = $info['headimgurl'];
|
|
|
$users['source'] = '微信';
|
|
|
$users['user_type'] = 2;
|
|
|
$users['create_time'] = time();
|
|
|
$userModel->create($users);
|
|
|
}
|
|
|
$userInfo = $this->findThird($where);
|
|
|
cmf_update_current_user($userInfo);
|
|
|
$this->redirect('/');
|
|
|
$this->getWxInfo($json_arr);
|
|
|
}
|
|
|
|
|
|
//第三方微信移动端网页登录
|
...
|
...
|
@@ -412,6 +383,11 @@ class LoginController extends HomeBaseController |
|
|
//用户登录
|
|
|
$this->redirect('/portal/login/login');
|
|
|
}
|
|
|
$this->getWxInfo($json_arr);
|
|
|
}
|
|
|
|
|
|
//获取第三方扫码,移动端微信授权之后的头像,昵称
|
|
|
public function getWxInfo($json_arr){
|
|
|
$token = $json_arr['access_token'];
|
|
|
$openid = $json_arr['openid'];
|
|
|
//通过access_token获取用户信息
|
...
|
...
|
|