123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace app\api\controller\v1;
- use app\hander\HelpHander;
- use think\Controller;
- use think\Db;
- class Login extends Controller
- {
- public function check(){
- $account = input('account','','trim');
- $password = input('password','','trim');
- if(!$account){
- HelpHander::error('请输入账号');
- }
- if(!$password){
- HelpHander::error('请输入密码');
- }
- $ret = model('User')->login($account,$password);
- HelpHander::success($ret);
- }
- public function smsLogin(){
- $phone = input('accountName','','trim');
- $code = input('code','','trim');
- if(!check_mobile($phone)){
- HelpHander::error('手机号格式不正确');
- }
- $user = Db::name('user')->where('phone',$phone)->where('del',0)->find();
- if(!$user){
- HelpHander::error('该手机号未注册');
- }
- $res = model('SmsRecord')->checkCode($phone,$code);
- if(!$res){
- HelpHander::error('验证码不正确或已失效');
- }
- $token = model('Token')->updateToken($user['id']);
- if(!$token){
- HelpHander::error('登录失败');
- }
- $orgs = model('User')->getUserOrgs($user['id']);
- $data = ['org_info' => $orgs, 'token_info' => $token];
- HelpHander::success($data,'登录成功');
- }
- public function updatePwd(){
- $phone = input('mobile','','trim');
- $password = input('newPassword','','trim');
- $code = input('code','','trim');
- model('User')->forgetPassword($phone,$password,$code);
- HelpHander::success([],'修改成功');
- }
- }
|