diff --git a/application/api/controller/User.php b/application/api/controller/User.php index 0d1abdb70c00e0f1591810d5f072b13a8142bdef..66a8d9bca7647bd748eb2b9325f9d3854a0cc222 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 1a9b88cfd9ba8181c2296d2ff4883f8998448fff..99444fbcdfcc779bdec394b2ecec2c253db7a2ca 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; } /**