作者 郭文星

123

... ... @@ -29,24 +29,19 @@ class Login extends Base
$encryptedData = $post['encryptedData'];//I('post.encryptedData');
$iv = $post['iv'];//I('post.iv');
// if ($post['type'] == 1) {
// $encryptedData = urldecode($encryptedData);
// $iv = urldecode($iv);
//// file_put_contents("ccc.txt", "授权A:" . date("Y-m-d H:i:s") . ":" . $encryptedData . PHP_EOL, FILE_APPEND);
//// file_put_contents("ccc.txt", "授权B:" . date("Y-m-d H:i:s") . ":" . $iv . PHP_EOL, FILE_APPEND);
//
// }
$encryptedData = urldecode($encryptedData);
print_r($encryptedData);return;
$iv = urldecode($iv);
$url = "https://api.weixin.qq.com/sns/jscode2session?appid=" . $appid . "&secret=" . $AppSecret . "&js_code=" . $code . "&grant_type=authorization_code";
$res = json_decode(http_request($url), true);
if (!$res) {
$res = json_decode(http_request($url), true);
}
print_r($res);return;
$sessionKey = $res['session_key'];
$openid = $res['openid'];//获取用户openid
$unionid = $res['unionid'];//获取用户openid
//$unionid = $res['unionid'];//获取用户openid
// file_put_contents("ccc.txt", "授权1:" . date("Y-m-d H:i:s") . ":" . json_encode($res, JSON_UNESCAPED_UNICODE) . PHP_EOL, FILE_APPEND);
require_once '../extend/lib/WXBizDataCrypt.class.php';
... ... @@ -67,7 +62,7 @@ class Login extends Base
if ($openid) {
$openid_info = [
"openid" => $openid,
"unionid" => $unionid,
//"unionid" => $unionid,
"from" => "wx",
];
if (!empty($data['nickName'])) {
... ... @@ -101,10 +96,7 @@ class Login extends Base
//如果通过小程序openid找不到会员
//注册处理
$extend_data = [
"nickname" => $openid_info['nickName'],
"avatar" => $openid_info["avatarUrl"],
"wx_xcx_openid" => $openid,
"unionid" => $unionid,
];
$username = $openid ? $openid : suiji_num("TY");
$ret = $this->auth->register($username, "a123456", '', $data['phoneNumber'], $extend_data);
... ...