From 0ebddab6a0525d9cc02b7818d1f9f361c9961434 Mon Sep 17 00:00:00 2001 From: zhangmeng <494089941@qq.com> Date: Fri, 14 May 2021 16:33:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=8E=A5=EF=BC=9Aapp=20=E5=8C=85?= =?UTF-8?q?=E8=A3=B9=E4=BB=A3=E6=94=B6=EF=BC=9A=E7=A1=AE=E8=AE=A4=E9=A2=86?= =?UTF-8?q?=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/constants/api.dart | 3 ++ .../express_package_card.dart | 36 ++++++++++++++++--- .../express_package_view.dart | 8 ++++- 3 files changed, 41 insertions(+), 6 deletions(-) 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;