diff --git a/app/controller/api/dataview/Login.php b/app/controller/api/dataview/Login.php index a33cd145..7d9b0aa7 100644 --- a/app/controller/api/dataview/Login.php +++ b/app/controller/api/dataview/Login.php @@ -39,8 +39,29 @@ class Login extends BaseController $expire = time()+ 3600 * 24; $token = md5($expire); // 缓存token - Cache::set($token.'_'.$user['uid'], $expire); + Cache::set($token.'_dataview_'.$user['id'], $expire); + return app('json')->success(compact('user','token', 'expire')); + } + public function mechantLogin(UserRepository $repository) + { + $account = $this->request->param('account'); + $password= $this->request->param('password'); + + if (!$account) return app('json')->fail('请输入账号'); + + $user = $repository->accountByUser($account); + + if (!$user)return app('json')->fail('账号不存在');; + if (!password_verify($password, $user['pwd'])) { + $msg = '账号或密码错误'; + throw new ValidateException($msg); + } + $expire = time()+ 3600 * 24; + $token = md5($expire); + // 缓存token + Cache::set($token.'_merchant_'.$user['uid'], $expire); return app('json')->success(compact('user','token', 'expire')); } + } \ No newline at end of file diff --git a/route/api.php b/route/api.php index d69d6519..38f63fcb 100644 --- a/route/api.php +++ b/route/api.php @@ -766,6 +766,7 @@ Route::group('api/', function () { // login Route::post('login', 'Login/login'); + Route::post('mechant_login', 'Login/mechantLogin'); /**---------------------数据之眼可视化大屏api-------------------- end */