From 134765255dfa6caf455b97e8c9e1a193b3d223d4 Mon Sep 17 00:00:00 2001 From: yaooo <272523191@qq.com> Date: Fri, 24 Nov 2023 10:53:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=A7=A3=E6=9E=90token?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/LoginLogic.php | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/app/api/logic/LoginLogic.php b/app/api/logic/LoginLogic.php index 5e9481194..4dc30ae3c 100755 --- a/app/api/logic/LoginLogic.php +++ b/app/api/logic/LoginLogic.php @@ -228,8 +228,35 @@ class LoginLogic extends BaseLogic $where = ['account|mobile' => $jwtData['phone']]; $user = User::where($where)->findOrEmpty(); if ($user->isEmpty()) { - self::setError('用户不存在,请联系管理员开通供销系统账户'); - return false; + $user_id = $jwtData['uid']; + $find = Db::name('user_other')->where('other_user_id', $user_id)->where('type', 'shop_user')->find(); + if ($find) { + $user = User::where('id', $find['user_id'])->findOrEmpty(); + if ($user->isEmpty()) { + self::setError('用户不存在,请联系管理员开通供销系统账户'); + return false; + } + $terminal=3; + $Android=IndexLogic::isAndroid(); + if($Android){ + $terminal=5; + } + $ios=IndexLogic::isIOS(); + if($ios){ + $terminal=6; + } + $userInfo = UserTokenService::setToken($user->id, $terminal); + //返回登录信息 + $avatar = $user->avatar ?: Config::get('project.default_image.user_avatar'); + $avatar = FileService::getFileUrl($avatar); + return [ + 'nickname' => $userInfo['nickname'], + 'sn' => $userInfo['sn'], + 'mobile' => $userInfo['mobile'], + 'avatar' => $avatar, + 'token' => $userInfo['token'], + ]; + } } //更新登录信息 $user->login_time = time();