|
@@ -1,8 +1,6 @@
|
|
|
|
|
|
-import 'package:cs_resources/generated/assets.dart';
|
|
|
|
import 'package:cs_resources/theme/app_colors_theme.dart';
|
|
import 'package:cs_resources/theme/app_colors_theme.dart';
|
|
-import 'package:domain/entity/garage_sale_rent_entity.dart';
|
|
|
|
-import 'package:domain/entity/newsfeed_detail_entity.dart';
|
|
|
|
|
|
+import 'package:domain/entity/repair_service_entity.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:plugin_platform/engine/dialog/dialog_engine.dart';
|
|
import 'package:plugin_platform/engine/dialog/dialog_engine.dart';
|
|
@@ -16,6 +14,7 @@ import 'package:widgets/my_checkbox_group.dart';
|
|
import 'package:widgets/picker/option_pick_util.dart';
|
|
import 'package:widgets/picker/option_pick_util.dart';
|
|
import 'package:widgets/widget_export.dart';
|
|
import 'package:widgets/widget_export.dart';
|
|
|
|
|
|
|
|
+import '../../../constants_services.dart';
|
|
import '../../../respository/services_respository.dart';
|
|
import '../../../respository/services_respository.dart';
|
|
import '../../../router/page/services_page_router.dart';
|
|
import '../../../router/page/services_page_router.dart';
|
|
import 'home_service_state.dart';
|
|
import 'home_service_state.dart';
|
|
@@ -55,7 +54,7 @@ class RepairHomeServiceVm extends _$RepairHomeServiceVm {
|
|
@override
|
|
@override
|
|
RepairHomeServiceState build(){
|
|
RepairHomeServiceState build(){
|
|
// 引入数据仓库
|
|
// 引入数据仓库
|
|
- // servicesRespositoryInstance = ref.read(commonGarageRespositoryProvider);
|
|
|
|
|
|
+ servicesRespositoryInstance = ref.read(servicesRespositoryProvider);
|
|
final state = initState();
|
|
final state = initState();
|
|
Log.d("--------------------------build---------------------");
|
|
Log.d("--------------------------build---------------------");
|
|
|
|
|
|
@@ -164,38 +163,37 @@ class RepairHomeServiceVm extends _$RepairHomeServiceVm {
|
|
// 'company_name': 'HONG YE GROUP PTE LTD',
|
|
// 'company_name': 'HONG YE GROUP PTE LTD',
|
|
// },
|
|
// },
|
|
// ];
|
|
// ];
|
|
- // handlerResultData(true, list:list);
|
|
|
|
|
|
|
|
- // try {
|
|
|
|
- // //请求网络
|
|
|
|
- // Map<String, dynamic> params = {
|
|
|
|
- // "sort": null, // 排序(desc=降序,asc=升序)
|
|
|
|
- // "sort_by": null, // 排序(likes_count=点赞量,orders_count=下单量,clicks_count=点击量)
|
|
|
|
- // "category_id": _queryParams['category_id'],
|
|
|
|
- // "keyword": _queryParams['keyword'],
|
|
|
|
- // "page": _page,
|
|
|
|
- // "limit": _limit,
|
|
|
|
- // };
|
|
|
|
- // Log.d("请求参数------$params");
|
|
|
|
- // final result = await servicesRespositoryInstance.fetchRepairServiceList(params);
|
|
|
|
- // //校验成功失败
|
|
|
|
- // if (result.isSuccess) {
|
|
|
|
- // handlerResultList((result.data as PaidServiceEntity).list as List<PaidServiceList>?, isLoadMore ?? false);
|
|
|
|
- // } else {
|
|
|
|
- // String errorMessage = result.errorMsg!;
|
|
|
|
- // changeLoadingState(LoadState.State_Error, errorMessage);
|
|
|
|
- // ToastEngine.show(result.errorMsg ?? "Network Load Error");
|
|
|
|
- // }
|
|
|
|
- // } catch (e) {
|
|
|
|
- // ToastEngine.show("Error: $e");
|
|
|
|
- // }
|
|
|
|
|
|
+ try {
|
|
|
|
+ //请求网络
|
|
|
|
+ Map<String, dynamic> params = {
|
|
|
|
+ "sort": null, // 排序(desc=降序,asc=升序)
|
|
|
|
+ "sort_by": null, // 排序(likes_count=点赞量,orders_count=下单量,clicks_count=点击量)
|
|
|
|
+ "category_id": _queryParams['category_id'],
|
|
|
|
+ "keyword": _queryParams['keyword'],
|
|
|
|
+ "page": _page,
|
|
|
|
+ "limit": _limit,
|
|
|
|
+ };
|
|
|
|
+ Log.d("请求参数------$params");
|
|
|
|
+ final result = await servicesRespositoryInstance.fetchRepairServiceList(params);
|
|
|
|
+ //校验成功失败
|
|
|
|
+ if (result.isSuccess) {
|
|
|
|
+ handlerResultList((result.data as RepairServiceEntity)?.list as List<RepairServiceList>?, isLoadMore ?? false);
|
|
|
|
+ } else {
|
|
|
|
+ String errorMessage = result.errorMsg!;
|
|
|
|
+ changeLoadingState(LoadState.State_Error, errorMessage);
|
|
|
|
+ ToastEngine.show(result.errorMsg ?? "Network Load Error");
|
|
|
|
+ }
|
|
|
|
+ } catch (e) {
|
|
|
|
+ ToastEngine.show("Error: $e");
|
|
|
|
+ }
|
|
|
|
|
|
// 最后赋值
|
|
// 最后赋值
|
|
_needShowPlaceholder = false;
|
|
_needShowPlaceholder = false;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- handlerResultData(bool isList, {List<Map<String, dynamic>>? list, dynamic? data}){
|
|
|
|
|
|
+ handlerResultData(bool isList, {List<RepairServiceList>? list, dynamic? data}){
|
|
Future.delayed(const Duration(seconds: 1)).then((value) {
|
|
Future.delayed(const Duration(seconds: 1)).then((value) {
|
|
if(isList){
|
|
if(isList){
|
|
// list 数据模式
|
|
// list 数据模式
|
|
@@ -241,20 +239,20 @@ class RepairHomeServiceVm extends _$RepairHomeServiceVm {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
- void handlerResultList(List<GarageSaleRentList>? list, bool isLoadMore) {
|
|
|
|
|
|
+ void handlerResultList(List<RepairServiceList>? list, bool isLoadMore) {
|
|
if (list != null && list.isNotEmpty) {
|
|
if (list != null && list.isNotEmpty) {
|
|
//有数据,判断是刷新还是加载更多的数据
|
|
//有数据,判断是刷新还是加载更多的数据
|
|
if (_page == 1) {
|
|
if (_page == 1) {
|
|
//刷新的方式
|
|
//刷新的方式
|
|
state.list!.clear();
|
|
state.list!.clear();
|
|
- state.list!.addAll(list.map((item) => item.toJson()).toList());
|
|
|
|
|
|
+ state.list!.addAll(list);
|
|
refreshController.finishRefresh();
|
|
refreshController.finishRefresh();
|
|
//更新展示的状态
|
|
//更新展示的状态
|
|
changeLoadingState(LoadState.State_Success, null);
|
|
changeLoadingState(LoadState.State_Success, null);
|
|
} else {
|
|
} else {
|
|
//加载更多
|
|
//加载更多
|
|
final allList = state.list;
|
|
final allList = state.list;
|
|
- allList!.addAll(list.map((item) => item.toJson()).toList());
|
|
|
|
|
|
+ allList!.addAll(list);
|
|
state = state.copyWith(list: allList);
|
|
state = state.copyWith(list: allList);
|
|
refreshController.finishLoad();
|
|
refreshController.finishLoad();
|
|
}
|
|
}
|
|
@@ -414,16 +412,12 @@ class RepairHomeServiceVm extends _$RepairHomeServiceVm {
|
|
//校验成功失败
|
|
//校验成功失败
|
|
if (result.isSuccess) {
|
|
if (result.isSuccess) {
|
|
// 修改 该id 的 liked 和 likes_count 字段
|
|
// 修改 该id 的 liked 和 likes_count 字段
|
|
- state.list!.forEach((Map<String, dynamic> element) {
|
|
|
|
- GarageSaleRentList elementEntity = GarageSaleRentList.fromJson(element);
|
|
|
|
|
|
+ state.list!.forEach((RepairServiceList elementEntity) {
|
|
|
|
|
|
if(elementEntity.id == id){
|
|
if(elementEntity.id == id){
|
|
elementEntity.liked = !elementEntity.liked!;
|
|
elementEntity.liked = !elementEntity.liked!;
|
|
elementEntity.likesCount = elementEntity.liked! ? (elementEntity.likesCount! + 1) : (elementEntity.likesCount! - 1);
|
|
elementEntity.likesCount = elementEntity.liked! ? (elementEntity.likesCount! + 1) : (elementEntity.likesCount! - 1);
|
|
}
|
|
}
|
|
-
|
|
|
|
- element = elementEntity.toJson();
|
|
|
|
-
|
|
|
|
});
|
|
});
|
|
return true;
|
|
return true;
|
|
} else {
|
|
} else {
|
|
@@ -501,12 +495,18 @@ class RepairHomeServiceVm extends _$RepairHomeServiceVm {
|
|
}
|
|
}
|
|
|
|
|
|
// 去详情页面
|
|
// 去详情页面
|
|
- void handlerGotoDetail({BuildContext? context, required int id, String? cleanServiceType }){
|
|
|
|
- Log.d("去详情页面 $id $cleanServiceType");
|
|
|
|
- if(cleanServiceType == 0 || cleanServiceType == 1){
|
|
|
|
|
|
+ void handlerGotoDetail({BuildContext? context, required int id, required RepairServiceListCategory repairServiceListCategory }){
|
|
|
|
+
|
|
|
|
+ final cleanServiceType = repairServiceListCategory.name!;
|
|
|
|
+ Log.d("去详情页面: $id $cleanServiceType");
|
|
|
|
+ if(cleanServiceType == servicesConstants.servicesType['repairAirConditioner']!['code']){
|
|
// clean service 跳转到 clean 详情页
|
|
// clean service 跳转到 clean 详情页
|
|
- appRouter.push(ServiceCleanDetailPageRoute(id: id, cleanServiceType: cleanServiceType!));
|
|
|
|
|
|
+ appRouter.push(ServiceRepairDetailPageRoute(id: id, cleanServiceType: cleanServiceType));
|
|
|
|
+ }else {
|
|
|
|
+ // other service 跳转到 other 详情页
|
|
|
|
+ ToastEngine.show("${cleanServiceType} 类型的详情暂未开放");
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|