fix market detail request fail

hmxc
小赖 4 years ago
parent a49c394648
commit c61d03371c

@ -43,6 +43,25 @@ class GoodsDetailModel extends Equatable {
@override
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) =>
_$GoodsDetailModelFromJson(json);
}

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

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

Loading…
Cancel
Save