修复数量显示错误的问题

hmxc
张萌 4 years ago
parent 67b2d07db9
commit 62434ed083

@ -21,6 +21,7 @@ class BorrowGoodsPage extends StatefulWidget {
class _BorrowGoodsPageState extends State<BorrowGoodsPage> {
EasyRefreshController _easyRefreshController;
List<int> _receiveIds = [];
List<int> _submitIds = [];
List<int> _counts = [];
@override
@ -52,16 +53,18 @@ class _BorrowGoodsPageState extends State<BorrowGoodsPage> {
path: API.manager.articleBorrow,
controller: _easyRefreshController,
convert: (models) {
_counts.addAll(List.filled(models.tableList.length, 0));
return models.tableList
.map((e) => ArticleBorrowModel.fromJson(e))
.toList();
},
builder: (items) {
if (_counts.isEmpty) {
_counts = List.filled(items.length, 0);
}
return ListView.separated(
padding: EdgeInsets.symmetric(vertical: 16.w, horizontal: 32.w),
itemBuilder: (context, index) {
return _goodsCard(items[index], _counts[index]);
return _goodsCard(items[index], index);
},
separatorBuilder: (_, __) {
return 16.w.heightBox;
@ -71,7 +74,11 @@ class _BorrowGoodsPageState extends State<BorrowGoodsPage> {
bottomNavi: Row(
children: [
'已选择 '.richText.color(ktextPrimary).size(24.sp).withTextSpanChildren([
'0'.textSpan.size(32.sp).color(ktextPrimary).make(),
'${_submitIds.length}'
.textSpan
.size(32.sp)
.color(ktextPrimary)
.make(),
''.textSpan.size(24.sp).color(ktextPrimary).make(),
]).make(),
Spacer(),
@ -173,15 +180,17 @@ class _BorrowGoodsPageState extends State<BorrowGoodsPage> {
.withRounded(value: 6.w)
.make()
.onInkTap(() async {
List<int> ids;
_receiveIds.forEach((element) {
_submitIds.remove(element);
});
await Get.to(() => BorrowGoodsDetailPage(
articleId: model.id,
)).then((value) {
ids = value;
_counts[index] = ids.length;
_submitIds.addAll(ids);
setState(() {});
_receiveIds = value;
});
_counts[index] = _receiveIds.length;
_submitIds.addAll(_receiveIds);
setState(() {});
});
}
}

@ -2,8 +2,6 @@ import 'package:akuCommunity/base/base_style.dart';
import 'package:akuCommunity/constants/api.dart';
import 'package:akuCommunity/model/common/img_model.dart';
import 'package:akuCommunity/model/manager/article_borrow_detail_model.dart';
import 'package:akuCommunity/pages/goods_deto_page/deto_create_page/widget/common_radio.dart';
import 'package:akuCommunity/pages/things_page/widget/bee_list_view.dart';
import 'package:akuCommunity/utils/network/base_model.dart';
import 'package:akuCommunity/utils/network/net_util.dart';
import 'package:akuCommunity/widget/animated/animated_scale.dart';
@ -18,7 +16,9 @@ import 'package:akuCommunity/const/resource.dart';
class BorrowGoodsDetailPage extends StatefulWidget {
final int articleId;
BorrowGoodsDetailPage({Key key, this.articleId}) : super(key: key);
final List<int> receiveIds;
BorrowGoodsDetailPage({Key key, this.articleId, this.receiveIds})
: super(key: key);
@override
_BorrowGoodsDetailPageState createState() => _BorrowGoodsDetailPageState();
@ -34,6 +34,9 @@ class _BorrowGoodsDetailPageState extends State<BorrowGoodsDetailPage> {
void initState() {
super.initState();
_easyRefreshController = EasyRefreshController();
if (widget.receiveIds != null && widget.receiveIds.isNotEmpty) {
_selectItems = widget.receiveIds;
}
}
@override

Loading…
Cancel
Save