params[ "username" ])) return $this->response($this->error([], "账号不能为空!")); if (empty($this->params[ "password" ])) return $this->response($this->error([], "密码不可为空!")); $captcha = new Captcha(); $check_res = $captcha->checkCaptcha(); if ($check_res[ 'code' ] < 0) return $this->response($check_res); // 登录 $login = new UserModel(); $res = $login->uniAppLogin($this->params[ 'username' ], $this->params[ "password" ], 'store'); //生成access_token if ($res[ 'code' ] >= 0) { $token = $this->createToken($res[ 'data' ]); return $this->response($this->success([ 'token' => $token, 'site_id' => $res[ 'data' ][ 'site_id' ] ])); } return $this->response($res); } }