diff --git a/lib/constants/api.dart b/lib/constants/api.dart index cd2d7d6b..fbb2c97d 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -218,6 +218,9 @@ class _Manager { ///app 包裹代收:查询所有的快递包裹(包含条件搜索) String get expressPackageList => '/user/packageCollection/list'; + + ///app 包裹代收:确认领取 + String get packageConfirm => '/user/packageCollection/confirmCollection'; } class _Community { diff --git a/lib/pages/express_packages/express_package_card.dart b/lib/pages/express_packages/express_package_card.dart index cba4cfec..048240cc 100644 --- a/lib/pages/express_packages/express_package_card.dart +++ b/lib/pages/express_packages/express_package_card.dart @@ -1,4 +1,8 @@ +import 'package:aku_community/constants/api.dart'; import 'package:aku_community/models/express_package/express_package_list_model.dart'; +import 'package:aku_community/utils/network/base_model.dart'; +import 'package:aku_community/utils/network/net_util.dart'; +import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -12,7 +16,12 @@ import 'package:aku_community/widget/bee_divider.dart'; class ExpressPackageCard extends StatefulWidget { final int index; final ExpressPackageListModel model; - ExpressPackageCard({Key? key, required this.index, required this.model}) + final VoidCallback callFresh; + ExpressPackageCard( + {Key? key, + required this.index, + required this.model, + required this.callFresh}) : super(key: key); @override @@ -72,8 +81,7 @@ class _ExpressPackageCardState extends State { _rowTile( R.ASSETS_ICONS_APPOINTMENT_DATE_PNG, '送达时间', - widget.model.createDateString - .text + widget.model.createDateString.text .size(24.sp) .color(ktextSubColor) .make()), @@ -97,8 +105,13 @@ class _ExpressPackageCardState extends State { hoverElevation: 0, disabledElevation: 0, highlightElevation: 0, - onPressed: () { - + onPressed: () async { + bool confirm = false; + confirm = + await _cofirmReceivePackage(widget.model.id); + if (confirm) { + widget.callFresh(); + } }, child: '确认领取' .text @@ -115,6 +128,19 @@ class _ExpressPackageCardState extends State { ); } + Future _cofirmReceivePackage(int id) async { + BaseModel baseModel = await NetUtil().get( + API.manager.packageConfirm, + params: { + "packageCollectionId": id, + }, + ); + if (baseModel.status ?? false) { + BotToast.showText(text: baseModel.message ?? '未知错误'); + } + return baseModel.status; + } + Widget _rowTile(String assetPath, String titile, Widget content) { return Row( children: [ diff --git a/lib/pages/express_packages/express_package_view.dart b/lib/pages/express_packages/express_package_view.dart index b1b2cfee..d7dd26b6 100644 --- a/lib/pages/express_packages/express_package_view.dart +++ b/lib/pages/express_packages/express_package_view.dart @@ -48,7 +48,13 @@ class _ExpressPackageViewState extends State { return ListView.separated( padding: EdgeInsets.symmetric(vertical: 16.w, horizontal: 32.w), itemBuilder: (context, index) { - return ExpressPackageCard(index: widget.index,model: items[index],); + return ExpressPackageCard( + index: widget.index, + model: items[index], + callFresh: () { + _refreshController.callRefresh(); + }, + ); }, separatorBuilder: (_, __) { return 16.w.heightBox;