diff --git a/app/api/common.php b/app/api/common.php index 8ebffca..873c690 100644 --- a/app/api/common.php +++ b/app/api/common.php @@ -1,14 +1,14 @@ request->isPost()) { return $this->renderError('不支持GET请求'); } - $data = $this->postData(); $model = new UserService; - // - $data = $this->postData(); - if (($userInfo = $model->register($data['uname'],$data['upass'])) === false) { - return $this->renderSuccess("登录成功"); + if (($userInfo = $model->register($this->postData())) === false) { + return $this->renderError($model->getError() ?: '注册失败'); } + return $this->renderSuccess("注册成功"); } } \ No newline at end of file diff --git a/app/api/service/UserService.php b/app/api/service/UserService.php index e41e670..21d5dd5 100644 --- a/app/api/service/UserService.php +++ b/app/api/service/UserService.php @@ -1,4 +1,5 @@ save($arr); - return true; + // 保存 + $model = new User; + $uid = $model->save($arr); + return isset($uid)?true:false; } } \ No newline at end of file