123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- import 'package:dio/dio.dart';
- import 'package:flutter_tracker/dio/api.dart';
- import 'package:flutter_tracker/model/submit_model.dart';
- import 'package:flutter_tracker/model/user_model.dart';
- /// Description:
- /// Time : 2021年12月03日 Friday
- /// Author : liuyuqi.gov@msncn
- class TrackDao {
- static Map<String, dynamic> params = <String, dynamic>{};
- static Future<SubmitEntity> uploadImg(
- String token, String filePath, String fileName) async {
- params.addAll({"token": token, "filePath": filePath, "fileName": fileName});
- try {
- var formData = FormData.fromMap({
- 'token': token,
- "file": await MultipartFile.fromFile(filePath, filename: fileName),
- });
- var response = await Dio().post(Api.uploadImgUrl, data: formData);
- return SubmitEntity.fromJson(response.data);
- } catch (e) {
- print(e);
- return null;
- }
- }
- static Future<SubmitModel> uploadTrack(String token, String username,
- String telphone, String address, int health, int submitid) async {
- params.addAll({
- "token": token,
- "username": username,
- "telphone": telphone,
- "address": address,
- "health": health,
- "submitid": submitid
- });
- await Dio().post(Api.uploadSubmitUrl, data: params).then((response) {
- return SubmitModel.fromJson(response.data);
- });
- return null;
- }
- // 返回最近15天用户的轨迹
- static Future<List<UserModel>> getContactList(String token) async {
- params.addAll({"token": token});
- await Dio().post(Api.getContactListUrl, data: params).then((response) {
- return UserModel.fromJson(response.data);
- });
- return null;
- }
- static Future<UserModel> uploadContact(String token, String id) async {
- params.addAll({"token": token});
- await Dio().post(Api.uploadContactUrl, data: params).then((response) {
- return UserModel.fromJson(response.data);
- });
- return null;
- }
- }
|