From 893657d66d8f2d2d4ac198634e1b398db8507133 Mon Sep 17 00:00:00 2001 From: Devil Date: Thu, 4 Mar 2021 23:14:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E6=89=8B=E6=9C=BA?= =?UTF-8?q?=E7=BB=91=E5=AE=9A=E6=8E=A5=E5=8F=A3=E6=9B=B4=E6=96=B0=EF=BC=8C?= =?UTF-8?q?api=E6=96=B0=E5=A2=9E=E6=B3=A8=E5=86=8C+=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=E7=A0=81=E5=8F=91=E9=80=81=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/controller/User.php | 161 +++++++++++++----- application/index/controller/User.php | 4 +- .../index/view/default/user/reg_info.html | 10 +- application/service/UserService.php | 32 ++-- changelog.txt | 3 +- .../alipay/default/pages/login/login.js | 4 +- sourcecode/baidu/default/pages/login/login.js | 4 +- sourcecode/qq/default/pages/login/login.js | 4 +- .../toutiao/default/pages/login/login.js | 4 +- .../weixin/default/pages/login/login.js | 4 +- 10 files changed, 156 insertions(+), 74 deletions(-) diff --git a/application/api/controller/User.php b/application/api/controller/User.php index 46e7d74a0..924629ec9 100755 --- a/application/api/controller/User.php +++ b/application/api/controller/User.php @@ -44,49 +44,135 @@ class User extends Common } /** - * [Reg 用户注册-数据添加] - * @author Devil - * @blog http://gong.gg/ - * @version 0.0.1 - * @datetime 2017-03-07T00:08:36+0800 + * 用户登录 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2021-03-04 + * @desc description + */ + public function Login() + { + return UserService::Login($this->data_post); + } + + /** + * 用户登录-验证码发送 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2021-03-04 + * @desc description + */ + public function LoginVerifySend() + { + return UserService::LoginVerifySend($this->data_post); + } + + /** + * 用户注册 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2021-03-04 + * @desc description */ public function Reg() { - // 是否ajax请求 - if(!IS_AJAX) - { - return $this->error('非法访问'); - } - - // 调用服务层 - return UserService::AppReg($this->data_post); + return UserService::Reg($this->data_post); } /** - * [RegVerifySend 用户注册-验证码发送] - * @author Devil - * @blog http://gong.gg/ - * @version 0.0.1 - * @datetime 2017-03-05T19:17:10+0800 + * 用户注册-验证码发送 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2021-03-04 + * @desc description */ public function RegVerifySend() { - // 是否ajax请求 - if(!IS_AJAX) - { - return $this->error('非法访问'); - } - - // 调用服务层 - return UserService::AppUserBindVerifySend($this->data_post); + return UserService::RegVerifySend($this->data_post); } /** - * [GetAlipayUserInfo 支付宝用户授权] - * @author Devil - * @blog http://gong.gg/ - * @version 1.0.0 - * @datetime 2017-09-23T21:52:49+0800 + * 密码找回 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2021-03-04 + * @desc description + */ + public function ForgetPwd() + { + return UserService::ForgetPwd($this->data_post); + } + + /** + * 密码找回-验证码发送 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2021-03-04 + * @desc description + */ + public function ForgetPwdVerifySend() + { + return UserService::ForgetPwdVerifySend($this->data_post); + } + + /** + * 用户-验证码显示 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2021-03-04 + * @desc description + */ + public function UserVerifyEntry() + { + $params = [ + 'width' => 100, + 'height' => 26, + 'key_prefix' => input('type', 'user_reg'), + ]; + $verify = new \base\Verify($params); + $verify->Entry(); + } + + /** + * app用户手机绑定 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2021-03-04 + * @desc description + */ + public function AppMobileBind() + { + return UserService::AppMobileBind($this->data_post); + } + + /** + * app用户手机绑定-验证码发送 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2021-03-04 + * @desc description + */ + public function AppMobileBindVerifySend() + { + return UserService::AppMobileBindVerifySend($this->data_post); + } + + /** + * 支付宝用户授权 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2021-03-04 + * @desc description */ public function AlipayUserAuth() { @@ -635,18 +721,5 @@ class User extends Common $this->data_post['is_onekey_mobile_bind'] = 1; return UserService::AuthUserProgram($this->data_post, APPLICATION_CLIENT_TYPE.'_openid'); } - - /** - * 用户登录 - * @author Devil - * @blog http://gong.gg/ - * @version 1.0.0 - * @date 2021-03-04 - * @desc description - */ - public function Login() - { - return UserService::Login($this->data_post); - } } ?> \ No newline at end of file diff --git a/application/index/controller/User.php b/application/index/controller/User.php index 7060d8969..2ff0c00f5 100755 --- a/application/index/controller/User.php +++ b/application/index/controller/User.php @@ -371,11 +371,11 @@ class User extends Common */ public function UserVerifyEntry() { - $params = array( + $params = [ 'width' => 100, 'height' => 26, 'key_prefix' => input('type', 'user_reg'), - ); + ]; $verify = new \base\Verify($params); $verify->Entry(); } diff --git a/application/index/view/default/user/reg_info.html b/application/index/view/default/user/reg_info.html index cbe30a725..f50a43138 100755 --- a/application/index/view/default/user/reg_info.html +++ b/application/index/view/default/user/reg_info.html @@ -251,17 +251,17 @@ function RegisterSuccessBack(e) { $.AMUI.progress.done(); Prompt(e.msg, 'success'); - +console.log(e.data) // 登录返回html处理 if((e.data.body_html || null) != null) { $('body').append(e.data.body_html); } - setTimeout(function() - { - window.location.href = '{{$referer_url}}'; - }, 1500); + // setTimeout(function() + // { + // window.location.href = '{{$referer_url}}'; + // }, 1500); } else { $('.register-container form.am-form').find('button[type="submit"]').button('reset'); $.AMUI.progress.done(); diff --git a/application/service/UserService.php b/application/service/UserService.php index 5ea178774..ab37a0e1a 100755 --- a/application/service/UserService.php +++ b/application/service/UserService.php @@ -822,7 +822,7 @@ class UserService return $ret; } - // 登录返回 + // 成功返回 if(APPLICATION == 'app') { $result = self::AppUserInfoHandle($user_id); @@ -985,7 +985,14 @@ class UserService // 用户登录session纪录 if(self::UserLoginRecord($user_ret['data']['user_id'])) { - return DataReturn('注册成功', 0, $user_ret); + // 成功返回 + if(APPLICATION == 'app') + { + $result = self::AppUserInfoHandle($user_ret['data']['user_id']); + } else { + $result = $user_ret['data']; + } + return DataReturn('注册成功', 0, $result); } return DataReturn('注册成功,请到登录页面登录帐号'); } else { @@ -1934,13 +1941,14 @@ class UserService $body_html = []; // 注册成功后钩子 + $user = Db::name('User')->field('id,username,nickname,mobile,email,gender,avatar,province,city,birthday')->where(['id'=>$user_id])->find(); $hook_name = 'plugins_service_user_register_end'; $ret = HookReturnHandle(Hook::listen($hook_name, [ 'hook_name' => $hook_name, 'is_backend' => true, 'params' => &$params, 'user_id' => $user_id, - 'user' => Db::name('User')->field('id,username,nickname,mobile,email,gender,avatar,province,city,birthday')->where(['id'=>$user_id])->find(), + 'user' => $user, 'body_html' => &$body_html, ])); if(isset($ret['code']) && $ret['code'] != 0) @@ -1960,7 +1968,7 @@ class UserService } /** - * app用户注册 + * app用户手机绑定 * @author Devil * @blog http://gong.gg/ * @version 1.0.0 @@ -1968,7 +1976,7 @@ class UserService * @desc description * @param [array] $params [输入参数] */ - public static function AppReg($params = []) + public static function AppMobileBind($params = []) { // 数据验证 $p = [ @@ -1989,8 +1997,8 @@ class UserService return DataReturn($ret, -1); } - // 用户注册前校验钩子 - $hook_name = 'plugins_service_user_app_register_begin_check'; + // 用户手机绑定前校验钩子 + $hook_name = 'plugins_service_user_app_mobile_bind_begin_check'; $ret = HookReturnHandle(Hook::listen($hook_name, [ 'hook_name' => $hook_name, 'is_backend' => true, @@ -2009,7 +2017,7 @@ class UserService // 验证码校验 $verify_params = [ - 'key_prefix' => 'bind_'.md5($params['mobile']), + 'key_prefix' => 'user_bind_'.md5($params['mobile']), 'expire_time' => MyC('common_verify_expire_time') ]; $obj = new \base\Sms($verify_params); @@ -2128,7 +2136,7 @@ class UserService } /** - * app用户绑定验证码发送 + * app用户手机绑定验证码发送 * @author Devil * @blog http://gong.gg/ * @version 1.0.0 @@ -2136,7 +2144,7 @@ class UserService * @desc description * @param [array] $params [输入参数] */ - public static function AppUserBindVerifySend($params = []) + public static function AppMobileBindVerifySend($params = []) { // 数据验证 $p = [ @@ -2160,8 +2168,8 @@ class UserService // 验证码公共基础参数 $verify_params = [ - 'key_prefix' => 'bind_'.md5($params['mobile']), - 'expire_time' => MyC('common_verify_expire_time'), + 'key_prefix' => 'user_bind_'.md5($params['mobile']), + 'expire_time' => MyC('common_verify_expire_time'), 'interval_time' => MyC('common_verify_interval_time'), ]; diff --git a/changelog.txt b/changelog.txt index 2b200481e..ced7898e4 100755 --- a/changelog.txt +++ b/changelog.txt @@ -18,12 +18,13 @@ web端 3. 插件(上传、安装、卸载、删除)新增回调事件 4. 后台管理登录优化(新增帐号密码+图片验证码、邮件验证码、手机验证码) 5. 用户登录优化(新增帐号密码+图片验证码、邮件验证码、手机验证码) - 6. API用户接口新增帐号密码、手机验证码、邮箱验证码登录方式 + 6. API用户接口新增帐号密码+手机+邮箱[登录、注册]方式、图片验证码+短信邮件验证码发送 小程序 1. 小程序商品详情标题去除高度限制 2. 签到优化,不强制填写信息 3. 微信小程序适配官方新规授权登录逻辑更新 + 4. 手机绑定接口更新 插件 1. 应用商店(在线自动安装应用插件、开发者提供优质插件、VIP授权管理) diff --git a/sourcecode/alipay/default/pages/login/login.js b/sourcecode/alipay/default/pages/login/login.js index 39e6b9fb3..eb2baf2c0 100644 --- a/sourcecode/alipay/default/pages/login/login.js +++ b/sourcecode/alipay/default/pages/login/login.js @@ -85,7 +85,7 @@ Page({ this.setData({verify_submit_text: '发送中', verify_loading: true, verify_disabled: true}); my.request({ - url: app.get_request_url('regverifysend', 'user'), + url: app.get_request_url('appmobilebindverifysend', 'user'), method: 'POST', data: {mobile: this.data.mobile}, dataType: 'json', @@ -149,7 +149,7 @@ Page({ // 网络请求 my.request({ - url: app.get_request_url('reg', 'user'), + url: app.get_request_url('appmobilebind', 'user'), method: 'POST', data: e.detail.value, dataType: 'json', diff --git a/sourcecode/baidu/default/pages/login/login.js b/sourcecode/baidu/default/pages/login/login.js index f44163ad0..978ca2360 100755 --- a/sourcecode/baidu/default/pages/login/login.js +++ b/sourcecode/baidu/default/pages/login/login.js @@ -94,7 +94,7 @@ Page({ this.setData({ verify_submit_text: '发送中', verify_loading: true, verify_disabled: true }); swan.request({ - url: app.get_request_url('regverifysend', 'user'), + url: app.get_request_url('appmobilebindverifysend', 'user'), method: 'POST', data: { mobile: this.data.mobile }, dataType: 'json', @@ -149,7 +149,7 @@ Page({ // 网络请求 swan.request({ - url: app.get_request_url('reg', 'user'), + url: app.get_request_url('appmobilebind', 'user'), method: 'POST', data: e.detail.value, dataType: 'json', diff --git a/sourcecode/qq/default/pages/login/login.js b/sourcecode/qq/default/pages/login/login.js index ce8fee4ce..2a4929d41 100755 --- a/sourcecode/qq/default/pages/login/login.js +++ b/sourcecode/qq/default/pages/login/login.js @@ -81,7 +81,7 @@ Page({ this.setData({verify_submit_text: '发送中', verify_loading: true, verify_disabled: true}); qq.request({ - url: app.get_request_url('regverifysend', 'user'), + url: app.get_request_url('appmobilebindverifysend', 'user'), method: 'POST', data: {mobile: this.data.mobile}, dataType: 'json', @@ -148,7 +148,7 @@ Page({ // 网络请求 qq.request({ - url: app.get_request_url('reg', 'user'), + url: app.get_request_url('appmobilebind', 'user'), method: 'POST', data: e.detail.value, dataType: 'json', diff --git a/sourcecode/toutiao/default/pages/login/login.js b/sourcecode/toutiao/default/pages/login/login.js index 5c53956f3..74ce5e8e3 100755 --- a/sourcecode/toutiao/default/pages/login/login.js +++ b/sourcecode/toutiao/default/pages/login/login.js @@ -113,7 +113,7 @@ Page({ this.setData({verify_submit_text: '发送中', verify_loading: true, verify_disabled: true}); tt.request({ - url: app.get_request_url('regverifysend', 'user'), + url: app.get_request_url('appmobilebindverifysend', 'user'), method: 'POST', data: {mobile: this.data.mobile}, dataType: 'json', @@ -179,7 +179,7 @@ Page({ // 网络请求 tt.request({ - url: app.get_request_url('reg', 'user'), + url: app.get_request_url('appmobilebind', 'user'), method: 'POST', data: e.detail.value, dataType: 'json', diff --git a/sourcecode/weixin/default/pages/login/login.js b/sourcecode/weixin/default/pages/login/login.js index 6ba05c6b0..cd9f117d5 100755 --- a/sourcecode/weixin/default/pages/login/login.js +++ b/sourcecode/weixin/default/pages/login/login.js @@ -103,7 +103,7 @@ Page({ this.setData({verify_submit_text: '发送中', verify_loading: true, verify_disabled: true}); wx.request({ - url: app.get_request_url('regverifysend', 'user'), + url: app.get_request_url('appmobilebindverifysend', 'user'), method: 'POST', data: {mobile: this.data.mobile}, dataType: 'json', @@ -168,7 +168,7 @@ Page({ // 网络请求 wx.request({ - url: app.get_request_url('reg', 'user'), + url: app.get_request_url('appmobilebind', 'user'), method: 'POST', data: e.detail.value, dataType: 'json',