scene('reg')->check($params)) { showJson(1002, $validate->getError()); } // 头像 $file = request()->file('avatar'); if ($file) { $fileData = Storage::uploadImg($file, 'avatar'); $params['avatar'] = isset($fileData['file']) ? $fileData['file'] : ''; } if(!Users::saveData($params)){ showJson(1002, 1011); } showJson(1001, 1012); } /** * 账号注册 * @throws \think\Exception * @throws \think\exception\PDOException */ public function login(){ $params = input(); $validate = new UsersValidate(); if (!$validate->scene('login')->check($params)) { showJson(1002, $validate->getError()); } $result = Users::login($params); if(!is_array($result)){ showJson(1002, $result); } showJson(1001, 1013, $result); } }