From 4cc56b0622eaa8a273a7543f51e2624f7469a92c Mon Sep 17 00:00:00 2001 From: zhangmeng <494089941@qq.com> Date: Thu, 20 Jan 2022 10:18:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=8E=A5=E9=83=A8=E5=88=86=E5=95=86?= =?UTF-8?q?=E5=9F=8E=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/constants/market_api.dart | 49 +++++++++++++++++++ lib/constants/sars_api.dart | 3 ++ .../market/market_statistics_model.dart | 18 +++++++ .../market/market_statistics_model.g.dart | 15 ++++++ lib/models/user/user_info_model.dart | 6 ++- lib/models/user/user_info_model.g.dart | 4 +- lib/ui/community/community_func.dart | 41 ++++++---------- lib/ui/market/market_page.dart | 18 +++---- 8 files changed, 116 insertions(+), 38 deletions(-) create mode 100644 lib/constants/market_api.dart create mode 100644 lib/models/market/market_statistics_model.dart create mode 100644 lib/models/market/market_statistics_model.g.dart diff --git a/lib/constants/market_api.dart b/lib/constants/market_api.dart new file mode 100644 index 00000000..2caa9523 --- /dev/null +++ b/lib/constants/market_api.dart @@ -0,0 +1,49 @@ +part of 'sars_api.dart'; + +class _MarketApi { + _Collection collection = _Collection(); + _Good good = _Good(); + _Category category = _Category(); + _Home home = _Home(); + _Rotation rotation = _Rotation(); +} + +class _Collection { + ///我的收藏夹 + String get myCollection => '/app/user/shop/collection/myCollection'; + + ///添加/取消 收藏 + String get changeCollection => '/app/user/shop/collection/isCollection'; +} + +class _Good { + ///查询最大人气值的几个(热搜及爆品推荐【爆品推荐后期用购买量来判断】) + String get popular => '/app/user/shop/goods/findMaxPopularity'; + + ///查询所有的品牌 + String get brand => '/app/user/shop/brand/list'; + + ///查询综合推荐商品列表 + String get recommend => '查询综合推荐商品列表'; + + ///查询商品详情 + String get goodDetail => '/app/user/shop/goods/findGoodsDetail'; +} + +class _Category { + ///app商城根据父类主键id查询商品分类 + String get category => '/app/user/shop/category/findCategory'; + + ///查询所有的可显示的分类信息 + String get categoryInfo => '/app/user/shop/category/findAllCategoryInfo'; +} + +class _Home { + ///查询app商城首页顶部信息(sku总数,入驻品牌数,今日上新产品件数) + String get topInfo => '/app/user/shop/frontPage/topInfo'; +} + +class _Rotation { + ///查询app商城首页轮播图 + String get rotation => '/app/user/rotation/shop/list'; +} diff --git a/lib/constants/sars_api.dart b/lib/constants/sars_api.dart index a0b4539f..7a2609fd 100644 --- a/lib/constants/sars_api.dart +++ b/lib/constants/sars_api.dart @@ -1,5 +1,7 @@ part 'profile_api.dart'; +part 'market_api.dart'; + class SARSAPI { ///HOST static const String host = 'http://121.41.26.225:8006'; @@ -16,6 +18,7 @@ class SARSAPI { static const int networkTimeOut = 10000; static _City city = _City(); static _ProfileApi profile = _ProfileApi(); + static _MarketApi market = _MarketApi(); static _Login login = _Login(); static _User user = _User(); static _House house = _House(); diff --git a/lib/models/market/market_statistics_model.dart b/lib/models/market/market_statistics_model.dart new file mode 100644 index 00000000..73d97f4c --- /dev/null +++ b/lib/models/market/market_statistics_model.dart @@ -0,0 +1,18 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'market_statistics_model.g.dart'; + +@JsonSerializable() +class MarketStatisticsModel { + final int skuTotal; + final int settledBrandsNum; + final int newProductsTodayNum; + factory MarketStatisticsModel.fromJson(Map json) => + _$MarketStatisticsModelFromJson(json); + + const MarketStatisticsModel({ + required this.skuTotal, + required this.settledBrandsNum, + required this.newProductsTodayNum, + }); +} diff --git a/lib/models/market/market_statistics_model.g.dart b/lib/models/market/market_statistics_model.g.dart new file mode 100644 index 00000000..f235ea94 --- /dev/null +++ b/lib/models/market/market_statistics_model.g.dart @@ -0,0 +1,15 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'market_statistics_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +MarketStatisticsModel _$MarketStatisticsModelFromJson( + Map json) => + MarketStatisticsModel( + skuTotal: json['skuTotal'] as int, + settledBrandsNum: json['settledBrandsNum'] as int, + newProductsTodayNum: json['newProductsTodayNum'] as int, + ); diff --git a/lib/models/user/user_info_model.dart b/lib/models/user/user_info_model.dart index d82fd42e..f86038dd 100644 --- a/lib/models/user/user_info_model.dart +++ b/lib/models/user/user_info_model.dart @@ -15,6 +15,8 @@ class UserInfoModel { final String? nickName; final bool isExistPassword; final bool isPointsSignSetting; + final bool isSign; + final int? points; String get sexValue { if (sex == 1) return '男'; @@ -41,9 +43,11 @@ class UserInfoModel { this.name, this.idCard, required this.tel, - required this.isPointsSignSetting, this.sex, this.nickName, required this.isExistPassword, + required this.isPointsSignSetting, + required this.isSign, + this.points, }); } diff --git a/lib/models/user/user_info_model.g.dart b/lib/models/user/user_info_model.g.dart index b5ad1616..3b98b9df 100644 --- a/lib/models/user/user_info_model.g.dart +++ b/lib/models/user/user_info_model.g.dart @@ -13,8 +13,10 @@ UserInfoModel _$UserInfoModelFromJson(Map json) => name: json['name'] as String?, idCard: json['idCard'] as String?, tel: json['tel'] as String, - isPointsSignSetting: json['isPointsSignSetting'] as bool, sex: json['sex'] as int?, nickName: json['nickName'] as String?, isExistPassword: json['isExistPassword'] as bool, + isPointsSignSetting: json['isPointsSignSetting'] as bool, + isSign: json['isSign'] as bool, + points: json['points'] as int?, ); diff --git a/lib/ui/community/community_func.dart b/lib/ui/community/community_func.dart index 0e17540d..afd45b72 100644 --- a/lib/ui/community/community_func.dart +++ b/lib/ui/community/community_func.dart @@ -1,4 +1,5 @@ import 'package:aku_new_community/constants/api.dart'; +import 'package:aku_new_community/constants/sars_api.dart'; import 'package:aku_new_community/model/community/activity_item_model.dart'; import 'package:aku_new_community/model/community/board_model.dart'; import 'package:aku_new_community/model/community/community_topic_model.dart'; @@ -9,10 +10,12 @@ import 'package:aku_new_community/model/good/category_model.dart'; import 'package:aku_new_community/model/good/market_swiper_model.dart'; import 'package:aku_new_community/models/market/goods_classification.dart'; import 'package:aku_new_community/models/market/goods_popular_model.dart'; +import 'package:aku_new_community/models/market/market_statistics_model.dart'; import 'package:aku_new_community/models/market/order/goods_home_model.dart'; import 'package:aku_new_community/utils/network/base_list_model.dart'; import 'package:aku_new_community/utils/network/base_model.dart'; import 'package:aku_new_community/utils/network/net_util.dart'; +import 'package:bot_toast/bot_toast.dart'; class CommunityFunc { ///查询热门话题 @@ -55,35 +58,21 @@ class CommunityFunc { 'newsId': newsId, }, ); - if (model.msg == null) return ''; - return (model.msg as String).toString(); + if (model.success) return ''; + return model.msg; } - ///查询当天上架的商品数量 - static Future getNewProductsTodayNum() async { + ///查询顶部统计信息 + static Future getMarketStatistics() async { BaseModel model = await NetUtil().get( - API.market.newProductsTodayNum, + SARSAPI.market.home.topInfo, ); - if (model.data! == null) return '0'; - return (model.data as int).toString(); - } - - ///查询当前所有的品牌数量 - static Future getSettledBrandsNum() async { - BaseModel model = await NetUtil().get( - API.market.settledBrandsNum, - ); - if (model.data! == null) return '0'; - return (model.data as int).toString(); - } - - ///查询SKU总数 - static Future getSkuTotal() async { - BaseModel model = await NetUtil().get( - API.market.skuTotal, - ); - if (model.data! == null) return '0'; - return (model.data as int).toString(); + if (model.success) { + return MarketStatisticsModel.fromJson(model.data); + } else { + BotToast.showText(text: model.msg); + return null; + } } ///获取商品分类 @@ -148,7 +137,7 @@ class CommunityFunc { ///获取商城的轮播图 static Future> marketSwiper() async { BaseModel model = await NetUtil().get( - API.market.findRotationList, + SARSAPI.market.rotation.rotation, ); if (model.data!.length == 0) return []; return (model.data as List) diff --git a/lib/ui/market/market_page.dart b/lib/ui/market/market_page.dart index 27283089..7d093d7f 100644 --- a/lib/ui/market/market_page.dart +++ b/lib/ui/market/market_page.dart @@ -4,12 +4,14 @@ import 'dart:ui' as ui; import 'package:aku_new_community/base/base_style.dart'; import 'package:aku_new_community/constants/api.dart'; +import 'package:aku_new_community/constants/sars_api.dart'; import 'package:aku_new_community/gen/assets.gen.dart'; import 'package:aku_new_community/model/common/img_model.dart'; import 'package:aku_new_community/model/good/category_model.dart'; import 'package:aku_new_community/model/good/market_swiper_model.dart'; import 'package:aku_new_community/models/market/goods_classification.dart'; import 'package:aku_new_community/models/market/goods_popular_model.dart'; +import 'package:aku_new_community/models/market/market_statistics_model.dart'; import 'package:aku_new_community/models/market/order/goods_home_model.dart'; import 'package:aku_new_community/provider/app_provider.dart'; import 'package:aku_new_community/ui/community/community_func.dart'; @@ -58,9 +60,7 @@ class _MarketPageState extends State double bannerHeight = 354.w; double buttonsHeight = 334.w; double searchHeight = 74.w; - String _total = ''; - String _newTotal = ''; - String _brandTotal = ''; + MarketStatisticsModel? _statistics; double tabBarHeight = 40.w; late TabController _tabController; @@ -87,7 +87,7 @@ class _MarketPageState extends State Future updateMarketInfo() async { _pageNum = 1; BaseListModel baseListModel = await NetUtil().getList( - API.market.findRecommendGoodsList, + SARSAPI.market.good.recommend, params: { 'pageNum': _pageNum, 'size': _size, @@ -187,9 +187,7 @@ class _MarketPageState extends State await updateMarketInfo(); //_swiperModels = await CommunityFunc.swiper(); _marketSwiperModels = await CommunityFunc.marketSwiper(); - _newTotal = await CommunityFunc.getNewProductsTodayNum(); - _total = await CommunityFunc.getSkuTotal(); - _brandTotal = await CommunityFunc.getSettledBrandsNum(); + _statistics = await CommunityFunc.getMarketStatistics(); _categoryModels = await CommunityFunc.getCategory(); @@ -677,7 +675,7 @@ class _MarketPageState extends State ), 20.wb, Text( - '今日上新${_total}件', + '今日上新${_statistics?.newProductsTodayNum ?? 0}件', style: TextStyle( color: Color(0xFFD0564B), fontSize: 24.sp, @@ -707,11 +705,11 @@ class _MarketPageState extends State mainAxisAlignment: MainAxisAlignment.center, children: [ Text( - 'SKU总数:${_newTotal}', + 'SKU总数:${_statistics?.skuTotal ?? 0}', style: TextStyle(color: Colors.white, fontSize: 24.sp), ), Text( - '入驻品牌数:${_brandTotal}', + '入驻品牌数:${_statistics?.settledBrandsNum ?? 0}', style: TextStyle(color: Colors.white, fontSize: 24.sp), ) ],