diff --git a/assets/image/2x/icon_like.png b/assets/image/2x/icon_like.png index 307c0cd6..b60f9bfc 100644 Binary files a/assets/image/2x/icon_like.png and b/assets/image/2x/icon_like.png differ diff --git a/assets/image/2x/icon_like_h.png b/assets/image/2x/icon_like_h.png index c82ca733..09f69c4f 100644 Binary files a/assets/image/2x/icon_like_h.png and b/assets/image/2x/icon_like_h.png differ diff --git a/assets/image/3x/icon_like.png b/assets/image/3x/icon_like.png index 4545e562..8810984a 100644 Binary files a/assets/image/3x/icon_like.png and b/assets/image/3x/icon_like.png differ diff --git a/assets/image/3x/icon_like_h.png b/assets/image/3x/icon_like_h.png index 2f7005ab..e110a8a5 100644 Binary files a/assets/image/3x/icon_like_h.png and b/assets/image/3x/icon_like_h.png differ diff --git a/assets/image/icon_like.png b/assets/image/icon_like.png index c3c1c68d..ded7335f 100644 Binary files a/assets/image/icon_like.png and b/assets/image/icon_like.png differ diff --git a/assets/image/icon_like_h.png b/assets/image/icon_like_h.png index c03cbf29..27551785 100644 Binary files a/assets/image/icon_like_h.png and b/assets/image/icon_like_h.png differ diff --git a/lib/article/hot_article_item.dart b/lib/article/hot_article_item.dart index 89467346..eb3a502d 100644 --- a/lib/article/hot_article_item.dart +++ b/lib/article/hot_article_item.dart @@ -51,7 +51,7 @@ class _HotArticlePage extends State { List
articles = []; queryArticle() async { - BaseData baseData = await apiService.queryArticle({ + BaseData> baseData = await apiService.queryArticle({ "pageNum": pageNum, "pageSize": 10, "searchKey": "", @@ -62,14 +62,13 @@ class _HotArticlePage extends State { refreshController.loadFailed(); }); if (baseData != null && baseData.isSuccess) { - PageInfo pageInfo = PageInfo.fromJson(baseData.data); refreshController.refreshCompleted(); refreshController.loadComplete(); if(pageNum == 1) { articles.clear(); } - articles.addAll(pageInfo.list.map((e) => Article.fromJson(e)).toList()); - if (pageInfo.pageNum == pageInfo.pages) { + articles.addAll(baseData.data.list); + if (baseData.data.pageNum == baseData.data.pages) { refreshController.loadNoData(); } else { pageNum += 1; diff --git a/lib/home/activity_list_page.dart b/lib/home/activity_list_page.dart index da44a72b..50edc487 100644 --- a/lib/home/activity_list_page.dart +++ b/lib/home/activity_list_page.dart @@ -46,7 +46,7 @@ class _ActivityListPage extends State List activityList; queryActivity() async { - BaseData baseData = await apiService.informationList({ + BaseData> baseData = await apiService.informationList({ "pageNum": 1, "pageSize": 10, "searchKey": "", @@ -56,10 +56,9 @@ class _ActivityListPage extends State _refreshController.refreshFailed(); }); if (baseData != null && baseData.isSuccess) { - PageInfo pageInfo = PageInfo.fromJson(baseData.data); _refreshController.refreshCompleted(); setState(() { - activityList = pageInfo.list.map((e) => Activity.fromJson(e)).toList(); + activityList = baseData.data.list; }); } } diff --git a/lib/home/home_page.dart b/lib/home/home_page.dart index 722fdbd5..fae84c68 100644 --- a/lib/home/home_page.dart +++ b/lib/home/home_page.dart @@ -87,25 +87,22 @@ class _HomePage extends State with AutomaticKeepAliveClientMixin { SmartDialog.showLoading( msg: S.of(context).zhengzaijiazai, animationDurationTemp: Duration(seconds: 1)); - BaseData baseData = await apiService.queryBanner({ + BaseData> baseData = await apiService.queryBanner({ "model": {"type": "HOME_PAGE"}, }).catchError((onError) { refreshController.refreshFailed(); }); if (baseData != null && baseData.isSuccess) { bannerData.clear(); - bannerData.addAll((baseData.data["records"] as List) - .map((e) => BannerData.fromJson(e)) - .toList()); + bannerData.addAll(baseData.data.records); setState(() { - controller.move(0, animation: false); + if (bannerData.length > 0) + controller.move(0, animation: false); }); } BaseData brand = await apiService.queryHomeBrand().catchError((onError) { refreshController.refreshFailed(); - }).catchError((onError) { - refreshController.refreshFailed(); }); if (brand != null && brand.isSuccess) { brandData.clear(); @@ -115,7 +112,7 @@ class _HomePage extends State with AutomaticKeepAliveClientMixin { founder = Founder.fromJson(brand.data["founder"]); } - BaseData article = await apiService.queryArticle({ + BaseData> article = await apiService.queryArticle({ "pageNum": 1, "pageSize": 10, "searchKey": "", @@ -126,11 +123,10 @@ class _HomePage extends State with AutomaticKeepAliveClientMixin { }); articles.clear(); if (article != null && article.isSuccess) { - PageInfo pageInfo = PageInfo.fromJson(article.data); - articles.addAll(pageInfo.list.map((e) => Article.fromJson(e)).toList()); + articles.addAll(article.data.list); } - BaseData goodsData = await apiService.creditGoods({ + BaseData> goodsData = await apiService.creditGoods({ "orderDesc": true, "orderType": 1, "pageNum": 1, @@ -138,9 +134,8 @@ class _HomePage extends State with AutomaticKeepAliveClientMixin { "state": 1 }); if (goodsData != null && goodsData.isSuccess) { - PageInfo page = PageInfo.fromJson(goodsData.data); gooods.clear(); - gooods.addAll(page.list.map((e) => Goods.fromJson(e))); + gooods.addAll(goodsData.data.list); } SmartDialog.dismiss(); if (baseData != null && baseData.isSuccess) { @@ -678,7 +673,7 @@ class _HomePage extends State with AutomaticKeepAliveClientMixin { ), ); }, - itemCount: bannerData != null ? bannerData.length : 1, + itemCount: (bannerData != null && bannerData.length > 0) ? bannerData.length : 1, ), ), ); diff --git a/lib/home/huixiang_brand_page.dart b/lib/home/huixiang_brand_page.dart index 3a4134fc..ba53605e 100644 --- a/lib/home/huixiang_brand_page.dart +++ b/lib/home/huixiang_brand_page.dart @@ -12,6 +12,7 @@ import 'package:huixiang/retrofit/data/banner.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/brand.dart'; import 'package:huixiang/retrofit/data/brand_data.dart'; +import 'package:huixiang/retrofit/data/page.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/utils/MyPainter.dart'; import 'package:huixiang/utils/event_type.dart'; @@ -43,18 +44,16 @@ class _BrandPage extends State var isShowMore = false; queryHome() async { - BaseData baseData = await apiService.queryHome().catchError((error) { + BaseData baseData = await apiService.queryHome().catchError((error) { refreshController.refreshFailed(); }); - BaseData banner = await apiService.queryBanner({ + BaseData> banner = await apiService.queryBanner({ "model": {"type": "BRAND_APP"}, }).catchError((error) { refreshController.refreshFailed(); }); bannerData.clear(); - bannerData.addAll((banner.data["records"] as List) - .map((e) => BannerData.fromJson(e)) - .toList()); + bannerData.addAll(banner.data.records); BaseData brand = await apiService.queryHomeBrand().catchError((onError) { refreshController.refreshFailed(); @@ -77,8 +76,7 @@ class _BrandPage extends State if (baseData != null && baseData.isSuccess) { refreshController.refreshCompleted(); - brandData = BrandData.fromJson(baseData.data); - // brandText = (brandData.contents as Map).keys.toList(); + brandData = baseData.data; setState(() {}); } else { refreshController.refreshFailed(); diff --git a/lib/home/points_mall_page.dart b/lib/home/points_mall_page.dart index ce4b4ad3..5b9c0e9b 100644 --- a/lib/home/points_mall_page.dart +++ b/lib/home/points_mall_page.dart @@ -90,28 +90,25 @@ class _PointsMallPage extends State //是否降序排列 bool orderDesc = true; - PageInfo page; List goods = []; List gooodsCategorys = []; UserInfo userinfo; List bannerData = []; queryUser() async { - BaseData banner = await client.queryBanner({ + BaseData> banner = await client.queryBanner({ "model": {"type": "CREDIT_INDEX"}, }); if (banner != null) { bannerData.clear(); - bannerData.addAll((banner.data["records"] as List) - .map((e) => BannerData.fromJson(e)) - .toList()); + bannerData.addAll(banner.data.records); setState(() {}); } - BaseData baseData = await client.queryInfo(); + BaseData baseData = await client.queryInfo(); if (baseData != null && baseData.isSuccess) { - userinfo = UserInfo.fromJson(baseData.data); + userinfo = baseData.data; SharedPreferences.getInstance().then((value) => { value.setString('user', jsonEncode(baseData.data)), }); @@ -120,7 +117,7 @@ class _PointsMallPage extends State } creditGoods(categoryId) async { - BaseData dataCategory = await client.goodsCategory({ + BaseData> dataCategory = await client.goodsCategory({ "current": 1, "map": {}, "model": {"pageNum": 1, "pageSize": 20, "searchKey": ""}, @@ -133,11 +130,9 @@ class _PointsMallPage extends State }); if (dataCategory != null && dataCategory.isSuccess) { - PageInfo pageInfo = PageInfo.fromJson(dataCategory.data); gooodsCategorys.clear(); gooodsCategorys.add(GoodsCategory(name: S.of(context).quanbu)); - gooodsCategorys.addAll( - pageInfo.records.map((e) => GoodsCategory.fromJson(e)).toList()); + gooodsCategorys.addAll(dataCategory.data.records); } var param = { @@ -148,21 +143,20 @@ class _PointsMallPage extends State "pageSize": 10, "state": 1 }; - BaseData baseData = await client.creditGoods(param).catchError((onError) { + BaseData> baseData = await client.creditGoods(param).catchError((onError) { _refreshController.loadFailed(); _refreshController.refreshFailed(); }); SmartDialog.dismiss(); if (baseData != null && baseData.isSuccess) { - page = PageInfo.fromJson(baseData.data); if (pageNum == 1) { goods.clear(); } - goods.addAll(page.list.map((e) => Goods.fromJson(e))); + goods.addAll(baseData.data.list); setState(() { _refreshController.refreshCompleted(); _refreshController.loadComplete(); - if (page.pageNum == page.pages) { + if (baseData.data.pageNum == baseData.data.pages) { _refreshController.loadNoData(); } else { pageNum += 1; diff --git a/lib/integral/integral_detailed_page.dart b/lib/integral/integral_detailed_page.dart index 0fb7a6cb..bc3d1847 100644 --- a/lib/integral/integral_detailed_page.dart +++ b/lib/integral/integral_detailed_page.dart @@ -72,7 +72,7 @@ class _IntegralDetailedPage extends State List userBill = []; queryDetail(category) async { - BaseData baseData = await apiService.queryBillInfo({ + BaseData> baseData = await apiService.queryBillInfo({ "current": current, "model": {"category": category, "title": "bill_title_point", "type": ""}, "order": "descending", @@ -84,12 +84,10 @@ class _IntegralDetailedPage extends State }); if (current == 1) userBill.clear(); if (baseData != null && baseData.isSuccess) { - PageInfo pageInfo = PageInfo.fromJson(baseData.data); - userBill - .addAll(pageInfo.records.map((e) => UserBill.fromJson(e)).toList()); + userBill.addAll(baseData.data.records); refreshController.loadComplete(); refreshController.refreshCompleted(); - if (current * 10 > int.tryParse(pageInfo.total)) { + if (current * 10 > int.tryParse(baseData.data.total)) { refreshController.loadNoData(); } else { current += 1; diff --git a/lib/integral/integral_page.dart b/lib/integral/integral_page.dart index 656a85b5..3731d73f 100644 --- a/lib/integral/integral_page.dart +++ b/lib/integral/integral_page.dart @@ -49,14 +49,12 @@ class _IntegralPage extends State { } querySignInfo() async { - BaseData baseData = await apiService.signInInfo(); + BaseData baseData = await apiService.signInInfo(); - BaseData rankData = await apiService.rankList(); + BaseData> rankData = await apiService.rankList(); if (rankData != null && rankData.isSuccess) { ranks.clear(); - ranks.addAll((rankData.data as List) - .map((e) => Rank.fromJson(e)) - .toList()); + ranks.addAll(rankData.data); } if (userinfo != null && @@ -69,7 +67,7 @@ class _IntegralPage extends State { } SmartDialog.dismiss(closeType: 3); if (baseData != null && baseData.isSuccess) { - signInfo = SignInfo.fromJson(baseData.data); + signInfo = baseData.data; setState(() {}); } } diff --git a/lib/integral_store/integral_store_details_page.dart b/lib/integral_store/integral_store_details_page.dart index 927c67b2..2796c722 100644 --- a/lib/integral_store/integral_store_details_page.dart +++ b/lib/integral_store/integral_store_details_page.dart @@ -50,10 +50,10 @@ class _IntegralStoreDetailsPage extends State { Goods goods; queryGoodsById() async { - BaseData baseData = await apiService.creditGoodsById(arguments["goodsId"]); + BaseData baseData = await apiService.creditGoodsById(arguments["goodsId"]); if (baseData != null && baseData.isSuccess) { setState(() { - goods = Goods.fromJson(baseData.data); + goods = baseData.data; }); } } diff --git a/lib/login/login_page.dart b/lib/login/login_page.dart index e891ef0b..2ed589eb 100644 --- a/lib/login/login_page.dart +++ b/lib/login/login_page.dart @@ -274,7 +274,7 @@ class _MyLoginPageState extends State with TickerProviderStateMixin { "capcha": code, "mobile": mobile, }; - SmartDialog.showLoading(msg: S.of(context).zhengzaijiazai, animationDurationTemp: Duration(seconds: 1)); + SmartDialog.showLoading(msg: S.of(context).zhengzaijiazai); BaseData value = await client.memberLogin(param).catchError((error) { print(error); SmartDialog.showToast("$error", alignment: Alignment.center); diff --git a/lib/message/system_message.dart b/lib/message/system_message.dart index f1aa7042..f880c5e0 100644 --- a/lib/message/system_message.dart +++ b/lib/message/system_message.dart @@ -44,7 +44,7 @@ class _SystemMessagePage extends State { } queryMessage() async { - BaseData baseData = await apiService.msgList({ + BaseData> baseData = await apiService.msgList({ "pageNum": pageNum, "pageSize": 10, "searchKey": "", @@ -56,15 +56,14 @@ class _SystemMessagePage extends State { }); if (baseData != null && baseData.isSuccess) { - PageInfo pageInfo = PageInfo.fromJson(baseData.data); if (pageNum == 1) { messages.clear(); } - messages.addAll(pageInfo.list.map((e) => Message.fromJson(e)).toList()); + messages.addAll(baseData.data.list); _refreshController.loadComplete(); _refreshController.refreshCompleted(); if (mounted) setState(() {}); - if (pageNum * 10 > int.tryParse(pageInfo.total)) { + if (pageNum * 10 > int.tryParse(baseData.data.total)) { _refreshController.loadNoData(); } else { pageNum += 1; diff --git a/lib/mine/coupons_page.dart b/lib/mine/coupons_page.dart index cf894551..1db1c705 100644 --- a/lib/mine/coupons_page.dart +++ b/lib/mine/coupons_page.dart @@ -54,7 +54,7 @@ class _CouponsPage extends State { } queryCard() async { - BaseData baseData = await apiService.queryCard({ + BaseData> baseData = await apiService.queryCard({ "centre": true, "pageNum": pageNum, "pageSize": 10, @@ -65,15 +65,14 @@ class _CouponsPage extends State { _refreshController.refreshFailed(); }); if (baseData != null && baseData.isSuccess) { - PageInfo pageInfo = PageInfo.fromJson(baseData.data); if (pageNum == 1) { coupons.clear(); } - coupons.addAll(pageInfo.list.map((e) => Coupon.fromJson(e))); + coupons.addAll(baseData.data.list); setState(() { _refreshController.refreshCompleted(); _refreshController.loadComplete(); - if (pageInfo.pageNum == pageInfo.pages) { + if (baseData.data.pageNum == baseData.data.pages) { _refreshController.loadNoData(); } else { pageNum += 1; diff --git a/lib/mine/manage_address_page.dart b/lib/mine/manage_address_page.dart index 56c52c6b..037fa6fb 100644 --- a/lib/mine/manage_address_page.dart +++ b/lib/mine/manage_address_page.dart @@ -41,12 +41,10 @@ class _ManageAddressPage extends State { List
addressList; queryMemberAddress() async { - BaseData baseData = await apiService.queryMemberAddress(); + BaseData> baseData = await apiService.queryMemberAddress(); if (baseData != null && baseData.isSuccess) { checkIndex = 0; - addressList = (baseData.data as List) - .map((e) => Address.fromJson(e)) - .toList(); + addressList = baseData.data; setState(() {}); } } diff --git a/lib/mine/mine_card_invalid_page.dart b/lib/mine/mine_card_invalid_page.dart index 396794ab..492237c0 100644 --- a/lib/mine/mine_card_invalid_page.dart +++ b/lib/mine/mine_card_invalid_page.dart @@ -52,7 +52,7 @@ class _MineCardInvalidPage extends State { } queryCard() async { - BaseData baseData = await apiService.queryCard({ + BaseData> baseData = await apiService.queryCard({ "centre": true, "pageNum": pageNum, "pageSize": 10, @@ -63,15 +63,14 @@ class _MineCardInvalidPage extends State { _refreshController.refreshFailed(); }); if (baseData != null && baseData.isSuccess) { - PageInfo pageInfo = PageInfo.fromJson(baseData.data); if (pageNum == 1) { coupons.clear(); } - coupons.addAll(pageInfo.list.map((e) => Coupon.fromJson(e))); + coupons.addAll(baseData.data.list); setState(() { _refreshController.refreshCompleted(); _refreshController.loadComplete(); - if (pageInfo.pageNum == pageInfo.pages) { + if (baseData.data.pageNum == baseData.data.pages) { _refreshController.loadNoData(); } else { pageNum += 1; diff --git a/lib/mine/mine_page.dart b/lib/mine/mine_page.dart index 36380cac..c1baa23c 100644 --- a/lib/mine/mine_page.dart +++ b/lib/mine/mine_page.dart @@ -100,17 +100,15 @@ class _MinePage extends State with AutomaticKeepAliveClientMixin { queryUserInfo() async { SmartDialog.showLoading(msg: S.of(context).zhengzaijiazai, animationDurationTemp: Duration(seconds: 1)); - BaseData rankData = await apiService.rankList(); + BaseData> rankData = await apiService.rankList(); if (rankData != null && rankData.isSuccess) { ranks.clear(); - ranks.addAll((rankData.data as List) - .map((e) => Rank.fromJson(e)) - .toList()); + ranks.addAll(rankData.data); } - BaseData baseDate = await apiService.queryInfo(); + BaseData baseDate = await apiService.queryInfo(); if (baseDate != null && baseDate.isSuccess) { - userinfo = UserInfo.fromJson(baseDate.data); + userinfo = baseDate.data; if (userinfo != null && userinfo.memberRankVo != null && ranks != null && diff --git a/lib/mine/mine_vip_level_page.dart b/lib/mine/mine_vip_level_page.dart index f6aa3a77..4732c5e5 100644 --- a/lib/mine/mine_vip_level_page.dart +++ b/lib/mine/mine_vip_level_page.dart @@ -41,12 +41,10 @@ class _MineVipLevelPage extends State { } queryVipLevel() async { - BaseData rankData = await apiService.rankList(); + BaseData> rankData = await apiService.rankList(); if (rankData != null && rankData.isSuccess) { ranks.clear(); - ranks.addAll((rankData.data as List) - .map((e) => Rank.fromJson(e)) - .toList()); + ranks.addAll(rankData.data); setState(() { controller.move((widget.arguments["rankLevel"] - 1), animation: false); }); diff --git a/lib/mine/mine_wallet_page.dart b/lib/mine/mine_wallet_page.dart index 2b5a0798..9fd608d7 100644 --- a/lib/mine/mine_wallet_page.dart +++ b/lib/mine/mine_wallet_page.dart @@ -57,9 +57,9 @@ class _MineWalletPage extends State { } queryUserBalance() async { - BaseData baseData = await apiService.queryInfo(); + BaseData baseData = await apiService.queryInfo(); if (baseData != null && baseData.isSuccess) { - userInfo = UserInfo.fromJson(baseData.data); + userInfo = baseData.data; mBalance = double.tryParse(userInfo.money); if (mounted) setState(() {}); } @@ -67,7 +67,7 @@ class _MineWalletPage extends State { loadBillInfo() async { queryUserBalance(); - BaseData baseData = await apiService.queryBillInfo({ + BaseData> baseData = await apiService.queryBillInfo({ "current": current, "model": {"category": "", "title": "bill_title_balance", "type": ""}, "order": "descending", @@ -78,15 +78,13 @@ class _MineWalletPage extends State { refreshController.loadFailed(); }); if (baseData != null && baseData.isSuccess) { - PageInfo pageInfo = PageInfo.fromJson(baseData.data); if (current == 1) { userBills.clear(); } - userBills - .addAll(pageInfo.records.map((e) => UserBill.fromJson(e)).toList()); + userBills.addAll(baseData.data.records); refreshController.refreshCompleted(); refreshController.loadComplete(); - if (current * 10 > int.tryParse(pageInfo.total)) { + if (current * 10 > int.tryParse(baseData.data.total)) { refreshController.loadNoData(); } else { current += 1; diff --git a/lib/mine/recharge_page.dart b/lib/mine/recharge_page.dart index 84f55143..25041acc 100644 --- a/lib/mine/recharge_page.dart +++ b/lib/mine/recharge_page.dart @@ -216,10 +216,9 @@ class _RechargePage extends State { await Min.initialize(); } - BaseData baseData = - await apiService.recharge({"amount": amount, "rechargeType": 2}); + BaseData baseData = await apiService.recharge({"amount": amount, "rechargeType": 2}); if (baseData != null && baseData.isSuccess) { - WxPay wxPay = WxPay.fromJson(baseData.data); + WxPay wxPay = baseData.data; await registerWxApi( appId: wxPay.appId, doOnAndroid: true, diff --git a/lib/mine/roll_center_page.dart b/lib/mine/roll_center_page.dart index a14e8acc..fb02707a 100644 --- a/lib/mine/roll_center_page.dart +++ b/lib/mine/roll_center_page.dart @@ -45,7 +45,7 @@ class _RollCenterPage extends State { List coupons = []; queryCoupon() async { - BaseData baseData = await apiService.queryCoupon({ + BaseData> baseData = await apiService.queryCoupon({ "centre": true, "pageNum": pageNum, "pageSize": 10, @@ -57,12 +57,10 @@ class _RollCenterPage extends State { }); if (pageNum == 1) coupons.clear(); if (baseData != null && baseData.isSuccess) { - PageInfo pageInfo = PageInfo.fromJson(baseData.data); - coupons.addAll(pageInfo.list.map((e) => Coupon.fromJson(e)).toList()); - + coupons.addAll(baseData.data.list); _refreshController.refreshCompleted(); _refreshController.loadComplete(); - if (pageInfo.pageNum == pageInfo.pages) { + if (baseData.data.pageNum == baseData.data.pages) { _refreshController.loadNoData(); } else { pageNum += 1; diff --git a/lib/mine/user_info_page.dart b/lib/mine/user_info_page.dart index 5d6d6a26..ceb0a162 100644 --- a/lib/mine/user_info_page.dart +++ b/lib/mine/user_info_page.dart @@ -340,9 +340,9 @@ class _UserInfoPage extends State { ///文件上传 fileUpload() async { if (filePath != null && filePath != "" && await File(filePath).exists()) { - BaseData baseData = await apiService.upload(File(filePath), 123123123); + BaseData baseData = await apiService.upload(File(filePath), 123123123); if (baseData != null && baseData.isSuccess) { - UploadResult uploadResult = UploadResult.fromJson(baseData.data); + UploadResult uploadResult = baseData.data; modifyInfo["headimg"] = uploadResult.url; modifyInfos(); } diff --git a/lib/mine/vip_balance_page.dart b/lib/mine/vip_balance_page.dart index 71763f15..24e90cc2 100644 --- a/lib/mine/vip_balance_page.dart +++ b/lib/mine/vip_balance_page.dart @@ -45,7 +45,7 @@ class _VipBalancePage extends State { List userBills = []; queryBillInfo() async { - BaseData baseData = await apiService.queryBillInfo({ + BaseData> baseData = await apiService.queryBillInfo({ "current": current, "model": { "category": "", @@ -61,15 +61,14 @@ class _VipBalancePage extends State { _refreshController.refreshFailed(); }); if (baseData != null && baseData.isSuccess) { - PageInfo pageInfo = PageInfo.fromJson(baseData.data); if (current == 1) { userBills.clear(); } - userBills.addAll(pageInfo.records.map((e) => UserBill.fromJson(e))); + userBills.addAll(baseData.data.records); setState(() { _refreshController.refreshCompleted(); _refreshController.loadComplete(); - if (pageInfo.pageNum == pageInfo.pages) { + if (baseData.data.pageNum == baseData.data.pages) { _refreshController.loadNoData(); } else { current += 1; diff --git a/lib/mine/vip_card_page.dart b/lib/mine/vip_card_page.dart index 4d4ed724..f0278885 100644 --- a/lib/mine/vip_card_page.dart +++ b/lib/mine/vip_card_page.dart @@ -39,13 +39,12 @@ class _VipCardPage extends State { List coupons = []; queryVipCard() async { - BaseData baseData = await apiService.vipList({}).catchError((error) { + BaseData> baseData = await apiService.vipList({}).catchError((error) { _refreshController.refreshFailed(); }); if (baseData != null && baseData.isSuccess) { coupons.clear(); - coupons.addAll( - (baseData.data as List).map((e) => VipCard.fromMap(e))); + coupons.addAll(baseData.data); setState(() { _refreshController.refreshCompleted(); }); diff --git a/lib/mine/vip_detail_page.dart b/lib/mine/vip_detail_page.dart index ded12871..8b7bf0a8 100644 --- a/lib/mine/vip_detail_page.dart +++ b/lib/mine/vip_detail_page.dart @@ -65,13 +65,13 @@ class _VipDetailPage extends State { int current = 1; vipDetail(latitude, longitude) async { - BaseData baseData = await apiService.vipDetail({ + BaseData baseData = await apiService.vipDetail({ "id": widget.arguments["id"], "latitude": "$latitude", "longitude": "$longitude", }); if (baseData != null && baseData.isSuccess) { - vipCard = VipCard.fromMap(baseData.data); + vipCard = baseData.data; refreshController.loadComplete(); setState(() {}); } else { diff --git a/lib/order/exchange_history_page.dart b/lib/order/exchange_history_page.dart index bfa11fc6..b1fb7953 100644 --- a/lib/order/exchange_history_page.dart +++ b/lib/order/exchange_history_page.dart @@ -132,7 +132,6 @@ class _ExchangeHistoryList extends State { } int pageNum = 1; - PageInfo pageInfo; List orders = []; queryHistory() async { @@ -144,21 +143,20 @@ class _ExchangeHistoryList extends State { if (widget.orderStatus != 0) { map["state"] = widget.orderStatus; } - BaseData baseData = + BaseData> baseData = await apiService.creditOrderList(map).catchError((error) { _refreshController.loadFailed(); _refreshController.refreshFailed(); }); if (baseData != null && baseData.isSuccess) { - pageInfo = PageInfo.fromJson(baseData.data); if (pageNum == 1) { orders.clear(); } - orders.addAll(pageInfo.list.map((e) => ExchangeOrder.fromJson(e))); + orders.addAll(baseData.data.list); setState(() { _refreshController.loadComplete(); _refreshController.refreshCompleted(); - if (pageInfo.pages == pageInfo.pageNum) { + if (baseData.data.pages == baseData.data.pageNum) { _refreshController.loadNoData(); } else { pageNum += 1; diff --git a/lib/order/logistics_information_page.dart b/lib/order/logistics_information_page.dart index fafbc5a0..68e004be 100644 --- a/lib/order/logistics_information_page.dart +++ b/lib/order/logistics_information_page.dart @@ -43,13 +43,13 @@ class _LogisticsInformationPage extends State { String shipStatus = ""; getShippingTrace(String shipperCode, String logisticCode) async { - BaseData baseData = await apiService + BaseData baseData = await apiService .shippingTrace(shipperCode, logisticCode) .catchError((error) { _refreshController.refreshFailed(); }); if (baseData != null && baseData.isSuccess) { - Logistics lgs = Logistics.fromMap(baseData.data); + Logistics lgs = baseData.data; logistics.clear(); logistics.addAll(lgs.traces.reversed); setState(() { diff --git a/lib/order/order_detail_page.dart b/lib/order/order_detail_page.dart index bcd37942..3f3d3108 100644 --- a/lib/order/order_detail_page.dart +++ b/lib/order/order_detail_page.dart @@ -55,9 +55,9 @@ class _OrderDetailPage extends State { // String storeType = "NORMALSTORE"; //NORMALSTORE FASTSTORE RETAILSTORE queryDetails() async { - BaseData baseData = await apiService.orderDetail(widget.arguments["id"]); + BaseData baseData = await apiService.orderDetail(widget.arguments["id"]); if (baseData != null && baseData.isSuccess) { - orderInfo = OrderInfo.fromJson(baseData.data); + orderInfo = baseData.data; payStatus = orderInfo.payStatus; orderStatus = orderInfo.orderStatus; sendStatus = orderInfo.sendStatus; diff --git a/lib/order/order_history_page.dart b/lib/order/order_history_page.dart index 9a30b44d..00a2fc39 100644 --- a/lib/order/order_history_page.dart +++ b/lib/order/order_history_page.dart @@ -164,7 +164,7 @@ class _OrderHistoryList extends State List orderInfos = []; queryOrder() async { - BaseData baseData = await apiService.orderList({ + BaseData> baseData = await apiService.orderList({ "current": current, "model": {"status": widget.orderStatus}, "order": "descending", @@ -176,15 +176,13 @@ class _OrderHistoryList extends State }); if (baseData != null && baseData.isSuccess) { - PageInfo pageInfo = PageInfo.fromJson(baseData.data); if (current == 1) { orderInfos.clear(); } - orderInfos - .addAll(pageInfo.records.map((e) => OrderInfo.fromJson(e)).toList()); + orderInfos.addAll(baseData.data.records); refreshController.refreshCompleted(); refreshController.loadComplete(); - if (current * 10 > int.tryParse(pageInfo.total)) { + if (current * 10 > int.tryParse(baseData.data.total)) { refreshController.loadNoData(); } else { current += 1; diff --git a/lib/order/store_selector_page.dart b/lib/order/store_selector_page.dart index 5282beb3..7b7c5448 100644 --- a/lib/order/store_selector_page.dart +++ b/lib/order/store_selector_page.dart @@ -102,9 +102,9 @@ class _StoreSelectorPage extends State { SharedPreferences prefs = await SharedPreferences.getInstance(); await prefs.setString("latitude", "${latLng.latitude}"); await prefs.setString("longitude", "${latLng.longitude}"); - await prefs.setString("province", province); - await prefs.setString("city", city); - await prefs.setString("district", district); + await prefs.setString("province", province ?? ""); + await prefs.setString("city", city ?? ""); + await prefs.setString("district", district ?? ""); } List storeList; @@ -210,7 +210,7 @@ class _StoreSelectorPage extends State { } queryStore(latitude, longitude, province, city, district) async { - BaseData baseData = await apiService.queryStore({ + BaseData> baseData = await apiService.queryStore({ "city": "", "district": "", "latitude": latitude, @@ -219,9 +219,7 @@ class _StoreSelectorPage extends State { "searchKey": "" }); if (baseData != null && baseData.isSuccess) { - storeList = (baseData.data as List) - .map((e) => Store.fromJson(e)) - .toList(); + storeList = baseData.data; if (mounted) setState(() {}); } } diff --git a/lib/retrofit/data/article.dart b/lib/retrofit/data/article.dart index ffd0ecb2..0085a6ed 100644 --- a/lib/retrofit/data/article.dart +++ b/lib/retrofit/data/article.dart @@ -2,23 +2,6 @@ import 'dart:convert'; import 'package:huixiang/retrofit/data/author.dart'; -/// id : "4" -/// createTime : "2021-07-05 14:20:43" -/// createUser : null -/// updateTime : "2021-07-05 14:23:47" -/// updateUser : null -/// storeId : "0" -/// mainTitle : "牡丹花的养护知识" -/// viceTitle : null -/// content : "阿斯顿发斯蒂芬" -/// coverImg : "https://pos.upload.gznl.top/MDAwMA==/2021/06/2a1060d8-08f6-4036-935a-0514aaade9d8.jpg" -/// author : "{\"name\":\"百花谷\",\"avatar\":\"https://pos.upload.gznl.top/MDAwMA==/2021/06/6a3586dc-a340-470f-b645-1e3155d5f558.jpg\"}" -/// type : 2 -/// startTime : "2021-07-05 14:25:10" -/// endTime : "2099-01-01 00:00:00" -/// state : 1 -/// isDelete : 0 -/// storeName : null class Article { String _id; @@ -69,6 +52,10 @@ class Article { _likes = value; } + set liked(bool value) { + _liked = value; + } + set viewers(int value) { _viewers = value; } diff --git a/lib/retrofit/data/base_data.dart b/lib/retrofit/data/base_data.dart index e536de2d..30954bd1 100644 --- a/lib/retrofit/data/base_data.dart +++ b/lib/retrofit/data/base_data.dart @@ -1,8 +1,16 @@ -class BaseData { + + + +import 'package:json_annotation/json_annotation.dart'; + +part 'base_data.g.dart'; + +@JsonSerializable(genericArgumentFactories: true) +class BaseData { BaseData(); int code; - dynamic data; + T data; dynamic extra; bool isError; bool isSuccess; @@ -10,24 +18,8 @@ class BaseData { String path; String timestamp; - factory BaseData.fromJson(Map json) => BaseData() - ..code = json['code'] as int - ..data = json['data'] - ..extra = json['extra'] - ..isError = json['isError'] as bool - ..isSuccess = json['isSuccess'] as bool - ..msg = json['msg'] as String - ..path = json['path'] as String - ..timestamp = json['timestamp'] as String; - - Map toJson() => { - 'code': this.code, - 'data': this.data, - 'extra': this.extra, - 'isError': this.isError, - 'isSuccess': this.isSuccess, - 'msg': this.msg, - 'path': this.path, - 'timestamp': this.timestamp, - }; + factory BaseData.fromJson(Map json, T Function(dynamic json) fromJsonT) => _$BaseDataFromJson(json, fromJsonT); + + Map toJson(Object Function(T value) toJsonT) => _$BaseDataToJson(this, toJsonT); + } diff --git a/lib/retrofit/data/logistics.dart b/lib/retrofit/data/logistics.dart index 60475bf0..73a18902 100644 --- a/lib/retrofit/data/logistics.dart +++ b/lib/retrofit/data/logistics.dart @@ -11,7 +11,7 @@ class Logistics { bool success; List traces; - static Logistics fromMap(Map map) { + static Logistics fromJson(Map map) { if (map == null) return null; Logistics logisticsBean = Logistics(); logisticsBean.logisticCode = map['logisticCode']; diff --git a/lib/retrofit/data/member_comment_list.dart b/lib/retrofit/data/member_comment_list.dart index 4ed89be5..193f7b82 100644 --- a/lib/retrofit/data/member_comment_list.dart +++ b/lib/retrofit/data/member_comment_list.dart @@ -41,7 +41,7 @@ class MemberCommentList { String username; bool liked; - static MemberCommentList fromMap(Map map) { + static MemberCommentList fromJson(Map map) { if (map == null) return null; MemberCommentList listBean = MemberCommentList(); listBean.content = map['content']; diff --git a/lib/retrofit/data/page.dart b/lib/retrofit/data/page.dart index b1290331..257ac7e0 100644 --- a/lib/retrofit/data/page.dart +++ b/lib/retrofit/data/page.dart @@ -1,5 +1,14 @@ -class PageInfo { + + + +import 'package:json_annotation/json_annotation.dart'; + +part 'page.g.dart'; + + +@JsonSerializable(genericArgumentFactories: true) +class PageInfo { PageInfo(); int pageNum; @@ -10,32 +19,10 @@ class PageInfo { bool hasPreviousPage; bool hasNextPage; String total; - List list; - List records; - - factory PageInfo.fromJson(Map json) => - PageInfo() - ..pageNum = json['pageNum'] as int - ..current = json['current'] - ..pageSize = json['pageSize'] as int - ..size = json['size'] - ..pages = json['pages'] - ..hasPreviousPage = json['hasPreviousPage'] as bool - ..hasNextPage = json['hasNextPage'] as bool - ..total = json['total'] as String - ..list = json['list'] as List - ..records = json['records'] as List; - - Map toJson() => { - 'pageNum': this.pageNum, - 'current': this.current, - 'pageSize': this.pageSize, - 'size': this.size, - 'pages': this.pages, - 'hasPreviousPage': this.hasPreviousPage, - 'hasNextPage': this.hasNextPage, - 'total': this.total, - 'list': this.list.map((e) => e.toString()).toList(), - 'records': this.records.map((e) => e.toString()).toList(), - }; + List list; + List records; + + factory PageInfo.fromJson(Map json, D Function(dynamic d) fromJsonD) => _$PageInfoFromJson(json, fromJsonD); + + Map toJson(Object Function(D value) toJsonD) => _$PageInfoToJson(this, toJsonD); } diff --git a/lib/retrofit/data/store_info.dart b/lib/retrofit/data/store_info.dart index b453e079..f2dae3a2 100644 --- a/lib/retrofit/data/store_info.dart +++ b/lib/retrofit/data/store_info.dart @@ -101,7 +101,9 @@ class StoreInfo { ..expireTime = json['expireTime'] as String ..vipFee = json['vipFee'] as String ..memberSource = json['memberSource'] != null ? MemberSource.fromJson(json['memberSource']) : null - ..informationVOPageVO = json['informationVOPageVO'] != null ? PageInfo.fromJson(json['informationVOPageVO']) : null; + ..informationVOPageVO = json['informationVOPageVO'] != null ? PageInfo.fromJson(json['informationVOPageVO'], (value){ + return value; + }) : null; Map toJson() => { 'address': this.address, @@ -142,7 +144,7 @@ class StoreInfo { 'expireTime': this.expireTime, 'vipFee': this.vipFee, 'memberSource': this.memberSource.toJson(), - 'informationVOPageVO': this.informationVOPageVO.toJson(), + 'informationVOPageVO': this.informationVOPageVO, }; } diff --git a/lib/retrofit/data/vip_card.dart b/lib/retrofit/data/vip_card.dart index 850fea0e..4142de74 100644 --- a/lib/retrofit/data/vip_card.dart +++ b/lib/retrofit/data/vip_card.dart @@ -60,7 +60,7 @@ class VipCard { String tenantLogo; List storeList; - static VipCard fromMap(Map map) { + static VipCard fromJson(Map map) { if (map == null) return null; VipCard vipCardBean = VipCard(); vipCardBean.id = map['id']; diff --git a/lib/retrofit/retrofit_api.dart b/lib/retrofit/retrofit_api.dart index 3e52c8ac..234a8d1f 100644 --- a/lib/retrofit/retrofit_api.dart +++ b/lib/retrofit/retrofit_api.dart @@ -7,11 +7,37 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:huixiang/generated/l10n.dart'; +import 'package:huixiang/retrofit/data/activity.dart'; +import 'package:huixiang/retrofit/data/article.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; +import 'package:huixiang/retrofit/data/coupon.dart'; +import 'package:huixiang/retrofit/data/order_info.dart'; import 'package:huixiang/view_widget/login_tips.dart'; import 'package:retrofit/retrofit.dart'; import 'package:shared_preferences/shared_preferences.dart'; +import 'data/address.dart'; +import 'data/banner.dart'; +import 'data/brand.dart'; +import 'data/brand_data.dart'; +import 'data/exchange_order.dart'; +import 'data/goods.dart'; +import 'data/goods_category.dart'; +import 'data/logistics.dart'; +import 'data/member_comment_list.dart'; +import 'data/message.dart'; +import 'data/page.dart'; +import 'data/rank.dart'; +import 'data/sign_info.dart'; +import 'data/store.dart'; +import 'data/store_info.dart'; +import 'data/upload_result.dart'; +import 'data/user_bill.dart'; +import 'data/user_entity.dart'; +import 'data/user_info.dart'; +import 'data/vip_card.dart'; +import 'data/wx_pay.dart'; + part 'retrofit_api.g.dart'; const base_url = "https://pos.platform.lotus-wallet.com/app/"; ///正式 @@ -131,7 +157,7 @@ abstract class ApiService { ///文件上传 @POST("/file/upload") @MultiPart() - Future upload( + Future> upload( @Part(name: "file") File data, @Part(name: "folderId") int folderId); /// 周边搜索 @@ -150,19 +176,19 @@ abstract class ApiService { ///积分商城商品列表 @POST("/creditGoods/list") - Future creditGoods(@Body() Map param); + Future>> creditGoods(@Body() Map param); ///积分商城商品分類列表 @POST("/creditGoodsCategory/page") - Future goodsCategory(@Body() Map param); + Future>> goodsCategory(@Body() Map param); ///积分商城商品详情 @GET("/creditGoods/{id}") - Future creditGoodsById(@Path("id") String id); + Future> creditGoodsById(@Path("id") String id); ///查询用户信息 @GET("/member/info") - Future queryInfo(); + Future> queryInfo(); ///编辑用户信息 @POST("/member/editMemberInfo") @@ -170,7 +196,7 @@ abstract class ApiService { ///用户签到信息 @GET("/member/signInInfo") - Future signInInfo(); + Future> signInInfo(); ///用户签到 @GET("/member/signIn") @@ -178,15 +204,15 @@ abstract class ApiService { ///会员充值 @POST("/wallet/recharge") - Future recharge(@Body() Map param); + Future> recharge(@Body() Map param); ///领取优惠券 @GET("/coupon/receive?couponId={couponId}") Future receiveCoupon(@Path("couponId") String couponId); - ///订单列表 + ///兑换订单列表 @POST("/creditOrder/list") - Future creditOrderList(@Body() Map param); + Future>> creditOrderList(@Body() Map param); ///创建积分订单 @POST("/creditOrder/create") @@ -206,7 +232,7 @@ abstract class ApiService { ///查询用户所有的收货地址 @GET("/address/queryMemberAddress") - Future queryMemberAddress(); + Future>> queryMemberAddress(); ///更新收货地址 @POST("/address/update") @@ -214,23 +240,27 @@ abstract class ApiService { ///查询领券列表 @POST("/coupon/centreList") - Future queryCoupon(@Body() Map param); + Future>> queryCoupon(@Body() Map param); ///查询卡包列表 @POST("/coupon/packageList") - Future queryCard(@Body() Map param); + Future>> queryCard(@Body() Map param); ///门店地址列表 @POST("/store/list") - Future queryStore(@Body() Map param); + Future>> queryStore(@Body() Map param); ///分页查看资讯列表 @POST("/information/list") - Future informationList(@Body() Map param); + Future>> informationList(@Body() Map param); ///查看资讯详情 @GET("/information/{id}") - Future informationInfo(@Path("id") String id); + Future> informationInfo(@Path("id") String id); + + ///查看活动详情 + @GET("/information/{id}") + Future> activityInfo(@Path("id") String id); ///积分订单兑换到券包 @GET("/creditOrder/receive/{id}") @@ -238,7 +268,7 @@ abstract class ApiService { ///首页数据 @GET("/home/home") - Future queryHome(); + Future> queryHome(); ///查询店铺商家详情 @GET("/store/{id}") @@ -246,11 +276,11 @@ abstract class ApiService { ///分页查看资讯列表 @POST("/information/list") - Future queryArticle(@Body() Map param); + Future>> queryArticle(@Body() Map param); ///banner查询 @POST("/banner/page") - Future queryBanner(@Body() Map param); + Future>> queryBanner(@Body() Map param); ///品牌信息 @GET("/home/brand") @@ -262,19 +292,19 @@ abstract class ApiService { /// @POST("/member/listBill") - Future queryBillInfo(@Body() Map param); + Future>> queryBillInfo(@Body() Map param); ///会员等级列表 @GET("/member/rankList") - Future rankList(); + Future>> rankList(); ///订单列表 @POST("/order/list") - Future orderList(@Body() Map param); + Future>> orderList(@Body() Map param); ///订单详情 @GET("/order/orderDetail?id={id}") - Future orderDetail(@Path("id") String id); + Future> orderDetail(@Path("id") String id); ///继续付款 @POST("/order/continuePay") @@ -286,15 +316,15 @@ abstract class ApiService { ///会员卡列表 @POST("/member/vipList") - Future vipList(@Body() Map param); + Future>> vipList(@Body() Map param); ///会员卡详情 @POST("/member/vipDetail") - Future vipDetail(@Body() Map param); + Future> vipDetail(@Body() Map param); ///分页查询App消息列表 @POST("/app-msg/list") - Future msgList(@Body() Map param); + Future>> msgList(@Body() Map param); ///App消息详情 @GET("/app-msg/{id}") @@ -310,7 +340,7 @@ abstract class ApiService { ///查询评论列表 @POST("/memberComment/list") - Future memberCommentList(@Body() Map param); + Future>> memberCommentList(@Body() Map param); ///评论点赞 @GET("/memberComment/likes/{id}") @@ -322,6 +352,6 @@ abstract class ApiService { ///查询物流轨迹 @GET("/order/getShippingTrace/{shipperCode}/{logisticCode}") - Future shippingTrace(@Path("shipperCode") String shipperCode, @Path("logisticCode") String logisticCode); + Future> shippingTrace(@Path("shipperCode") String shipperCode, @Path("logisticCode") String logisticCode); } diff --git a/lib/retrofit/retrofit_api.g.dart b/lib/retrofit/retrofit_api.g.dart deleted file mode 100644 index 5cbe9cb6..00000000 --- a/lib/retrofit/retrofit_api.g.dart +++ /dev/null @@ -1,939 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'retrofit_api.dart'; - -// ************************************************************************** -// RetrofitGenerator -// ************************************************************************** - -class _ApiService implements ApiService { - _ApiService(this._dio, {this.baseUrl}) { - ArgumentError.checkNotNull(_dio, '_dio'); - baseUrl ??= 'https://pos.platform.lotus-wallet.com/app/'; - } - - final Dio _dio; - - String baseUrl; - - @override - Future upload(data, folderId) async { - ArgumentError.checkNotNull(data, 'data'); - ArgumentError.checkNotNull(folderId, 'folderId'); - const _extra = {}; - final queryParameters = {}; - final _data = FormData(); - _data.files.add(MapEntry( - 'file', - MultipartFile.fromFileSync(data.path, - filename: data.path.split(Platform.pathSeparator).last))); - if (folderId != null) { - _data.fields.add(MapEntry('folderId', folderId.toString())); - } - final _result = await _dio.request>('/file/upload', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future searchPoi(lat, lng, keywords, size, page) async { - ArgumentError.checkNotNull(lat, 'lat'); - ArgumentError.checkNotNull(lng, 'lng'); - ArgumentError.checkNotNull(keywords, 'keywords'); - ArgumentError.checkNotNull(size, 'size'); - ArgumentError.checkNotNull(page, 'page'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request( - 'https://restapi.amap.com/v3/place/around?key=542b46afa8e4b88fe1eb3c4d0ba0872f&location=$lat,$lng&keywords=$keywords&offset={size}&page={page}&extensions=all', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = _result.data; - return value; - } - - @override - Future memberLogin(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - '/auth/platform/memberLogin', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future sendVerify(mobile) async { - ArgumentError.checkNotNull(mobile, 'mobile'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/auth/sendVerify/$mobile', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future creditGoods(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - '/creditGoods/list', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future goodsCategory(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - '/creditGoodsCategory/page', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future creditGoodsById(id) async { - ArgumentError.checkNotNull(id, 'id'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>('/creditGoods/$id', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future queryInfo() async { - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>('/member/info', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future editInfo(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - '/member/editMemberInfo', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future signInInfo() async { - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/member/signInInfo', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future signIn() async { - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>('/member/signIn', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future recharge(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>('/wallet/recharge', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future receiveCoupon(couponId) async { - ArgumentError.checkNotNull(couponId, 'couponId'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/coupon/receive?couponId=$couponId', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future creditOrderList(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - '/creditOrder/list', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future creditOrder(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - '/creditOrder/create', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future addAddress(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>('/address/add', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future deleteAddress(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>('/address/delete', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future queryAddress(id) async { - ArgumentError.checkNotNull(id, 'id'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/address/detail/$id', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future queryMemberAddress() async { - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/address/queryMemberAddress', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future updateAddress(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>('/address/update', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future queryCoupon(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - '/coupon/centreList', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future queryCard(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - '/coupon/packageList', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future queryStore(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>('/store/list', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future informationList(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - '/information/list', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future informationInfo(id) async { - ArgumentError.checkNotNull(id, 'id'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>('/information/$id', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future creditOrderReceive(id) async { - ArgumentError.checkNotNull(id, 'id'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/creditOrder/receive/$id', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future queryHome() async { - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>('/home/home', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future queryStoreInfo(id) async { - ArgumentError.checkNotNull(id, 'id'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>('/store/$id', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future queryArticle(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - '/information/list', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future queryBanner(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>('/banner/page', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future queryHomeBrand() async { - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>('/home/brand', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future minLogin(storeId) async { - ArgumentError.checkNotNull(storeId, 'storeId'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/auth/mini/login/$storeId', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future queryBillInfo(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>('/member/listBill', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future rankList() async { - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>('/member/rankList', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future orderList(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>('/order/list', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future orderDetail(id) async { - ArgumentError.checkNotNull(id, 'id'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/order/orderDetail?id=$id', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future continuePay(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - '/order/continuePay', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future receiveToCard(id) async { - ArgumentError.checkNotNull(id, 'id'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/creditOrder/receive/$id', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future vipList(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>('/member/vipList', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future vipDetail(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - '/member/vipDetail', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future msgList(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>('/app-msg/list', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future queryMsg(id) async { - ArgumentError.checkNotNull(id, 'id'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>('/app-msg/$id', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future informationLikes(id) async { - ArgumentError.checkNotNull(id, 'id'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/information/likes/$id', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future memberComment(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>('/memberComment', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future memberCommentList(param) async { - ArgumentError.checkNotNull(param, 'param'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - _data.addAll(param ?? {}); - final _result = await _dio.request>( - '/memberComment/list', - queryParameters: queryParameters, - options: RequestOptions( - method: 'POST', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future commentLike(id) async { - ArgumentError.checkNotNull(id, 'id'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/memberComment/likes/$id', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future delComment(id) async { - ArgumentError.checkNotNull(id, 'id'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/memberComment/delete/$id', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } - - @override - Future shippingTrace(shipperCode, logisticCode) async { - ArgumentError.checkNotNull(shipperCode, 'shipperCode'); - ArgumentError.checkNotNull(logisticCode, 'logisticCode'); - const _extra = {}; - final queryParameters = {}; - final _data = {}; - final _result = await _dio.request>( - '/order/getShippingTrace/$shipperCode/$logisticCode', - queryParameters: queryParameters, - options: RequestOptions( - method: 'GET', - headers: {}, - extra: _extra, - baseUrl: baseUrl), - data: _data); - final value = BaseData.fromJson(_result.data); - return value; - } -} diff --git a/lib/union/store_details_page.dart b/lib/union/store_details_page.dart index edc54deb..ff7a4de5 100644 --- a/lib/union/store_details_page.dart +++ b/lib/union/store_details_page.dart @@ -3,6 +3,7 @@ import 'dart:ui'; import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; import 'package:flutter_html/flutter_html.dart'; import 'package:flutter_html/image_render.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -49,7 +50,6 @@ class _StoreDetailsPage extends State with WidgetsBindingObserver { ApiService apiService; RefreshController _refreshController; - bool isLiked = false; int commentTotal = 0; var commentTextController = TextEditingController(); var commentFocus = FocusNode(); @@ -97,19 +97,25 @@ class _StoreDetailsPage extends State Activity activity; Article article; List memberList = []; + GlobalKey commentKey = GlobalKey(); + ScrollController scrollController = ScrollController(); - queryHtml() async { - BaseData baseData = await apiService.informationInfo( - widget.arguments["activityId"] ?? widget.arguments["articleId"]); - - if (baseData != null && baseData.isSuccess) { - setState(() { - if (widget.arguments.containsKey("activityId")) { - activity = Activity.fromJson(baseData.data); - } else if (widget.arguments.containsKey("articleId")) { - article = Article.fromJson(baseData.data); - } - }); + queryHtml() async { //activityInfo + if (widget.arguments["activityId"] != null) { + BaseData baseData = await apiService.activityInfo(widget.arguments["activityId"]); + if (baseData != null && baseData.isSuccess) { + setState(() { + activity = baseData.data; + }); + } + } + if (widget.arguments["articleId"] != null) { + BaseData
baseData = await apiService.informationInfo(widget.arguments["articleId"]); + if (baseData != null && baseData.isSuccess) { + setState(() { + article = baseData.data; + }); + } } } @@ -177,7 +183,7 @@ class _StoreDetailsPage extends State //评论列表 queryMemberCommentList() async { - BaseData baseData = await apiService.memberCommentList({ + BaseData> baseData = await apiService.memberCommentList({ "pageNum": 1, "pageSize": 100, "relationalId": @@ -187,12 +193,10 @@ class _StoreDetailsPage extends State _refreshController.refreshFailed(); }); if (baseData != null && baseData.isSuccess) { - PageInfo pageInfo = PageInfo.fromJson(baseData.data); _refreshController.refreshCompleted(); setState(() { - commentTotal = pageInfo.size; - memberList = - pageInfo.list.map((e) => MemberCommentList.fromMap(e)).toList(); + commentTotal = baseData.data.size; + memberList = baseData.data.list; }); } } @@ -216,8 +220,7 @@ class _StoreDetailsPage extends State return; } - BaseData baseData = - await apiService.commentLike(id).catchError((onError) {}); + BaseData baseData = await apiService.commentLike(id).catchError((onError) {}); if (baseData != null && baseData.isSuccess) { setState(() { memberList.forEach((element) { @@ -233,31 +236,29 @@ class _StoreDetailsPage extends State }); }); } - /* else { - if (baseData.msg == "您已点过赞") { - setState(() { - memberList.forEach((element) { - if (element.id == id) { - element.liked = true; - } - }); - }); - } else SmartDialog.showToast(baseData.msg, alignment: Alignment.center); - }*/ } //给文章/活动点赞 queryInformationLikes() async { - BaseData baseData = await apiService - .informationLikes( - widget.arguments["activityId"] ?? widget.arguments["articleId"]) - .catchError((onError) {}); + BaseData baseData = await apiService.informationLikes( + widget.arguments["activityId"] ?? widget.arguments["articleId"]); if (baseData != null && baseData.isSuccess) { setState(() { - isLiked = true; - if (article != null) - article.likes += 1; - else if (activity != null) activity.likes += 1; + if (article != null) { + if (article.liked) { + article.likes -= 1; + } else { + article.likes += 1; + } + article.liked = !article.liked; + } else if (activity != null) { + if (activity.liked) { + activity.likes -= 1; + } else { + activity.likes += 1; + } + activity.liked = !activity.liked; + } }); } else { SmartDialog.showToast(baseData.msg, alignment: Alignment.center); @@ -321,6 +322,7 @@ class _StoreDetailsPage extends State parenId = "0"; }, child: SingleChildScrollView( + controller: scrollController, physics: BouncingScrollPhysics(), child: Column( children: [ @@ -460,7 +462,8 @@ class _StoreDetailsPage extends State mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ - Padding( + Container( + key: commentKey, padding: EdgeInsets.all(16), child: Row( children: [ @@ -489,27 +492,42 @@ class _StoreDetailsPage extends State ], ), ), - ListView.builder( - shrinkWrap: true, - physics: NeverScrollableScrollPhysics(), - itemCount: - memberList != null ? memberList.length : 0, - scrollDirection: Axis.vertical, - itemBuilder: (context, position) { - return Material( - color: Colors.white, - child: InkWell( - onTap: () { - showPressMenu( - memberList[position].createUser, - memberList[position]); - }, - child: commentItem(memberList[position], - position, memberList.length), + if (memberList != null && memberList.length > 0) + ListView.builder( + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + itemCount: + memberList != null ? memberList.length : 0, + scrollDirection: Axis.vertical, + itemBuilder: (context, position) { + return Material( + color: Colors.white, + child: InkWell( + onTap: () { + showPressMenu( + memberList[position].createUser, + memberList[position]); + }, + child: commentItem(memberList[position], + position, memberList.length), + ), + ); + }, + ) + else + Container( + width: double.infinity, + height: 80.h, + alignment: Alignment.center, + child: Text( + "暂无评论,快来评论吧", + style: TextStyle( + fontSize: 14.sp, + fontWeight: FontWeight.bold, + color: Color(0xFFA0A0A0), ), - ); - }, - ), + ), + ), ], ), ), @@ -622,7 +640,7 @@ class _StoreDetailsPage extends State hintText: hintText, hintStyle: TextStyle( fontSize: 14.sp, - color: Color(0xffCDCCCC), + color: Color(0xFF868686), ), ), ), @@ -631,9 +649,8 @@ class _StoreDetailsPage extends State ), ), ), - Padding( - padding: EdgeInsets.only(left: 20.w, right: 20.w), - child: GestureDetector( + if (isKeyBoardShow) + GestureDetector( onTap: () { var commentText = commentTextController.text; if (commentText == "") { @@ -641,35 +658,93 @@ class _StoreDetailsPage extends State } queryMemberComment(commentText); }, - child: Text( - S.of(context).fasong, - style: TextStyle( - fontSize: 16.sp, - fontWeight: FontWeight.bold, - color: Color(0XFF1A1A1A), + child: Container( + padding: EdgeInsets.symmetric(horizontal: 20.w), + child: Text( + S.of(context).fasong, + style: TextStyle( + fontSize: 16.sp, + fontWeight: FontWeight.bold, + color: Color(0XFF1A1A1A), + ), ), ), ), - ), - GestureDetector( - onTap: () { - if (isLiked) return; - queryInformationLikes(); - }, - child: Image.asset( - isLiked - ? "assets/image/icon_like.png" - : "assets/image/icon_like_h.png", - fit: BoxFit.fill, - width: 24, - height: 24, + if (!isKeyBoardShow) + InkWell( + onTap: toComment, + child: Container( + padding: EdgeInsets.only(left: 20, right: 10), + child: Image.asset( + "assets/image/icon_comment.png", + width: 24, + height: 24, + ), + ), + ), + if (!isKeyBoardShow) + LikeButton( + padding: EdgeInsets.all(10), + size: 24, + circleSize: 24, + circleColor: CircleColor( + start: Color(0xff00ddff), + end: Color(0xff0099cc), + ), + bubblesColor: BubblesColor( + dotPrimaryColor: Color(0xff33b5e5), + dotSecondaryColor: Color(0xff0099cc), + ), + bubblesSize: 24, + likeBuilder: (bool isLiked) { + return isLiked + ? Image.asset( + "assets/image/icon_like.png", + width: 24, + height: 24, + ) + : Image.asset( + "assets/image/icon_like_h.png", + width: 24, + height: 24, + ); + }, + isLiked: (activity != null + ? activity.liked + : article != null + ? article.liked + : false), + onTap: (isLiked) async { + await queryInformationLikes(); + return (activity != null + ? activity.liked + : article != null + ? article.liked + : false); + }, + // likeCount: memberList.likes, + countBuilder: (int count, bool isLiked, String text) { + return Text( + text, + style: TextStyle( + color: Color(0xFF1A1A1A), + fontSize: 12.sp, + ), + ); + }, ), - ) ], ), ); } + toComment() { + if (commentKey.currentContext == null) return; + RenderBox firstRenderBox = commentKey.currentContext.findRenderObject(); + Offset first = firstRenderBox.localToGlobal(Offset.zero); + scrollController.animateTo(first.dy + scrollController.offset - (kToolbarHeight + MediaQuery.of(context).padding.top), duration: Duration(milliseconds: 100), curve: Curves.easeIn); + } + VideoPlayerController videoPlayerController; ChewieController chewieAudioController; Chewie chewies; @@ -784,7 +859,6 @@ class _StoreDetailsPage extends State alignment: Alignment.topRight, child: LikeButton( padding: EdgeInsets.all(10), - size: 16, circleSize: 16, circleColor: CircleColor( start: Color(0xff00ddff), end: Color(0xff0099cc)), diff --git a/lib/union/union_details_page.dart b/lib/union/union_details_page.dart index fbd107dd..008e376b 100644 --- a/lib/union/union_details_page.dart +++ b/lib/union/union_details_page.dart @@ -63,8 +63,7 @@ class _UnionDetailsPage extends State { List activitys; queryStoreInfo() async { - BaseData baseData = await apiService - .queryStoreInfo(widget.arguments["id"]) + BaseData baseData = await apiService.queryStoreInfo(widget.arguments["id"]) .catchError((error) { refreshController.refreshFailed(); }); @@ -198,10 +197,8 @@ class _UnionDetailsPage extends State { ), ), Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - crossAxisAlignment: - CrossAxisAlignment.end, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.end, children: [ Expanded( child: Text( @@ -258,14 +255,14 @@ class _UnionDetailsPage extends State { width: 24.w, height: 24.h, ), - ) + ), ], ), ], ), ), flex: 1, - ) + ), ], ), ), diff --git a/lib/union/union_page.dart b/lib/union/union_page.dart index 3d784eef..2ab441d8 100644 --- a/lib/union/union_page.dart +++ b/lib/union/union_page.dart @@ -190,7 +190,7 @@ class _UnionPage extends State List storeList; queryStore(latitude, longitude, province, city, district, searchKey) async { - BaseData baseData = await apiService.queryStore({ + BaseData> baseData = await apiService.queryStore({ // "city": city, // "district": district, // "province": province, @@ -202,10 +202,7 @@ class _UnionPage extends State }); SmartDialog.dismiss(); if (baseData != null && baseData.isSuccess) { - storeList = (baseData.data as List) - .map((e) => Store.fromJson(e)) - .toList(); - // buildMarker(); + storeList = baseData.data; refreshController.refreshCompleted(); if (mounted) setState(() {}); } else { diff --git a/pubspec.lock b/pubspec.lock index b7f09328..b8f9df2e 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -35,7 +35,7 @@ packages: name: async url: "https://pub.flutter-io.cn" source: hosted - version: "2.5.0" + version: "2.6.1" barcode: dependency: transitive description: @@ -900,7 +900,7 @@ packages: name: test_api url: "https://pub.flutter-io.cn" source: hosted - version: "0.2.19" + version: "0.3.0" timing: dependency: transitive description: