fix market detail request fail

hmxc
小赖 4 years ago
parent a49c394648
commit c61d03371c

@ -43,6 +43,25 @@ class GoodsDetailModel extends Equatable {
@override @override
List<Object?> get props => throw UnimplementedError(); List<Object?> get props => throw UnimplementedError();
factory GoodsDetailModel.fail() => GoodsDetailModel(
0,
'',
'',
0.0,
0.0,
'',
0,
'',
'',
[],
0,
'',
'',
'',
[],
0,
);
factory GoodsDetailModel.fromJson(Map<String, dynamic> json) => factory GoodsDetailModel.fromJson(Map<String, dynamic> json) =>
_$GoodsDetailModelFromJson(json); _$GoodsDetailModelFromJson(json);
} }

@ -72,14 +72,14 @@ class _GoodsDetailPageState extends State<GoodsDetailPage> {
firstRefresh: true, firstRefresh: true,
header: MaterialHeader(), header: MaterialHeader(),
onRefresh: () async { onRefresh: () async {
BaseModel baseModel = await NetUtil().get(API.market.goodsDetail, BaseModel baseModel = await NetUtil().get(
params: { API.market.goodsDetail,
"goodsId": widget.id, params: {"goodsId": widget.id},
"id": userProvider.userDetailModel!.id );
}); if (baseModel.status == true && baseModel.data != null) {
if (baseModel.status ?? false) {
_goodsModel = GoodsDetailModel.fromJson(baseModel.data); _goodsModel = GoodsDetailModel.fromJson(baseModel.data);
} else { } else {
_goodsModel = GoodsDetailModel.fail();
BotToast.showText(text: baseModel.message ?? '未知错误'); BotToast.showText(text: baseModel.message ?? '未知错误');
} }
baseModel = await NetUtil().get(API.market.hotTop); baseModel = await NetUtil().get(API.market.hotTop);

@ -2,7 +2,7 @@ class BaseModel {
int? code; int? code;
String? message; String? message;
bool? status; bool? status;
dynamic data; dynamic? data;
BaseModel({ BaseModel({
this.code, this.code,
this.message, this.message,

Loading…
Cancel
Save