瀏覽代碼

1、商品列表添加占位图

2、搜索结果页两列修改不能加载更多的bug
3、搜索结果请求参数去掉size,根据返回列表长度判断是否加载完毕
tags/0.0.14+4
PH2 3 年之前
父節點
當前提交
dc6288e674
共有 4 個檔案被更改,包括 45 行新增13 行删除
  1. +20
    -7
      lib/widgets/home/home_goods/home_goods_item.dart
  2. +19
    -0
      lib/widgets/home/home_goods/home_goods_item_single.dart
  3. +4
    -4
      lib/widgets/search_result/goods_list/bloc/search_result_goods_list_bloc.dart
  4. +2
    -2
      lib/widgets/search_result/goods_list/bloc/search_result_goods_list_repository.dart

+ 20
- 7
lib/widgets/home/home_goods/home_goods_item.dart 查看文件

@@ -46,13 +46,14 @@ class HomeGoodsItem extends StatelessWidget {
Container(
width: double.infinity,
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')),
);
}

/// 商品占位骨架视图
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,
);
}
}

+ 19
- 0
lib/widgets/home/home_goods/home_goods_item_single.dart 查看文件

@@ -59,6 +59,12 @@ class HomeGoodsItemSingle extends StatelessWidget {
child: CachedNetworkImage(
imageUrl: goods.goodImage,
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,
);
}

}

+ 4
- 4
lib/widgets/search_result/goods_list/bloc/search_result_goods_list_bloc.dart 查看文件

@@ -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();
if (!EmptyUtil.isEmpty(result)) {
yield SearchResultGoodsListLoadSuccessState();
@@ -93,7 +93,7 @@ class SearchResultGoodsListBloc extends Bloc<SearchResultGoodsListEvent, SearchR
if (!EmptyUtil.isEmpty(result)) {
yield SearchResultGoodsListChangeStyleState(result['style'], result['datas']);
} else {
// yield SearchResultGoodsListNoMoreDataState();
yield SearchResultGoodsListErrorState();
}
}



+ 2
- 2
lib/widgets/search_result/goods_list/bloc/search_result_goods_list_repository.dart 查看文件

@@ -88,7 +88,7 @@ class SearchResultGoodsListRepository {
var result = await NetUtil.post(url,
params: {
'keyword': keyword,
'size': MAX.toString(),
// 'size': MAX.toString(),
'p': _currentPage.toString(),
},
method: NetMethod.POST);
@@ -96,7 +96,7 @@ class SearchResultGoodsListRepository {
// search_list
if (NetUtil.isSuccess(result) && !EmptyUtil.isEmpty(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA])) {
List data = List.from(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA]['search_list']);
if (data.length >= MAX) {
if ((data?.length ?? 0) > 0) {
_hasNomore = true;
++_currentPage;
} else {


Loading…
取消
儲存