diff --git a/app/api/controller/User.php b/app/api/controller/User.php index 8bd035d3f33d64d262605b9d7513f7bba4c7310a..2b8f89d6a44810f4d3cf27bbdff7923d44756096 100755 --- a/app/api/controller/User.php +++ b/app/api/controller/User.php @@ -124,52 +124,50 @@ class User extends Common } /** - * 用户-验证码显示 + * app用户手机绑定 * @author Devil * @blog http://gong.gg/ * @version 1.0.0 * @date 2021-03-04 * @desc description */ - public function UserVerifyEntry() + public function AppMobileBind() { - $params = [ - 'width' => 100, - 'height' => 28, - 'key_prefix' => input('type', 'user_reg'), - ]; - $verify = new \base\Verify($params); - $verify->Entry(); + return ApiService::ApiDataReturn(UserService::AppMobileBind($this->data_post)); } /** - * app用户手机绑定 + * app用户手机绑定-验证码发送 * @author Devil * @blog http://gong.gg/ * @version 1.0.0 * @date 2021-03-04 * @desc description */ - public function AppMobileBind() + public function AppMobileBindVerifySend() { - return ApiService::ApiDataReturn(UserService::AppMobileBind($this->data_post)); + return ApiService::ApiDataReturn(UserService::AppMobileBindVerifySend($this->data_post)); } /** - * app用户手机绑定-验证码发送 + * 用户-验证码显示 * @author Devil * @blog http://gong.gg/ * @version 1.0.0 * @date 2021-03-04 * @desc description */ - public function AppMobileBindVerifySend() + public function UserVerifyEntry() { - return ApiService::ApiDataReturn(UserService::AppMobileBindVerifySend($this->data_post)); + $params = [ + 'width' => 100, + 'height' => 28, + 'key_prefix' => input('type', 'user_reg'), + ]; + $verify = new \base\Verify($params); + $verify->Entry(); } - - /** * 支付宝用户授权 * @author Devil diff --git a/app/service/ConstService.php b/app/service/ConstService.php index 67db9d50a34666f2722539fc8649fcddd5cd1aab..5883070a5163d5129dc9a0fc85414c59d5b5b312 100644 --- a/app/service/ConstService.php +++ b/app/service/ConstService.php @@ -92,9 +92,9 @@ class ConstService // 用户注册类型列表 'common_user_reg_type_list' => [ - 0 => ['value' => 'sms', 'name' => '短信'], - 1 => ['value' => 'email', 'name' => '邮箱'], - 2 => ['value' => 'username', 'name' => '用户名'], + 0 => ['value' => 'username', 'name' => '账号'], + 1 => ['value' => 'sms', 'name' => '短信'], + 2 => ['value' => 'email', 'name' => '邮箱'], ], // 登录方式 diff --git a/app/service/UserService.php b/app/service/UserService.php index 6308cfbab35d98e621d622d7dc1ac6a37e06d6e3..cc2cbc0a60c47eec386218f6a6a551580ca74a88 100755 --- a/app/service/UserService.php +++ b/app/service/UserService.php @@ -766,7 +766,7 @@ class UserService // 获取用户账户信息 $where = [$ac['data'] => $params['accounts'], 'is_delete_time'=>0]; - $user = Db::name('User')->field('id,pwd,salt,status')->where($where)->find(); + $user = Db::name('User')->where($where)->find(); if(empty($user)) { return DataReturn('帐号不存在', -3); @@ -804,14 +804,38 @@ class UserService // 返回数据,更新数据库 $data = [ - 'upd_time' => time(), - ]; + 'upd_time' => time(), + ]; if($params['type'] == 'username') { $salt = GetNumberCode(6); $data['salt'] = $salt; $data['pwd'] = LoginPwdEncryption($params['pwd'], $salt); } + + // 用户openid + if(empty($user[APPLICATION_CLIENT_TYPE.'_openid'])) + { + $openid = self::UserOpenidHandle($params); + if(!empty($openid['field']) && !empty($openid['value'])) + { + // openid放入用户data中 + $data[$openid['field']] = $openid['value']; + } + } + + // 用户unionid + if(empty($user[APPLICATION_CLIENT_TYPE.'_unionid'])) + { + $unionid = self::UserUnionidHandle($params); + if(!empty($unionid['field']) && !empty($unionid['value'])) + { + // unionid放入用户data中 + $data[$unionid['field']] = $unionid['value']; + } + } + + // 更新用户信息 if(Db::name('User')->where(['id'=>$user['id']])->update($data) !== false) { // 清除图片验证码 @@ -1230,7 +1254,7 @@ class UserService return DataReturn($ret, -1); } - // 是否开启用户注册 + // 是否开启用户登录 if(!in_array($params['type'], MyC('home_user_login_type', [], true))) { return DataReturn('暂时关闭登录', -1); @@ -1857,6 +1881,33 @@ class UserService return Db::name('User')->where(['id'=>$user_id])->update($data); } + /** + * 用户openid处理 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2020-02-11 + * @desc description + * @param [array] $params [输入参数] + */ + public static function UserOpenidHandle($params = []) + { + $field = null; + $value = null; + $fields_arr = array_column(MyConst('common_appmini_type'), 'value'); + foreach($fields_arr as $type) + { + $openid = $type.'_openid'; + if(!empty($params[$openid])) + { + $field = $openid; + $value = $params[$openid]; + break; + } + } + return ['field'=>$field, 'value'=>$value]; + } + /** * 用户unionid处理 * @author Devil @@ -1873,8 +1924,8 @@ class UserService // QQ用户unionid $field = null; $value = null; - $unionid_all = ['weixin_unionid', 'qq_unionid']; - foreach($unionid_all as $unionid) + $fields_arr = ['weixin_unionid', 'qq_unionid']; + foreach($fields_arr as $unionid) { if(!empty($params[$unionid])) { @@ -2042,6 +2093,14 @@ class UserService // 用户基础信息处理 $data = self::UserBaseHandle($data, $params); + // 用户openid + $openid = self::UserOpenidHandle($params); + if(!empty($openid['field']) && !empty($openid['value'])) + { + // openid放入用户data中 + $data[$openid['field']] = $openid['value']; + } + // 用户unionid $unionid = self::UserUnionidHandle($params); if(!empty($unionid['field']) && !empty($unionid['value']))