作者 郭文星

123

@@ -29,24 +29,19 @@ class Login extends Base @@ -29,24 +29,19 @@ class Login extends Base
29 $encryptedData = $post['encryptedData'];//I('post.encryptedData'); 29 $encryptedData = $post['encryptedData'];//I('post.encryptedData');
30 $iv = $post['iv'];//I('post.iv'); 30 $iv = $post['iv'];//I('post.iv');
31 31
32 -// if ($post['type'] == 1) {  
33 -// $encryptedData = urldecode($encryptedData);  
34 -// $iv = urldecode($iv);  
35 -//// file_put_contents("ccc.txt", "授权A:" . date("Y-m-d H:i:s") . ":" . $encryptedData . PHP_EOL, FILE_APPEND);  
36 -//// file_put_contents("ccc.txt", "授权B:" . date("Y-m-d H:i:s") . ":" . $iv . PHP_EOL, FILE_APPEND);  
37 -//  
38 -// } 32 +
39 $encryptedData = urldecode($encryptedData); 33 $encryptedData = urldecode($encryptedData);
  34 + print_r($encryptedData);return;
40 $iv = urldecode($iv); 35 $iv = urldecode($iv);
41 $url = "https://api.weixin.qq.com/sns/jscode2session?appid=" . $appid . "&secret=" . $AppSecret . "&js_code=" . $code . "&grant_type=authorization_code"; 36 $url = "https://api.weixin.qq.com/sns/jscode2session?appid=" . $appid . "&secret=" . $AppSecret . "&js_code=" . $code . "&grant_type=authorization_code";
42 $res = json_decode(http_request($url), true); 37 $res = json_decode(http_request($url), true);
43 if (!$res) { 38 if (!$res) {
44 $res = json_decode(http_request($url), true); 39 $res = json_decode(http_request($url), true);
45 } 40 }
46 - print_r($res);return; 41 +
47 $sessionKey = $res['session_key']; 42 $sessionKey = $res['session_key'];
48 $openid = $res['openid'];//获取用户openid 43 $openid = $res['openid'];//获取用户openid
49 - $unionid = $res['unionid'];//获取用户openid 44 + //$unionid = $res['unionid'];//获取用户openid
50 // file_put_contents("ccc.txt", "授权1:" . date("Y-m-d H:i:s") . ":" . json_encode($res, JSON_UNESCAPED_UNICODE) . PHP_EOL, FILE_APPEND); 45 // file_put_contents("ccc.txt", "授权1:" . date("Y-m-d H:i:s") . ":" . json_encode($res, JSON_UNESCAPED_UNICODE) . PHP_EOL, FILE_APPEND);
51 46
52 require_once '../extend/lib/WXBizDataCrypt.class.php'; 47 require_once '../extend/lib/WXBizDataCrypt.class.php';
@@ -67,7 +62,7 @@ class Login extends Base @@ -67,7 +62,7 @@ class Login extends Base
67 if ($openid) { 62 if ($openid) {
68 $openid_info = [ 63 $openid_info = [
69 "openid" => $openid, 64 "openid" => $openid,
70 - "unionid" => $unionid, 65 + //"unionid" => $unionid,
71 "from" => "wx", 66 "from" => "wx",
72 ]; 67 ];
73 if (!empty($data['nickName'])) { 68 if (!empty($data['nickName'])) {
@@ -101,10 +96,7 @@ class Login extends Base @@ -101,10 +96,7 @@ class Login extends Base
101 //如果通过小程序openid找不到会员 96 //如果通过小程序openid找不到会员
102 //注册处理 97 //注册处理
103 $extend_data = [ 98 $extend_data = [
104 - "nickname" => $openid_info['nickName'],  
105 - "avatar" => $openid_info["avatarUrl"],  
106 "wx_xcx_openid" => $openid, 99 "wx_xcx_openid" => $openid,
107 - "unionid" => $unionid,  
108 ]; 100 ];
109 $username = $openid ? $openid : suiji_num("TY"); 101 $username = $openid ? $openid : suiji_num("TY");
110 $ret = $this->auth->register($username, "a123456", '', $data['phoneNumber'], $extend_data); 102 $ret = $this->auth->register($username, "a123456", '', $data['phoneNumber'], $extend_data);