修复数量显示错误的问题

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

@ -21,6 +21,7 @@ class BorrowGoodsPage extends StatefulWidget {
class _BorrowGoodsPageState extends State<BorrowGoodsPage> { class _BorrowGoodsPageState extends State<BorrowGoodsPage> {
EasyRefreshController _easyRefreshController; EasyRefreshController _easyRefreshController;
List<int> _receiveIds = [];
List<int> _submitIds = []; List<int> _submitIds = [];
List<int> _counts = []; List<int> _counts = [];
@override @override
@ -52,16 +53,18 @@ class _BorrowGoodsPageState extends State<BorrowGoodsPage> {
path: API.manager.articleBorrow, path: API.manager.articleBorrow,
controller: _easyRefreshController, controller: _easyRefreshController,
convert: (models) { convert: (models) {
_counts.addAll(List.filled(models.tableList.length, 0));
return models.tableList return models.tableList
.map((e) => ArticleBorrowModel.fromJson(e)) .map((e) => ArticleBorrowModel.fromJson(e))
.toList(); .toList();
}, },
builder: (items) { builder: (items) {
if (_counts.isEmpty) {
_counts = List.filled(items.length, 0);
}
return ListView.separated( return ListView.separated(
padding: EdgeInsets.symmetric(vertical: 16.w, horizontal: 32.w), padding: EdgeInsets.symmetric(vertical: 16.w, horizontal: 32.w),
itemBuilder: (context, index) { itemBuilder: (context, index) {
return _goodsCard(items[index], _counts[index]); return _goodsCard(items[index], index);
}, },
separatorBuilder: (_, __) { separatorBuilder: (_, __) {
return 16.w.heightBox; return 16.w.heightBox;
@ -71,7 +74,11 @@ class _BorrowGoodsPageState extends State<BorrowGoodsPage> {
bottomNavi: Row( bottomNavi: Row(
children: [ children: [
'已选择 '.richText.color(ktextPrimary).size(24.sp).withTextSpanChildren([ '已选择 '.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(), ''.textSpan.size(24.sp).color(ktextPrimary).make(),
]).make(), ]).make(),
Spacer(), Spacer(),
@ -144,7 +151,7 @@ class _BorrowGoodsPageState extends State<BorrowGoodsPage> {
_counts[index] == 0 _counts[index] == 0
? SizedBox() ? SizedBox()
: Column( : Column(
crossAxisAlignment: CrossAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end,
children: [ children: [
Container( Container(
alignment: Alignment.center, alignment: Alignment.center,
@ -173,15 +180,17 @@ class _BorrowGoodsPageState extends State<BorrowGoodsPage> {
.withRounded(value: 6.w) .withRounded(value: 6.w)
.make() .make()
.onInkTap(() async { .onInkTap(() async {
List<int> ids; _receiveIds.forEach((element) {
_submitIds.remove(element);
});
await Get.to(() => BorrowGoodsDetailPage( await Get.to(() => BorrowGoodsDetailPage(
articleId: model.id, articleId: model.id,
)).then((value) { )).then((value) {
ids = value; _receiveIds = value;
_counts[index] = ids.length;
_submitIds.addAll(ids);
setState(() {});
}); });
_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/constants/api.dart';
import 'package:akuCommunity/model/common/img_model.dart'; import 'package:akuCommunity/model/common/img_model.dart';
import 'package:akuCommunity/model/manager/article_borrow_detail_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/base_model.dart';
import 'package:akuCommunity/utils/network/net_util.dart'; import 'package:akuCommunity/utils/network/net_util.dart';
import 'package:akuCommunity/widget/animated/animated_scale.dart'; import 'package:akuCommunity/widget/animated/animated_scale.dart';
@ -18,7 +16,9 @@ import 'package:akuCommunity/const/resource.dart';
class BorrowGoodsDetailPage extends StatefulWidget { class BorrowGoodsDetailPage extends StatefulWidget {
final int articleId; 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 @override
_BorrowGoodsDetailPageState createState() => _BorrowGoodsDetailPageState(); _BorrowGoodsDetailPageState createState() => _BorrowGoodsDetailPageState();
@ -34,6 +34,9 @@ class _BorrowGoodsDetailPageState extends State<BorrowGoodsDetailPage> {
void initState() { void initState() {
super.initState(); super.initState();
_easyRefreshController = EasyRefreshController(); _easyRefreshController = EasyRefreshController();
if (widget.receiveIds != null && widget.receiveIds.isNotEmpty) {
_selectItems = widget.receiveIds;
}
} }
@override @override

Loading…
Cancel
Save