import 'dart:async'; import 'dart:io'; import 'package:dio/dio.dart'; import 'package:sk_base_mobile/constants/global_url.dart'; import 'package:sk_base_mobile/models/base_response.dart'; import 'package:sk_base_mobile/models/dict_type.model.dart'; import 'package:sk_base_mobile/services/dio.service.dart'; import '../constants/constants.dart'; // 登录 Future login(String username, String password) { return DioService.dio.post( Urls.login, data: {'username': username, 'password': password}, ); } // 获取个人信息 Future getUserInfo() { return DioService.dio.get( Urls.getUserInfo, ); } // 分页获取项目列表 Future> getProjects(Map params) { return DioService.dio.get(Urls.getProjects, queryParameters: {'page': 1, 'pageSize': 10, ...params}); } // 分页获取产品列表 Future> getProducts(Map params) { return DioService.dio.get(Urls.getProducts, queryParameters: {'page': 1, 'pageSize': 10, ...params}); } // 分页获取原材料出入库列表 Future> getInventoryInout(Map params) { return DioService.dio.get(Urls.getInventoryInout, queryParameters: {'page': 1, 'pageSize': 10, ...(params)}); } // 一次性获取所有的字典类型(不分页) Future getDictTypeAll(Map params) { return DioService.dio.post(Urls.getDictType, data: params); } Future logout() { return DioService.dio.post( Urls.logout, ); } Future deleteAccount() { return DioService.dio.post( Urls.deleteAccount, ); } Future getAppConfig() { Map query = {'ver': 0}; return DioService.dio.get(Urls.getAppConfig, queryParameters: query); } Future saveUserInfo(Map data) { return DioService.dio.post(Urls.saveUserInfo, data: data); } Future uploadImg(File file) async { // DateTime dateTime = DateTime.now(); // String fileName = file.path.split('/').last; // String format = fileName.split('.').last; // int imageTimeName = dateTime.millisecondsSinceEpoch + // (dateTime.microsecondsSinceEpoch ~/ 1000000); // String imageName = '$imageTimeName.$format'; // String host = AppInfoService.to.ossPolicy.host!; // String dir = AppInfoService.to.ossPolicy.dir!; // final filePath = await MultipartFile.fromFile(file.path, filename: fileName); // final formData = FormData.fromMap({ // 'ossaccessKeyId': AppInfoService.to.ossPolicy.accessKeyId, // 'policy': AppInfoService.to.ossPolicy.policy, // 'signature': AppInfoService.to.ossPolicy.signature, // 'callback': AppInfoService.to.ossPolicy.callback, // 'key': '$dir/$imageName', // 'file': filePath, // }); // return DioService.dio.post(host, data: formData); return {} as Response; } Future updateAvatar(String filename) { return DioService.dio.post(Urls.updateAvatar, data: {'avatarPath': filename}); }