...
|
...
|
@@ -29,9 +29,13 @@ class Login extends Base |
|
|
$code = $post['code'];// I('post.code');
|
|
|
$encryptedData = $post['encryptedData'];//I('post.encryptedData');
|
|
|
$iv = $post['iv'];//I('post.iv');
|
|
|
//file_put_contents("ccc_v2.txt", "授权0-提交的内容:" . date("Y-m-d H:i:s") . json_encode($post) . PHP_EOL, FILE_APPEND);
|
|
|
$url = "https://api.weixin.qq.com/sns/jscode2session?appid=" . $appid . "&secret=" . $AppSecret . "&js_code=" . $code . "&grant_type=authorization_code";
|
|
|
//file_put_contents("1.txt","8-1. ".($code)."\r\n",FILE_APPEND);
|
|
|
$result = http_request($url);
|
|
|
//file_put_contents("111111111111222.txt","3-1. ".($result)."\r\n",FILE_APPEND);
|
|
|
$res = json_decode($result, true);
|
|
|
|
|
|
if (!$res) {
|
|
|
$this->error("授权失败,请尝试重新授权");
|
|
|
//$res = json_decode(send_post($url), true);
|
...
|
...
|
@@ -39,11 +43,8 @@ class Login extends Base |
|
|
//查询到openid 通过openid查询到用户
|
|
|
$user=Db::name("user")->where('wx_xcx_openid',$res['openid'])->find();
|
|
|
if($user){
|
|
|
$res=$this->auth->direct($user['id']);
|
|
|
$return_data = $this->auth->getUserinfo();
|
|
|
$this->success(__('登录成功'), $return_data);
|
|
|
//查询到了用户信息
|
|
|
//$this->bind($user['id'],$user['moblie']);
|
|
|
$this->bind($user['id'],$user['moblie']);
|
|
|
}else{
|
|
|
//未查询到用户信息 添加用户信息
|
|
|
$username = $res['openid'] ? $res['openid'] : suiji_num("TY");
|
...
|
...
|
@@ -52,7 +53,6 @@ class Login extends Base |
|
|
"wx_xcx_openid" => $res['openid'],
|
|
|
];
|
|
|
$ret = $this->auth->register($username, "a123456", '','', $extend_data);
|
|
|
|
|
|
if($ret){
|
|
|
$return_data = $this->auth->getUserinfo();
|
|
|
$this->success('查询用户信息成功2',$return_data);
|
...
|
...
|
|