正在显示
1 个修改的文件
包含
5 行增加
和
5 行删除
@@ -29,9 +29,13 @@ class Login extends Base | @@ -29,9 +29,13 @@ class Login extends Base | ||
29 | $code = $post['code'];// I('post.code'); | 29 | $code = $post['code'];// I('post.code'); |
30 | $encryptedData = $post['encryptedData'];//I('post.encryptedData'); | 30 | $encryptedData = $post['encryptedData'];//I('post.encryptedData'); |
31 | $iv = $post['iv'];//I('post.iv'); | 31 | $iv = $post['iv'];//I('post.iv'); |
32 | + //file_put_contents("ccc_v2.txt", "授权0-提交的内容:" . date("Y-m-d H:i:s") . json_encode($post) . PHP_EOL, FILE_APPEND); | ||
32 | $url = "https://api.weixin.qq.com/sns/jscode2session?appid=" . $appid . "&secret=" . $AppSecret . "&js_code=" . $code . "&grant_type=authorization_code"; | 33 | $url = "https://api.weixin.qq.com/sns/jscode2session?appid=" . $appid . "&secret=" . $AppSecret . "&js_code=" . $code . "&grant_type=authorization_code"; |
34 | + //file_put_contents("1.txt","8-1. ".($code)."\r\n",FILE_APPEND); | ||
33 | $result = http_request($url); | 35 | $result = http_request($url); |
36 | + //file_put_contents("111111111111222.txt","3-1. ".($result)."\r\n",FILE_APPEND); | ||
34 | $res = json_decode($result, true); | 37 | $res = json_decode($result, true); |
38 | + | ||
35 | if (!$res) { | 39 | if (!$res) { |
36 | $this->error("授权失败,请尝试重新授权"); | 40 | $this->error("授权失败,请尝试重新授权"); |
37 | //$res = json_decode(send_post($url), true); | 41 | //$res = json_decode(send_post($url), true); |
@@ -39,11 +43,8 @@ class Login extends Base | @@ -39,11 +43,8 @@ class Login extends Base | ||
39 | //查询到openid 通过openid查询到用户 | 43 | //查询到openid 通过openid查询到用户 |
40 | $user=Db::name("user")->where('wx_xcx_openid',$res['openid'])->find(); | 44 | $user=Db::name("user")->where('wx_xcx_openid',$res['openid'])->find(); |
41 | if($user){ | 45 | if($user){ |
42 | - $res=$this->auth->direct($user['id']); | ||
43 | - $return_data = $this->auth->getUserinfo(); | ||
44 | - $this->success(__('登录成功'), $return_data); | ||
45 | //查询到了用户信息 | 46 | //查询到了用户信息 |
46 | - //$this->bind($user['id'],$user['moblie']); | 47 | + $this->bind($user['id'],$user['moblie']); |
47 | }else{ | 48 | }else{ |
48 | //未查询到用户信息 添加用户信息 | 49 | //未查询到用户信息 添加用户信息 |
49 | $username = $res['openid'] ? $res['openid'] : suiji_num("TY"); | 50 | $username = $res['openid'] ? $res['openid'] : suiji_num("TY"); |
@@ -52,7 +53,6 @@ class Login extends Base | @@ -52,7 +53,6 @@ class Login extends Base | ||
52 | "wx_xcx_openid" => $res['openid'], | 53 | "wx_xcx_openid" => $res['openid'], |
53 | ]; | 54 | ]; |
54 | $ret = $this->auth->register($username, "a123456", '','', $extend_data); | 55 | $ret = $this->auth->register($username, "a123456", '','', $extend_data); |
55 | - | ||
56 | if($ret){ | 56 | if($ret){ |
57 | $return_data = $this->auth->getUserinfo(); | 57 | $return_data = $this->auth->getUserinfo(); |
58 | $this->success('查询用户信息成功2',$return_data); | 58 | $this->success('查询用户信息成功2',$return_data); |
-
请 注册 或 登录 后发表评论