对接部分商城接口

pull/1/head
张萌 3 years ago
parent f6feb831db
commit 4cc56b0622

@ -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 {
///appid
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';
}

@ -1,5 +1,7 @@
part 'profile_api.dart'; part 'profile_api.dart';
part 'market_api.dart';
class SARSAPI { class SARSAPI {
///HOST ///HOST
static const String host = 'http://121.41.26.225:8006'; static const String host = 'http://121.41.26.225:8006';
@ -16,6 +18,7 @@ class SARSAPI {
static const int networkTimeOut = 10000; static const int networkTimeOut = 10000;
static _City city = _City(); static _City city = _City();
static _ProfileApi profile = _ProfileApi(); static _ProfileApi profile = _ProfileApi();
static _MarketApi market = _MarketApi();
static _Login login = _Login(); static _Login login = _Login();
static _User user = _User(); static _User user = _User();
static _House house = _House(); static _House house = _House();

@ -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<String, dynamic> json) =>
_$MarketStatisticsModelFromJson(json);
const MarketStatisticsModel({
required this.skuTotal,
required this.settledBrandsNum,
required this.newProductsTodayNum,
});
}

@ -0,0 +1,15 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'market_statistics_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
MarketStatisticsModel _$MarketStatisticsModelFromJson(
Map<String, dynamic> json) =>
MarketStatisticsModel(
skuTotal: json['skuTotal'] as int,
settledBrandsNum: json['settledBrandsNum'] as int,
newProductsTodayNum: json['newProductsTodayNum'] as int,
);

@ -15,6 +15,8 @@ class UserInfoModel {
final String? nickName; final String? nickName;
final bool isExistPassword; final bool isExistPassword;
final bool isPointsSignSetting; final bool isPointsSignSetting;
final bool isSign;
final int? points;
String get sexValue { String get sexValue {
if (sex == 1) return ''; if (sex == 1) return '';
@ -41,9 +43,11 @@ class UserInfoModel {
this.name, this.name,
this.idCard, this.idCard,
required this.tel, required this.tel,
required this.isPointsSignSetting,
this.sex, this.sex,
this.nickName, this.nickName,
required this.isExistPassword, required this.isExistPassword,
required this.isPointsSignSetting,
required this.isSign,
this.points,
}); });
} }

@ -13,8 +13,10 @@ UserInfoModel _$UserInfoModelFromJson(Map<String, dynamic> json) =>
name: json['name'] as String?, name: json['name'] as String?,
idCard: json['idCard'] as String?, idCard: json['idCard'] as String?,
tel: json['tel'] as String, tel: json['tel'] as String,
isPointsSignSetting: json['isPointsSignSetting'] as bool,
sex: json['sex'] as int?, sex: json['sex'] as int?,
nickName: json['nickName'] as String?, nickName: json['nickName'] as String?,
isExistPassword: json['isExistPassword'] as bool, isExistPassword: json['isExistPassword'] as bool,
isPointsSignSetting: json['isPointsSignSetting'] as bool,
isSign: json['isSign'] as bool,
points: json['points'] as int?,
); );

@ -1,4 +1,5 @@
import 'package:aku_new_community/constants/api.dart'; 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/activity_item_model.dart';
import 'package:aku_new_community/model/community/board_model.dart'; import 'package:aku_new_community/model/community/board_model.dart';
import 'package:aku_new_community/model/community/community_topic_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/model/good/market_swiper_model.dart';
import 'package:aku_new_community/models/market/goods_classification.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/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/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_list_model.dart';
import 'package:aku_new_community/utils/network/base_model.dart'; import 'package:aku_new_community/utils/network/base_model.dart';
import 'package:aku_new_community/utils/network/net_util.dart'; import 'package:aku_new_community/utils/network/net_util.dart';
import 'package:bot_toast/bot_toast.dart';
class CommunityFunc { class CommunityFunc {
/// ///
@ -55,35 +58,21 @@ class CommunityFunc {
'newsId': newsId, 'newsId': newsId,
}, },
); );
if (model.msg == null) return ''; if (model.success) return '';
return (model.msg as String).toString(); return model.msg;
} }
/// ///
static Future<String> getNewProductsTodayNum() async { static Future<MarketStatisticsModel?> getMarketStatistics() async {
BaseModel model = await NetUtil().get( BaseModel model = await NetUtil().get(
API.market.newProductsTodayNum, SARSAPI.market.home.topInfo,
); );
if (model.data! == null) return '0'; if (model.success) {
return (model.data as int).toString(); return MarketStatisticsModel.fromJson(model.data);
} else {
BotToast.showText(text: model.msg);
return null;
} }
///
static Future<String> 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<String> getSkuTotal() async {
BaseModel model = await NetUtil().get(
API.market.skuTotal,
);
if (model.data! == null) return '0';
return (model.data as int).toString();
} }
/// ///
@ -148,7 +137,7 @@ class CommunityFunc {
/// ///
static Future<List<MarketSwiperModel>> marketSwiper() async { static Future<List<MarketSwiperModel>> marketSwiper() async {
BaseModel model = await NetUtil().get( BaseModel model = await NetUtil().get(
API.market.findRotationList, SARSAPI.market.rotation.rotation,
); );
if (model.data!.length == 0) return []; if (model.data!.length == 0) return [];
return (model.data as List) return (model.data as List)

@ -4,12 +4,14 @@ import 'dart:ui' as ui;
import 'package:aku_new_community/base/base_style.dart'; import 'package:aku_new_community/base/base_style.dart';
import 'package:aku_new_community/constants/api.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/gen/assets.gen.dart';
import 'package:aku_new_community/model/common/img_model.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/category_model.dart';
import 'package:aku_new_community/model/good/market_swiper_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_classification.dart';
import 'package:aku_new_community/models/market/goods_popular_model.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/models/market/order/goods_home_model.dart';
import 'package:aku_new_community/provider/app_provider.dart'; import 'package:aku_new_community/provider/app_provider.dart';
import 'package:aku_new_community/ui/community/community_func.dart'; import 'package:aku_new_community/ui/community/community_func.dart';
@ -58,9 +60,7 @@ class _MarketPageState extends State<MarketPage>
double bannerHeight = 354.w; double bannerHeight = 354.w;
double buttonsHeight = 334.w; double buttonsHeight = 334.w;
double searchHeight = 74.w; double searchHeight = 74.w;
String _total = ''; MarketStatisticsModel? _statistics;
String _newTotal = '';
String _brandTotal = '';
double tabBarHeight = 40.w; double tabBarHeight = 40.w;
late TabController _tabController; late TabController _tabController;
@ -87,7 +87,7 @@ class _MarketPageState extends State<MarketPage>
Future updateMarketInfo() async { Future updateMarketInfo() async {
_pageNum = 1; _pageNum = 1;
BaseListModel baseListModel = await NetUtil().getList( BaseListModel baseListModel = await NetUtil().getList(
API.market.findRecommendGoodsList, SARSAPI.market.good.recommend,
params: { params: {
'pageNum': _pageNum, 'pageNum': _pageNum,
'size': _size, 'size': _size,
@ -187,9 +187,7 @@ class _MarketPageState extends State<MarketPage>
await updateMarketInfo(); await updateMarketInfo();
//_swiperModels = await CommunityFunc.swiper(); //_swiperModels = await CommunityFunc.swiper();
_marketSwiperModels = await CommunityFunc.marketSwiper(); _marketSwiperModels = await CommunityFunc.marketSwiper();
_newTotal = await CommunityFunc.getNewProductsTodayNum(); _statistics = await CommunityFunc.getMarketStatistics();
_total = await CommunityFunc.getSkuTotal();
_brandTotal = await CommunityFunc.getSettledBrandsNum();
_categoryModels = await CommunityFunc.getCategory(); _categoryModels = await CommunityFunc.getCategory();
@ -677,7 +675,7 @@ class _MarketPageState extends State<MarketPage>
), ),
20.wb, 20.wb,
Text( Text(
'今日上新${_total}', '今日上新${_statistics?.newProductsTodayNum ?? 0}',
style: TextStyle( style: TextStyle(
color: Color(0xFFD0564B), color: Color(0xFFD0564B),
fontSize: 24.sp, fontSize: 24.sp,
@ -707,11 +705,11 @@ class _MarketPageState extends State<MarketPage>
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Text( Text(
'SKU总数${_newTotal}', 'SKU总数${_statistics?.skuTotal ?? 0}',
style: TextStyle(color: Colors.white, fontSize: 24.sp), style: TextStyle(color: Colors.white, fontSize: 24.sp),
), ),
Text( Text(
'入驻品牌数:${_brandTotal}', '入驻品牌数:${_statistics?.settledBrandsNum ?? 0}',
style: TextStyle(color: Colors.white, fontSize: 24.sp), style: TextStyle(color: Colors.white, fontSize: 24.sp),
) )
], ],

Loading…
Cancel
Save