1
This commit is contained in:
54
lib/api/endpoints/skin_api.dart
Normal file
54
lib/api/endpoints/skin_api.dart
Normal file
@@ -0,0 +1,54 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:derma_flutter/api/dto/article_detail_dto.dart';
|
||||
import 'package:derma_flutter/api/dto/record_list_dto.dart';
|
||||
import 'package:derma_flutter/api/dto/skin_check_dto.dart';
|
||||
import 'package:derma_flutter/api/network/request.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
import '../dto/article_dto.dart';
|
||||
|
||||
///皮肤检测
|
||||
Future<SkinCheckDto> skinDetectApi(String path) async {
|
||||
FormData formData = FormData.fromMap({
|
||||
"skin_image": await MultipartFile.fromFile(path),
|
||||
});
|
||||
var res = await Request().post("/skin/check", formData);
|
||||
return SkinCheckDto.fromJson(res);
|
||||
}
|
||||
|
||||
///提交联系邮箱
|
||||
Future<void> skinContactApi(int id, String email) async {
|
||||
await Request().post("/customer-health/submit-demand", {
|
||||
"email": email,
|
||||
"skin_check_record_id": id,
|
||||
});
|
||||
}
|
||||
|
||||
///皮肤检测记录
|
||||
Future<RecordListDto> skinRecordApi({
|
||||
int page = 1,
|
||||
int pageSize = 20,
|
||||
Map<String, dynamic>? query,
|
||||
}) async {
|
||||
var res = await Request().get("/skin/records", {
|
||||
"search_params": jsonEncode(query),
|
||||
"page": page,
|
||||
"page_size": pageSize,
|
||||
});
|
||||
return RecordListDto.fromJson(res);
|
||||
}
|
||||
|
||||
///获取文章列表
|
||||
Future<List<ArticleDto>> articleListApi() async{
|
||||
var res = await Request().get("/customer-health/get_articles");
|
||||
return (res['list'] as List).map((e) => ArticleDto.fromJson(e)).toList();
|
||||
}
|
||||
|
||||
///文章详情
|
||||
Future<ArticleDetailDto> articleDetailApi(String id) async{
|
||||
var res = await Request().get("/customer-health/get_article_detail", {
|
||||
"id": id,
|
||||
});
|
||||
return ArticleDetailDto.fromJson(res);
|
||||
}
|
||||
50
lib/api/endpoints/user_api.dart
Normal file
50
lib/api/endpoints/user_api.dart
Normal file
@@ -0,0 +1,50 @@
|
||||
import 'package:derma_flutter/api/dto/login_dto.dart';
|
||||
import 'package:derma_flutter/api/network/request.dart';
|
||||
import 'package:derma_flutter/data/models/other_login_type.dart';
|
||||
|
||||
///检查是否注册
|
||||
Future<bool> checkRegisterApi(String email) async {
|
||||
var res = await Request().post("/auth/email_check", {
|
||||
"email": email,
|
||||
});
|
||||
if (res["next"] == "login") {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
// return res;
|
||||
}
|
||||
|
||||
///邮箱密码登陆
|
||||
Future<LoginDto> loginApi(String email, String password) async {
|
||||
var res = await Request().post("/auth/login/account", {
|
||||
"email": email,
|
||||
"password": password,
|
||||
});
|
||||
return LoginDto.fromJson(res);
|
||||
}
|
||||
|
||||
///注册处
|
||||
Future<LoginDto> 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<void> sendEmailCodeApi(String email) async {
|
||||
return Request().post("/send_email_code", {
|
||||
"email": email,
|
||||
});
|
||||
}
|
||||
|
||||
///三方登录
|
||||
Future<LoginDto> 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);
|
||||
}
|
||||
Reference in New Issue
Block a user