import 'dart:io';

import 'package:dio/dio.dart';
import 'package:flustars/flustars.dart';
import 'package:flustars/flustars.dart' as f;
import 'package:flutter/cupertino.dart';
import 'package:jpush_flutter/jpush_flutter.dart';
import 'package:liftmanager/common/common.dart';
import 'package:liftmanager/common/user_db.dart';
import 'package:liftmanager/internal/account/account_router.dart';
import 'package:liftmanager/internal/account/model/certificate_item.dart';
import 'package:liftmanager/internal/account/model/user_entity.dart';
import 'package:liftmanager/internal/account/model/user_info_entity.dart';
import 'package:liftmanager/internal/bbs/model/banner_model.dart';
import 'package:liftmanager/internal/bbs/model/brand_model.dart' as brandM;
import 'package:liftmanager/internal/bbs/model/brand_model_type.dart';
import 'package:liftmanager/internal/bbs/model/control_model.dart' as controlM;
import 'package:liftmanager/internal/bbs/model/expert_model.dart';
import 'package:liftmanager/internal/bbs/model/hot_search_model.dart';
import 'package:liftmanager/internal/bbs/model/coupon_model_page.dart'
    as coupon;
import 'package:liftmanager/internal/bbs/model/error_model.dart';
import 'package:liftmanager/internal/bbs/model/expert_comment_model.dart';
import 'package:liftmanager/internal/bbs/model/expert_model.dart' as expertM;
import 'package:liftmanager/internal/bbs/model/file_categorys_tree.dart';
import 'package:liftmanager/internal/bbs/model/find_one.dart';
import 'package:liftmanager/internal/bbs/model/hot_search_model.dart';
import 'package:liftmanager/internal/bbs/model/liftcase_model.dart' as liftcase;
import 'package:liftmanager/internal/bbs/model/means_model.dart';
import 'package:liftmanager/internal/bbs/model/mix_model.dart' as mixmix;
import 'package:liftmanager/internal/bbs/model/news_detail_item.dart';
import 'package:liftmanager/internal/bbs/model/position_model.dart';
import 'package:liftmanager/internal/bbs/model/question_detail.dart';
import 'package:liftmanager/internal/bbs/model/resume_model.dart';
import 'package:liftmanager/internal/bbs/model/search_model.dart';
import 'package:liftmanager/internal/bbs/model/shop_detail.dart';
import 'package:liftmanager/internal/bbs/model/upload_model.dart';
import 'package:liftmanager/internal/bbs/model/video_detail.dart';
import 'package:liftmanager/internal/friends/model/friend_model.dart';
import 'package:liftmanager/internal/friends/model/near_model.dart';
import 'package:liftmanager/internal/heavy/model/heavy_count_item.dart';
import 'package:liftmanager/internal/heavy/model/heavy_item.dart';
import 'package:liftmanager/internal/heavy/model/heavy_list_entity.dart';
import 'package:liftmanager/internal/heavy/model/heavy_user_entity.dart';
import 'package:liftmanager/internal/lift/model/lift_brand_entity.dart';
import 'package:liftmanager/internal/lift/model/lift_item.dart';
import 'package:liftmanager/internal/lift/model/lift_list_entity.dart';
import 'package:liftmanager/internal/maintenance/model/maintenance_count_item.dart';
import 'package:liftmanager/internal/maintenance/model/maintenance_detail_item.dart';
import 'package:liftmanager/internal/maintenance/model/maintenance_last_entity.dart';
import 'package:liftmanager/internal/maintenance/model/maintenance_list_entity.dart';
import 'package:liftmanager/internal/maintenance/model/maintenance_options_item.dart';
import 'package:liftmanager/internal/message/model/message_list_entity.dart';
import 'package:liftmanager/internal/news/model/news_comm_entity.dart';
import 'package:liftmanager/internal/project/model/project_list_entity.dart';
import 'package:liftmanager/internal/project/model/worker_entity.dart';
import 'package:liftmanager/internal/repair/model/repair_count_item.dart';
import 'package:liftmanager/internal/repair/model/repair_fault_entity.dart';
import 'package:liftmanager/internal/repair/model/repair_list_entity.dart';
import 'package:liftmanager/internal/sign/model/sign_config_item.dart';
import 'package:liftmanager/internal/sign/model/sign_list_entity.dart';
import 'package:liftmanager/internal/team/model/team_auth_item.dart';
import 'package:liftmanager/internal/team/model/team_entity.dart';
import 'package:liftmanager/internal/team/model/team_info_item.dart';
import 'package:liftmanager/internal/team/model/team_user_entity.dart';
import 'package:liftmanager/internal/wode/model/become_model.dart';
import 'package:liftmanager/internal/wode/model/comment_model.dart';
import 'package:liftmanager/internal/wode/model/invoices_model.dart';
import 'package:liftmanager/internal/wode/model/message_model.dart';
import 'package:liftmanager/internal/wode/model/order_model.dart';
import 'package:liftmanager/internal/wode/model/piao_model.dart' as piao;
import 'package:liftmanager/internal/wode/model/piao_order_model.dart';
import 'package:liftmanager/internal/wode/model/piao_tou_model.dart' as piaotou;
import 'package:liftmanager/internal/wode/model/privilege_model.dart';
import 'package:liftmanager/internal/wode/model/punishments_model.dart'
    as punishments;
import 'package:liftmanager/internal/wode/model/punishments_model.dart';
import 'package:liftmanager/internal/wode/model/representation_model.dart';
import 'package:liftmanager/internal/wode/model/share_model.dart';
import 'package:liftmanager/internal/wode/model/table_dicts_model.dart';
import 'package:liftmanager/internal/wode/model/user_xieyi_model.dart';
import 'package:liftmanager/internal/wode/model/version_item.dart';
import 'package:liftmanager/internal/wode/model/vipfee_model.dart';
import 'package:liftmanager/internal/wode/model/wallet_model.dart';
import 'package:liftmanager/internal/wode/model/xieyi_model.dart';
import 'package:liftmanager/internal/work/model/banner_entity.dart';
import 'package:liftmanager/internal/work/model/count_doing_item.dart';
import 'package:liftmanager/internal/yearly/model/yearly_count_item.dart';
import 'package:liftmanager/internal/yearly/model/yearly_list_entity.dart';
import 'package:liftmanager/net/dio_utils.dart';
import 'package:liftmanager/net/net_utils.dart';
import 'package:liftmanager/routers/fluro_navigator.dart';
import 'package:liftmanager/utils/oss_upload.dart';
import 'package:liftmanager/utils/toast.dart';
import 'package:liftmanager/utils/url.dart';

class ApiUrl {
  ///上传图片
  static const String upload = "/business/common/upload";
  static const String uploads = "/business/common/uploads";

//  static const String upload = "http://121.40.159.228:20234/common/upload";
//  static const String uploads = "http://121.40.159.228:20234/common/uploads";
//  static const String upload = ":10111/upload";
//  static const String uploads = ":10111/uploads";
  ///banner
  static const String banner_list = "/system/banner/list";

  ///统计
  static const String count_doing = "/business/common/countDoing";
  static const String case_num = "/udream/api/liftCases/getUndealedCaseNum";

  ///登录
  static const String version = "/system/version";
  static const String account_login = "/system/login/login";
  static const String account_wxlogin = "/system/login/wxLogin";
  static const String account_smscode = "/system/login/smsCode";
  static const String account_register = "/system/login/register";
  static const String account_wxregister = "/system/login/wxRegister";
  static const String account_resetPassword = "/system/login/resetPassword";
  static const String account_appBindMobile = "/system/login/appBindMobile";

  ///用户信息相关
  static const String user_info = "/system/user/info";
  static const String modify_avatar = "/system/user/modifyAvatar";
  static const String modify_name = "/system/user/modifyName";
  static const String user_update = "/system/user/update";

  ///操作证
  static const String liftCertificate_add =
      "/enterprise/oa/liftCertificate/add";
  static const String liftCertificate_findByUser =
      "/enterprise/oa/liftCertificate/findByUser";

  ///消息中心列表
  static const String notification_list = "/system/notification/list";

  ///团队
  static const String mtcompany_ownList = "/system/mtcompany/ownList";
  static const String mtcompany_list = "/system/mtcompany/list";
  static const String mtcompany_createTeam = "/system/mtcompany/createTeam";
  static const String mtcompany_changeTeam = "/system/login/changeTeam";
  static const String mtcompany_applyTeam = "/system/userapply/applyTeam";
  static const String mtcompany_auditResult = "/system/attestation/auditResult";
  static const String mtcompany_applyAudit = "/system/attestation/applyAudit";
  static const String mtcompany_teamInfo = "/system/mtcompany/teamInfo";
  static const String mtcompany_userList =
      "/system/companyuser/app/getCompanyMembers";

  ///项目
  static const String project_list = "/business/app/project/list";
  static const String project_detail = "/business/app/project/detail";
  static const String project_user = "/business/app/project/user/list";

  ///电梯
  static const String lift_brand = "/business/common/brand/list";

  static const String lift_list = "/business/app/lift/list";
  static const String lift_detail = "/business/lift/detail";
  static const String lift_add = "/business/app/lift/add";
  static const String lift_modify = "/business/lift/modify";

  ///急修
  static const String repair_count =
      "/business/emergency/emergency-repair/count";
  static const String repair_list =
      "/business/emergency/emergency-repair/pageWorker";
  static const String repair_add = "/business/emergency/emergency-repair/add";
  static const String repair_taking =
      "/business/emergency/emergency-repair/taking";
  static const String repair_arrive =
      "/business/emergency/emergency-repair/arrive";
  static const String repair_stop = "/business/emergency/emergency-repair/stop";
  static const String repair_fault_tree =
      "/business/emergency/emergency-repair/fault/tree";
  static const String repair_fault_list =
      "/business/emergency/emergency-repair/fault/list";
  static const String repair_repairOrder =
      "/business/emergency/emergency-repair/repairOrder";
  static const String repair_detail =
      "/business/emergency/emergency-repair/findOne";
  static const String repair_evaluate =
      "/business/emergency/emergency-repair/evaluate";

  ///日常保养
  static const String maintenance_count = "/business/app/maintenance/count";
  static const String maintenance_planTask_list =
      "/business/app/maintenance/planTask";
  static const String maintenance_recordTask_list =
      "/business/app/maintenance/recordTask";

//  static const String maintenance_list = "/business/app/maintenance/task";
  static const String maintenance_record_info =
      "/business/app/maintenance/record/info";
  static const String maintenance_options =
      "/enterprise/maintenance-option/options";
  static const String maintenance_record_add = "/business/app/record/add";
  static const String maintenance_record_modify = "/business/app/record/modify";
  static const String maintenance_record_detail =
      "/business/maintenance/record/one";
  static const String maintenance_record_evaluate =
      "/business/maintenance/record/evaluate";

  ///年检
  static const String yearly_list =
      "/business/annualinspection/annual-inspection/pageWorker";
  static const String yearly_toConfirmList =
      "/business/annualinspection/annual-inspection/toConfirm";
  static const String yearly_confirm =
      "/business/annualinspection/annual-inspection/confirm";
  static const String yearly_selfcheck =
      "/business/annualinspection/annual-inspection/selfcheck";
  static const String yearly_check =
      "/business/annualinspection/annual-inspection/check";
  static const String yearly_finish =
      "/business/annualinspection/annual-inspection/finish";
  static const String yearly_count =
      "/business/annualinspection/annual-inspection/count";

  ///新闻
  static const String news_city = "/quan/news/location";

  // static const String news_list = "/quan/news/app/list";
  static const String news_list = "/quan/news/app/getMoreNewsList";
  // static const String news_list = "/quan/news/app/getTopNewsList";
  static const String top_news_list = "/quan/news/app/getTopNewsList";

  static const String news_detail = "/quan/news";
  static const String news_zan = "/quan/news/like";

  ///考勤签到
  static const String sign_list = "/enterprise/oa/attendance/pageByUser";
  static const String sign_config = "/enterprise/oa/attendance/time";
  static const String sign_add = "/enterprise/oa/attendance/clock";

  ///大修
  static const String capital_count = "/business/app/capital/count";
  static const String capital_project_list =
      "/business/app/capital/project/list";
  static const String capital_lift_list = "/business/app/capital/lift/list";
  static const String capital_attendance_list =
      "/business/app/capital/attendance/list";
  static const String capital_sign_in = "/business/app/capital/sign/in";
  static const String capital_overdueApply =
      "/business/app/capital/overdueApply";
  static const String capital_project_detail =
      "/business/app/capital/project/detail";
  static const String capital_begin = "/business/app/capital/begin";
  static const String capital_completed = "/business/app/capital/completed";

  ///消息
  static const String push_msg_list = "/push/message/list";
  static const String push_msg = "/push/message";
}

//class ApiService {
//  BuildContext context;
//  ApiService({this.context});

final JPush jpush = JPush();

//  Future uploadMore(List<File> files,
//      {String name="",String code="",Function onSuccess, Function(int code, String msg) onError}) async {
//    FormData formData = FormData.fromMap({
//      "workerName":name,
//      "registrationCode":code
//    });
//
//    for (var i = 0; i < files.length; ++i) {
//      File file = files[i];
//      print(file.path);
//      var name = file.path.substring(file.path.lastIndexOf("/") + 1);
//      formData.files.add(MapEntry(
//        "files",
//        MultipartFile.fromFileSync(file.path, filename: "${name}.jpg"),
//      ));
//    }
////    Map<String, dynamic> map = Map();
////    List<MultipartFile> list = [];
////    for (var i = 0; i < files.length; ++i) {
////      var file = files[i];
////      list.add(await MultipartFile.fromFile(file.path));
////    }
//    await DioUtils().requestNetwork<String>(Method.post, ApiUrl.uploads,
//        params: formData,
//        options: _getFormOptions(),
//        isList: true,
//        onSuccessList: onSuccess,
//        onError:(code,msg){
//      loginExpire(code);
//        onError(code,msg);
//    });
//  }
//
//  ///上传图片
//  Future upload(String file,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var name = file.substring(file.lastIndexOf("/") + 1);
//    FormData formData =
//        FormData.fromMap({"file": await MultipartFile.fromFile(file)});
//    await DioUtils().requestNetwork<String>(Method.post, ApiUrl.upload,
//        params: formData,
//        options: _getFormOptions(),
//        onSuccess: onSuccess, onError: (code, msg) {
//      loginExpire(code);
//      onError(code, msg);
//    });
//  }
//
//  ///获取City
//  Future getCity(lat, lng,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    await DioUtils().requestNetwork<String>(
//        Method.get, "${ApiUrl.news_city}?point=${lat},${lng}",
//        onSuccessList: onSuccess, onError: (code, msg) {
//      loginExpire(code);
//      onError(code, msg);
//    });
//  }
//
//  ///获取banner图
//  Future getBanner(
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {"type": 1};
//    await DioUtils()
//        .requestNetwork<BannerEntity>(Method.post, ApiUrl.banner_list,
//            objectFromJson: (res) => BannerEntity.fromJsonMap(res),
//            params: data,
//            isList: true,
//            onSuccessList: onSuccess,
//            onError: (code, msg) {
//              loginExpire(code);
//              onError(code, msg);
//            });
//  }
//
//  ///获取统计
//  Future countDoing(
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "userId": int.parse(SpUtil.getString(Constant.userId)),
//      "mtCompanyId": SpUtil.getString(Constant.companyId),
//    };
//
//    await DioUtils()
//        .requestNetwork<CountDoingItem>(Method.post, ApiUrl.count_doing,
//            objectFromJson: (res) => CountDoingItem.fromJsonMap(res),
//            params: data,
//            onSuccess: onSuccess,
//            onError: (code, msg) {
//              loginExpire(code);
//              onError(code, msg);
//            });
//  }
//
//  Future version( {Function onSuccess, Function(int code, String msg) onError}) async {
//    await DioUtils().requestNetwork<VersionItem>(
//        Method.post, ApiUrl.version,
//        objectFromJson: (res) => VersionItem.fromJsonMap(res),
//        params: {
//          "deviceModel":Platform.isIOS?2:1
//        },
//        onSuccess: onSuccess,
//        onError:(code,msg){
//      loginExpire(code);
//        onError(code,msg);
//    });
//  }
//
//  ///手机号密码登录
//  Future login(String account, String password,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "mobile": account,
//      "password": password,
//      "deviceModel": Platform.isIOS ? 2 : 1,
//      "deviceFlag": await _push.getDeviceToken(),
//      "mobileType": 1
//    };
//
//    await DioUtils()
//        .requestNetwork<UserEntity>(Method.post, ApiUrl.account_login,
//            objectFromJson: (res) => UserEntity.fromJsonMap(res),
//            params: data,
//            onSuccess: onSuccess,
//            onError: (code, msg) {
//              loginExpire(code);
//              onError(code, msg);
//            });
//  }
//
//  ///微信登录
//  void wxLogin(String authCode,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "authCode": "${authCode}",
//      "deviceModel": Platform.isIOS ? 2 : 1,
//      "deviceFlag": await _push.getDeviceToken()
//    };
//
//    await DioUtils().requestNetwork<UserEntity>(
//        Method.post, ApiUrl.account_wxlogin, params: data, onSuccess: onSuccess,
//        onError: (code, msg) {
//      loginExpire(code);
//      onError(code, msg);
//    });
//  }
//
//  ///获取验证码
//  Future getVCode(String account,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "mobile": account,
//    };
//    await DioUtils().requestNetwork(Method.get, ApiUrl.account_smscode,
//        queryParameters: data, onSuccess: onSuccess, onError: (code, msg) {
//      loginExpire(code);
//      onError(code, msg);
//    });
//  }
//
//  ///注册
//  Future register(String account, String password, String name, String vCode,
//      String authCode,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//
//    var data = {
//      "mobile": account,
//      "password": password,
//      "name": name,
//      "inputSmsCode": vCode,
//      "authCode": authCode,
//      "deviceModel":Platform.isIOS?2:1,
//      "deviceFlag":await _push.getDeviceToken()
//    };
//    await DioUtils().requestNetwork(Method.post,authCode.length>0?ApiUrl.account_wxregister: ApiUrl.account_register,
//        params: data, onSuccess: onSuccess, onError:(code,msg){
//          loginExpire(code);
//          onError(code,msg);
//        });
//  }
//
//  ///注册
//  Future resetPassword(String account, String password, String vCode,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "mobile": account,
//      "password": password,
//      "inputSmsCode": vCode,
//    };
//    await DioUtils().requestNetwork(Method.post, ApiUrl.account_resetPassword,
//        params: data, onSuccess: onSuccess, onError: (code, msg) {
//      loginExpire(code);
//      onError(code, msg);
//    });
//  }
//
//  Future accountAppBindMobile(String authCode, {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "authCode": authCode,
//      "deviceModel":Platform.isIOS?2:1,
//      "deviceFlag":await _push.getDeviceToken()
//    };
//
//    print(data);
//
//    await DioUtils().requestNetwork(Method.post,ApiUrl.account_appBindMobile,
//        params: data, onSuccess: onSuccess, onError:(code,msg){
//          loginExpire(code);
//          onError(code,msg);
//        });
//  }
//
//  ///用户信息
//  Future userInfo(
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "userId": int.parse(SpUtil.getString(Constant.userId)),
//      "companyId": SpUtil.getString(Constant.companyId)
//    };
//    print("用户信息接口参数");
//    print(data);
//    await DioUtils()
//        .requestNetwork<UserInfoEntity>(Method.post, ApiUrl.user_info,
//            objectFromJson: (res) => UserInfoEntity.fromJsonMap(res),
//            params: data,
//            onSuccess: onSuccess,
//            onError: (code, msg) {
//              loginExpire(code);
//              onError(code, msg);
//            });
//  }
//
//  Future modifyAvatar(url,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "userId": int.parse(SpUtil.getString(Constant.userId)),
//      "avatarUrl": url
//    };
//    await DioUtils().requestNetwork<String>(Method.post, ApiUrl.modify_avatar,
//        params: data, onSuccess: onSuccess, onError: (code, msg) {
//      loginExpire(code);
//      onError(code, msg);
//    });
//  }
//
//  Future modifyName(name,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "userId": int.parse(SpUtil.getString(Constant.userId)),
//      "name": name
//    };
//    await DioUtils().requestNetwork<String>(Method.post, ApiUrl.modify_name,
//        params: data, onSuccess: onSuccess, onError: (code, msg) {
//      loginExpire(code);
//      onError(code, msg);
//    });
//  }
//
//  Future userUpdate(name,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "userId": int.parse(SpUtil.getString(Constant.userId)),
//      "name": name
//    };
//    await DioUtils().requestNetwork<String>(Method.post, ApiUrl.user_update,
//        params: data, onSuccess: onSuccess, onError: (code, msg) {
//      loginExpire(code);
//      onError(code, msg);
//    });
//  }
//
//  Future userUpdates(name,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "userId": int.parse(SpUtil.getString(Constant.userId)),
//      "realName": name
//    };
//    await DioUtils().requestNetwork<String>(Method.post, ApiUrl.user_update,
//        params: data, onSuccess: onSuccess, onError: (code, msg) {
//      loginExpire(code);
//      onError(code, msg);
//    });
//  }
//
//  Future userUpdateJj(name,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "userId": int.parse(SpUtil.getString(Constant.userId)),
//      "signature": name
//    };
//    await DioUtils().requestNetwork<String>(Method.post, ApiUrl.user_update,
//        params: data, onSuccess: onSuccess, onError: (code, msg) {
//      loginExpire(code);
//      onError(code, msg);
//    });
//  }
//
//
//  Future liftCertificateAdd(code, issuanceAgency, expirationDate,
//      certificateType, firstImgUrl, secondImgUrl,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "ownerId": int.parse(SpUtil.getString(Constant.userId)),
//      "mtCompanyId": SpUtil.getString(Constant.companyId),
//      "code": code,
//      "issuanceAgency": issuanceAgency,
//      "expirationDate": expirationDate,
//      "certificateType": certificateType,
//      "firstImgUrl": firstImgUrl,
//      "secondImgUrl": secondImgUrl,
//    };
//    await DioUtils().requestNetwork<bool>(
//        Method.post, ApiUrl.liftCertificate_add,
//        params: data, onSuccess: onSuccess, onError: (code, msg) {
//      loginExpire(code);
//      onError(code, msg);
//    });
//  }
//
//  Future liftCertificateFindByUser(
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "ownerId": int.parse(SpUtil.getString(Constant.userId)),
//      "mtCompanyId": SpUtil.getString(Constant.companyId)
//    };
//    await DioUtils().requestNetwork<CertificateItem>(
//        Method.post, ApiUrl.liftCertificate_findByUser,
//        objectFromJson: (res) => CertificateItem.fromJsonMap(res),
//        params: data,
//        onSuccess: onSuccess,
//        onError: (code, msg) {
//          loginExpire(code);
//          onError(code, msg);
//        });
//  }
//
//  ///项目列表
//  Future searchProject(pageNum, pageSize, searchStr,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "mtCompanyId": SpUtil.getString(Constant.companyId),
//      "pageNum": pageNum,
//      "projectName": searchStr,
//      "pageSize": pageSize
//    };
//    await DioUtils()
//        .requestNetwork<ProjectListEntity>(Method.post, ApiUrl.project_list,
//            objectFromJson: (res) => ProjectListEntity.fromJsonMap(res),
//            params: data,
//            onSuccess: onSuccess,
//            onError: (code, msg) {
//              loginExpire(code);
//              onError(code, msg);
//            });
//  }
//
//  ///项目详情
//  Future projectDetail(id,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "id": id,
//    };
//    await DioUtils()
//        .requestNetwork<ProjectListItem>(Method.post, ApiUrl.project_detail,
//            objectFromJson: (res) => ProjectListItem.fromJsonMap(res),
//            params: data,
//            onSuccess: onSuccess,
//            onError: (code, msg) {
//              loginExpire(code);
//              onError(code, msg);
//            });
//  }
//
//  ///项目用户
//  Future projectUser(id,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "id": id,
//    };
//    await DioUtils()
//        .requestNetwork<WorkerItem>(Method.post, ApiUrl.project_user,
//            objectFromJson: (res) => WorkerItem.fromJsonMap(res),
//            isList: true,
//            params: data,
//            onSuccessList: onSuccess,
//            onError: (code, msg) {
//              loginExpire(code);
//              onError(code, msg);
//            });
//  }
//
//  ///电梯列表
//  Future searchLift(projectId, pageNum, pageSize, searchStr,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "id": projectId,
//      "pageNum": pageNum,
//      "pageSize": pageSize,
//      "registrationCode": searchStr
//    };
//    await DioUtils()
//        .requestNetwork<LiftListEntity>(Method.post, ApiUrl.lift_list,
//            objectFromJson: (res) => LiftListEntity.fromJsonMap(res),
//            params: data,
//            onSuccess: onSuccess,
//            onError: (code, msg) {
//              loginExpire(code);
//              onError(code, msg);
//            });
//  }
//
//  ///电梯详情
//  Future liftDetail(projectId,id,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "projectId":projectId,
//      "id": id,
//    };
//    await DioUtils().requestNetwork<LiftItem>(
//        Method.post, ApiUrl.lift_detail,
//        objectFromJson: (res) => LiftItem.fromJsonMap(res),
//        params: data,
//        onSuccess: onSuccess,
//        onError:(code,msg){
//      loginExpire(code);
//        onError(code,msg);
//    });
//  }
//
//  ///品牌
//  Future liftBrand(
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    await DioUtils().requestNetwork<LiftBrandEntity>(
//        Method.post, ApiUrl.lift_brand,
//        objectFromJson: (res) => LiftBrandEntity.fromJsonMap(res),
//        params: {},
//        isList: true,
//        onSuccessList: onSuccess,
//        onError:(code,msg){
//          loginExpire(code);
//          onError(code,msg);
//        });
//  }
//
//  ///添加电梯
//  Future liftAdd(projectId, workerId, lift,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "workerId": workerId,
//      "mtCompanyId": SpUtil.getString(Constant.companyId),
//      "projectId": projectId,
//      "lift": lift
//    };
//    await DioUtils().requestNetwork<bool>(
//        Method.post, ApiUrl.lift_add,
//        params: data,
//        onSuccess: onSuccess,
//        onError:(code,msg){
//          loginExpire(code);
//          onError(code,msg);
//        });
//  }
//
//  ///编辑电梯
//  Future liftEdit(projectId, workerId, lift,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "workerId": workerId,
//      "mtCompanyId": SpUtil.getString(Constant.companyId),
//      "projectId": projectId,
//      "lift": lift
//    };
//    await DioUtils().requestNetwork<bool>(
//        Method.post, ApiUrl.lift_modify,
//        params: data,
//        onSuccess: onSuccess,
//        onError:(code,msg){
//          loginExpire(code);
//          onError(code,msg);
//        });
//  }
//
//  ///获取消息中心列表
//  Future notificationList(
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "userId": SpUtil.getString(Constant.userId),
//      "companyId": SpUtil.getString(Constant.companyId)
//    };
//    await DioUtils().requestNetwork<TeamItem>(
//        Method.post, ApiUrl.notification_list,
//        objectFromJson: (res) => TeamItem.fromJsonMap(res),
//        params: data, onSuccessList: onSuccess, onError: (code,msg){
//      loginExpire(code);
//      onError(code,msg);
//    });
//  }
//
//  ///已加入的团队列表
//  Future teamList(
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "userId": SpUtil.getString(Constant.userId),
//      "companyId": SpUtil.getString(Constant.companyId)
//    };
//    await DioUtils().requestNetwork<TeamItem>(
//        Method.post, ApiUrl.mtcompany_ownList,
//        objectFromJson: (res) => TeamItem.fromJsonMap(res),
//        params: data, isList: true, onSuccessList: onSuccess, onError: (code,msg){
//      loginExpire(code);
//      onError(code,msg);
//    });
//  }
//
//  ///搜索团队列表
//  Future teamSearch(pageNum, pageSize, companyName,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "pageNum": "${pageNum}",
//      "pageSize": "${pageSize}",
//      "companyName": "${companyName}",
//    };
//    await DioUtils().requestNetwork<TeamEntity>(
//        Method.post, ApiUrl.mtcompany_list,
//        objectFromJson: (res) => TeamEntity.fromJsonMap(res),
//        params: data, onSuccess: onSuccess, onError: (code,msg){
//      loginExpire(code);
//      onError(code,msg);
//    });
//  }
//
//  ///团队创建
//  Future teamCreate(logoImg, companyName, remarks, corporator, telephone,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "logoImg": "${logoImg}",
//      "companyName": "${companyName}",
//      "remarks": "${remarks}",
//      "corporator": "${corporator}",
//      "telephone": "${telephone}",
//      "userId": SpUtil.getString(Constant.userId)
//    };
//    await DioUtils().requestNetwork<TeamEntity>(
//        Method.post, ApiUrl.mtcompany_createTeam,
//        objectFromJson: (res) => TeamEntity.fromJsonMap(res),
//        params: data, onSuccess: onSuccess, onError
//        : (code,msg){
//      loginExpire(code);
//      onError(code,msg);
//    });
//  }
//
//  ///切换团队
//  Future changTeam(companyId,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "companyId": companyId,
//      "userId": SpUtil.getString(Constant.userId)
//    };
//    await DioUtils().requestNetwork<UserEntity>(
//        Method.post, ApiUrl.mtcompany_changeTeam,
//        objectFromJson: (res) => UserEntity.fromJsonMap(res),
//        params: data, onSuccess: onSuccess, onError: (code,msg){
//      loginExpire(code);
//      onError(code,msg);
//    });
//  }
//
//  ///申请加入团队
//  Future applyTeam(companyId, desc,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "companyId": companyId,
//      "userId": SpUtil.getString(Constant.userId),
//      "description": desc
//    };
//    await DioUtils().requestNetwork<TeamEntity>(
//        Method.post, ApiUrl.mtcompany_applyTeam,
//        objectFromJson: (res) => TeamEntity.fromJsonMap(res),
//        params: data, onSuccess: onSuccess, onError: (code,msg){
//      loginExpire(code);
//      onError(code,msg);
//    });
//  }
//
//
//
//  Future teamUserList(pageNum, pageSize,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "companyId": SpUtil.getString(Constant.companyId),
//      "pageNum": pageNum,
//      "pageSize": pageSize
//    };
//    await DioUtils().requestNetwork<TeamUserEntity>(
//        Method.post, ApiUrl.mtcompany_userList,
//        objectFromJson: (res) => TeamUserEntity.fromJsonMap(res),
//        params: data, onSuccess: onSuccess, onError: (code,msg){
//      loginExpire(code);
//      onError(code,msg);
//    });
//  }
//
//  /**
//   * 发起认证
//   */
//  Future teamUploadAuth(id,attestationName,contactsName,contactsTel,businessLicenseAnnex,taxRegistration,logo,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "id":id,
//      "attestationName":attestationName,
//      "contactsName":contactsName,
//      "contactsTel":contactsTel,
//      "businessLicenseAnnex":businessLicenseAnnex,
//      "taxRegistration":taxRegistration,
//      "logoImg":logo,
//      "userId": SpUtil.getString(Constant.userId),
//      "mtCompanyId": SpUtil.getString(Constant.companyId),
//    };
//    await DioUtils().requestNetwork<TeamAuthItem>(
//        Method.post, ApiUrl.mtcompany_applyAudit,
//        objectFromJson: (res) => TeamAuthItem.fromJsonMap(res),
//        params: data, onSuccess: onSuccess, onError: (code,msg){
//      loginExpire(code);
//      onError(code,msg);
//    });
//  }
//
//  Future teamDetail(
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "companyId": SpUtil.getString(Constant.companyId),
//    };
//    await DioUtils().requestNetwork<TeamInfoItem>(
//        Method.post, ApiUrl.mtcompany_teamInfo,
//        objectFromJson: (res) => TeamInfoItem.fromJsonMap(res),
//        params: data, onSuccess: onSuccess, onError: (code,msg){
//      loginExpire(code);
//      onError(code,msg);
//    });
//  }
//
//  Future teamAuth(
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "mtCompanyId": SpUtil.getString(Constant.companyId),
//    };
//    await DioUtils().requestNetwork<TeamAuthItem>(
//        Method.post, ApiUrl.mtcompany_auditResult,
//        objectFromJson: (res) => TeamAuthItem.fromJsonMap(res),
//        params: data, onSuccess: onSuccess, onError: (code,msg){
//      loginExpire(code);
//      onError(code,msg);
//    });
//  }
//
//  Future maintenanceCount(String time,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "userId": SpUtil.getString(Constant.userId),
//      "beginTime":time.substring(0,8)+"01",
//    };
//    await DioUtils().requestNetwork<MantenanceCountItem>(
//        Method.post, ApiUrl.maintenance_count,
//        objectFromJson: (res) => MantenanceCountItem.fromJsonMap(res),
//        isList: true,
//        params: data, onSuccessList: onSuccess, onError: (code,msg){
//      loginExpire(code);
//      onError(code,msg);
//    });
//  }
//
//  ///保养列表
//  Future maintenanceList(pageNum, pageSize, status,time,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    if(status == 0 || status == 3){
//      var data = {
//        "pageNum": pageNum,
//        "pageSize": pageSize,
//        "workerId": SpUtil.getString(Constant.userId),
//        "status": status==3?-1:status,
//        "currentTime": time
//      };
//      await DioUtils().requestNetwork<MaintenanceListEntity>(
//          Method.post, ApiUrl.maintenance_planTask_list,
//          objectFromJson: (res) => MaintenanceListEntity.fromJsonMap(res),
//          params: data,
//          onSuccess: onSuccess,
//          onError: (code,msg){
//            loginExpire(code);
//            onError(code,msg);
//          });
//    }else{
//      var data = {
//        "pageNum": pageNum,
//        "pageSize": pageSize,
//        "workerId": SpUtil.getString(Constant.userId),
//        "status": status,
//        "currentTime": time
//      };
//      await DioUtils().requestNetwork<MaintenanceListEntity>(
//          Method.post, ApiUrl.maintenance_recordTask_list,
//          objectFromJson: (res) => MaintenanceListEntity.fromJsonMap(res),
//          params: data,
//          onSuccess: onSuccess,
//          onError: (code,msg){
//            loginExpire(code);
//            onError(code,msg);
//          });
//    }
//
//  }
//
//  ///保养详情
//  Future maintenanceRecordDetail(id,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "id": id
//    };
//    await DioUtils().requestNetwork<MaintenanceDetailEntity>(
//        Method.post, ApiUrl.maintenance_record_detail,
//        objectFromJson: (res)=>MaintenanceDetailEntity.fromJsonMap(res),
//        params: data,
//        onSuccess: onSuccess,
//        onError: (code,msg){
//          loginExpire(code);
//          onError(code,msg);
//        });
//  }
//
//  ///保养评价
//  Future maintenanceEvaluate(id, advice, serviceLevel, starLevel, imgUrl,
//      {Function onSuccess,
//        Function(int code, String msg) onError}) async {
//    var data = {
//      "userId": SpUtil.getString(Constant.userId),
//      "recordId": id,
//      "type": 2,
//      "advice": advice,
//      "serviceLevel": serviceLevel,
//      "starLevel": starLevel,
//      "imgUrl": imgUrl,
//    };
//    await DioUtils().requestNetwork<bool>(
//        Method.post, ApiUrl.maintenance_record_evaluate,
//        params: data, onSuccess: onSuccess, onError: (code,msg){
//      loginExpire(code);
//      onError(code,msg);
//    });
//  }
//
//  ///上次维保信息
//  Future maintenanceRecordInfo(liftId,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "mtCompanyId": SpUtil.getString(Constant.companyId),
//      "liftId": liftId
//    };
//    await DioUtils().requestNetwork<MaintenanceLastEntity>(
//        Method.post, ApiUrl.maintenance_record_info,
//        objectFromJson: (res) => MaintenanceLastEntity.fromJsonMap(res),
//        params: data,
//        onSuccess: onSuccess,
//        onError: (code,msg){
//          loginExpire(code);
//          onError(code,msg);
//        });
//  }
//
//  ///保养项目
//  Future maintenanceOptions(type, liftType,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "mtCompanyId": SpUtil.getString(Constant.companyId),
//      "type": type,
//      "liftCategory": liftType
//    };
//    await DioUtils().requestNetwork<MaintenanceOptionsItem>(
//        Method.post, ApiUrl.maintenance_options,
//        objectFromJson: (res) => MaintenanceOptionsItem.fromJsonMap(res),
//        params: data,
//        isList: true,
//        onSuccessList: onSuccess,
//        onError: (code,msg){
//          loginExpire(code);
//          onError(code,msg);
//        });
//  }
//
//  ///保养项目
//  Future maintenanceRecordAdd(id,workerId, liftId, liftType, projectId, type,
//      safetyConfirm, coordinate, address,isRegular,isRepair,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    String mType = "1";
//    if(type == "6" || type == "18"){
//      mType = "2";
//    }else if(type == "12"){
//      mType = "3";
//    }else if(type == "24" ){
//      mType ="4";
//    }
//    var data = {
//      "coordinate":coordinate,
//      "periods":type,
//      "record": {
//        "mtCompanyId": SpUtil.getString(Constant.companyId),
//        "workerId1": SpUtil.getString(Constant.userId),
//        "workerId": workerId,
//        "mtPlanId": id,
//        "liftId": liftId,
//        "liftType": liftType,
//        "projectId": projectId,
//        "type": mType,
//        "safetyConfirm": safetyConfirm,
//        "position": address,
//        "isRegular":isRegular,
//        "isRepair":isRepair
//      }
//    };
//    await
//    DioUtils().requestNetwork<String>(
//        Method.post, ApiUrl.maintenance_record_add,
//        params: data,
//        onSuccess: onSuccess,
//        onError: (code,msg){
//          loginExpire(code);
//          onError(code,msg);
//        });
//  }
//
//  ///提交保养单
//  Future maintenanceRecordModify(id, maintenanceAdvice, options,
//      signatureImg1, signatureImg2, images,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data =
//    {
//      "record": {
//        "id": id,
//        "maintenanceAdvice": maintenanceAdvice,
//        "maintenanceOption": options,
//        "signatureImg1": signatureImg1,
//        "signatureImg2": signatureImg2,
//      },
//      "recordImageList": images
//    };
//    await DioUtils().requestNetwork<bool>(
//        Method.post, ApiUrl.maintenance_record_modify,
//        params: data,
//        onSuccess: onSuccess,
//        onError: (code,msg){
//          loginExpire(code);
//          onError(code,msg);
//        });
//  }
//
//  ///急修列表
//  Future repairCount(
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    await DioUtils().requestNetwork<RepairCountItem>(
//        Method.post, ApiUrl.repair_count,
//        objectFromJson: (res) => RepairCountItem.fromJsonMap(res),
//        params: {},
//        onSuccess: onSuccess,
//        onError: (code,msg){
//          loginExpire(code);
//          onError(code,msg);
//        });
//  }
//
//  ///急修列表
//  Future repairList(pageNum, pageSize, status,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "pageNum": pageNum,
//      "pageSize": pageSize,
//      "workerId": SpUtil.getString(Constant.userId),
//      "status": status
//    };
//    await DioUtils().requestNetwork<RepairListEntity>(
//        Method.post, ApiUrl.repair_list,
//        objectFromJson: (res) => RepairListEntity.fromJsonMap(res),
//        params: data,
//        onSuccess: onSuccess,
//        onError: (code,msg){
//          loginExpire(code);
//          onError(code,msg);
//        });
//  }
//
//  ///新增急修
//  Future repairAdd(projectId,liftId, isTrapped,isCritical,repairReason,callerFaultDescription,callerName,callerTel,callerDate,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "mtCompanyId": SpUtil.getString(Constant.companyId),
//      "workerId1":SpUtil.getString(Constant.userId),
//      "projectId": projectId,
//      "liftId": liftId,
//      "isTrapped": isTrapped,
//      "isCritical": isCritical,
//      "repairReason": repairReason,
//      "callerFaultDescription": callerFaultDescription,
//      "source": 2,
//      "callerName": callerName,
//      "callerTel": callerTel,
//      "callerDate": callerDate,
//    };
//    await DioUtils().requestNetwork<bool>(Method.post, ApiUrl.repair_add,
//        params: data, onSuccess: onSuccess, onError: (code,msg){
//          loginExpire(code);
//          onError(code,msg);
//        });
//  }
//
//  ///接单
//  Future repairTaking(id, takingTime,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "id": id,
//      "takingTime": takingTime,
//    };
//    await DioUtils().requestNetwork<bool>(Method.post, ApiUrl.repair_taking,
//        params: data, onSuccess: onSuccess, onError: (code,msg){
//          loginExpire(code);
//          onError(code,msg);
//        });
//  }
//
//  ///到达
//  Future repairArrive(id, arriveTime, position,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {"id": id, "arriveTime": arriveTime, "position": position};
//    await DioUtils().requestNetwork<bool>(Method.post, ApiUrl.repair_arrive,
//        params: data, onSuccess: onSuccess, onError: (code,msg){
//          loginExpire(code);
//          onError(code,msg);
//        });
//  }
//
//  ///停梯
//  Future repairStop(id, stopDate, safetyConfirm,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {"id": id, "stopDate": stopDate, "safetyConfirm": safetyConfirm};
//    await DioUtils().requestNetwork<bool>(Method.post, ApiUrl.repair_stop,
//        params: data, onSuccess: onSuccess, onError: (code,msg){
//          loginExpire(code);
//          onError(code,msg);
//        });
//  }
//
//  ///获取急修故障
//  Future repairFaultTree(liftCategory,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {"liftCategory": liftCategory};
//    await DioUtils().requestNetwork<RepairFaultEntity>(
//        Method.post, ApiUrl.repair_fault_tree,
//        objectFromJson: (res) => RepairFaultEntity.fromJsonMap(res),
//        params: data,
//        isList: true,
//        onSuccessList: onSuccess,
//        onError: (code,msg){
//          loginExpire(code);
//          onError(code,msg);
//        });
//  }
//
//  ///保存急修单
//  Future repairSaveOrder(
//      id,
//      recoveryDate,
//      erRecordImg,
//      fieldDescription,
//      mainSign,
//      secondSign,
//      faultPart,
//      faultReason,
//      faultHandle,
//      faultNature,
//      faultDuty,
//      {Function onSuccess,
//      Function(int code, String msg) onError}) async {
//    var data = {
//      "id": id,
//      "recoveryDate": recoveryDate,
//      "erRecordImg": erRecordImg,
//      "fieldDescription": fieldDescription,
//      "mainSign": mainSign,
//      "secondSign": secondSign,
//      "faultPart": faultPart,
//      "faultReason": faultReason,
//      "faultHandle": faultHandle,
//      "faultNature": faultNature,
//      "faultDuty": faultDuty,
//    };
//    await DioUtils().requestNetwork<bool>(
//        Method.post, ApiUrl.repair_repairOrder,
//        params: data, onSuccess: onSuccess, onError: (code,msg){
//      loginExpire(code);
//      onError(code,msg);
//    });
//  }
//
//  ///获取急修单
//  Future repairDetail(id,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {"id": id};
//    await DioUtils().requestNetwork<RepairItem>(
//        Method.post, ApiUrl.repair_detail,
//        objectFromJson: (res) => RepairItem.fromJsonMap(res),
//        params: data, onSuccess: onSuccess, onError: (code,msg){
//      loginExpire(code);
//      onError(code,msg);
//    });
//  }
//
//  ///急修评价
//  Future repairEvaluate(id, advice, serviceLevel, starLevel, imgUrl,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "userId": SpUtil.getString(Constant.userId),
//      "recordId": id,
//      "type": 2,
//      "advice": advice,
//      "serviceLevel": serviceLevel,
//      "starLevel": starLevel,
//      "imgUrl": imgUrl,
//    };
//    await DioUtils().requestNetwork<bool>(
//        Method.post, ApiUrl.repair_evaluate,
//        params: data, onSuccess: onSuccess, onError: (code,msg){
//      loginExpire(code);
//      onError(code,msg);
//    });
//  }
//
//  ///年检列表
//  Future yearlyList(pageNum, pageSize, status,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "pageNum": pageNum,
//      "pageSize": pageSize,
//      "workerId": SpUtil.getString(Constant.userId),
//      "status": status //年检完成状态（0 待完成；1 已完成；2 超期）
//    };
//    await DioUtils().requestNetwork<YearlyListEntity>(
//        Method.post, ApiUrl.yearly_list,
//        objectFromJson: (res) => YearlyListEntity.fromJsonMap(res),
//        params: data,
//        onSuccess: onSuccess,
//        onError: (code,msg){
//          loginExpire(code);
//          onError(code,msg);
//        });
//  }
//
//  ///年检列表
//  Future yearlyConfirm(liftId,isCheckGoverner,loadInspectionSetting,planDate,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "liftId": liftId,
//      "mtCompanyId": SpUtil.getString(Constant.companyId),
//      "isCheckGoverner": isCheckGoverner,
//      "loadInspectionSetting": loadInspectionSetting,
//      "planDate": planDate
//    };
//    await DioUtils().requestNetwork<String>(Method.post, ApiUrl.yearly_confirm,
//        params: data, onSuccess: onSuccess, onError: (code,msg){
//          loginExpire(code);
//          onError(code,msg);
//        });
//  }
//
//  ///年检管理-待确认年检列表
//  Future yearlyNoConfirmList(pageNum, pageSize, status,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "pageNum": pageNum,
//      "pageSize": pageSize,
//      "mtCompanyId": SpUtil.getString(Constant.companyId),
//    };
//    await DioUtils().requestNetwork<YearlyListEntity>(
//        Method.post, ApiUrl.yearly_toConfirmList,
//        objectFromJson: (res) => YearlyListEntity.fromJsonMap(res),
//        params: data,
//        onSuccess: onSuccess,
//        onError: (code,msg){
//          loginExpire(code);
//          onError(code,msg);
//        });
//  }
//
//  ///上传质检报告
//  Future yearlySelfCheck(id, time, imgUrl,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "id": id,
//      "selfcheckDate": "${time}",
//      "selfcheckReportImg": "${imgUrl}"
//    };
//    await DioUtils().requestNetwork<bool>(Method.post, ApiUrl.yearly_selfcheck,
//        params: data, onSuccess: onSuccess, onError: (code,msg){
//          loginExpire(code);
//          onError(code,msg);
//        });
//  }
//
//  ///上传检验结果
//  Future yearlyCheck(id, time, imgUrl,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "id": id,
//      "checkDate": "${time}",
//      "checkResultImg": "${imgUrl}"
//    };
//    await DioUtils().requestNetwork<bool>(Method.post, ApiUrl.yearly_check,
//        params: data, onSuccess: onSuccess, onError: (code,msg){
//          loginExpire(code);
//          onError(code,msg);
//        });
//  }
//
//  ///上传检验结果
//  Future yearlyFinish(id, imgUrl, imgUrl2,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "id": id,
//      "certificateImgUrl": "${imgUrl}",
//      "annualInspectionImg": "${imgUrl2}"
//    };
//    await DioUtils().requestNetwork<bool>(Method.post, ApiUrl.yearly_finish,
//        params: data, onSuccess: onSuccess, onError: (code,msg){
//          loginExpire(code);
//          onError(code,msg);
//        });
//  }
//
//  ///年检统计
//  Future yearlyCount(
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    await DioUtils().requestNetwork<YearlyCountItem>(Method.post, ApiUrl.yearly_count,
//        objectFromJson:(res) => YearlyCountItem.fromJsonMap(res),
//        params: {}, onSuccess: onSuccess, onError: (code,msg){
//          loginExpire(code);
//          onError(code,msg);
//        });
//  }
//
//  Future newsList(pageNum, pageSize, haveTops, title, city,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "pageNum": pageNum,
//      "pageSize": pageSize,
//      "haveTops": haveTops,
//      "title": title,
//      "district": city
//    };
//    await DioUtils().requestNetwork<NewsCommEntity>(Method.post, ApiUrl.news_list,
//        objectFromJson: (res) => NewsCommEntity.fromJsonMap(res),
//        params: data, onSuccess: onSuccess, onError: (code,msg){
//          loginExpire(code);
//          onError(code,msg);
//        });
//  }
//
//  Future newsDetail(id,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "id": id,
//    };
//    await DioUtils().requestNetwork<NewsDetailItem>(Method.post, ApiUrl.news_detail,
//        objectFromJson: (res) => NewsDetailItem.fromJsonMap(res),
//        params: data, onSuccess: onSuccess, onError: (code,msg){
//          loginExpire(code);
//          onError(code,msg);
//        });
//  }
//  Future newsZan(id,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "id": id,
//      "userId": SpUtil.getString(Constant.userId)
//    };
//    await DioUtils().requestNetwork<NewsDetailItem>(Method.post, ApiUrl.news_zan,
//        objectFromJson: (res) => NewsDetailItem.fromJsonMap(res),
//        params: data, onSuccess: onSuccess, onError: (code,msg){
//          loginExpire(code);
//          onError(code,msg);
//        });
//  }
//
//  Future signList(pageNum, pageSize, clockTime,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "pageNum": pageNum,
//      "pageSize": pageSize,
//      "userId": int.parse(SpUtil.getString(Constant.userId)),
//      "clockTime": clockTime,
//    };
//    await DioUtils().requestNetwork<SignListEntity>(Method.post, ApiUrl.sign_list,
//        objectFromJson: (res) => SignListEntity.fromJsonMap(res),
//        params: data, onSuccess: onSuccess, onError: (code,msg){
//          loginExpire(code);
//          onError(code,msg);
//        });
//  }
//
//  Future signConfig(
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "mtCompanyId": SpUtil.getString(Constant.companyId),
//    };
//    await DioUtils().requestNetwork<SignConfigItem>(Method.post, ApiUrl.sign_config,
//        objectFromJson: (res) => SignConfigItem.fromJsonMap(res),
//        params: data, onSuccess: onSuccess, onError: (code,msg){
//          loginExpire(code);
//          onError(code,msg);
//        });
//  }
//
//  Future signAdd(coordinate, address, type,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "mtCompanyId": SpUtil.getString(Constant.companyId),
//      "userId": int.parse(SpUtil.getString(Constant.userId)),
//      "coordinate": coordinate,
//      "address": address,
//      "type": type
//    };
//    await DioUtils().requestNetwork<bool>(Method.post, ApiUrl.sign_add,
//        params: data, onSuccess: onSuccess, onError: (code,msg){
//          loginExpire(code);
//          onError(code,msg);
//        });
//  }
//
//  ///大修统计
//  Future heavyCount(
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    await DioUtils().requestNetwork<HeavyCountItem>(
//        Method.post, ApiUrl.capital_count,
//        objectFromJson: (res) => HeavyCountItem.fromJsonMap(res),
//        params:  {},
//        onSuccess: onSuccess,
//        onError: (code,msg){
//          loginExpire(code);
//          onError(code,msg);
//        });
//  }
//  ///大修项目列表
//  Future searchHeavyProject(pageNum, pageSize, status,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "mtCompanyId": SpUtil.getString(Constant.companyId),
//      "userId":SpUtil.getString(Constant.userId),
//      "projectStatus":status,
//      "pageNum": pageNum,
//      "projectName":"",
//      "pageSize": pageSize
//    };
//    await DioUtils().requestNetwork<HeavyListEntity>(
//        Method.post, ApiUrl.capital_project_list,
//        objectFromJson: (res) => HeavyListEntity.fromJsonMap(res),
//        params: data,
//        onSuccess: onSuccess,
//        onError: (code,msg){
//          loginExpire(code);
//          onError(code,msg);
//        });
//  }
//
//  ///大修电梯列表
//  Future searchHeavyLift(projectId, pageNum, pageSize, searchStr,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "id": projectId,
//      "pageNum": pageNum,
//      "pageSize": pageSize,
//      "registrationCode":searchStr
//    };
//    await DioUtils().requestNetwork<LiftListEntity>(
//        Method.post, ApiUrl.capital_lift_list,
//        objectFromJson: (res) => LiftListEntity.fromJsonMap(res),
//        params: data,
//        onSuccess: onSuccess,
//        onError: (code,msg){
//          loginExpire(code);
//          onError(code,msg);
//        });
//  }
//
//  ///大修项目详情
//  Future heavyProjectDetail(id,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "id": id,
//    };
//
//    await DioUtils().requestNetwork<HeavyItem>(
//        Method.post, ApiUrl.capital_project_detail,
//        objectFromJson: (res) => HeavyItem.fromJsonMap(res),
//        params: data,
//        onSuccess: onSuccess,
//        onError: (code,msg){
//          loginExpire(code);
//          onError(code,msg);
//        });
//  }
//
//  ///大修项目用户列表
//  Future heavyUserList(projectId,isUser,signDate,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "mtCompanyId": SpUtil.getString(Constant.companyId),
//      "projectId":projectId,
//      "userId":isUser?SpUtil.getString(Constant.userId):"",
//    };
//    if(signDate.length>0){
//      data['signDate'] = signDate;
//    }
//    await DioUtils().requestNetwork<HeavyUserEntity>(
//        Method.post, ApiUrl.capital_attendance_list,
//        objectFromJson: (res) => HeavyUserEntity.fromJsonMap(res),
//        isList: true,
//        params: data, onSuccessList: onSuccess, onError: (code,msg){
//      loginExpire(code);
//        onError(code,msg);
//    });
//  }
//
//  ///大修签到
//  Future heavySignAdd(coordinate,address,projectId,{Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "mtCompanyId": SpUtil.getString(Constant.companyId),
//      "userId": SpUtil.getString(Constant.userId),
//      "projectId":projectId,
//      "coordinate": coordinate,
//      "address": address
//    };
//    await DioUtils().requestNetwork<bool>(Method.post, ApiUrl.capital_sign_in,
//        params: data, onSuccess: onSuccess, onError: (code,msg){
//          loginExpire(code);
//          onError(code,msg);
//        });
//  }
//
//  ///开始项目
//  Future capitalBegin(id,{Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "projectId": id,
//    };
//    await DioUtils().requestNetwork<bool>(Method.post, ApiUrl.capital_begin,
//        params: data, onSuccess: onSuccess, onError: (code,msg){
//          loginExpire(code);
//          onError(code,msg);
//        });
//  }
//  ///竣工
//  Future capitalCompleted(id,imgs,{Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "mtCompanyId": SpUtil.getString(Constant.companyId),
//      "projectId": id,
//      "imageUrlList":imgs
//    };
//    await DioUtils().requestNetwork<String>(Method.post, ApiUrl.capital_completed,
//        params: data, onSuccess: onSuccess, onError: (code,msg){
//          loginExpire(code);
//          onError(code,msg);
//        });
//  }
//
//  ///消息列表
//  Future messageList(pageIndex,pageSize,type,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "userId": SpUtil.getString(Constant.userId),
//      "type":type,
//      "pageNum":pageIndex,
//      "pageSize":pageSize,
//    };
//    await DioUtils().requestNetwork<MessageListEntity>(
//        Method.post, ApiUrl.push_msg_list,
//        objectFromJson: (res) => MessageListEntity.fromJsonMap(res),
//        params: data, onSuccess: onSuccess, onError: (code,msg){
//      loginExpire(code);
//      onError(code,msg);
//    });
//  }
//
//  ///消息列表
//  Future messageDetail(id,
//      {Function onSuccess, Function(int code, String msg) onError}) async {
//    var data = {
//      "id":id,
//    };
//    await DioUtils().requestNetwork<MessageListItem>(
//        Method.post, ApiUrl.push_msg,
//        objectFromJson: (res) => MessageListItem.fromJsonMap(res),
//        params: data, onSuccess: onSuccess, onError: (code,msg){
//      loginExpire(code);
//      onError(code,msg);
//    });
//  }
//
//  loginExpire(int code) {
//    if (code == 10 && context != null) {
//      showAlert(context, "提示", "用户登录失效,请重新登录", "重新登录", () {
//        User().clearUser();
//        _push.unbindAccount(account: f.SpUtil.getString(Constant.phone));
//        NavigatorUtils.push(context, AccountRouter.loginPage, clearStack: true);
//      });
//    }
//  }
//
//  Options _getFormOptions() {
//    Map<String, String> map = new Map();
////    map["Content-Type"] = "multipart/form-data; charset=utf-8";
//    map["Accept"] = "application/json";
////    return Options(contentType: "multipart/form-data; charset=utf-8",responseType: ResponseType.json);
//    return Options(contentType: "multipart/form-data; charset=utf-8");
//  }
//}

class ApiService {
  BuildContext context;

  ApiService({this.context});

  Future uploadMore(List<File> files,
      {String name = "",
      String code = "",
      Function onSuccess,
      Function(int code, String msg) onError}) async {
    FormData formData =
        FormData.fromMap({"workerName": name, "registrationCode": code});

    for (var i = 0; i < files.length; ++i) {
      File file = files[i];
      print(file.path);
      var name = file.path.substring(file.path.lastIndexOf("/") + 1);
      formData.files.add(MapEntry(
        "files",
        MultipartFile.fromFileSync(file.path, filename: "${name}.jpg"),
      ));
    }
//    Map<String, dynamic> map = Map();
//    List<MultipartFile> list = [];
//    for (var i = 0; i < files.length; ++i) {
//      var file = files[i];
//      list.add(await MultipartFile.fromFile(file.path));
//    }
    await DioUtils().requestNetwork<String>(Method.post, ApiUrl.uploads,
        params: formData,
        options: _getFormOptions(),
        isList: true,
        onSuccessList: onSuccess, onError: (code, msg) {
      loginExpire(code);
      onError(code, msg);
    });
  }

  ///上传图片
  Future upload(String file,
      {String name = "",
      String code = "",
      Function onSuccess,
      Function(int code, String msg) onError}) async {
//    var name = file.substring(file.lastIndexOf("/") + 1);
    FormData formData = FormData.fromMap({
      "workerName": name,
      "registrationCode": code,
      "file": await MultipartFile.fromFile(file)
    });
    await DioUtils().requestNetwork<String>(Method.post, ApiUrl.upload,
        params: formData,
        options: _getFormOptions(),
        onSuccess: onSuccess, onError: (code, msg) {
      loginExpire(code);
      onError(code, msg);
    });
  }

  ///获取City
  Future getCity(lat, lng,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<String>(
        Method.get, "${ApiUrl.news_city}?point=${lat},${lng}",
        onSuccessList: onSuccess, onError: (code, msg) {
      loginExpire(code);
      onError(code, msg);
    });
  }

  ///获取banner图
  Future getBanner(
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {"type": 1};
    await DioUtils()
        .requestNetwork<BannerEntity>(Method.post, ApiUrl.banner_list,
            objectFromJson: (res) => BannerEntity.fromJsonMap(res),
            params: data,
            isList: true,
            onSuccessList: onSuccess,
            onError: (code, msg) {
              loginExpire(code);
              onError(code, msg);
            });
  }

  ///获取统计
  Future countDoing(
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "userId": int.parse(SpUtil.getString(Constant.userId)),
      "mtCompanyId": SpUtil.getString(Constant.companyId),
    };

    await DioUtils()
        .requestNetwork<CountDoingItem>(Method.post, ApiUrl.count_doing,
            objectFromJson: (res) => CountDoingItem.fromJsonMap(res),
            params: data,
            onSuccess: onSuccess,
            onError: (code, msg) {
              loginExpire(code);
              onError(code, msg);
            });
  }

  ///获取统计
  Future getcaseNum(
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "userId": SpUtil.getString(Constant.userId),
      // "mtCompanyId": SpUtil.getString(Constant.companyId),
    };

    await DioUtils().requestNetwork<int>(Method.get, ApiUrl.case_num,
        // objectFromJson: (res) {
        // return res;
        // },
        queryParameters: data,
        onSuccess: onSuccess, onError: (code, msg) {
      loginExpire(code);
      onError(code, msg);
    });
  }

  ///版本号
  Future version(
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<VersionItem>(Method.post, ApiUrl.version,
        objectFromJson: (res) => VersionItem.fromJsonMap(res),
        params: {"deviceModel": Platform.isIOS ? 2 : 1},
        onSuccess: onSuccess,
        onError: (code, msg) {
          loginExpire(code);
          onError(code, msg);
        });
  }

  ///手机号密码登录
  Future login(String account, String password,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "mobile": account,
      "password": password,
      "deviceModel": Platform.isIOS ? 2 : 1,
      "deviceFlag": await jpush.getRegistrationID()
    };

    await DioUtils()
        .requestNetwork<UserEntity>(Method.post, ApiUrl.account_login,
            objectFromJson: (res) {
              return UserEntity.fromJsonMap(res);
            },
            params: data,
            onSuccess: onSuccess,
            onError: (code, msg) {
              loginExpire(code);
              onError(code, msg);
            });
  }

  ///微信登录
  void wxLogin(String authCode,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "authCode": authCode,
      "deviceModel": Platform.isIOS ? 2 : 1,
      "deviceFlag": await jpush.getRegistrationID()
    };

    await DioUtils().requestNetwork<UserEntity>(
        Method.post, ApiUrl.account_wxlogin, params: data, onSuccess: onSuccess,
        onError: (code, msg) {
      loginExpire(code);
      onError(code, msg);
    });
  }

  ///获取验证码
  Future getVCode(String account,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "mobile": account,
    };
    await DioUtils().requestNetwork(Method.get, ApiUrl.account_smscode,
        queryParameters: data, onSuccess: onSuccess, onError: (code, msg) {
      loginExpire(code);
      onError(code, msg);
    });
  }

  ///注册
  Future register(String account, String password, String name, String vCode,
      String authCode,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "mobile": account,
      "password": password,
      "name": name,
      "inputSmsCode": vCode,
      "authCode": authCode,
      "deviceModel": Platform.isIOS ? 2 : 1,
      "deviceFlag": await jpush.getRegistrationID()
    };
    await DioUtils().requestNetwork(
        Method.post,
        authCode.length > 0
            ? ApiUrl.account_wxregister
            : ApiUrl.account_register,
        params: data,
        onSuccess: onSuccess, onError: (code, msg) {
      loginExpire(code);
      onError(code, msg);
    });
  }

  Future accountAppBindMobile(String authCode,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "authCode": authCode,
      "deviceModel": Platform.isIOS ? 2 : 1,
      "deviceFlag": await jpush.getRegistrationID()
    };

    print(data);

    await DioUtils().requestNetwork(Method.post, ApiUrl.account_appBindMobile,
        params: data, onSuccess: onSuccess, onError: (code, msg) {
      loginExpire(code);
      onError(code, msg);
    });
  }

  ///注册
  Future resetPassword(String account, String password, String vCode,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "mobile": account,
      "password": password,
      "inputSmsCode": vCode,
    };
    await DioUtils().requestNetwork(Method.post, ApiUrl.account_resetPassword,
        params: data, onSuccess: onSuccess, onError: (code, msg) {
      loginExpire(code);
      onError(code, msg);
    });
  }

  ///用户信息
  Future userInfo(
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "userId": int.parse(SpUtil.getString(Constant.userId)),
      "companyId": SpUtil.getString(Constant.companyId)
    };
    await DioUtils()
        .requestNetwork<UserInfoEntity>(Method.post, ApiUrl.user_info,
            objectFromJson: (res) => UserInfoEntity.fromJsonMap(res),
            params: data,
            onSuccess: onSuccess,
            onError: (code, msg) {
              loginExpire(code);
              onError(code, msg);
            });
  }

  Future modifyAvatar(url,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "userId": int.parse(SpUtil.getString(Constant.userId)),
      "avatarUrl": url
    };
    await DioUtils().requestNetwork<String>(Method.post, ApiUrl.modify_avatar,
        params: data, onSuccess: onSuccess, onError: (code, msg) {
      loginExpire(code);
      onError(code, msg);
    });
  }

  Future modifyName(name,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "userId": int.parse(SpUtil.getString(Constant.userId)),
      "name": name
    };
    await DioUtils().requestNetwork<String>(Method.post, ApiUrl.modify_name,
        params: data, onSuccess: onSuccess, onError: (code, msg) {
      loginExpire(code);
      onError(code, msg);
    });
  }

  Future userUpdate(name,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "userId": int.parse(SpUtil.getString(Constant.userId)),
      "name": name
    };
    await DioUtils().requestNetwork<String>(Method.post, ApiUrl.user_update,
        params: data, onSuccess: onSuccess, onError: (code, msg) {
      loginExpire(code);
      onError(code, msg);
    });
  }

  Future userUpdates(name,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "userId": int.parse(SpUtil.getString(Constant.userId)),
      "realName": name
    };
    await DioUtils().requestNetwork<String>(Method.post, ApiUrl.user_update,
        params: data, onSuccess: onSuccess, onError: (code, msg) {
      loginExpire(code);
      onError(code, msg);
    });
  }

  Future userUpdateJj(name,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "userId": int.parse(SpUtil.getString(Constant.userId)),
      "signature": name
    };
    await DioUtils().requestNetwork<String>(Method.post, ApiUrl.user_update,
        params: data, onSuccess: onSuccess, onError: (code, msg) {
      loginExpire(code);
      onError(code, msg);
    });
  }

  Future liftCertificateAdd(code, issuanceAgency, expirationDate,
      certificateType, firstImgUrl, secondImgUrl,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "ownerId": int.parse(SpUtil.getString(Constant.userId)),
      "mtCompanyId": SpUtil.getString(Constant.companyId),
      "code": code,
      "issuanceAgency": issuanceAgency,
      "expirationDate": expirationDate,
      "certificateType": certificateType,
      "firstImgUrl": firstImgUrl,
      "secondImgUrl": secondImgUrl,
    };
    await DioUtils().requestNetwork<bool>(
        Method.post, ApiUrl.liftCertificate_add,
        params: data, onSuccess: onSuccess, onError: (code, msg) {
      loginExpire(code);
      onError(code, msg);
    });
  }

  Future liftCertificateFindByUser(
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "ownerId": int.parse(SpUtil.getString(Constant.userId)),
      "mtCompanyId": SpUtil.getString(Constant.companyId)
    };
    await DioUtils().requestNetwork<CertificateItem>(
        Method.post, ApiUrl.liftCertificate_findByUser,
        objectFromJson: (res) => CertificateItem.fromJsonMap(res),
        params: data,
        onSuccess: onSuccess,
        onError: (code, msg) {
          loginExpire(code);
          onError(code, msg);
        });
  }

  ///项目列表
  Future searchProject(pageNum, pageSize, searchStr,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "mtCompanyId": SpUtil.getString(Constant.companyId),
      "pageNum": pageNum,
      "projectName": searchStr,
      "pageSize": pageSize
    };
    await DioUtils()
        .requestNetwork<ProjectListEntity>(Method.post, ApiUrl.project_list,
            objectFromJson: (res) => ProjectListEntity.fromJsonMap(res),
            params: data,
            onSuccess: onSuccess,
            onError: (code, msg) {
              loginExpire(code);
              onError(code, msg);
            });
  }

  ///项目详情
  Future projectDetail(id,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "id": id,
    };
    await DioUtils()
        .requestNetwork<ProjectListItem>(Method.post, ApiUrl.project_detail,
            objectFromJson: (res) => ProjectListItem.fromJsonMap(res),
            params: data,
            onSuccess: onSuccess,
            onError: (code, msg) {
              loginExpire(code);
              onError(code, msg);
            });
  }

  ///项目用户
  Future projectUser(id,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "id": id,
    };
    await DioUtils()
        .requestNetwork<WorkerItem>(Method.post, ApiUrl.project_user,
            objectFromJson: (res) => WorkerItem.fromJsonMap(res),
            isList: true,
            params: data,
            onSuccessList: onSuccess,
            onError: (code, msg) {
              loginExpire(code);
              onError(code, msg);
            });
  }

  ///电梯列表
  Future searchLift(projectId, pageNum, pageSize, searchStr,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "id": projectId,
      "pageNum": pageNum,
      "pageSize": pageSize,
      "registrationCode": searchStr
    };
    await DioUtils()
        .requestNetwork<LiftListEntity>(Method.post, ApiUrl.lift_list,
            objectFromJson: (res) => LiftListEntity.fromJsonMap(res),
            params: data,
            onSuccess: onSuccess,
            onError: (code, msg) {
              loginExpire(code);
              onError(code, msg);
            });
  }

  ///电梯详情
  Future liftDetail(projectId, id,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "projectId": projectId,
      "id": id,
    };
    await DioUtils().requestNetwork<LiftItem>(Method.post, ApiUrl.lift_detail,
        objectFromJson: (res) => LiftItem.fromJsonMap(res),
        params: data,
        onSuccess: onSuccess,
        onError: (code, msg) {
          loginExpire(code);
          onError(code, msg);
        });
  }

  ///品牌
  Future liftBrand(
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils()
        .requestNetwork<LiftBrandEntity>(Method.post, ApiUrl.lift_brand,
            objectFromJson: (res) => LiftBrandEntity.fromJsonMap(res),
            params: {},
            isList: true,
            onSuccessList: onSuccess,
            onError: (code, msg) {
              loginExpire(code);
              onError(code, msg);
            });
  }

  ///添加电梯
  Future liftAdd(projectId, workerId, lift,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "workerId": workerId,
      "mtCompanyId": SpUtil.getString(Constant.companyId),
      "projectId": projectId,
      "lift": lift
    };
    await DioUtils().requestNetwork<bool>(Method.post, ApiUrl.lift_add,
        params: data, onSuccess: onSuccess, onError: (code, msg) {
      loginExpire(code);
      onError(code, msg);
    });
  }

  ///编辑电梯
  Future liftEdit(projectId, workerId, lift,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "workerId": workerId,
      "mtCompanyId": SpUtil.getString(Constant.companyId),
      "projectId": projectId,
      "relevanceId": lift["relevanceId"],
      "lift": lift
    };
    await DioUtils().requestNetwork<bool>(Method.post, ApiUrl.lift_modify,
        params: data, onSuccess: onSuccess, onError: (code, msg) {
      loginExpire(code);
      onError(code, msg);
    });
  }

  ///获取消息中心列表
  Future notificationList(
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "userId": SpUtil.getString(Constant.userId),
      "companyId": SpUtil.getString(Constant.companyId)
    };
    await DioUtils()
        .requestNetwork<TeamItem>(Method.post, ApiUrl.notification_list,
            objectFromJson: (res) => TeamItem.fromJsonMap(res),
            params: data,
            onSuccessList: onSuccess,
            onError: (code, msg) {
              loginExpire(code);
              onError(code, msg);
            });
  }

  ///已加入的团队列表
  Future teamList(
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "userId": SpUtil.getString(Constant.userId),
      "companyId": SpUtil.getString(Constant.companyId)
    };
    await DioUtils()
        .requestNetwork<TeamItem>(Method.post, ApiUrl.mtcompany_ownList,
            objectFromJson: (res) => TeamItem.fromJsonMap(res),
            params: data,
            isList: true,
            onSuccessList: onSuccess,
            onError: (code, msg) {
              loginExpire(code);
              onError(code, msg);
            });
  }

  ///搜索团队列表
  Future teamSearch(pageNum, pageSize, companyName,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "pageNum": "${pageNum}",
      "pageSize": "${pageSize}",
      "companyName": "${companyName}",
    };
    await DioUtils()
        .requestNetwork<TeamEntity>(Method.post, ApiUrl.mtcompany_list,
            objectFromJson: (res) => TeamEntity.fromJsonMap(res),
            params: data,
            onSuccess: onSuccess,
            onError: (code, msg) {
              loginExpire(code);
              onError(code, msg);
            });
  }

  ///团队创建
  Future teamCreate(logoImg, companyName, remarks, corporator, telephone,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "logoImg": "${logoImg}",
      "companyName": "${companyName}",
      "remarks": "${remarks}",
      "corporator": "${corporator}",
      "telephone": "${telephone}",
      "userId": SpUtil.getString(Constant.userId)
    };
    await DioUtils()
        .requestNetwork<TeamEntity>(Method.post, ApiUrl.mtcompany_createTeam,
            objectFromJson: (res) => TeamEntity.fromJsonMap(res),
            params: data,
            onSuccess: onSuccess,
            onError: (code, msg) {
              loginExpire(code);
              onError(code, msg);
            });
  }

  ///切换团队
  Future changTeam(companyId,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "companyId": companyId,
      "userId": SpUtil.getString(Constant.userId)
    };
    await DioUtils()
        .requestNetwork<UserEntity>(Method.post, ApiUrl.mtcompany_changeTeam,
            objectFromJson: (res) => UserEntity.fromJsonMap(res),
            params: data,
            onSuccess: onSuccess,
            onError: (code, msg) {
              loginExpire(code);
              onError(code, msg);
            });
  }

  ///申请加入团队
  Future applyTeam(companyId, desc,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "companyId": companyId,
      "userId": SpUtil.getString(Constant.userId),
      "description": desc
    };
    await DioUtils()
        .requestNetwork<TeamEntity>(Method.post, ApiUrl.mtcompany_applyTeam,
            objectFromJson: (res) => TeamEntity.fromJsonMap(res),
            params: data,
            onSuccess: onSuccess,
            onError: (code, msg) {
              loginExpire(code);
              onError(code, msg);
            });
  }

  Future teamDetail(
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "companyId": SpUtil.getString(Constant.companyId),
    };
    await DioUtils()
        .requestNetwork<TeamInfoItem>(Method.post, ApiUrl.mtcompany_teamInfo,
            objectFromJson: (res) => TeamInfoItem.fromJsonMap(res),
            params: data,
            onSuccess: onSuccess,
            onError: (code, msg) {
              loginExpire(code);
              onError(code, msg);
            });
  }

  Future teamAuth(
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "mtCompanyId": SpUtil.getString(Constant.companyId),
    };
    await DioUtils()
        .requestNetwork<TeamAuthItem>(Method.post, ApiUrl.mtcompany_auditResult,
            objectFromJson: (res) => TeamAuthItem.fromJsonMap(res),
            params: data,
            onSuccess: onSuccess,
            onError: (code, msg) {
              loginExpire(code);
              onError(code, msg);
            });
  }

  /**
   * 发起认证
   */
  Future teamUploadAuth(id, attestationName, contactsName, contactsTel,
      businessLicenseAnnex, taxRegistration, logo,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "id": id,
      "attestationName": attestationName,
      "contactsName": contactsName,
      "contactsTel": contactsTel,
      "businessLicenseAnnex": businessLicenseAnnex,
      "taxRegistration": taxRegistration,
      "logoImg": logo,
      "userId": SpUtil.getString(Constant.userId),
      "mtCompanyId": SpUtil.getString(Constant.companyId),
    };
    await DioUtils()
        .requestNetwork<TeamAuthItem>(Method.post, ApiUrl.mtcompany_applyAudit,
            objectFromJson: (res) => TeamAuthItem.fromJsonMap(res),
            params: data,
            onSuccess: onSuccess,
            onError: (code, msg) {
              loginExpire(code);
              onError(code, msg);
            });
  }

  Future teamUserList(pageNum, pageSize,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "companyId": SpUtil.getString(Constant.companyId),
      "pageNum": pageNum,
      "pageSize": pageSize
    };
    await DioUtils()
        .requestNetwork<TeamUserEntity>(Method.post, ApiUrl.mtcompany_userList,
            objectFromJson: (res) => TeamUserEntity.fromJsonMap(res),
            params: data,
            onSuccess: onSuccess,
            onError: (code, msg) {
              loginExpire(code);
              onError(code, msg);
            });
  }

  Future maintenanceCount(String time,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "userId": SpUtil.getString(Constant.userId),
      "beginTime": time.substring(0, 8) + "01",
    };
    await DioUtils().requestNetwork<MantenanceCountItem>(
        Method.post, ApiUrl.maintenance_count,
        objectFromJson: (res) => MantenanceCountItem.fromJsonMap(res),
        isList: true,
        params: data,
        onSuccessList: onSuccess,
        onError: (code, msg) {
          loginExpire(code);
          onError(code, msg);
        });
  }

  ///保养列表
  Future maintenanceList(pageNum, pageSize, status, time,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    if (status == 0 || status == 3) {
      var data = {
        "pageNum": pageNum,
        "pageSize": pageSize,
        "workerId": SpUtil.getString(Constant.userId),
        "status": status == 3 ? -1 : status,
        "currentTime": time
      };
      await DioUtils().requestNetwork<MaintenanceListEntity>(
          Method.post, ApiUrl.maintenance_planTask_list,
          objectFromJson: (res) => MaintenanceListEntity.fromJsonMap(res),
          params: data,
          onSuccess: onSuccess,
          onError: (code, msg) {
            loginExpire(code);
            onError(code, msg);
          });
    } else {
      var data = {
        "pageNum": pageNum,
        "pageSize": pageSize,
        "workerId": SpUtil.getString(Constant.userId),
        "status": status,
        "currentTime": time
      };
      await DioUtils().requestNetwork<MaintenanceListEntity>(
          Method.post, ApiUrl.maintenance_recordTask_list,
          objectFromJson: (res) => MaintenanceListEntity.fromJsonMap(res),
          params: data,
          onSuccess: onSuccess,
          onError: (code, msg) {
            loginExpire(code);
            onError(code, msg);
          });
    }
  }

  ///上次维保信息
  Future maintenanceRecordInfo(liftId,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "mtCompanyId": SpUtil.getString(Constant.companyId),
      "liftId": liftId
    };
    await DioUtils().requestNetwork<MaintenanceLastEntity>(
        Method.post, ApiUrl.maintenance_record_info,
        objectFromJson: (res) => MaintenanceLastEntity.fromJsonMap(res),
        params: data,
        onSuccess: onSuccess,
        onError: (code, msg) {
          loginExpire(code);
          onError(code, msg);
        });
  }

  ///保养项目
  Future maintenanceOptions(type, liftCategory,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "mtCompanyId": SpUtil.getString(Constant.companyId),
      "type": type,
      "liftCategory": liftCategory
    };
    await DioUtils().requestNetwork<MaintenanceOptionsItem>(
        Method.post, ApiUrl.maintenance_options,
        objectFromJson: (res) => MaintenanceOptionsItem.fromJsonMap(res),
        params: data,
        isList: true,
        onSuccessList: onSuccess,
        onError: (code, msg) {
          loginExpire(code);
          onError(code, msg);
        });
  }

  ///保养项目
  Future maintenanceRecordAdd(id, workerId, liftId, liftType, projectId, type,
      safetyConfirm, coordinate, address, isRegular, isRepair,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    String mType = "1";
    if (type == "6" || type == "18") {
      mType = "2";
    } else if (type == "12") {
      mType = "3";
    } else if (type == "24") {
      mType = "4";
    }
    var data = {
      "coordinate": coordinate,
      "periods": type,
      "record": {
        "mtCompanyId": SpUtil.getString(Constant.companyId),
        "workerId1": SpUtil.getString(Constant.userId),
        "workerId": workerId,
        "mtPlanId": id,
        "liftId": liftId,
        "liftType": liftType,
        "projectId": projectId,
        "type": mType,
        "safetyConfirm": safetyConfirm,
        "position": address,
        "isRegular": isRegular,
        "isRepair": isRepair
      }
    };
    await DioUtils().requestNetwork<String>(
        Method.post, ApiUrl.maintenance_record_add,
        params: data, onSuccess: onSuccess, onError: (code, msg) {
      loginExpire(code);
      onError(code, msg);
    });
  }

  ///提交保养单
  Future maintenanceRecordModify(
      id, maintenanceAdvice, options, signatureImg1, signatureImg2, images,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "record": {
        "id": id,
        "maintenanceAdvice": maintenanceAdvice,
        "maintenanceOption": options,
        "signatureImg1": signatureImg1,
        "signatureImg2": signatureImg2,
      },
      "recordImageList": images
    };
    await DioUtils().requestNetwork<bool>(
        Method.post, ApiUrl.maintenance_record_modify,
        params: data, onSuccess: onSuccess, onError: (code, msg) {
      loginExpire(code);
      onError(code, msg);
    });
  }

  ///保养详情
  Future maintenanceRecordDetail(id,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {"id": id};
    await DioUtils().requestNetwork<MaintenanceDetailEntity>(
        Method.post, ApiUrl.maintenance_record_detail,
        objectFromJson: (res) => MaintenanceDetailEntity.fromJsonMap(res),
        params: data,
        onSuccess: onSuccess,
        onError: (code, msg) {
          loginExpire(code);
          onError(code, msg);
        });
  }

  ///保养评价
  Future maintenanceEvaluate(id, advice, serviceLevel, starLevel, imgUrl,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "userId": SpUtil.getString(Constant.userId),
      "recordId": id,
      "type": 2,
      "advice": advice,
      "serviceLevel": serviceLevel,
      "starLevel": starLevel,
      "imgUrl": imgUrl,
    };
    await DioUtils().requestNetwork<bool>(
        Method.post, ApiUrl.maintenance_record_evaluate,
        params: data, onSuccess: onSuccess, onError: (code, msg) {
      loginExpire(code);
      onError(code, msg);
    });
  }

  ///急修列表
  Future repairCount(
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils()
        .requestNetwork<RepairCountItem>(Method.post, ApiUrl.repair_count,
            objectFromJson: (res) => RepairCountItem.fromJsonMap(res),
            params: {},
            onSuccess: onSuccess,
            onError: (code, msg) {
              loginExpire(code);
              onError(code, msg);
            });
  }

  ///急修列表
  Future repairList(pageNum, pageSize, status,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "pageNum": pageNum,
      "pageSize": pageSize,
      "workerId": SpUtil.getString(Constant.userId),
      "status": status
    };
    await DioUtils()
        .requestNetwork<RepairListEntity>(Method.post, ApiUrl.repair_list,
            objectFromJson: (res) => RepairListEntity.fromJsonMap(res),
            params: data,
            onSuccess: onSuccess,
            onError: (code, msg) {
              loginExpire(code);
              onError(code, msg);
            });
  }

  ///新增急修
  Future repairAdd(projectId, liftId, isTrapped, isCritical, repairReason,
      callerFaultDescription, callerName, callerTel, callerDate,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "mtCompanyId": SpUtil.getString(Constant.companyId),
      "workerId1": SpUtil.getString(Constant.userId),
      "projectId": projectId,
      "liftId": liftId,
      "isTrapped": isTrapped,
      "isCritical": isCritical,
      "repairReason": repairReason,
      "callerFaultDescription": callerFaultDescription,
      "source": 2,
      "callerName": callerName,
      "callerTel": callerTel,
      "callerDate": callerDate,
    };
    await DioUtils().requestNetwork<bool>(Method.post, ApiUrl.repair_add,
        params: data, onSuccess: onSuccess, onError: (code, msg) {
      loginExpire(code);
      onError(code, msg);
    });
  }

  ///接单
  Future repairTaking(id, takingTime,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "id": id,
      "takingTime": takingTime,
    };
    await DioUtils().requestNetwork<bool>(Method.post, ApiUrl.repair_taking,
        params: data, onSuccess: onSuccess, onError: (code, msg) {
      loginExpire(code);
      onError(code, msg);
    });
  }

  ///到达
  Future repairArrive(id, arriveTime, position,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {"id": id, "arriveTime": arriveTime, "position": position};
    await DioUtils().requestNetwork<bool>(Method.post, ApiUrl.repair_arrive,
        params: data, onSuccess: onSuccess, onError: (code, msg) {
      loginExpire(code);
      onError(code, msg);
    });
  }

  ///停梯
  Future repairStop(id, stopDate, safetyConfirm,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {"id": id, "stopDate": stopDate, "safetyConfirm": safetyConfirm};
    await DioUtils().requestNetwork<bool>(Method.post, ApiUrl.repair_stop,
        params: data, onSuccess: onSuccess, onError: (code, msg) {
      loginExpire(code);
      onError(code, msg);
    });
  }

  ///获取急修故障
  Future repairFaultTree(liftCategory,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {"liftCategory": liftCategory};
    await DioUtils().requestNetwork<RepairFaultEntity>(
        Method.post, ApiUrl.repair_fault_tree,
        objectFromJson: (res) => RepairFaultEntity.fromJsonMap(res),
        params: data,
        isList: true,
        onSuccessList: onSuccess,
        onError: (code, msg) {
          loginExpire(code);
          onError(code, msg);
        });
  }

  ///保存急修单
  Future repairSaveOrder(
      id,
      recoveryDate,
      erRecordImg,
      fieldDescription,
      mainSign,
      secondSign,
      faultPart,
      faultReason,
      faultHandle,
      faultNature,
      faultDuty,
      {Function onSuccess,
      Function(int code, String msg) onError}) async {
    var data = {
      "id": id,
      "recoveryDate": recoveryDate,
      "erRecordImg": erRecordImg,
      "fieldDescription": fieldDescription,
      "mainSign": mainSign,
      "secondSign": secondSign,
      "faultPart": faultPart,
      "faultReason": faultReason,
      "faultHandle": faultHandle,
      "faultNature": faultNature,
      "faultDuty": faultDuty,
    };
    print(data);
    await DioUtils().requestNetwork<bool>(
        Method.post, ApiUrl.repair_repairOrder,
        params: data, onSuccess: onSuccess, onError: (code, msg) {
      loginExpire(code);
      onError(code, msg);
    });
  }

  ///获取急修单
  Future repairDetail(id,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {"id": id};
    await DioUtils()
        .requestNetwork<RepairItem>(Method.post, ApiUrl.repair_detail,
            objectFromJson: (res) => RepairItem.fromJsonMap(res),
            params: data,
            onSuccess: onSuccess,
            onError: (code, msg) {
              loginExpire(code);
              onError(code, msg);
            });
  }

  ///急修评价
  Future repairEvaluate(id, advice, serviceLevel, starLevel, imgUrl,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "userId": SpUtil.getString(Constant.userId),
      "recordId": id,
      "type": 2,
      "advice": advice,
      "serviceLevel": serviceLevel,
      "starLevel": starLevel,
      "imgUrl": imgUrl,
    };
    await DioUtils().requestNetwork<bool>(Method.post, ApiUrl.repair_evaluate,
        params: data, onSuccess: onSuccess, onError: (code, msg) {
      loginExpire(code);
      onError(code, msg);
    });
  }

  ///年检列表
  Future yearlyList(pageNum, pageSize, status,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "pageNum": pageNum,
      "pageSize": pageSize,
      "workerId": SpUtil.getString(Constant.userId),
      "status": status //年检完成状态（0 待完成；1 已完成；2 超期）
    };
    await DioUtils()
        .requestNetwork<YearlyListEntity>(Method.post, ApiUrl.yearly_list,
            objectFromJson: (res) => YearlyListEntity.fromJsonMap(res),
            params: data,
            onSuccess: onSuccess,
            onError: (code, msg) {
              loginExpire(code);
              onError(code, msg);
            });
  }

  ///年检管理-待确认年检列表
  Future yearlyNoConfirmList(pageNum, pageSize, status,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "pageNum": pageNum,
      "pageSize": pageSize,
      "mtCompanyId": SpUtil.getString(Constant.companyId),
    };
    await DioUtils().requestNetwork<YearlyListEntity>(
        Method.post, ApiUrl.yearly_toConfirmList,
        objectFromJson: (res) => YearlyListEntity.fromJsonMap(res),
        params: data,
        onSuccess: onSuccess,
        onError: (code, msg) {
          loginExpire(code);
          onError(code, msg);
        });
  }

  Future yearlyConfirm(liftId, isCheckGoverner, loadInspectionSetting, planDate,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "liftId": liftId,
      "mtCompanyId": SpUtil.getString(Constant.companyId),
      "isCheckGoverner": isCheckGoverner,
      "loadInspectionSetting": loadInspectionSetting,
      "planDate": planDate
    };
    await DioUtils().requestNetwork<String>(Method.post, ApiUrl.yearly_confirm,
        params: data, onSuccess: onSuccess, onError: (code, msg) {
      loginExpire(code);
      onError(code, msg);
    });
  }

  ///上传质检报告
  Future yearlySelfCheck(id, time, imgUrl,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "id": id,
      "selfcheckDate": "${time}",
      "selfcheckReportImg": "${imgUrl}"
    };
    await DioUtils().requestNetwork<bool>(Method.post, ApiUrl.yearly_selfcheck,
        params: data, onSuccess: onSuccess, onError: (code, msg) {
      loginExpire(code);
      onError(code, msg);
    });
  }

  ///上传检验结果
  Future yearlyCheck(id, time, imgUrl,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "id": id,
      "checkDate": "${time}",
      "checkResultImg": "${imgUrl}"
    };
    await DioUtils().requestNetwork<bool>(Method.post, ApiUrl.yearly_check,
        params: data, onSuccess: onSuccess, onError: (code, msg) {
      loginExpire(code);
      onError(code, msg);
    });
  }

  ///上传检验结果
  Future yearlyFinish(id, imgUrl, imgUrl2,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "id": id,
      "certificateImgUrl": "${imgUrl2}",
      "annualInspectionImg": "${imgUrl}"
    };
    await DioUtils().requestNetwork<bool>(Method.post, ApiUrl.yearly_finish,
        params: data, onSuccess: onSuccess, onError: (code, msg) {
      loginExpire(code);
      onError(code, msg);
    });
  }

  ///年检统计
  Future yearlyCount(
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils()
        .requestNetwork<YearlyCountItem>(Method.post, ApiUrl.yearly_count,
            objectFromJson: (res) => YearlyCountItem.fromJsonMap(res),
            params: {},
            onSuccess: onSuccess,
            onError: (code, msg) {
              loginExpire(code);
              onError(code, msg);
            });
  }

  Future newsList(pageNum, pageSize, haveTops, title, city,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "pageNum": pageNum,
      "pageSize": pageSize,
      "haveTops": haveTops,
      "title": title,
      "district": city
    };
    await DioUtils()
        .requestNetwork<NewsCommEntity>(Method.post, ApiUrl.news_list,
            objectFromJson: (res) => NewsCommEntity.fromJsonMap(res),
            params: data,
            onSuccess: onSuccess,
            onError: (code, msg) {
              loginExpire(code);
              onError(code, msg);
            });
  }

  Future newsDetail(id,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "id": id,
    };
    await DioUtils()
        .requestNetwork<NewsDetailItem>(Method.post, ApiUrl.news_detail,
            objectFromJson: (res) => NewsDetailItem.fromJsonMap(res),
            params: data,
            onSuccess: onSuccess,
            onError: (code, msg) {
              loginExpire(code);
              onError(code, msg);
            });
  }

  Future newsZan(id,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {"id": id, "userId": SpUtil.getString(Constant.userId)};
    await DioUtils()
        .requestNetwork<NewsDetailItem>(Method.post, ApiUrl.news_zan,
            objectFromJson: (res) => NewsDetailItem.fromJsonMap(res),
            params: data,
            onSuccess: onSuccess,
            onError: (code, msg) {
              loginExpire(code);
              onError(code, msg);
            });
  }

  Future signList(pageNum, pageSize, clockTime,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "pageNum": pageNum,
      "pageSize": pageSize,
      "userId": SpUtil.getString(Constant.userId),
      "clockTime": clockTime,
    };
    await DioUtils()
        .requestNetwork<SignListEntity>(Method.post, ApiUrl.sign_list,
            objectFromJson: (res) => SignListEntity.fromJsonMap(res),
            params: data,
            onSuccess: onSuccess,
            onError: (code, msg) {
              loginExpire(code);
              onError(code, msg);
            });
  }

  Future signConfig(
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "mtCompanyId": SpUtil.getString(Constant.companyId),
    };
    await DioUtils()
        .requestNetwork<SignConfigItem>(Method.post, ApiUrl.sign_config,
            objectFromJson: (res) => SignConfigItem.fromJsonMap(res),
            params: data,
            onSuccess: onSuccess,
            onError: (code, msg) {
              loginExpire(code);
              onError(code, msg);
            });
  }

  Future signAdd(coordinate, address, type,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "mtCompanyId": SpUtil.getString(Constant.companyId),
      "userId": SpUtil.getString(Constant.userId),
      "coordinate": coordinate,
      "address": address,
      "type": type
    };
    await DioUtils().requestNetwork<bool>(Method.post, ApiUrl.sign_add,
        params: data, onSuccess: onSuccess, onError: (code, msg) {
      loginExpire(code);
      onError(code, msg);
    });
  }

  ///大修统计
  Future heavyCount(
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils()
        .requestNetwork<HeavyCountItem>(Method.post, ApiUrl.capital_count,
            objectFromJson: (res) => HeavyCountItem.fromJsonMap(res),
            params: {},
            onSuccess: onSuccess,
            onError: (code, msg) {
              loginExpire(code);
              onError(code, msg);
            });
  }

  ///大修项目列表
  Future searchHeavyProject(pageNum, pageSize, status,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "mtCompanyId": SpUtil.getString(Constant.companyId),
      "userId": SpUtil.getString(Constant.userId),
      "projectStatus": status,
      "pageNum": pageNum,
      "projectName": "",
      "pageSize": pageSize
    };
    await DioUtils().requestNetwork<HeavyListEntity>(
        Method.post, ApiUrl.capital_project_list,
        objectFromJson: (res) => HeavyListEntity.fromJsonMap(res),
        params: data,
        onSuccess: onSuccess,
        onError: (code, msg) {
          loginExpire(code);
          onError(code, msg);
        });
  }

  ///大修电梯列表
  Future searchHeavyLift(projectId, pageNum, pageSize, searchStr,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "id": projectId,
      "pageNum": pageNum,
      "pageSize": pageSize,
      "registrationCode": searchStr
    };
    await DioUtils()
        .requestNetwork<LiftListEntity>(Method.post, ApiUrl.capital_lift_list,
            objectFromJson: (res) => LiftListEntity.fromJsonMap(res),
            params: data,
            onSuccess: onSuccess,
            onError: (code, msg) {
              loginExpire(code);
              onError(code, msg);
            });
  }

  ///大修项目详情
  Future heavyProjectDetail(id,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "id": id,
    };

    await DioUtils()
        .requestNetwork<HeavyItem>(Method.post, ApiUrl.capital_project_detail,
            objectFromJson: (res) => HeavyItem.fromJsonMap(res),
            params: data,
            onSuccess: onSuccess,
            onError: (code, msg) {
              loginExpire(code);
              onError(code, msg);
            });
  }

  ///大修项目用户列表
  Future heavyUserList(projectId, isUser, signDate,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "mtCompanyId": SpUtil.getString(Constant.companyId),
      "projectId": projectId,
      "userId": isUser ? SpUtil.getString(Constant.userId) : "",
    };
    if (signDate.length > 0) {
      data['signDate'] = signDate;
    }
    await DioUtils().requestNetwork<HeavyUserEntity>(
        Method.post, ApiUrl.capital_attendance_list,
        objectFromJson: (res) => HeavyUserEntity.fromJsonMap(res),
        isList: true,
        params: data,
        onSuccessList: onSuccess,
        onError: (code, msg) {
          loginExpire(code);
          onError(code, msg);
        });
  }

  ///大修签到
  Future heavySignAdd(coordinate, address, projectId,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "mtCompanyId": SpUtil.getString(Constant.companyId),
      "userId": SpUtil.getString(Constant.userId),
      "projectId": projectId,
      "coordinate": coordinate,
      "address": address
    };
    await DioUtils().requestNetwork<bool>(Method.post, ApiUrl.capital_sign_in,
        params: data, onSuccess: onSuccess, onError: (code, msg) {
      loginExpire(code);
      onError(code, msg);
    });
  }

  ///开始项目
  Future capitalBegin(id,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "projectId": id,
    };
    await DioUtils().requestNetwork<bool>(Method.post, ApiUrl.capital_begin,
        params: data, onSuccess: onSuccess, onError: (code, msg) {
      loginExpire(code);
      onError(code, msg);
    });
  }

  ///竣工
  Future capitalCompleted(id, imgs,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "mtCompanyId": SpUtil.getString(Constant.companyId),
      "projectId": id,
      "imageUrlList": imgs
    };
    await DioUtils().requestNetwork<String>(
        Method.post, ApiUrl.capital_completed,
        params: data, onSuccess: onSuccess, onError: (code, msg) {
      loginExpire(code);
      onError(code, msg);
    });
  }

  ///消息列表
  Future messageList(pageIndex, pageSize, type,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "userId": SpUtil.getString(Constant.userId),
      "type": type,
      "pageNum": pageIndex,
      "pageSize": pageSize,
    };
    await DioUtils()
        .requestNetwork<MessageListEntity>(Method.post, ApiUrl.push_msg_list,
            objectFromJson: (res) => MessageListEntity.fromJsonMap(res),
            params: data,
            onSuccess: onSuccess,
            onError: (code, msg) {
              loginExpire(code);
              onError(code, msg);
            });
  }

  ///消息列表
  Future messageDetail(id,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "id": id,
    };
    await DioUtils()
        .requestNetwork<MessageListItem>(Method.post, ApiUrl.push_msg,
            objectFromJson: (res) => MessageListItem.fromJsonMap(res),
            params: data,
            onSuccess: onSuccess,
            onError: (code, msg) {
              loginExpire(code);
              onError(code, msg);
            });
  }

  loginExpire(int code) {
    if (code == 10 && context != null) {
      showAlert(context, "提示", "用户登录失效,请重新登录", "重新登录", () {
        User().clearUser();
        // _push.unbindAccount(account: f.SpUtil.getString(Constant.phone));
        NavigatorUtils.push(context, AccountRouter.loginPage, clearStack: true);
      });
    }
  }

  Options _getFormOptions() {
    Map<String, String> map = new Map();
//    map["Content-Type"] = "multipart/form-data; charset=utf-8";
    map["Accept"] = "application/json";
//    return Options(contentType: "multipart/form-data; charset=utf-8",responseType: ResponseType.json);
    return Options(contentType: "multipart/form-data; charset=utf-8");
  }
}

class NewApiUrl {
  static const String banner_list = "/udream/api/bannerImages/query-page";
  static const String userCoupons = "/udream/api/userCoupons/couponNum";
  static const String money_detail = "/udream/api/userBills/query";

  static const String rewardsecond =
      "/udream/api/userInfos/getExpertRewardedCount";
  static const String uploadFiles = "/udream/files";
  static const String uploadFilesOss = "/udream/files/oss";
  static const String question_list = "/udream/api/questionBanks/query-page";
  static const String question_detail_all = "/udream/api/questionBanks/query/";
  static const String product_collect_list =
      "/udream/api/userCollects/query-shopping";
  static const String position_collect_list =
      "/udream/api/userCollects/query-recruitmentInfo";
  static const String question_collect_list =
      "/udream/api/userCollects/query-question";
  static const String video_collect_list =
      "/udream/api/userCollects/query-schoolVideo";
  static const String question_detail = "/udream/api/questionBanks/query-app/";
  static const String question_like = "/udream/api/questionBanks/like/";
  static const String question_noLike = "/udream/api/questionBanks/noLike/";
  static const String question_fav = "/udream/api/questionBanks/collect/";
  static const String question_noFav = "/udream/api/questionBanks/noCollect/";
  static const String add_video = "/udream/api/schoolVideos/insert";
  static const String edit_video = "/udream/api/schoolVideos/update";
  static const String updateDownLoadNum =
      "/udream/api/liftFiles/updateDownLoadNum/";
  static const String video_list = "/udream/api/schoolVideos/query-page";
  static const String video_detail =
      "/udream/api/schoolVideos/detailWithRecord";
  static const String video_like = "/udream/api/schoolVideoOperates/insert";
  static const String video_like_cancel =
      "/udream/api/schoolVideoOperates/delete/";
  static const String shop_fav = "/udream/api/shoppingOperates/insert";
  static const String shop_fav_cancel = "/udream/api/shoppingOperates/delete/";
  static const String shop_list = "/udream/api/shoppings/query-page";
  static const String expertsPunishments =
      "/udream/api/expertsPunishments/query-page";
  static const String rewardList = "/udream/api/userInfos/getRewardList";
  static const String shop_detail = "/udream/api/shoppings/detailWithRecord";
  static const String punishments_detail =
      "/udream/api/expertsPunishments/query/";
  static const String position_list = "/udream/api/recruitmentInfos/query-page";
  static const String xieyiListNoPage =
      "/udream/api/userAgreements/queryListCharge";
  static const String liftFilesDetail = "/udream/api/liftFiles/query/";
  static const String position_detail =
      "/udream/api/recruitmentInfos/detailWithRecord";
  static const String insertRecruitmentOperates =
      "/udream/api/recruitmentOperates/insert";
  static const String deleteRecruitmentOperates =
      "/udream/api/recruitmentOperates/delete/";

  static const String applyJob = "/udream/api/userResumes/applyJob";
  static const String get_resume = "/udream/api/userResumes/getResumeByUserId";

  static const String brand_list_page = "/udream/api/liftBrands/query-page";
  static const String brand_list_nopage = "/udream/api/liftBrands/query";
  static const String coupon_list_nopage = "/udream/api/userCoupons/queryAll";
  static const String coupon_list_page = "/udream/api/userCoupons/query-page";
  static const String brand_list_type = "/udream/api/liftBrands/brandListApp";
  static const String add_brand = "/udream/api/liftBrands/insert";
  static const String control_list_page = "/udream/api/liftControls/query-page";
  static const String control_detail = "/udream/api/liftControls/query/";
  static const String expert_list = "/udream/api/userInfos/listExpert";
  static const String getAllRebate = "/udream/api/userRebates/getAllRebate/";
  static const String expert_comment_list =
      "/udream/api/expertComments/query-expert";
  static const String expert_list_nopage =
      "/udream/api/userInfos/queryAllExpert";
  static const String expert_list_grouped =
      "/udream/api/userInfos/listGroupExpert";
  static const String expert_detail = "/udream/api/userInfos/query/";
  static const String rest_qrcode = "/udream/api/userInfos/rebuildQrCode/";
  static const String coupon_list = "/udream/api/userCoupons/query-page";
  static const String lift_files_page = "/udream/api/liftFiles/query-page";
  static const String brand_detail = "/udream/api/liftBrands/query/";
  static const String fault_code_page = "/udream/api/liftFaultCodes/query-page";
  static const String fault_code_detail = "/udream/api/liftFaultCodes/query/";
  static const String liftcase_list_page = "/udream/api/liftCases/query-page";
  static const String liftcase_list_nopage =
      "/udream/api/liftCases/getAllCaseToInvoice";
  static const String liftcase_detail = "/udream/api/liftCases/query/";
  static const String liftcase_receiving =
      "/udream/api/liftCases/inviteExperts";
  static const String liftcase_refuze = "/udream/api/liftCases/refusedExperts";
  static const String fileCategorysTree =
      "/udream/api/liftCategorys/queryToTree";
  static const String create_case = "/udream/api/liftCases/createLiftCase";
  static const String aliPayTo = "/udream/api/alipay";
  static const String wxTo = "/udream/api/wxpay/case";
  static const String tableDictsConstant =
      "/udream/api/tableDicts/query-constant";
  static const String wallet_list = "/udream/api/userBills/query-page";
  static const String findOneByLiftCase =
      "/udream/api/chatSessions/findOneByLiftCase";
  static const String generateOrder = "/udream/api/liftCases/generateOrder";
  static const String generateRoom = "/udream/api/liftCases/generateRoom";
  static const String testAlipayNotify = "/udream/api/testAlipayNotify/";
  static const String getServiceFee =
      "/udream/api/liftCases/platformServiceFee";

  static const String user_order_page = "/udream/api/userOrderss/query-page";
  static const String vipFeeSettings = "/udream/api/vipFeeSettings/query-page";
  static const String user_order_detail = "/udream/api/userOrderss/query/";
  static const String becomeMasterDetail =
      "/udream/api/applyExperts/queryByUserId/";
  static const String updataUserLoginInfo = "/udream/api/userInfos/getNewInfo";
  static const String becomeMasterUpdate = "/udream/api/applyExperts/update";
  static const String isDelayAddressUrl = "/udream/api/otherSettings/query-new";
  static const String startDelayAddressUrl =
      "/udream/api/motionTrails/addTrail";
  static const String msgHistoryList = "/udream/api/chatMsgs/msgHistoryList";
  static const String user_order_update = "/udream/api/userOrderss/update";
  static const String apply_invoice = "/udream/api/applyInvoices/applyInvoice";
  static const String submit_comments = "/udream/api/expertComments/insert";
  static const String search_index = "/udream/api/searchIndexs/search-index/";
  static const String search_hot = "/udream/api/searchHistorys/getHotSearch";
  static const String piaotou_list_page = "/udream/api/userInvoices/query-page";
  static const String getNearUser = "/udream/api/userInfos/getNearUser";
  static const String add_piaotou = "/udream/api/userInvoices/insert";
  static const String edit_piaotou = "/udream/api/userInvoices/update";
  static const String detail_piaotou = "/udream/api/userInvoices/query/";
  static const String add_appeal = "/udream/api/liftCaseAppeals/insert";
  static const String delete_piaotou = "/udream/api/userInvoices/delete/";
  static const String vipOrExpert = "/udream/api/userRebates/isVipOrExpert/";
  static const String setVipluckNum = "/udream/api/userInfos/saveVipID/";

  static const String queryPageByInvoiceId =
      "/udream/api/liftCases/queryPageByInvoiceId";
  static const String piao_list_page = "/udream/api/applyInvoices/query-page";
  static const String piao_detail = "/udream/api/applyInvoices/query/";
  static const String update_user = "/udream/api/userInfos/updateUser";
  static const String alipayBalanceApp = "/udream/api/alipayBalanceApp";
  static const String createPrivateChatRoom =
      "/udream/api/chatSessions/createPrivateChatRoom";
  static const String friend_list = "/udream/api/chatSessions/findFriendList";
  static const String chat_session_delete = "/udream/api/chatSessions/delete";
  static const String chat_session_pin = "/udream/api/chatSessions/set-top";
  static const String friend_set_remarks = "/udream/api/kindlyCall/insert";

  // static const String friend_list = "/udream/api/chatSessions/query-page";

  static const String user_make_sure_case =
      "/udream/api/liftCases/userMakeSureCase"; // 用户确认诊单
  static const String user_Delete_order =
      "/udream/api/liftCases/delete"; // 用户删除订单
  static const String user_cancel_order =
      "/udream/api/liftCases/cancelCase"; // 用户取消订单

  static const String quote = "/udream/api/liftCases/toOffer"; // 专家报价
  static const String chargeToClock =
      "/udream/api/liftCases/chargeToClock"; // 专家打卡
  static const String chargeMakeSureCase =
      "/udream/api/liftCases/chargeMakeSureCase/"; // 专家确认订单
  static const String userToClock =
      "/udream/api/liftCases/userToClock"; // 用户确认打卡
  static const String question_collect =
      "/udream/api/questionBanks/question-collect"; // 问题归档

  static const String update_vip = "/udream/api/userInfos/toVip"; // 修改用户信息
  static const String getMemberAllMenu =
      "/udream/api/appuserMenus/getMemberAllMenu"; // 获取vip等级和对应权限
  static const String getAllMenu =
      "/udream/api/appuserMenus/getAllMenu"; // 根据用户角色获取用户权益
  static const String getUserXieyi =
      "/udream/api/userAgreements/getAgreementByUser"; // 根据用户角色获取用户协议

  static const String createRecharge =
      "/udream/api/userRechargeDetails/createRecharge"; // 创建充值订单
  static const String insetWithdrwa =
      "/udream/api/userWithdraws/insetWithdrwa"; // 提现
  static const String alipayRecharge =
      "/udream/api/alipayRecharge"; // 支付宝-APP用户充值
  static const String alipayRechargewx =
      "/udream/api/wxpay/recharge"; // wx-APP用户充值
  static const String alipayReward = "/udream/api/reward"; // 支付宝-打赏
  static const String wxReward = "/udream/api/wxpay/reward"; // 微信-打赏
  static const String rechargeVIP = "/udream/api/rechargeVIP"; // 支付宝-VIP
  static const String rechargeVIPwx = "/udream/api/wxpay/rechargeVIP"; // wx-VIP
  static const String userRebates = "/udream/api/userRebates/insert"; //
  static const String applyExperts =
      "/udream/api/applyExperts/insert"; // 申请成为专家
  static const String expertsOrderCont =
      "/udream/api/liftCases/getMyCase"; // 我的接单统计数字
  ///我的消息列表
  // static const String mynotifica_list = "/push/message/list";
  static const String mynotifica_updata = "/push/message/read";
  static const String mynotifica_delete = "/push/message/deleteMessageList";
  static const String messageOverview = "/push/message/newMessageOne";
  static const String systemMessageList = "/push/message/systemList";
  static const String notificationMessageList = "/push/message/noticeList";
  static const String deleteAllMessage = "/push/message/deleteMessageList";

  //获取OSS Token
  static final String URL_TOKEN = "****/getAliyunOssToken";

  //获取OS上传图片服务器地址
  static final String URL_UPLOAD_IMAGE_OSS = ossUrl;
}

class NewApiService {
  Options _getFormOptions() {
    Map<String, String> map = new Map();
//    map["Content-Type"] = "multipart/form-data; charset=utf-8";
    map["Accept"] = "application/json";
//    return Options(contentType: "multipart/form-data; charset=utf-8",responseType: ResponseType.json);
    return Options(contentType: "multipart/form-data; charset=utf-8");
  }

  Future newsDetail(id,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "id": id,
    };
    await DioUtils().requestNetwork<NewsDetailItem>(
        Method.post, ApiUrl.news_detail,
        objectFromJson: (res) => NewsDetailItem.fromJsonMap(res),
        params: data,
        onSuccess: onSuccess,
        onError: onError);
  }

  // 文件上传
  Future upload(String file,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var name = file.substring(file.lastIndexOf("/") + 1);
    FormData formData =
        FormData.fromMap({"files": await MultipartFile.fromFile(file)});
    await DioUtils().requestNetwork<UploadModel>(
        Method.post, NewApiUrl.uploadFilesOss,
        objectFromJson: (res) => UploadModel.fromJson(res),
        params: formData,
        options: _getFormOptions(),
        onSuccess: onSuccess,
        onError: onError);
  }

  ///附近的人列表
  Future nearListNoPage(obj,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<NearModel>(
        Method.post, "${NewApiUrl.getNearUser}",
        params: obj,
        objectFromJson: (res) => NearModel.fromJson(res),
        isList: true,
        onSuccessList: onSuccess,
        onError: onError);
  }

  ///搜索
  Future getSearchIndex(text,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<SearchModel>(
        Method.post, "${NewApiUrl.search_index}$text",
        // Method.post, "${NewApiUrl.search_index}${Uri.encodeComponent(text)}",
        objectFromJson: (res) => SearchModel.fromJson(res),
        isList: true,
        onSuccessList: onSuccess,
        onError: onError);
  }

  Future getSearchHot(
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<HotSearchModel>(
        Method.post, "${NewApiUrl.search_hot}",
        objectFromJson: (res) => HotSearchModel.fromJson(res),
        isList: true,
        onSuccessList: onSuccess,
        onError: onError);
  }

  ///获取banner图
  Future getBanner(pageNum, pageSize,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {"pageNum": pageNum, "pageSize": pageSize, "type": 3};
    await DioUtils().requestNetwork<BannerModel>(
        Method.post, NewApiUrl.banner_list,
        objectFromJson: (res) => BannerModel.fromJson(res),
        params: data,
        onSuccess: onSuccess,
        onError: onError);
  }

  ///朋友分页列表
  Future getFriendListPage(pageNum, pageSize, searchWord,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      // "pageNum": pageNum,
      // "pageSize": pageSize,
      "userId": int.parse(SpUtil.getString(Constant.userId)),
      "caseExpression": searchWord,
      // "sort": {
      //   "order": "desc",
      //   "orderBy": "msgCreateTime"
      // }
    };
    await DioUtils().requestNetwork<FriendModel>(
        Method.post, "${NewApiUrl.friend_list}",
        objectFromJson: (res) => FriendModel.fromJson(res),
        params: data,
        onSuccess: onSuccess,
        onError: onError);
  }

  Future removeChatSession(int id, String sessionId,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "id": id,
      "sessionId": sessionId,
      // "userId": int.parse(SpUtil.getString(Constant.userId))
    };
    await DioUtils()
        .requestNetwork<bool>(Method.delete, "${NewApiUrl.chat_session_delete}",
            // objectFromJson: (res) => Object(),
            params: data,
            onSuccess: onSuccess,
            onError: onError);
  }

  Future pinChatSession(String sessionId, int flag,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "topFlag": flag,
      "sessionId": sessionId,
      // "userId": int.parse(SpUtil.getString(Constant.userId))
    };
    await DioUtils()
        .requestNetwork<String>(Method.post, "${NewApiUrl.chat_session_pin}",
            // objectFromJson: (res) => Object(),
            params: data,
            onSuccess: onSuccess,
            onError: onError);
  }

  Future setRemarksForFriend(
      {String remarks,
      int targetUserId,
      Function onSuccess,
      Function(int code, String msg) onError}) async {
    var data = {
      "nickname": remarks,
      "targetUserId": targetUserId,
      "userId": int.parse(SpUtil.getString(Constant.userId))
    };
    await DioUtils()
        .requestNetwork<bool>(Method.post, "${NewApiUrl.friend_set_remarks}",
            // objectFromJson: (res) => Object(),
            params: data,
            onSuccess: onSuccess,
            onError: onError);
  }

  // Handle messages

  Future getMessageOverview(
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<MessageOverview>(Method.get,
        "${NewApiUrl.messageOverview}?userId=${SpUtil.getString(Constant.userId)}",
        objectFromJson: (res) => MessageOverview.fromJson(res),
        onSuccess: onSuccess,
        onError: onError);
  }

  Future getSystemMessageList(int pageNum, int pageSize,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<MessageModel>(
        Method.post, "${NewApiUrl.systemMessageList}",
        params: {
          "userId": SpUtil.getString(Constant.userId),
          "pageNum": pageNum,
          "pageSize": pageSize,
        },
        objectFromJson: (res) => MessageModel.fromJson(res),
        onSuccess: onSuccess,
        onError: onError);
  }

  Future getNotificationMessageList(int pageNum, int pageSize,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<MessageModel>(
        Method.post, "${NewApiUrl.notificationMessageList}",
        params: {
          "userId": SpUtil.getString(Constant.userId),
          "pageNum": pageNum,
          "pageSize": pageSize,
        },
        objectFromJson: (res) => MessageModel.fromJson(res),
        onSuccess: onSuccess,
        onError: onError);
  }

  Future removeAllMessage(List<String> ids, int type,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<bool>(
        Method.post, "${NewApiUrl.deleteAllMessage}",
        params: {
          "userId": SpUtil.getString(Constant.userId),
          "type": type,
          "ids": ids
        },
        onSuccess: onSuccess,
        onError: onError);
  }

  Future deleteAllMessage(int type,
      {List ids,
      Function onSuccess,
      Function(int code, String msg) onError}) async {
    Map parmars = {
      "userId": SpUtil.getString(Constant.userId),
      "type": type,
    };
    if (ids != null) {
      parmars.addAll({
        "ids": ids,
      });
    }
    await DioUtils().requestNetwork<bool>(
        Method.post, "${NewApiUrl.deleteAllMessage}",
        params: parmars, onSuccess: onSuccess, onError: onError);
  }

  ///变更消息状态
  Future markMessagesRead(idList,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils()
        .requestNetwork<String>(Method.post, "${NewApiUrl.mynotifica_updata}",
            params: {
              "ids": idList,
            },
            onSuccess: onSuccess,
            onError: onError);
  }

  ///变更消息状态
  // Future markMessagDetele(type,
  //     {Function onSuccess, Function(int code, String msg) onError}) async {
  //   await DioUtils()
  //       .requestNetwork<String>(Method.post, "${NewApiUrl.mynotifica_updata}",
  //           params: {
  //             'userId':
  //             "type": type,
  //           },
  //           onSuccess: onSuccess,
  //           onError: onError);
  // }

  ///进入私聊初始化房间号
  Future createPrivateChatRoom(createUserId,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "userId": SpUtil.getString(Constant.userId),
      "createUserId": createUserId
    };
    await DioUtils().requestNetwork<Map>(
        Method.post, "${NewApiUrl.createPrivateChatRoom}",
        params: data, onSuccess: onSuccess, onError: onError);
  }

  ///发票抬头分页列表
  Future getPiaoTouListPage(pageNum, pageSize, type, isDefault,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "isDefault": isDefault,
      "type": type,
      "pageNum": pageNum,
      "pageSize": pageSize,
      "userId": int.parse(SpUtil.getString(Constant.userId))
    };
    await DioUtils().requestNetwork<piaotou.PiaoTouModel>(
        Method.post, "${NewApiUrl.piaotou_list_page}",
        objectFromJson: (res) => piaotou.PiaoTouModel.fromJson(res),
        params: data,
        onSuccess: onSuccess,
        onError: onError);
  }

  ///删除抬头
  Future getTouDelete(id,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "id": id,
    };
    await DioUtils().requestNetwork<piaotou.Records>(
        Method.delete, "${NewApiUrl.delete_piaotou}",
        // Method.delete, "${NewApiUrl.delete_piaotou}${id.toString()}",
        // objectFromJson: (res) => piaotou.Records.fromJson(res),
        params: data,
        onSuccess: onSuccess,
        onError: onError);
  }

  ///获取抬头详情
  Future getTouDetail(id,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    // var data = {
    //   "id": id,
    // };
    await DioUtils().requestNetwork<piaotou.Records>(
        Method.get, "${NewApiUrl.detail_piaotou}${id.toString()}",
        objectFromJson: (res) => piaotou.Records.fromJson(res),
        // params: data,
        onSuccess: onSuccess,
        onError: onError);
  }

  ///改变用户信息
  Future updateUser(obj,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<String>(
        Method.post, "${NewApiUrl.update_user}",
        params: obj, onSuccess: onSuccess, onError: onError);
  }

  ///账户余额支付
  Future getAlipayBalanceApp(obj,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<String>(
        Method.post, "${NewApiUrl.alipayBalanceApp}",
        params: obj, onSuccess: onSuccess, onError: onError);
  }

  ///我的卡券红包数量
  Future getUserCoupons(
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<Map>(Method.post,
        "${NewApiUrl.userCoupons}?userId=${SpUtil.getString(Constant.userId)}",
        onSuccess: onSuccess, onError: onError);
  }

  ///我的钱包详情数据
  Future getMoneyDetail(id,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<Map>(
        Method.get, "${NewApiUrl.money_detail}?id=$id",
        onSuccess: onSuccess, onError: onError);
  }

  ///打赏次数
  Future getRewardSecond(
      {id, Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<int>(
        Method.get, "${NewApiUrl.rewardsecond}?expert=$id",
        onSuccess: onSuccess, onError: onError);
  }

  ///添加发票抬头
  Future addPiaoTouListPage(obj,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<String>(
        Method.post, "${NewApiUrl.add_piaotou}",
        params: obj, onSuccess: onSuccess, onError: onError);
  }

  ///编辑发票抬头
  Future editPiaoTouListPage(obj,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<String>(
        Method.put, "${NewApiUrl.edit_piaotou}",
        params: obj, onSuccess: onSuccess, onError: onError);
  }

  ///我的发票查订单分页列表
  Future getQueryPageByInvoiceId(pageNum, pageSize, invoiceId,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "pageNum": pageNum,
      "pageSize": pageSize,
      "invoiceId": invoiceId
    };
    await DioUtils().requestNetwork<PiaoOrderModel>(
        Method.post, "${NewApiUrl.queryPageByInvoiceId}",
        objectFromJson: (res) => PiaoOrderModel.fromJson(res),
        params: data,
        onSuccess: onSuccess,
        onError: onError);
  }

  ///我的发票分页列表
  Future getPiaoListPage(pageNum, pageSize, userId,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "pageNum": pageNum,
      "pageSize": pageSize,
      "userId": int.parse(SpUtil.getString(Constant.userId))
    };
    await DioUtils().requestNetwork<piao.PiaoModelPage>(
        Method.post, "${NewApiUrl.piao_list_page}",
        objectFromJson: (res) => piao.PiaoModelPage.fromJson(res),
        params: data,
        onSuccess: onSuccess,
        onError: onError);
  }

  ///获取发票详情
  Future getPiaoDetail(id,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    // var data = {
    //   "id": id,
    // };
    await DioUtils().requestNetwork<piao.Records>(
        Method.get, "${NewApiUrl.piao_detail}${id.toString()}",
        objectFromJson: (res) => piao.Records.fromJson(res),
        // params: data,
        onSuccess: onSuccess,
        onError: onError);
  }

  ///根据订单id支付
  Future getTestAlipayNotify(orderId,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<int>(
        Method.get, "${NewApiUrl.testAlipayNotify}${orderId.toString()}",
        onSuccess: onSuccess, onError: onError);
  }

  ///根据诊单id查询房间信息
  Future findOne(dataId,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "dataId": dataId,
      "userId": int.parse(SpUtil.getString(Constant.userId)),
    };
    await DioUtils().requestNetwork<FindOneModel>(
        Method.post, NewApiUrl.findOneByLiftCase,
        objectFromJson: (res) => FindOneModel.fromJson(res),
        params: data,
        onSuccess: onSuccess,
        onError: onError);
  }

  ///完善诊单，创建订单
  Future generateOrder(data,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<String>(
        Method.post, NewApiUrl.generateOrder,
        params: data, onSuccess: onSuccess, onError: onError);
  }

  ///绑定专家
  Future generateRoom(data,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<String>(Method.post, NewApiUrl.generateRoom,
        params: data, onSuccess: onSuccess, onError: onError);
  }

  ///获取新闻列表
  Future newsList(int pageNum, int pageSize, int haveTops, String title,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "pageNum": pageNum,
      "pageSize": pageSize,
      "haveTops": haveTops,
      "title": title,
    };
    await DioUtils().requestNetwork<NewsEntity>(
        Method.post, ApiUrl.news_list, objectFromJson: (res) {
      return NewsEntity.fromJsonMap(res);
    }, params: data, onSuccess: onSuccess, onError: onError);
  }

  ///获取新闻列表
  Future topNewsList(int pageNum, int pageSize, int haveTops, String title,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "pageNum": pageNum,
      "pageSize": pageSize,
      "haveTops": haveTops,
      "title": title,
    };
    await DioUtils().requestNetwork<NewsEntity>(
        Method.post, ApiUrl.top_news_list, objectFromJson: (res) {
      return NewsEntity.fromJsonMap(res);
    }, params: data, onSuccess: onSuccess, onError: onError);
  }

  ///获取题库列表
  Future getQuestionList(pageNum, pageSize, brandId, name, title,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "pageNum": pageNum,
      "pageSize": pageSize,
      "platform": "app",
      "brandId": brandId,
      "userName": name,
      "title": title,
    };
    await DioUtils()
        .requestNetwork<mixmix.MixModel>(Method.post, NewApiUrl.question_list,
            objectFromJson: (res) => mixmix.MixModel.fromJson(res),
            // objectFromJson: (res) => QuestionModel.fromJson(res),
            params: data,
            onSuccess: onSuccess,
            onError: onError);
  }

  ///获取题库详情
  Future getQuestionDetail(id,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    // var data = {
    //   "id": id,
    // };
    await DioUtils().requestNetwork<QuestionDetailModel>(Method.get,
        "${NewApiUrl.question_detail}${id.toString()}/${SpUtil.getString(Constant.userId)}",
        objectFromJson: (res) {
      return QuestionDetailModel.fromJson(res);
    },
        // params: data,
        onSuccess: onSuccess,
        onError: onError);
  }

  ///获取题库详情
  Future getQuestionDetailAll(id,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "pageNum": 1,
      "platform": "web",
      "liftCaseId": id,
    };
    await DioUtils()
        .requestNetwork<mixmix.MixModel>(Method.post, NewApiUrl.question_list,
            objectFromJson: (res) => mixmix.MixModel.fromJson(res),
            // objectFromJson: (res) => QuestionModel.fromJson(res),
            params: data,
            onSuccess: onSuccess,
            onError: onError);
  }

  ///问题点赞
  Future questionLike(questionId, userId,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<bool>(Method.post,
        "${NewApiUrl.question_like}${SpUtil.getString(Constant.userId)}/${questionId.toString()}",
        onSuccess: onSuccess, onError: onError);
  }

  ///问题取消点赞
  Future questionLikeCancel(questionId, userId,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<bool>(Method.post,
        "${NewApiUrl.question_noLike}${SpUtil.getString(Constant.userId)}/${questionId.toString()}",
        onSuccess: onSuccess, onError: onError);
  }

  ///问题收藏
  Future questionFav(questionId, userId,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<bool>(Method.post,
        "${NewApiUrl.question_fav}${SpUtil.getString(Constant.userId)}/${questionId.toString()}",
        onSuccess: onSuccess, onError: onError);
  }

  ///问题取消收藏
  Future questionFavCancel(questionId, userId,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<bool>(Method.post,
        "${NewApiUrl.question_noFav}${SpUtil.getString(Constant.userId)}/${questionId.toString()}",
        onSuccess: onSuccess, onError: onError);
  }

  ///上传视频
  Future addVideo(obj,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<String>(Method.post, NewApiUrl.add_video,
        params: obj, onSuccess: onSuccess, onError: onError);
  }

  ///编辑视频
  Future editVideo(obj,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<String>(Method.put, NewApiUrl.edit_video,
        params: obj, onSuccess: onSuccess, onError: onError);
  }

  ///获取学堂列表
  Future getVideoList(pageNum, pageSize, userId, title, brandId, type,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "pageNum": pageNum,
      "pageSize": pageSize,
      "platform": type,
      "userId": userId,
      "title": title,
      "brandId": brandId
    };
    await DioUtils()
        .requestNetwork<mixmix.MixModel>(Method.post, NewApiUrl.video_list,
            objectFromJson: (res) => mixmix.MixModel.fromJson(res),
            // objectFromJson: (res) => VideoModel.fromJson(res),
            params: data,
            onSuccess: onSuccess,
            onError: onError);
  }

  ///获取学堂详情
  Future getVideoDetail(id, userId,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<VideoDetailModel>(Method.get,
        "${NewApiUrl.video_detail}?id=${id.toString()}&userId=${SpUtil.getString(Constant.userId)}",
        objectFromJson: (res) => VideoDetailModel.fromJson(res),
        onSuccess: onSuccess,
        onError: onError);
  }

  ///获取我的接单统计数字
  Future getExpertOrderCont(
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork(Method.get,
        "${NewApiUrl.expertsOrderCont}?userId=${SpUtil.getString(Constant.userId)}",
        objectFromJson: (res) => res, onSuccess: onSuccess, onError: onError);
  }

  ///获取下载量
  Future getUpdateDownLoadNum(id,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<String>(
        Method.get, "${NewApiUrl.updateDownLoadNum}${id.toString()}",
        onSuccess: onSuccess, onError: onError);
  }

  ///学堂点赞
  Future videoLike(dataId, type, userId,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "dataId": dataId,
      "type": type,
      "userId": int.parse(SpUtil.getString(Constant.userId)),
    };
    await DioUtils().requestNetwork<bool>(Method.post, NewApiUrl.video_like,
        params: data, onSuccess: onSuccess, onError: onError);
  }

  ///学堂取消点赞
  Future videoLikeCancel(id,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {"id": id};
    await DioUtils().requestNetwork<bool>(
        Method.delete, "${NewApiUrl.video_like_cancel}",
        params: data, onSuccess: onSuccess, onError: onError);
  }

  ///商城收藏
  Future shopFav(dataId, type, userId,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "dataId": dataId,
      "type": type,
      "userId": int.parse(SpUtil.getString(Constant.userId)),
    };
    await DioUtils().requestNetwork<bool>(Method.post, NewApiUrl.shop_fav,
        params: data, onSuccess: onSuccess, onError: onError);
  }

  ///商城取消收藏
  Future shopFavCancel(id,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {"id": id};
    await DioUtils().requestNetwork<bool>(
        Method.delete, "${NewApiUrl.shop_fav_cancel}",
        params: data, onSuccess: onSuccess, onError: onError);
  }

  ///获取商品列表
  Future getShopList(pageNum, pageSize, userId, name, brandId,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "pageNum": pageNum,
      "pageSize": pageSize,
      "platform": "app",
      "userId": userId,
      "name": name,
      "brandId": brandId,
    };
    await DioUtils().requestNetwork<mixmix.MixModel>(
        Method.post, NewApiUrl.shop_list,
        objectFromJson: (res) => mixmix.MixModel.fromJson(res),
        params: data,
        onSuccess: onSuccess,
        onError: onError);
  }

  ///惩罚列表
  Future getExpertsPunishmentsList(pageNum, pageSize,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "pageNum": pageNum,
      "pageSize": pageSize,
      "chargeId": int.parse(SpUtil.getString(Constant.userId))
    };
    await DioUtils().requestNetwork<punishments.PunishmentsModel>(
        Method.post, NewApiUrl.expertsPunishments,
        objectFromJson: (res) => punishments.PunishmentsModel.fromJson(res),
        params: data,
        onSuccess: onSuccess,
        onError: onError);
  }

  ///打赏记录列表
  Future getRewardRecordList(pageNum, pageSize,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "pageNum": pageNum,
      "pageSize": pageSize,
      "userId": int.parse(SpUtil.getString(Constant.userId))
    };
    await DioUtils().requestNetwork(Method.get, NewApiUrl.rewardList,
        queryParameters: data, isList: true, objectFromJson: (res) {
      // print(res);
      // List<ExpertsRewardRecordModel> a = [];
      // for (var item in res['data']) {
      //   a.add(ExpertsRewardRecordModel.fromJson(item));
      // }
      return ExpertsRewardRecordModel.fromJson(res);
      //
    }, params: data, onSuccessList: onSuccess, onError: onError);
  }

  ///获取钱包明细列表
  Future getWalletList(pageNum, pageSize,
      {int currentYear,
      int currentMonth,
      Function onSuccess,
      Function(int code, String msg) onError}) async {
    var data = {
      "pageNum": pageNum,
      "pageSize": pageSize,
      "currentYear": currentYear,
      "currentMonth": currentMonth,
      "userId": int.parse(SpUtil.getString(Constant.userId)),
      "sort": {
        "order": "desc",
        "orderBy": "create_time",
      }
    };
    await DioUtils().requestNetwork<WalletModel>(
        Method.post, NewApiUrl.wallet_list,
        objectFromJson: (res) => WalletModel.fromJson(res),
        params: data,
        onSuccess: onSuccess,
        onError: onError);
  }

  ///获取商品详情
  Future getShopDetail(id, userId,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<ShopDetailModel>(Method.get,
        "${NewApiUrl.shop_detail}?id=${id.toString()}&userId=${SpUtil.getString(Constant.userId)}",
        objectFromJson: (res) => ShopDetailModel.fromJson(res),
        onSuccess: onSuccess,
        onError: onError);
  }

  ///获取惩罚详情
  Future getPunishmentsDetail(id,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<punishments.Records>(
        Method.get, "${NewApiUrl.punishments_detail}$id",
        objectFromJson: (res) => punishments.Records.fromJson(res),
        onSuccess: onSuccess,
        onError: onError);
  }

  ///获取职位列表
  Future getPositionList(
    pageNum,
    pageSize, {
    String provinceName,
    String cityName,
    int minSalary,
    int maxSalary,
    String job,
    Function onSuccess,
    Function(int code, String msg) onError,
  }) async {
    var data = {
      "pageNum": pageNum,
      "pageSize": pageSize,
      "platform": "app",
      // "userId": userId,
      "provinceName": provinceName,
      "cityName": cityName,
      "minSalary": minSalary,
      "maxSalary": maxSalary,
      "job": job,
      "statuz": 1
    };
    await DioUtils().requestNetwork<mixmix.MixModel>(
        Method.post, NewApiUrl.position_list,
        objectFromJson: (res) => mixmix.MixModel.fromJson(res),
        params: data,
        onSuccess: onSuccess,
        onError: onError);
  }

  // 获取专家协议列表
  Future getXieyiListNoPage(
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<XieyiModel>(
        Method.get, "${NewApiUrl.xieyiListNoPage}",
        objectFromJson: (res) => XieyiModel.fromJson(res),
        isList: true,
        onSuccessList: onSuccess,
        onError: onError);
  }

  // 获取职位详情
  Future getPositionDetail(id,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<PositionDetailModel>(Method.get,
        "${NewApiUrl.position_detail}?id=${id.toString()}&userId=${SpUtil.getString(Constant.userId)}",
        objectFromJson: (res) => PositionDetailModel.fromJson(res),
        onSuccess: onSuccess,
        onError: onError);
  }

  // 获取文件详情
  Future getLiftFilesDetail(id,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<Map>(
        Method.get, "${NewApiUrl.liftFilesDetail}${id.toString()}",
        onSuccess: onSuccess, onError: onError);
  }

  // 插入招聘操作记录
  Future insertRecruitmentOperates(dataId, type,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<PositionDetailModel>(
        Method.post, "${NewApiUrl.insertRecruitmentOperates}",
        objectFromJson: (res) => PositionDetailModel.fromJson(res),
        params: {
          "userId": int.parse(SpUtil.getString(Constant.userId)),
          "dataId": dataId,
          "type": type
        },
        onSuccess: onSuccess,
        onError: onError);
  }

  ///添加品牌
  Future addBrand(name,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<bool>(Method.post, NewApiUrl.add_brand,
        params: {"name": name}, onSuccess: onSuccess, onError: onError);
  }

  ///品牌按字母排序
  Future getBrandListType(title,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<BrandModelType>(
        Method.post, "${NewApiUrl.brand_list_type}",
        params: {"sercheKey": title},
        objectFromJson: (res) => BrandModelType.fromJson(res),
        isList: true,
        onSuccessList: onSuccess,
        onError: onError);
  }

  ///品牌不分页列表
  Future getBrandListNoPage(
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<brandM.Records>(
        Method.post, NewApiUrl.brand_list_nopage,
        objectFromJson: (res) => brandM.Records.fromJson(res),
        isList: true,
        onSuccessList: onSuccess,
        onError: onError);
  }

  ///卡券不分页列表
  Future getCouponListNoPage(type, amount,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<coupon.Records>(Method.get,
        "${NewApiUrl.coupon_list_nopage}?type=${type.toString()}&userId=${SpUtil.getString(Constant.userId)}&amount=$amount",
        objectFromJson: (res) => coupon.Records.fromJson(res),
        isList: true,
        onSuccessList: onSuccess,
        onError: onError);
  }

  ///卡券分页列表
  Future getCouponListPage(pageNum, pageSize, usedFlag, type, userId,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "pageNum": pageNum,
      "pageSize": pageSize,
      "usedFlag": usedFlag,
      "type": type,
      "userId": int.parse(SpUtil.getString(Constant.userId))
    };
    await DioUtils().requestNetwork<coupon.CouponModelPage>(
        Method.post, "${NewApiUrl.coupon_list_page}",
        objectFromJson: (res) => coupon.CouponModelPage.fromJson(res),
        params: data,
        onSuccess: onSuccess,
        onError: onError);
  }

  ///品牌分页列表
  Future getBrandListPage(pageNum, pageSize,
      {String searchWord,
      int hotFlag,
      Function onSuccess,
      Function(int code, String msg) onError}) async {
    var data = {
      "pageNum": pageNum,
      "pageSize": pageSize,
      "statuz": 1,
      "name": searchWord,
      "hotFlag": hotFlag
    };
    await DioUtils().requestNetwork<brandM.BrandModel>(
        Method.post, NewApiUrl.brand_list_page,
        objectFromJson: (res) => brandM.BrandModel.fromJson(res),
        params: data,
        onSuccess: onSuccess,
        onError: onError);
  }

  ///专家分页列表
  Future getExpertList(pageNum, pageSize, sortType, brandId, lat, lng,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "lat": lat,
      "lng": lng,
      "userId": int.parse(SpUtil.getString(Constant.userId)),
      "expertFlag": 1,
      "deleteFlag": 0,
      "pageNum": pageNum,
      "pageSize": pageSize,
      "statuz": 1,
      "brandId": brandId ?? null,
      "sort": {"order": "desc", "orderBy": sortType}
    };
    print(753);
    await DioUtils().requestNetwork<expertM.ExpertModel>(
        Method.post, NewApiUrl.expert_list,
        objectFromJson: (res) => expertM.ExpertModel.fromJson(res),
        params: data,
        onSuccess: onSuccess,
        onError: onError);
  }

  ///专家评论分页列表
  Future getExpertCommentList(pageNum, pageSize, expertId,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "expertId": expertId,
      "pageNum": pageNum,
      "pageSize": pageSize,
      // "statuz":1,
    };
    await DioUtils().requestNetwork<ExpertCommentModel>(
        Method.post, NewApiUrl.expert_comment_list,
        objectFromJson: (res) => ExpertCommentModel.fromJson(res),
        params: data,
        onSuccess: onSuccess,
        onError: onError);
  }

  ///返利记录

  Future getPayMoneyList(
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<ShareModel>(Method.post,
        "${NewApiUrl.getAllRebate}${SpUtil.getString(Constant.userId)}",
        objectFromJson: (res) => ShareModel.fromJson(res),
        isList: true,
        onSuccessList: onSuccess,
        onError: onError);
  }

  ///专家不分页列表
  Future getExpertListNoPage(
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<expertM.Records>(
        Method.post, NewApiUrl.expert_list_nopage,
        objectFromJson: (res) => expertM.Records.fromJson(res),
        isList: true,
        onSuccessList: onSuccess,
        onError: onError);
  }

  // Experts grouped by alphabets
  Future getExpertListGrouped(
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<ExpertListGrouped>(
        Method.post, NewApiUrl.expert_list_grouped,
        objectFromJson: (res) => ExpertListGrouped.fromJson(res),
        params: {},
        onSuccess: onSuccess,
        onError: onError);
  }

  ///获取专家详情
  Future getExpertDetail(id,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<expertM.Records>(
        Method.get, "${NewApiUrl.expert_detail}${id.toString()}",
        objectFromJson: (res) {
      return expertM.Records.fromJson(res);
    }, onSuccess: onSuccess, onError: onError);
  }

  ///重新获取二维码
  Future getQrCode(
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<expertM.Records>(Method.post,
        "${NewApiUrl.rest_qrcode}${SpUtil.getString(Constant.userId)}",
        objectFromJson: (res) => expertM.Records.fromJson(res),
        onSuccess: onSuccess,
        onError: onError);
  }

  ///获取诊单费用
  Future getFee(
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<double>(Method.get, NewApiUrl.getServiceFee,
        onSuccess: onSuccess, onError: onError);
  }

  ///获取诊单详情
  Future getLiftcaseDetail(id,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<liftcase.LiftCasesDetailModel>(
        Method.get, "${NewApiUrl.liftcase_detail}${id.toString()}",
        objectFromJson: (res) => liftcase.LiftCasesDetailModel.fromJson(res),
        onSuccess: onSuccess,
        onError: onError);
  }

  ///诊单接单
  Future orderReceiving(obj,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<String>(
        Method.post, NewApiUrl.liftcase_receiving,
        params: obj, onSuccess: onSuccess, onError: onError);
  }

  ///诊单拒绝接单
  Future orderRefuze(id,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<String>(
        Method.get, "${NewApiUrl.liftcase_refuze}?id=${id.toString()}",
        onSuccess: onSuccess, onError: onError);
  }

  ///诊单分页列表
  Future getLiftCasesListPage(dataInfo, userType,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "pageNum": dataInfo['pageNum'],
      "pageSize": dataInfo['pageSize'],
      "type": dataInfo['type'],
      "createUserId": dataInfo['createUserId'],
      "chargerId": dataInfo['chargerId'],
      "sort": {"order": "desc", "orderBy": "create_time"},
      "userType": userType
    };
    await DioUtils().requestNetwork<liftcase.LiftCasesModel>(
        Method.post, NewApiUrl.liftcase_list_page,
        objectFromJson: (res) => liftcase.LiftCasesModel.fromJson(res),
        params: data,
        onSuccess: onSuccess,
        onError: onError);
  }

  ///诊单不分页列表
  Future getLiftCasesListNoPage(
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<liftcase.LiftCasesDetailModel>(Method.get,
        "${NewApiUrl.liftcase_list_nopage}?userId=${SpUtil.getString(Constant.userId)}",
        objectFromJson: (res) => liftcase.LiftCasesDetailModel.fromJson(res),
        isList: true,
        onSuccessList: onSuccess,
        onError: onError);
  }

  // 创建诊单
  Future createCase(obj,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<int>(
        Method.post, "${NewApiUrl.create_case}",
        params: obj, onSuccess: onSuccess, onError: onError);
  }

  ///控制系统分页列表
  Future getControlListPage(pageNum, pageSize,
      {int topFlag,
      String searchWord,
      Function onSuccess,
      Function(int code, String msg) onError}) async {
    var data = {
      "pageNum": pageNum,
      "pageSize": pageSize,
      "statuz": 1,
      "name": searchWord,
      "topFlag": topFlag,
    };
    await DioUtils().requestNetwork<controlM.ControlModelPage>(
        Method.post, NewApiUrl.control_list_page,
        objectFromJson: (res) => controlM.ControlModelPage.fromJson(res),
        params: data,
        onSuccess: onSuccess,
        onError: onError);
  }

  //获取电梯控制系统详情
  Future getControlDetail(id,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<controlM.Records>(
        Method.get, "${NewApiUrl.control_detail}${id.toString()}",
        objectFromJson: (res) => controlM.Records.fromJson(res),
        onSuccess: onSuccess,
        onError: onError);
  }

  // 根据id删除招聘操作记录
  Future deleteRecruitmentOperates(id,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {"id": id};
    await DioUtils().requestNetwork<PositionDetailModel>(
        Method.delete, "${NewApiUrl.deleteRecruitmentOperates}",
        params: data, onSuccess: onSuccess, onError: onError);
  }

  // 用户投递简历
  Future applyJob(Map<String, dynamic> form,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<PositionDetailModel>(
        Method.post, "${NewApiUrl.applyJob}",
        objectFromJson: (res) => PositionDetailModel.fromJson(res),
        params: form,
        onSuccess: onSuccess,
        onError: onError);
  }

  Future getResume(
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<ResumeModel>(Method.get,
        "${NewApiUrl.get_resume}?userId=${SpUtil.getString(Constant.userId)}",
        objectFromJson: (res) => ResumeModel.fromJson(res),
        onSuccess: onSuccess,
        onError: onError);
  }

  //获取官网文件列表
  Future getMeansList(pageNum, pageSize, dataTable, catagoryId, brandId,
      {String searchWord,
      Function onSuccess,
      Function(int code, String msg) onError}) async {
    var data = {
      "pageNum": pageNum,
      "pageSize": pageSize,
      "statuz": 1,
      "brandId": brandId,
      "dataTable": dataTable,
      "catagoryId": catagoryId,
      "name": searchWord,
    };
    print(data);
    await DioUtils().requestNetwork<MeansModel>(
        Method.post, NewApiUrl.lift_files_page,
        objectFromJson: (res) => MeansModel.fromJson(res),
        params: data,
        onSuccess: onSuccess,
        onError: onError);
  }

  //获取电梯品牌详情
  Future getBrandDetail(id,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<brandM.Records>(
        Method.get, "${NewApiUrl.brand_detail}${id.toString()}",
        objectFromJson: (res) => brandM.Records.fromJson(res),
        onSuccess: onSuccess,
        onError: onError);
  }

  //获取错误码列表
  Future getFaultCodeList(brandId, pageNum, pageSize,
      {String searchWord,
      int topFlag,
      Function onSuccess,
      Function(int code, String msg) onError}) async {
    var data = {
      "brandId": brandId,
      "pageNum": pageNum,
      "pageSize": pageSize,
      "statuz": 1,
      "topFlag": topFlag,
      "code": searchWord,
    };
    await DioUtils().requestNetwork<ErrorModel>(
        Method.post, NewApiUrl.fault_code_page,
        objectFromJson: (res) => ErrorModel.fromJson(res),
        params: data,
        onSuccess: onSuccess,
        onError: onError);
  }

  //获取错误码详情
  Future getFaultCodeDetail(id,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<ErrorDetailModel>(
        Method.get, "${NewApiUrl.fault_code_detail}${id.toString()}",
        objectFromJson: (res) => ErrorDetailModel.fromJson(res),
        onSuccess: onSuccess,
        onError: onError);
  }

  //获取资料的树型分类接口
  Future getFileCategorysTree(brandId,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<FileCategorysTreeModel>(Method.get,
        "${NewApiUrl.fileCategorysTree}?brandId=${brandId.toString()}",
        objectFromJson: (res) => FileCategorysTreeModel.fromJson(res),
        isList: true,
        onSuccessList: onSuccess,
        onError: onError);
  }

  // 支付宝支付
  Future aliPay(
      {String orders,
      int liftCaseType,
      String payway,
      bool isUserId = false,
      Function onSuccess,
      Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<String>(Method.post, NewApiUrl.aliPayTo,
        params: {
          "orders": orders,
          "liftCaseType": liftCaseType,
          'payway': payway,
          "userId":
              isUserId ? int.parse(SpUtil.getString(Constant.userId)) : null
        },
        onSuccess: onSuccess,
        onError: onError);
  }

  // 支付宝支付
  Future wxPay(
      {String orders,
      int liftCaseType,
      String payway,
      bool isUserId = false,
      Function onSuccess,
      Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<Map>(Method.post, NewApiUrl.wxTo,
        params: {
          "orders": orders,
          "liftCaseType": liftCaseType,
          "payway": payway,
          "userId":
              isUserId ? int.parse(SpUtil.getString(Constant.userId)) : null
        },
        onSuccess: onSuccess,
        onError: onError);
  }

  //字典表-根据表名和字段查询常量
  Future queryConstant(tableName, field,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<TableDictsModel>(
        Method.post, "${NewApiUrl.tableDictsConstant}",
        objectFromJson: (res) => TableDictsModel.fromJson(res),
        params: {"tableName": tableName, "field": field},
        isList: true,
        onSuccessList: onSuccess,
        onError: onError);
  }

  //获取会费列表
  Future getVipFeeList(userLevelId,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "pageNum": 1,
      "pageSize": 999999,
      "examineFlag": 1,
      "userLevelId": userLevelId
    };
    await DioUtils().requestNetwork<FeeModel>(
        Method.post, NewApiUrl.vipFeeSettings,
        objectFromJson: (res) => FeeModel.fromJson(res),
        params: data,
        onSuccess: onSuccess,
        onError: onError);
  }

  //获取错误码列表
  Future getOrderList(pageNum, pageSize, orderStatus,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "pageNum": pageNum,
      "pageSize": pageSize,
      "orderStatus": orderStatus,
      "userId": int.parse(SpUtil.getString(Constant.userId))
    };
    await DioUtils().requestNetwork<OrderModel>(
        Method.post, NewApiUrl.user_order_page,
        objectFromJson: (res) => OrderModel.fromJson(res),
        params: data,
        onSuccess: onSuccess,
        onError: onError);
  }

  //获取电梯品牌详情
  Future getOrderDetail(id,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<OrerDetailModel>(
        Method.get, "${NewApiUrl.user_order_detail}${id.toString()}",
        objectFromJson: (res) => OrerDetailModel.fromJson(res),
        onSuccess: onSuccess,
        onError: onError);
  }

  //修改订单信息
  Future updateOrder(data,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<OrerDetailModel>(
        Method.put, "${NewApiUrl.user_order_update}",
        params: data,
        objectFromJson: (res) => OrerDetailModel.fromJson(res),
        onSuccess: onSuccess,
        onError: onError);
  }

  // 申请开票
  Future applyInvoice(invoiceInfo,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<InvoicesDetailModel>(
        Method.post, "${NewApiUrl.apply_invoice}",
        objectFromJson: (res) => InvoicesDetailModel.fromJson(res),
        params: invoiceInfo,
        onSuccess: onSuccess,
        onError: onError);
  }

  // 发布评论
  Future submitComments(commentInfo,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<CommentDetailModel>(
        Method.post, "${NewApiUrl.submit_comments}",
        objectFromJson: (res) => CommentDetailModel.fromJson(res),
        params: commentInfo,
        onSuccess: onSuccess,
        onError: onError);
  }

  ///获取题库收藏列表
  Future getCollectQuestionList(pageNum, pageSize,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "pageNum": pageNum,
      "pageSize": pageSize,
      "uid": int.parse(SpUtil.getString(Constant.userId))
    };
    await DioUtils().requestNetwork<mixmix.MixModel>(
        Method.post, NewApiUrl.question_collect_list,
        objectFromJson: (res) => mixmix.MixModel.fromJson(res),
        // objectFromJson: (res) => QuestionModel.fromJson(res),
        params: data,
        onSuccess: onSuccess,
        onError: onError);
  }

  ///获取视频收藏列表
  Future getCollectVideoList(pageNum, pageSize,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "pageNum": pageNum,
      "pageSize": pageSize,
      "uid": int.parse(SpUtil.getString(Constant.userId))
    };
    await DioUtils().requestNetwork<mixmix.MixModel>(
        Method.post, NewApiUrl.video_collect_list,
        objectFromJson: (res) => mixmix.MixModel.fromJson(res),
        // objectFromJson: (res) => QuestionModel.fromJson(res),
        params: data,
        onSuccess: onSuccess,
        onError: onError);
  }

  ///获取职位收藏列表
  Future getCollectPositionList(pageNum, pageSize,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "pageNum": pageNum,
      "pageSize": pageSize,
      "uid": int.parse(SpUtil.getString(Constant.userId))
    };
    await DioUtils().requestNetwork<mixmix.MixModel>(
        Method.post, NewApiUrl.position_collect_list,
        objectFromJson: (res) => mixmix.MixModel.fromJson(res),
        // objectFromJson: (res) => QuestionModel.fromJson(res),
        params: data,
        onSuccess: onSuccess,
        onError: onError);
  }

  ///获取商品收藏列表
  Future getCollectProductList(pageNum, pageSize,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "pageNum": pageNum,
      "pageSize": pageSize,
      "uid": int.parse(SpUtil.getString(Constant.userId))
    };
    await DioUtils().requestNetwork<mixmix.MixModel>(
        Method.post, NewApiUrl.product_collect_list,
        objectFromJson: (res) => mixmix.MixModel.fromJson(res),
        // objectFromJson: (res) => QuestionModel.fromJson(res),
        params: data,
        onSuccess: onSuccess,
        onError: onError);
  }

  // 提交申诉
  Future submitAppeal(data,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    print(data);
    var applyInfo = {
      "appealerId": int.parse(SpUtil.getString(Constant.userId)),
      "dataId": data['dataId'],
      "content": data['content'],
      "imgs": data['imgs']
    };
    await DioUtils().requestNetwork<RepresentationDetailModel>(
        Method.post, "${NewApiUrl.add_appeal}",
        objectFromJson: (res) => RepresentationDetailModel.fromJson(res),
        params: applyInfo,
        onSuccess: onSuccess,
        onError: onError);
  }

  // 用户确认诊单
  Future userConfirmOrder(id,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<dynamic>(
        Method.get, "${NewApiUrl.user_make_sure_case}?id=${id.toString()}",
        onSuccess: onSuccess, onError: onError);
  }

  // 用户删除订单
  Future deleteOrder(id,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "id": id,

      // "userId": int.parse(SpUtil.getString(Constant.userId))
    };
    await DioUtils().requestNetwork<dynamic>(
        Method.delete, "${NewApiUrl.user_Delete_order}",
        params: data, onSuccess: onSuccess, onError: onError);
  }

  // 用户取消订单
  Future cancelOrder(id,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<dynamic>(
        Method.get, "${NewApiUrl.user_cancel_order}?id=${id.toString()}",
        onSuccess: onSuccess, onError: onError);
  }

  // 专家报价
  Future quote(data,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<dynamic>(Method.post, "${NewApiUrl.quote}",
        params: data, onSuccess: onSuccess, onError: onError);
  }

  // 专家打卡
  Future chargeToClock(data,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<dynamic>(
        Method.post, "${NewApiUrl.chargeToClock}",
        params: data, onSuccess: onSuccess, onError: onError);
  }

  // 专家确认订单
  Future chargeMakeSureCase(data,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<dynamic>(
        Method.post, "${NewApiUrl.chargeMakeSureCase}",
        params: data, onSuccess: onSuccess, onError: onError);
  }

  // 专家确认订单
  Future userToClock(id,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<dynamic>(
        Method.get, "${NewApiUrl.userToClock}?id=${id.toString()}",
        onSuccess: onSuccess, onError: onError);
  }

  // 问题归档
  Future questionCollect(data,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<dynamic>(
        Method.post, "${NewApiUrl.question_collect}",
        params: data, onSuccess: onSuccess, onError: onError);
  }

  // 是否是专家和VIP
  Future getIsVipOrExpert(
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<String>(Method.post,
        "${NewApiUrl.vipOrExpert}${SpUtil.getString(Constant.userId)}",
        onSuccess: onSuccess, onError: onError);
  }

  // vip幸运数字
  Future upLoadVipluckNum(
      {String vipId,
      Function onSuccess,
      Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<String>(
        Method.post, "${NewApiUrl.setVipluckNum}",
        params: {'userId': SpUtil.getString(Constant.userId), 'vipId': vipId},
        onSuccess: onSuccess,
        onError: onError);
  }

  // 修改用户Vip等级
  Future updateVip(appRoleId,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    var data = {
      "userId": int.parse(SpUtil.getString(Constant.userId)),
      "appRoleId": appRoleId,
    };
    await DioUtils().requestNetwork<dynamic>(
        Method.post, "${NewApiUrl.update_vip}",
        params: data, onSuccess: onSuccess, onError: onError);
  }

  // 获取vip等级和对应权限
  Future getMemberAllMenu(
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<PrivilegeModel>(
        Method.get, "${NewApiUrl.getMemberAllMenu}",
        objectFromJson: (res) => PrivilegeModel.fromJson(res),
        isList: true,
        onSuccessList: onSuccess,
        onError: onError);
  }

  // 根据用户角色获取用户权益
  Future getAllMenu(levelId,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<MenuList>(
        Method.get, "${NewApiUrl.getAllMenu}?levelId=${levelId}",
        objectFromJson: (res) => MenuList.fromJson(res),
        isList: true,
        onSuccessList: onSuccess,
        onError: onError);
  }

  Future getUserXieYi(userid,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<UserXieyi>(
        Method.get, "${NewApiUrl.getUserXieyi}?userId=$userid",
        objectFromJson: (res) {
      return UserXieyi.fromJson(res);
    }, isList: true, onSuccessList: onSuccess, onError: onError);
  }

  // 创建充值记录
  Future createRecharge(
      {int payType,
      String productPrice,
      String productName,
      String memo,
      Function onSuccess,
      Function(int code, String msg) onError}) async {
    await DioUtils()
        .requestNetwork<String>(Method.post, "${NewApiUrl.createRecharge}",
            params: {
              "payType": payType,
              "productPrice": productPrice,
              "productName": productName,
              "memo": memo,
              "userId": int.parse(SpUtil.getString(Constant.userId)),
            },
            onSuccess: onSuccess,
            onError: onError);
  }

  // 提现
  Future getInsetWithdrwa(
      {amount,
      type,
      Function onSuccess,
      Function(int code, String msg) onError}) async {
    await DioUtils()
        .requestNetwork<String>(Method.post, "${NewApiUrl.insetWithdrwa}",
            params: {
              "type": type,
              "amount": amount,
              "userId": int.parse(SpUtil.getString(Constant.userId)),
            },
            onSuccess: onSuccess,
            onError: onError);
  }

  // 支付宝支付-用户充值
  Future alipayRecharge(
      {String orders,
      Function onSuccess,
      String payway,
      Function(int code, String msg) onError}) async {
    await DioUtils()
        .requestNetwork<String>(Method.post, NewApiUrl.alipayRecharge,
            params: {
              "orders": orders,
              'payway': payway,
            },
            onSuccess: onSuccess,
            onError: onError);
  }

  // wx支付-用户充值
  Future alipayRechargewx(
      {String orders,
      String payway,
      Function onSuccess,
      Function(int code, String msg) onError}) async {
    await DioUtils()
        .requestNetwork<Map>(Method.post, NewApiUrl.alipayRechargewx,
            params: {
              "orders": orders,
              "payway": payway,
            },
            onSuccess: onSuccess,
            onError: onError);
  }

  // 支付宝支付-用户打赏
  Future alipayReward(
      {String orders,
      int rewardType,
      String payway,
      String reawrdMoney,
      Function onSuccess,
      Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<String>(Method.post, NewApiUrl.alipayReward,
        params: {
          "orders": orders,
          "rewardType": rewardType,
          "payway": payway,
          "reawrdMoney": reawrdMoney,
          "userId": int.parse(SpUtil.getString(Constant.userId)),
        },
        onSuccess: onSuccess,
        onError: onError);
  }

  // 微信支付-用户打赏
  Future wxReward(
      {String orders,
      int rewardType,
      String payway,
      String reawrdMoney,
      Function onSuccess,
      Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<Map>(Method.post, NewApiUrl.wxReward,
        params: {
          "orders": orders,
          "rewardType": rewardType,
          "payway": payway,
          "reawrdMoney": reawrdMoney,
          "userId": int.parse(SpUtil.getString(Constant.userId)),
        },
        onSuccess: onSuccess,
        onError: onError);
  }

  // 支付宝支付-VIP
  Future getRechargeVIP(
      {String orders,
      Function onSuccess,
      String payway,
      Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<String>(Method.post, NewApiUrl.rechargeVIP,
        params: {
          "orders": orders,
          "payway": payway,
          "userId": int.parse(SpUtil.getString(Constant.userId)),
        },
        onSuccess: onSuccess,
        onError: onError);
  }

  // wx支付-VIP
  Future getRechargeVIPwx(
      {String orders,
      String payway,
      Function onSuccess,
      Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<Map>(Method.post, NewApiUrl.rechargeVIPwx,
        params: {
          "orders": orders,
          "payway": payway,
          "userId": int.parse(SpUtil.getString(Constant.userId)),
        },
        onSuccess: onSuccess,
        onError: onError);
  }

  // 邀请成为其他人下线
  Future getUserRebates(id,
      {String orders,
      Function onSuccess,
      Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<String>(Method.post, NewApiUrl.userRebates,
        params: {
          "userId": id,
          "lowerUserId": SpUtil.getString(Constant.userId),
        },
        onSuccess: onSuccess,
        onError: onError);
  }

  // 申请成为专家
  Future applyExperts(data,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<String>(Method.post, NewApiUrl.applyExperts,
        params: data, onSuccess: onSuccess, onError: onError);
  }

  //申请专家详情
  Future getBecomeMasterDetail(
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<BecomeModel>(Method.get,
        "${NewApiUrl.becomeMasterDetail}${SpUtil.getString(Constant.userId)}",
        objectFromJson: (res) => BecomeModel.fromJson(res),
        onSuccess: onSuccess,
        onError: onError);
  }

  //申请专家编辑
  Future updateBecomeMaster(obj,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<String>(
        Method.put, "${NewApiUrl.becomeMasterUpdate}",
        params: obj, onSuccess: onSuccess, onError: onError);
  }

  //更新用户权限
  Future upDataUserLogin(
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<UserEntity>(Method.get,
        "${NewApiUrl.updataUserLoginInfo}?userId=${SpUtil.getString(Constant.userId)}",
        objectFromJson: (res) => UserEntity.fromJsonMap(res),
        onSuccess: onSuccess,
        onError: onError);
  }

  //判断是否要定时传当前位置
  Future isDelayAddress(
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<Map>(
        Method.get, "${NewApiUrl.isDelayAddressUrl}",
        onSuccess: onSuccess, onError: onError);
  }

  //定时传当前位置
  Future startDelayAddress(data,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<String>(
        Method.post, "${NewApiUrl.startDelayAddressUrl}",
        params: data, onSuccess: onSuccess, onError: onError);
  }

  //聊天历史记录
  Future getMsgHistoryList(data,
      {Function onSuccess, Function(int code, String msg) onError}) async {
    await DioUtils().requestNetwork<Map>(
        Method.post, "${NewApiUrl.msgHistoryList}",
        isList: true, params: data, onSuccessList: onSuccess, onError: onError);
  }

  static Future<Response> uploadImage(
      BuildContext context, String uploadName, String filePath,
      {cancelToken}) async {
    BaseOptions options = new BaseOptions();
    options.responseType =
        ResponseType.plain; //必须,否则上传失败后aliyun返回的提示信息(非JSON格式)看不到
    //创建一个formdata，作为dio的参数
    File file = new File(filePath);
    FormData data = new FormData.fromMap({
      'Filename': uploadName,
      //文件名，随意
      'key': uploadName,
      //"可以填写文件夹名（对应于oss服务中的文件夹）/" + fileName
      'policy': OssUtil.policy,
      'OSSAccessKeyId': OssUtil.accesskeyId,
      //Bucket 拥有者的AccessKeyId。
      'success_action_status': '200',
      //让服务端返回200，不然，默认会返回204
      'signature': OssUtil.instance.getSignature(OssUtil.accessKeySecret),
      'x-oss-security-token': OssUtil.stsToken,
      //临时用户授权时必须，需要携带后台返回的security-token
      'file': await MultipartFile.fromFile(filePath,
          filename: OssUtil.instance.getImageNameByPath(filePath))
      //必须放在参数最后
    });
    return NetUtils.instance.post(context, NewApiUrl.URL_UPLOAD_IMAGE_OSS,
        data: data, options: options);
  }
}
