import 'package:domain/constants/api_constants.dart'; import 'package:domain/entity/garage_sale_rent_detail_entity.dart'; import 'package:domain/entity/garage_sale_rent_entity.dart'; import 'package:domain/entity/myposts_sale_rent_entity.dart'; import 'package:domain/entity/newsfeed_foryou_entity.dart'; import 'package:domain/entity/newsfeed_news_entity.dart'; import 'package:domain/entity/server_time.dart'; import 'package:plugin_platform/engine/toast/toast_engine.dart'; import 'package:plugin_platform/platform_export.dart'; import 'package:plugin_platform/http/dio_engine.dart'; import 'package:plugin_platform/http/http_result.dart'; import 'package:riverpod_annotation/riverpod_annotation.dart'; import 'package:shared/utils/log_utils.dart'; import 'package:shared/utils/util.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:plugin_basic/provider/http_provider/http_provider.dart'; part 'services_respository.g.dart'; @Riverpod(keepAlive: true) ServicesRespository servicesRespository(Ref ref) { final dioEngine = ref.watch(dioEngineProvider); return ServicesRespository(dioEngine: dioEngine); } /* * 数据仓库 */ class ServicesRespository { DioEngine dioEngine; ServicesRespository({required this.dioEngine}); //服务 获取 分类 字典 Future> fetchServiceCateGoryList( Map? data, { CancelToken? cancelToken, }) async { Map params = {}; params = data!; Map headers = {}; headers["Content-Type"] = "application/x-www-form-urlencoded"; headers["Accept"] = "application/x.yyjobs-api.v1+json"; final result = await dioEngine.requestNetResult( // ApiConstants.apiServerTime, // api 地址 '/api/v1/user/service/category/index', // api 地址 params: params, headers: headers, method: HttpMethod.GET, isShowLoadingDialog: true, //是否展示默认的Loading弹窗 networkDebounce: true, //是否防抖防止重复请求 cancelToken: cancelToken, ); //根据返回的结果,封装原始数据为Bean/Entity对象 if (result.isSuccess) { //重新赋值data或list final json = result.getDataJson(); // var data = NewsfeedForyouEntity.fromJson(json!); //重新赋值data或list return result.convert(data: json); }else { if(result.errorMsg != null && result.errorMsg!.isNotEmpty){ ToastEngine.show("${result.errorMsg}"); } } return result.convert(); } // 付费服务 获取 列表 Future> fetchPaidServiceDataList( Map? data, { CancelToken? cancelToken, }) async { Map params = {}; params = data!; Map headers = {}; headers["Content-Type"] = "application/x-www-form-urlencoded"; headers["Accept"] = "application/x.yyjobs-api.v1+json"; final result = await dioEngine.requestNetResult( // ApiConstants.apiServerTime, // api 地址 '/api/v1/user/service/paid-service/index', // api 地址 params: params, headers: headers, method: HttpMethod.GET, isShowLoadingDialog: false, //是否展示默认的Loading弹窗 networkDebounce: true, //是否防抖防止重复请求 cancelToken: cancelToken, ); //根据返回的结果,封装原始数据为Bean/Entity对象 if (result.isSuccess) { //重新赋值data或list final json = result.getDataJson(); var data = GarageSaleRentEntity.fromJson(json!); //重新赋值data或list return result.convert(data: data); }else { if(result.errorMsg != null && result.errorMsg!.isNotEmpty){ ToastEngine.show("${result.errorMsg}"); } } return result.convert(); } // 付费/维修 服务 列表 点赞/取消点赞 Future> fetchServiceLiked( Map? data, { CancelToken? cancelToken, }) async { Map params = {}; params = data!; Map headers = {}; headers["Content-Type"] = "application/x-www-form-urlencoded"; headers["Accept"] = "application/x.yyjobs-api.v1+json"; final result = await dioEngine.requestNetResult( // ApiConstants.apiServerTime, // api 地址 '/api/v1/user/service/paid-service/liked', // api 地址 params: params, headers: headers, method: HttpMethod.POST, isShowLoadingDialog: true, //是否展示默认的Loading弹窗 networkDebounce: true, //是否防抖防止重复请求 cancelToken: cancelToken, ); //根据返回的结果,封装原始数据为Bean/Entity对象 if (result.isSuccess) { //重新赋值data或list final json = result.getDataDynamic(); // var data = NewsfeedForyouEntity.fromJson(json!); //重新赋值data或list return result.convert(data: json); }else { if(result.errorMsg != null && result.errorMsg!.isNotEmpty){ ToastEngine.show("${result.errorMsg}"); } } return result.convert(); } // 提交评价 Future> fetchPublishEvaluation( Map? data, { CancelToken? cancelToken, }) async { Map params = {}; params = data!; Map headers = {}; headers["Content-Type"] = "application/x-www-form-urlencoded"; headers["Accept"] = "application/x.yyjobs-api.v1+json"; List paths = data!["resources"] as List; Map files = {}; if (paths != null && paths.isNotEmpty) { paths.asMap().forEach((index, path) { files["resources[$index]"] = path; }); } // 删除 resources 属性 params.remove("resources"); final result = await dioEngine.requestNetResult( // ApiConstants.apiServerTime, // api 地址 '/api/v1/user/service/evaluation/publish', // api 地址 params: params, paths: files, headers: headers, method: HttpMethod.POST, isShowLoadingDialog: true, //是否展示默认的Loading弹窗 networkDebounce: true, //是否防抖防止重复请求 cancelToken: cancelToken, ); //根据返回的结果,封装原始数据为Bean/Entity对象 if (result.isSuccess) { //重新赋值data或list final json = result.getDataJson(); // var data = NewsfeedForyouEntity.fromJson(json!); //重新赋值data或list return result.convert(data: json); }else { if(result.errorMsg != null && result.errorMsg!.isNotEmpty){ ToastEngine.show("${result.errorMsg}"); } } return result.convert(); } // 评价列表 Future> fetchEvaluationDataList( Map? data, { CancelToken? cancelToken, }) async { Map params = {}; params = data!; Map headers = {}; headers["Content-Type"] = "application/x-www-form-urlencoded"; headers["Accept"] = "application/x.yyjobs-api.v1+json"; final result = await dioEngine.requestNetResult( // ApiConstants.apiServerTime, // api 地址 '/api/v1/user/service/evaluation/index', // api 地址 params: params, headers: headers, method: HttpMethod.GET, isShowLoadingDialog: false, //是否展示默认的Loading弹窗 networkDebounce: true, //是否防抖防止重复请求 cancelToken: cancelToken, ); //根据返回的结果,封装原始数据为Bean/Entity对象 if (result.isSuccess) { //重新赋值data或list final json = result.getDataJson(); var data = GarageSaleRentEntity.fromJson(json!); //重新赋值data或list return result.convert(data: data); }else { if(result.errorMsg != null && result.errorMsg!.isNotEmpty){ ToastEngine.show("${result.errorMsg}"); } } return result.convert(); } // 获取 付费服务 详情信息 Future> fetchPaidServiceCleanDetailInfo( Map? data, { CancelToken? cancelToken, }) async { Map params = {}; params = data!; Map headers = {}; // headers["Content-Type"] = "application/x-www-form-urlencoded"; // headers["Accept"] = "application/x.yyjobs-api.v1+json"; final result = await dioEngine.requestNetResult( // ApiConstants.apiServerTime, // api 地址 '/api/v1/user/service/paid-service/detail', // api 地址 params: params, headers: headers, method: HttpMethod.GET, isShowLoadingDialog: false, //是否展示默认的Loading弹窗 networkDebounce: true, //是否防抖防止重复请求 cancelToken: cancelToken, ); //根据返回的结果,封装原始数据为Bean/Entity对象 if (result.isSuccess) { //重新赋值data或list final json = result.getDataJson(); // var data = GarageSaleRentDetailEntity.fromJson(json!); //重新赋值data或list return result.convert(data: json); }else { if(result.errorMsg != null && result.errorMsg!.isNotEmpty){ ToastEngine.show("${result.errorMsg}"); } } return result.convert(); } // 付费服务 下单 Future> fetchPaidServiceBook( Map? data, { CancelToken? cancelToken, }) async { Map params = {}; params = data!; Map headers = {}; headers["Content-Type"] = "application/x-www-form-urlencoded"; headers["Accept"] = "application/x.yyjobs-api.v1+json"; final result = await dioEngine.requestNetResult( // ApiConstants.apiServerTime, // api 地址 '/api/v1/user/service/paid-service-order/book', // api 地址 params: params, headers: headers, method: HttpMethod.POST, isShowLoadingDialog: true, //是否展示默认的Loading弹窗 networkDebounce: true, //是否防抖防止重复请求 cancelToken: cancelToken, ); //根据返回的结果,封装原始数据为Bean/Entity对象 if (result.isSuccess) { //重新赋值data或list final json = result.getDataJson(); // var data = NewsfeedForyouEntity.fromJson(json!); //重新赋值data或list return result.convert(data: json); }else { if(result.errorMsg != null && result.errorMsg!.isNotEmpty){ ToastEngine.show("${result.errorMsg}"); } } return result.convert(); } // 付费服务 订单列表 Future> fetchPaidServiceOrderList( Map? data, { CancelToken? cancelToken, }) async { Map params = {}; params = data!; Map headers = {}; headers["Content-Type"] = "application/x-www-form-urlencoded"; headers["Accept"] = "application/x.yyjobs-api.v1+json"; final result = await dioEngine.requestNetResult( // ApiConstants.apiServerTime, // api 地址 '/api/v1/user/service/paid-service-order/index', // api 地址 params: params, headers: headers, method: HttpMethod.GET, isShowLoadingDialog: false, //是否展示默认的Loading弹窗 networkDebounce: true, //是否防抖防止重复请求 cancelToken: cancelToken, ); //根据返回的结果,封装原始数据为Bean/Entity对象 if (result.isSuccess) { //重新赋值data或list final json = result.getDataJson(); var data = GarageSaleRentEntity.fromJson(json!); //重新赋值data或list return result.convert(data: data); }else { if(result.errorMsg != null && result.errorMsg!.isNotEmpty){ ToastEngine.show("${result.errorMsg}"); } } return result.convert(); } // 获取 付费服务 订单详情 Future> fetchPaidServiceCleanOrderDetailInfo( Map? data, { CancelToken? cancelToken, }) async { Map params = {}; params = data!; Map headers = {}; // headers["Content-Type"] = "application/x-www-form-urlencoded"; // headers["Accept"] = "application/x.yyjobs-api.v1+json"; final result = await dioEngine.requestNetResult( // ApiConstants.apiServerTime, // api 地址 '/api/v1/user/service/paid-service-order/detail', // api 地址 params: params, headers: headers, method: HttpMethod.GET, isShowLoadingDialog: false, //是否展示默认的Loading弹窗 networkDebounce: true, //是否防抖防止重复请求 cancelToken: cancelToken, ); //根据返回的结果,封装原始数据为Bean/Entity对象 if (result.isSuccess) { //重新赋值data或list final json = result.getDataJson(); // var data = GarageSaleRentDetailEntity.fromJson(json!); //重新赋值data或list return result.convert(data: json); }else { if(result.errorMsg != null && result.errorMsg!.isNotEmpty){ ToastEngine.show("${result.errorMsg}"); } } return result.convert(); } // 获取 付费订单实际需要支付的价格 Future> fetchPaidServiceCleanOrderPrice( Map? data, { CancelToken? cancelToken, }) async { Map params = {}; params = data!; Map headers = {}; // headers["Content-Type"] = "application/x-www-form-urlencoded"; // headers["Accept"] = "application/x.yyjobs-api.v1+json"; final result = await dioEngine.requestNetResult( // ApiConstants.apiServerTime, // api 地址 '/api/v1/user/service/paid-service-order/price', // api 地址 params: params, headers: headers, method: HttpMethod.GET, isShowLoadingDialog: false, //是否展示默认的Loading弹窗 networkDebounce: true, //是否防抖防止重复请求 cancelToken: cancelToken, ); //根据返回的结果,封装原始数据为Bean/Entity对象 if (result.isSuccess) { //重新赋值data或list final json = result.getDataJson(); // var data = GarageSaleRentDetailEntity.fromJson(json!); //重新赋值data或list return result.convert(data: json); }else { if(result.errorMsg != null && result.errorMsg!.isNotEmpty){ ToastEngine.show("${result.errorMsg}"); } } return result.convert(); } // 付费服务 取消订单 Future> fetchCancelPaidServiceOrder( Map? data, { CancelToken? cancelToken, }) async { Map params = {}; params = data!; Map headers = {}; headers["Content-Type"] = "application/x-www-form-urlencoded"; headers["Accept"] = "application/x.yyjobs-api.v1+json"; final result = await dioEngine.requestNetResult( // ApiConstants.apiServerTime, // api 地址 '/api/v1/user/service/paid-service-order/cancel', // api 地址 params: params, headers: headers, method: HttpMethod.POST, isShowLoadingDialog: true, //是否展示默认的Loading弹窗 networkDebounce: true, //是否防抖防止重复请求 cancelToken: cancelToken, ); //根据返回的结果,封装原始数据为Bean/Entity对象 if (result.isSuccess) { //重新赋值data或list final json = result.getDataJson(); // var data = NewsfeedForyouEntity.fromJson(json!); //重新赋值data或list return result.convert(data: json); }else { if(result.errorMsg != null && result.errorMsg!.isNotEmpty){ ToastEngine.show("${result.errorMsg}"); } } return result.convert(); } ///-------------------咨询类--------------------------------- // 维修服务 列表 Future> fetchRepairServiceList( Map? data, { CancelToken? cancelToken, }) async { Map params = {}; params = data!; Map headers = {}; headers["Content-Type"] = "application/x-www-form-urlencoded"; headers["Accept"] = "application/x.yyjobs-api.v1+json"; final result = await dioEngine.requestNetResult( // ApiConstants.apiServerTime, // api 地址 '/api/v1/user/service/inquiry-service/index', // api 地址 params: params, headers: headers, method: HttpMethod.GET, isShowLoadingDialog: false, //是否展示默认的Loading弹窗 networkDebounce: true, //是否防抖防止重复请求 cancelToken: cancelToken, ); //根据返回的结果,封装原始数据为Bean/Entity对象 if (result.isSuccess) { //重新赋值data或list final json = result.getDataJson(); var data = GarageSaleRentEntity.fromJson(json!); //重新赋值data或list return result.convert(data: data); }else { if(result.errorMsg != null && result.errorMsg!.isNotEmpty){ ToastEngine.show("${result.errorMsg}"); } } return result.convert(); } // 获取 repair 详情信息 Future> fetchServiceRepairDetailInfo( Map? data, { CancelToken? cancelToken, }) async { Map params = {}; params = data!; Map headers = {}; // headers["Content-Type"] = "application/x-www-form-urlencoded"; // headers["Accept"] = "application/x.yyjobs-api.v1+json"; final result = await dioEngine.requestNetResult( // ApiConstants.apiServerTime, // api 地址 '/api/v1/user/service/inquiry-service/detail', // api 地址 params: params, headers: headers, method: HttpMethod.GET, isShowLoadingDialog: false, //是否展示默认的Loading弹窗 networkDebounce: true, //是否防抖防止重复请求 cancelToken: cancelToken, ); //根据返回的结果,封装原始数据为Bean/Entity对象 if (result.isSuccess) { //重新赋值data或list final json = result.getDataJson(); var data = GarageSaleRentDetailEntity.fromJson(json!); //重新赋值data或list return result.convert(data: data); }else { if(result.errorMsg != null && result.errorMsg!.isNotEmpty){ ToastEngine.show("${result.errorMsg}"); } } return result.convert(); } // 维修服务 提交咨询 Future> fetchRepairServiceSubmit( Map? data, { CancelToken? cancelToken, }) async { Map params = {}; params = data!; Map headers = {}; headers["Content-Type"] = "application/x-www-form-urlencoded"; headers["Accept"] = "application/x.yyjobs-api.v1+json"; final result = await dioEngine.requestNetResult( // ApiConstants.apiServerTime, // api 地址 '/api/v1/user/service/inquiry-service-order/submit', // api 地址 params: params, headers: headers, method: HttpMethod.POST, isShowLoadingDialog: true, //是否展示默认的Loading弹窗 networkDebounce: true, //是否防抖防止重复请求 cancelToken: cancelToken, ); //根据返回的结果,封装原始数据为Bean/Entity对象 if (result.isSuccess) { //重新赋值data或list final json = result.getDataJson(); // var data = NewsfeedForyouEntity.fromJson(json!); //重新赋值data或list return result.convert(data: json); }else { if(result.errorMsg != null && result.errorMsg!.isNotEmpty){ ToastEngine.show("${result.errorMsg}"); } } return result.convert(); } // 维修服务 订单列表 Future> fetchRepairServiceOrderList( Map? data, { CancelToken? cancelToken, }) async { Map params = {}; params = data!; Map headers = {}; headers["Content-Type"] = "application/x-www-form-urlencoded"; headers["Accept"] = "application/x.yyjobs-api.v1+json"; final result = await dioEngine.requestNetResult( // ApiConstants.apiServerTime, // api 地址 '/api/v1/user/service/inquiry-service-order/index', // api 地址 params: params, headers: headers, method: HttpMethod.GET, isShowLoadingDialog: false, //是否展示默认的Loading弹窗 networkDebounce: true, //是否防抖防止重复请求 cancelToken: cancelToken, ); //根据返回的结果,封装原始数据为Bean/Entity对象 if (result.isSuccess) { //重新赋值data或list final json = result.getDataJson(); var data = GarageSaleRentEntity.fromJson(json!); //重新赋值data或list return result.convert(data: data); }else { if(result.errorMsg != null && result.errorMsg!.isNotEmpty){ ToastEngine.show("${result.errorMsg}"); } } return result.convert(); } }