From 0cec480a6df01e68f2131b14ff6c1d9a2314e769 Mon Sep 17 00:00:00 2001 From: devil_gong Date: Sat, 29 Jun 2019 13:39:45 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/controller/User.php | 4 ++-- application/service/UserService.php | 34 ++++++++++++++++++++++------- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/application/api/controller/User.php b/application/api/controller/User.php index 0d1abdb70..66a8d9bca 100755 --- a/application/api/controller/User.php +++ b/application/api/controller/User.php @@ -131,7 +131,7 @@ class User extends Common $this->data_post['gender'] = empty($this->data_post['gender']) ? 0 : ($this->data_post['gender'] == 'f') ? 1 : 2; return UserService::AuthUserProgram($this->data_post, 'alipay_openid'); } else { - $user['is_mandatory_bind_mobile'] = intval(MyC('common_user_is_mandatory_bind_mobile')); + $user = UserService::AppUserInfoHandle($user); return DataReturn('授权成功', 0, $user); } return DataReturn('获取用户信息失败', -100); @@ -212,7 +212,7 @@ class User extends Common return UserService::AuthUserProgram($result, 'weixin_openid'); } } else { - $user['is_mandatory_bind_mobile'] = intval(MyC('common_user_is_mandatory_bind_mobile')); + $user = UserService::AppUserInfoHandle($user); return DataReturn('授权成功', 0, $user); } return DataReturn(empty($result) ? '获取用户信息失败' : $result, -100); diff --git a/application/service/UserService.php b/application/service/UserService.php index 1a9b88cfd..99444fbcd 100755 --- a/application/service/UserService.php +++ b/application/service/UserService.php @@ -1586,9 +1586,6 @@ class UserService */ public static function AuthUserProgram($params, $field) { - // 是否强制绑定手机号码 - $is_mandatory_bind_mobile = intval(MyC('common_user_is_mandatory_bind_mobile')); - // 用户信息 $data = [ $field => $params['openid'], @@ -1604,7 +1601,8 @@ class UserService { $data = $user; } else { - if($is_mandatory_bind_mobile != 1) + // 不强制绑定手机则写入用户信息 + if(intval(MyC('common_user_is_mandatory_bind_mobile')) != 1) { $ret = self::UserInsert($data, $params); if($ret['code'] == 0) @@ -1616,11 +1614,31 @@ class UserService } } - // 是否强制绑定手机号码 - $data['is_mandatory_bind_mobile'] = $is_mandatory_bind_mobile; - // 返回成功 - return DataReturn('授权成功', 0, $data); + return DataReturn('授权成功', 0, self::AppUserInfoHandle($data)); + } + + /** + * app用户信息 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2018-11-06 + * @desc description + * @param [arrat] $user [用户信息] + */ + public static function AppUserInfoHandle($user) + { + if(!empty($user)) + { + // 用户信息处理 + $user = self::GetUserViewInfo(0, $user); + + // 是否强制绑定手机号码 + $user['is_mandatory_bind_mobile'] = intval(MyC('common_user_is_mandatory_bind_mobile'));; + } + + return $user; } /** -- GitLab