@@ -46,13 +46,14 @@ class HomeGoodsItem extends StatelessWidget { | |||||
Container( | Container( | ||||
width: double.infinity, | width: double.infinity, | ||||
margin: EdgeInsets.only(right: 0), | margin: EdgeInsets.only(right: 0), | ||||
child: ClipRRect( | |||||
borderRadius: BorderRadius.only( | |||||
topLeft: Radius.circular(7.5), | |||||
topRight: Radius.circular(7.5)), | |||||
child: CachedNetworkImage( | |||||
imageUrl: goods?.goodImage ?? '', | |||||
fit: BoxFit.fitWidth, | |||||
child: ClipRRect(borderRadius: BorderRadius.only(topLeft: Radius.circular(7.5), topRight: Radius.circular(7.5)), | |||||
child: CachedNetworkImage(imageUrl: goods?.goodImage ?? '', fit: BoxFit.fitWidth, | |||||
placeholder: (context, url) { | |||||
return _createShimmerWidget(width: double.infinity); | |||||
}, | |||||
errorWidget: (context, url, error,) { | |||||
return _createShimmerWidget(width: double.infinity); | |||||
}, | |||||
), | ), | ||||
), | ), | ||||
), | ), | ||||
@@ -352,4 +353,16 @@ class HomeGoodsItem extends StatelessWidget { | |||||
style: TextStyle(fontSize: 11, color: HexColor.fromHex('#999999')), | style: TextStyle(fontSize: 11, color: HexColor.fromHex('#999999')), | ||||
); | ); | ||||
} | } | ||||
/// 商品占位骨架视图 | |||||
Widget _createShimmerWidget({double width, double height}) { | |||||
//修改后返回默认图片 | |||||
return Image.asset( | |||||
'assets/images/occupation_map/occupation_map.png', | |||||
package: 'zhiying_base_widget', | |||||
width: width, | |||||
height: height, | |||||
fit: BoxFit.fill, | |||||
); | |||||
} | |||||
} | } |
@@ -59,6 +59,12 @@ class HomeGoodsItemSingle extends StatelessWidget { | |||||
child: CachedNetworkImage( | child: CachedNetworkImage( | ||||
imageUrl: goods.goodImage, | imageUrl: goods.goodImage, | ||||
fit: BoxFit.fitHeight, | fit: BoxFit.fitHeight, | ||||
placeholder: (context, url) { | |||||
return _createShimmerWidget(width: double.infinity, height: double.infinity); | |||||
}, | |||||
errorWidget: (BuildContext context, String url, dynamic error) { | |||||
return _createShimmerWidget(width: double.infinity, height: double.infinity); | |||||
}, | |||||
), | ), | ||||
), | ), | ||||
), | ), | ||||
@@ -427,4 +433,17 @@ class HomeGoodsItemSingle extends StatelessWidget { | |||||
], | ], | ||||
); | ); | ||||
} | } | ||||
/// 商品占位骨架视图 | |||||
Widget _createShimmerWidget({double width, double height}) { | |||||
//修改后返回默认图片 | |||||
return Image.asset( | |||||
'assets/images/occupation_map/occupation_map.png', | |||||
package: 'zhiying_base_widget', | |||||
width: width, | |||||
height: height, | |||||
fit: BoxFit.fill, | |||||
); | |||||
} | |||||
} | } |
@@ -35,8 +35,8 @@ class SearchResultGoodsListBloc extends Bloc<SearchResultGoodsListEvent, SearchR | |||||
} | } | ||||
/// 上拉更多 | /// 上拉更多 | ||||
if (event is SearchResultGoodsListOnLoadEvent && state is SearchResultGoodsListLoadedState) { | |||||
yield* _mapOnLoadToState(event, state); | |||||
if (event is SearchResultGoodsListOnLoadEvent && (state is SearchResultGoodsListLoadedState || state is SearchResultGoodsListChangeStyleState)) { | |||||
yield* _mapOnLoadToState(event); | |||||
} | } | ||||
/// 修改样式 | /// 修改样式 | ||||
@@ -77,7 +77,7 @@ class SearchResultGoodsListBloc extends Bloc<SearchResultGoodsListEvent, SearchR | |||||
} | } | ||||
/// 上拉更多 | /// 上拉更多 | ||||
Stream<SearchResultGoodsListState> _mapOnLoadToState(SearchResultGoodsListOnLoadEvent event, SearchResultGoodsListLoadedState state) async* { | |||||
Stream<SearchResultGoodsListState> _mapOnLoadToState(SearchResultGoodsListOnLoadEvent event) async* { | |||||
var result = await repository.fetchLoadData(); | var result = await repository.fetchLoadData(); | ||||
if (!EmptyUtil.isEmpty(result)) { | if (!EmptyUtil.isEmpty(result)) { | ||||
yield SearchResultGoodsListLoadSuccessState(); | yield SearchResultGoodsListLoadSuccessState(); | ||||
@@ -93,7 +93,7 @@ class SearchResultGoodsListBloc extends Bloc<SearchResultGoodsListEvent, SearchR | |||||
if (!EmptyUtil.isEmpty(result)) { | if (!EmptyUtil.isEmpty(result)) { | ||||
yield SearchResultGoodsListChangeStyleState(result['style'], result['datas']); | yield SearchResultGoodsListChangeStyleState(result['style'], result['datas']); | ||||
} else { | } else { | ||||
// yield SearchResultGoodsListNoMoreDataState(); | |||||
yield SearchResultGoodsListErrorState(); | |||||
} | } | ||||
} | } | ||||
@@ -88,7 +88,7 @@ class SearchResultGoodsListRepository { | |||||
var result = await NetUtil.post(url, | var result = await NetUtil.post(url, | ||||
params: { | params: { | ||||
'keyword': keyword, | 'keyword': keyword, | ||||
'size': MAX.toString(), | |||||
// 'size': MAX.toString(), | |||||
'p': _currentPage.toString(), | 'p': _currentPage.toString(), | ||||
}, | }, | ||||
method: NetMethod.POST); | method: NetMethod.POST); | ||||
@@ -96,7 +96,7 @@ class SearchResultGoodsListRepository { | |||||
// search_list | // search_list | ||||
if (NetUtil.isSuccess(result) && !EmptyUtil.isEmpty(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA])) { | if (NetUtil.isSuccess(result) && !EmptyUtil.isEmpty(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA])) { | ||||
List data = List.from(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA]['search_list']); | List data = List.from(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA]['search_list']); | ||||
if (data.length >= MAX) { | |||||
if ((data?.length ?? 0) > 0) { | |||||
_hasNomore = true; | _hasNomore = true; | ||||
++_currentPage; | ++_currentPage; | ||||
} else { | } else { | ||||