|
@@ -119,100 +119,77 @@ class ForsaleVm extends _$ForsaleVm {
|
|
|
}
|
|
|
|
|
|
Log.d("for_sale_vm加载listData数据---------------start--${_page}---");
|
|
|
- // try {
|
|
|
- // //请求网络
|
|
|
- // Map<String, dynamic> params = {
|
|
|
- // "page": _page,
|
|
|
- // "limit": _limit,
|
|
|
- // };
|
|
|
- // Log.d("请求参数------$params");
|
|
|
- // final result = await propertyNewsRepository.fetchPropertyNewsList(params);
|
|
|
- // Log.d("请求完成结果------${result.data}");
|
|
|
- // //校验成功失败
|
|
|
- // if (result.isSuccess) {
|
|
|
- // // state = state.copyWith(serverTime: result.data);
|
|
|
- // state = state;
|
|
|
- // handleList(listResult.data?.rows);
|
|
|
- // ToastEngine.show("获取数据成功");
|
|
|
- // } else {
|
|
|
- // errorMessage = listResult.errorMsg;
|
|
|
- // changeLoadingState(LoadState.State_Error);
|
|
|
- // ToastEngine.show(result.errorMsg ?? "Network Load Error");
|
|
|
- // }
|
|
|
- // } catch (e) {
|
|
|
- // ToastEngine.show("Error: $e");
|
|
|
- // }
|
|
|
|
|
|
// await Future.delayed(const Duration(milliseconds: 1500));
|
|
|
// final List<Map<String, dynamic>> listData = [
|
|
|
- // {
|
|
|
- // 'id':1,
|
|
|
- // 'goods_img': 'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
|
|
|
- // 'title': 'Electronic keyboard',
|
|
|
- // 'price': '\$66',
|
|
|
- // 'isCollection': true,
|
|
|
- // 'collection_num': 12,
|
|
|
- // 'publisher': 'William Jefferson',
|
|
|
- // 'publish_time': 'June 17,2016 at 7:23 p.m.',
|
|
|
- // 'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
|
|
|
- // },
|
|
|
- // {
|
|
|
- // 'id':2,
|
|
|
- // 'goods_img': 'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
|
|
|
- // 'title': 'Electronic keyboard',
|
|
|
- // 'price': '\$88',
|
|
|
- // 'isCollection': false,
|
|
|
- // 'collection_num': 12,
|
|
|
- // 'publisher': 'William Jefferson',
|
|
|
- // 'publish_time': 'June 17,2016 at 7:23 p.m.',
|
|
|
- // 'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
|
|
|
- // },
|
|
|
- // {
|
|
|
- // 'id':3,
|
|
|
- // 'goods_img': 'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
|
|
|
- // 'title': 'Electronic keyboard',
|
|
|
- // 'price': '\$66',
|
|
|
- // 'isCollection': true,
|
|
|
- // 'collection_num': 12,
|
|
|
- // 'publisher': 'William Jefferson',
|
|
|
- // 'publish_time': 'June 17,2016 at 7:23 p.m.',
|
|
|
- // 'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
|
|
|
- // },
|
|
|
- // {
|
|
|
- // 'id':4,
|
|
|
- // 'goods_img': 'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
|
|
|
- // 'title': 'Electronic keyboard',
|
|
|
- // 'price': '\$88',
|
|
|
- // 'isCollection': false,
|
|
|
- // 'collection_num': 12,
|
|
|
- // 'publisher': 'William Jefferson',
|
|
|
- // 'publish_time': 'June 17,2016 at 7:23 p.m.',
|
|
|
- // 'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
|
|
|
- // },
|
|
|
- // {
|
|
|
- // 'id':5,
|
|
|
- // 'goods_img': 'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
|
|
|
- // 'title': 'Electronic keyboard',
|
|
|
- // 'price': '\$66',
|
|
|
- // 'isCollection': true,
|
|
|
- // 'collection_num': 12,
|
|
|
- // 'publisher': 'William Jefferson',
|
|
|
- // 'publish_time': 'June 17,2016 at 7:23 p.m.',
|
|
|
- // 'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
|
|
|
- // },
|
|
|
- // {
|
|
|
- // 'id':6,
|
|
|
- // 'goods_img': 'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
|
|
|
- // 'title': 'Electronic keyboard',
|
|
|
- // 'price': '\$88',
|
|
|
- // 'isCollection': false,
|
|
|
- // 'collection_num': 12,
|
|
|
- // 'publisher': 'William Jefferson',
|
|
|
- // 'publish_time': 'June 17,2016 at 7:23 p.m.',
|
|
|
- // 'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
|
|
|
- // },
|
|
|
+ // {
|
|
|
+ // 'id':1,
|
|
|
+ // 'goods_img': 'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
|
|
|
+ // 'title': 'Electronic keyboard',
|
|
|
+ // 'price': '\$66',
|
|
|
+ // 'isCollection': true,
|
|
|
+ // 'collection_num': 12,
|
|
|
+ // 'publisher': 'William Jefferson',
|
|
|
+ // 'publish_time': 'June 17,2016 at 7:23 p.m.',
|
|
|
+ // 'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // 'id':2,
|
|
|
+ // 'goods_img': 'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
|
|
|
+ // 'title': 'Electronic keyboard',
|
|
|
+ // 'price': '\$88',
|
|
|
+ // 'isCollection': false,
|
|
|
+ // 'collection_num': 12,
|
|
|
+ // 'publisher': 'William Jefferson',
|
|
|
+ // 'publish_time': 'June 17,2016 at 7:23 p.m.',
|
|
|
+ // 'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // 'id':3,
|
|
|
+ // 'goods_img': 'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
|
|
|
+ // 'title': 'Electronic keyboard',
|
|
|
+ // 'price': '\$66',
|
|
|
+ // 'isCollection': true,
|
|
|
+ // 'collection_num': 12,
|
|
|
+ // 'publisher': 'William Jefferson',
|
|
|
+ // 'publish_time': 'June 17,2016 at 7:23 p.m.',
|
|
|
+ // 'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // 'id':4,
|
|
|
+ // 'goods_img': 'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
|
|
|
+ // 'title': 'Electronic keyboard',
|
|
|
+ // 'price': '\$88',
|
|
|
+ // 'isCollection': false,
|
|
|
+ // 'collection_num': 12,
|
|
|
+ // 'publisher': 'William Jefferson',
|
|
|
+ // 'publish_time': 'June 17,2016 at 7:23 p.m.',
|
|
|
+ // 'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // 'id':5,
|
|
|
+ // 'goods_img': 'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
|
|
|
+ // 'title': 'Electronic keyboard',
|
|
|
+ // 'price': '\$66',
|
|
|
+ // 'isCollection': true,
|
|
|
+ // 'collection_num': 12,
|
|
|
+ // 'publisher': 'William Jefferson',
|
|
|
+ // 'publish_time': 'June 17,2016 at 7:23 p.m.',
|
|
|
+ // 'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // 'id':6,
|
|
|
+ // 'goods_img': 'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
|
|
|
+ // 'title': 'Electronic keyboard',
|
|
|
+ // 'price': '\$88',
|
|
|
+ // 'isCollection': false,
|
|
|
+ // 'collection_num': 12,
|
|
|
+ // 'publisher': 'William Jefferson',
|
|
|
+ // 'publish_time': 'June 17,2016 at 7:23 p.m.',
|
|
|
+ // 'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
|
|
|
+ // },
|
|
|
// ];
|
|
|
-
|
|
|
+ //
|
|
|
// if (_page == 1) {
|
|
|
// //刷新的方式
|
|
|
// state = state.copyWith(list: listData);
|
|
@@ -303,28 +280,36 @@ class ForsaleVm extends _$ForsaleVm {
|
|
|
}
|
|
|
|
|
|
|
|
|
- // 点击 like comments share
|
|
|
- void handlerClickActionBtn(String? actionStr, item){
|
|
|
- final id = item['id'];
|
|
|
- switch (actionStr) {
|
|
|
- case 'like':
|
|
|
- Log.d("点击了 点赞");
|
|
|
- handlerGotoDetail(id);
|
|
|
- break;
|
|
|
- case 'comments':
|
|
|
- Log.d("点击了 评论");
|
|
|
- handlerGotoDetail(id);
|
|
|
- break;
|
|
|
- case 'share':
|
|
|
- Log.d("点击了 分享");
|
|
|
- handlerGotoDetail(id);
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
+ // 点击 收藏/取消收藏
|
|
|
+ Future<bool?> handlerClickCollection(int id, bool? isCollection) async{
|
|
|
+ try {
|
|
|
+ //请求网络
|
|
|
+ Map<String, dynamic> params = {
|
|
|
+ "id": id,
|
|
|
+ };
|
|
|
+ Log.d("请求参数------$params");
|
|
|
+ final result = await commonGarageRepositoryInstance.fetchGarageColleciton(params);
|
|
|
+ //校验成功失败
|
|
|
+ if (result.isSuccess) {
|
|
|
+ // 修改 该id 的 liked 和 likes_count 字段
|
|
|
+ state.list!.forEach((Map<String, dynamic> element) {
|
|
|
+ if(element['id'] == id){
|
|
|
+ element['liked'] = !element['liked'];
|
|
|
+ element['collection_num'] = element['liked'] ? element['collection_num'] + 1 : element['collection_num'] - 1;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ String errorMessage = result.errorMsg!;
|
|
|
+ changeLoadingState(LoadState.State_Error, errorMessage);
|
|
|
+ ToastEngine.show(result.errorMsg ?? "Network Load Error");
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ ToastEngine.show("Error: $e");
|
|
|
}
|
|
|
}
|
|
|
// 去详情页面
|
|
|
- void handlerGotoDetail(id){
|
|
|
+ void handlerGotoDetail({BuildContext? context, required int id, String type='forSale'}){
|
|
|
Log.d("去详情页面");
|
|
|
appRouter.push(GaragesaleDetailPageRoute(id: id, type: 'forSale'));
|
|
|
}
|