import 'package:dio/dio.dart'; import '../../data/models/other_login_type.dart'; import '../dto/login_dto.dart'; import '../network/request.dart'; ///检查是否注册 Future checkRegisterApi(String email) async { var res = await Request().post("/auth/email_check", { "email": email, }); if (res["next"] == "login") { return true; } return false; } ///邮箱密码登陆 Future loginApi(String email, String password) async { var res = await Request().post("/auth/login/account", { "email": email, "password": password, }); return LoginDto.fromJson(res); } ///注册处 Future registerApi(String email, String password, String code) async { var res = await Request().post("/auth/register", { "email": email, "password": password, "email_code": code, }); return LoginDto.fromJson(res); } ///发送邮箱验证码 Future sendEmailCodeApi(String email) async { return Request().post("/send_email_code", { "email": email, }); } ///三方登录 Future thirdLoginApi(String token, OtherLoginType type) async { var res = await Request().post("/auth/login/oauth", { "login_token": token, "login_type": type.value, }); return LoginDto.fromJson(res); } ///删除账号 Future deleteAccountApi() async { return Request().get("/delete_account"); } ///修改用户资料 Future updateUserInfoApi({ String? name, List? avatar, String? description, }) async { FormData formData = FormData.fromMap({ "avatar": avatar != null ? MultipartFile.fromBytes( avatar, filename: "upload.jpg", contentType: DioMediaType("image", "jpeg"), ) : null, "description": description, "name": name, }); //请求 var res = await Request().post("/user/update_profile", formData); return UserInfo.fromJson(res); }