作者 郭文星

123

... ... @@ -34,4 +34,22 @@ if (!function_exists('http_request')) {
return $data;
}
}
if (!function_exists('insert_openid_info')) {
/**
* 将授权用户信息保存起来
*/
function insert_openid_info($data)
{
$data['upt_time'] = time();
$res = \think\Db::name("openid_info")->where("openid", $data['openid'])->find();
// file_put_contents("ccc.txt", date("Y-m-d H:i:s") . json_encode($data) . PHP_EOL, FILE_APPEND);
if (!empty($res)) {
\think\Db::name("openid_info")->where("openid", $data['openid'])->update($data);
} else {
\think\Db::name("openid_info")->insertGetId($data);
}
return true;
}
}
\ No newline at end of file
... ...
... ... @@ -48,7 +48,6 @@ class Login extends Base
$errCode = $res['errcode'] == "-41001" || $res['errcode'] == "-41003" ? "授权失败,请尝试重新授权" : $res['errcode'];
$this->error($errCode);
}
print_r($res);return;
$sessionKey = $res['session_key'];
$openid = $res['openid'];//获取用户openid
... ... @@ -74,7 +73,6 @@ class Login extends Base
if ($openid) {
$openid_info = [
"openid" => $openid,
"unionid" => $unionid,
"from" => "wx",
];
if (!empty($data['nickName'])) {
... ...