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 params = {}; static Future 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 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> 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 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; } }