From 1ede9fad50975744db62006d1a5a104883e3989f Mon Sep 17 00:00:00 2001 From: wangxinglong <2371974647@qq.com> Date: Thu, 16 Dec 2021 11:18:14 +0800 Subject: [PATCH] setter --- app/controller/api/User.php | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/app/controller/api/User.php b/app/controller/api/User.php index fded2c3..b1bb7db 100644 --- a/app/controller/api/User.php +++ b/app/controller/api/User.php @@ -99,7 +99,11 @@ class User extends Base } else { $updateData = [ - 'login_time' => $nowDate, + 'login_time' => $nowDate, + 'lat' => empty($account->lat)?$params['lat'] :$account->lat,//如果之前的位置信息是空的 + 'lng' => empty($account->lng)?$params['lng'] :$account->lng,//如果之前的位置信息是空的 + 'mobile' => (!is_mobile($account->mobile))?$params['mobile']:$account->mobile,//如果之前的电话信息是空的 + 'real_name' => empty($account->real_name)?$params['real_name']:$account->real_name,//如果之前的电话信息是空的 ]; // 更新资料 @@ -258,15 +262,25 @@ class User extends Base . $code . '&grant_type=authorization_code'; $data = json_decode(Tool::httpRequest($url, "get"), true); + //返回状态 if (isset($data["openid"])) { $account = AccountRepository::getInstance()->findByOpenID($data["openid"]); if(empty($account)){ - return $this->json(0, "fail",["isNewAccount"=>true,"session_key"=>$data["session_key"]]); + return $this->json(0, "success",[ + "showMobile"=>true, + "showRealName"=>true, + "session_key"=>$data["session_key"]]); } - return $this->json(0, "fail",["isNewAccount"=>false,"session_key"=>$data["session_key"]]); + return $this->json(0, "success",[ + "showMobile"=>is_mobile($account->mobile)?false:true, + "showRealName"=>(!empty($account->real_name))?false:true, + "session_key"=>$data["session_key"] + ]); } - return $this->json(0, "fail",["isNewAccount"=>true]); + return $this->json(5001, "获取登录状态失败", ["showMobile"=>true, + "showRealName"=>true, + "session_key"=>'']); } /**