Pārlūkot izejas kodu

两个端兼容登录

lizhen_gitee 1 gadu atpakaļ
vecāks
revīzija
f952539bb0

+ 14 - 1
application/api/controller/User.php

@@ -10,7 +10,6 @@ use think\Config;
 use think\Validate;
 use think\Validate;
 
 
 use think\Db;
 use think\Db;
-use miniprogram\wxBizDataCrypt;
 
 
 /**
 /**
  * 会员接口
  * 会员接口
@@ -52,6 +51,13 @@ class User extends Api
         if (!$account || !$password) {
         if (!$account || !$password) {
             $this->error(__('Invalid parameters'));
             $this->error(__('Invalid parameters'));
         }
         }
+        //先判断是老师还是学员
+        $coach_find = Db::name('coach')->where('email',$account)->find();
+        if($coach_find){
+            return action('api/coach/user/emaillogin');
+        }
+
+        //学员登录
         $ret = $this->auth->login($account, $password);
         $ret = $this->auth->login($account, $password);
         if ($ret) {
         if ($ret) {
             $data = $this->auth->getUserinfo();
             $data = $this->auth->getUserinfo();
@@ -222,6 +228,13 @@ class User extends Api
         $this->success();
         $this->success();
     }
     }
 
 
+    //用户详细资料
+    public function userInfo(){
+        $info = $this->auth->getUserinfo();
+
+        $this->success(__('success'),$info);
+    }
+
     /**
     /**
      * 修改邮箱
      * 修改邮箱
      *
      *

+ 1 - 0
application/common/library/Auth.php

@@ -407,6 +407,7 @@ class Auth
 
 
         //追加
         //追加
         $userinfo['avatar'] = one_domain_image($userinfo['avatar']);
         $userinfo['avatar'] = one_domain_image($userinfo['avatar']);
+        $userinfo['role_type'] = 'user';//角色:用户
 
 
         return $userinfo;
         return $userinfo;
     }
     }

+ 1 - 0
application/common/library/Authcoach.php

@@ -282,6 +282,7 @@ class Authcoach
 
 
         //追加
         //追加
         $userinfo['avatar'] = one_domain_image($userinfo['avatar']);
         $userinfo['avatar'] = one_domain_image($userinfo['avatar']);
+        $userinfo['role_type'] = 'coach';//角色:教练
 
 
         return $userinfo;
         return $userinfo;
     }
     }