From 29b762e56ac2c48e3b4539a57a30530e4efcb131 Mon Sep 17 00:00:00 2001 From: zhangmeng <494089941@qq.com> Date: Fri, 14 May 2021 15:36:04 +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=E6=9F=A5=E8=AF=A2=E6=89=80?= =?UTF-8?q?=E6=9C=89=E7=9A=84=E5=BF=AB=E9=80=92=E5=8C=85=E8=A3=B9=EF=BC=88?= =?UTF-8?q?=E5=8C=85=E5=90=AB=E6=9D=A1=E4=BB=B6=E6=90=9C=E7=B4=A2=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/constants/api.dart | 3 ++ .../express_package_list_model.dart | 37 ++++++++++++++ .../express_package_list_model.g.dart | 22 ++++++++ .../express_package_card.dart | 35 +++++++++---- .../express_package_view.dart | 50 ++++++++++++++++--- 5 files changed, 129 insertions(+), 18 deletions(-) create mode 100644 lib/models/express_package/express_package_list_model.dart create mode 100644 lib/models/express_package/express_package_list_model.g.dart diff --git a/lib/constants/api.dart b/lib/constants/api.dart index 12ea24c2..cd2d7d6b 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -215,6 +215,9 @@ class _Manager { ///生活缴费:缴费记录 String get paymentRecord => '/user/dailyPayment/paymentRecord'; + + ///app 包裹代收:查询所有的快递包裹(包含条件搜索) + String get expressPackageList => '/user/packageCollection/list'; } class _Community { diff --git a/lib/models/express_package/express_package_list_model.dart b/lib/models/express_package/express_package_list_model.dart new file mode 100644 index 00000000..2d414ea5 --- /dev/null +++ b/lib/models/express_package/express_package_list_model.dart @@ -0,0 +1,37 @@ +import 'package:equatable/equatable.dart'; +import 'package:flustars/flustars.dart'; +import 'package:json_annotation/json_annotation.dart'; + +part 'express_package_list_model.g.dart'; + +@JsonSerializable() +class ExpressPackageListModel extends Equatable { + final int id; + final String code; + final String addresseeName; + final String addresseeTel; + final String address; + final int status; + final String? receiveDate; + final String createDate; + final String placePosition; + ExpressPackageListModel({ + required this.id, + required this.code, + required this.addresseeName, + required this.addresseeTel, + required this.address, + required this.status, + required this.receiveDate, + required this.createDate, + required this.placePosition, + }); + factory ExpressPackageListModel.fromJson(Map json) => + _$ExpressPackageListModelFromJson(json); + String get createDateString => DateUtil.formatDateStr(this.createDate, + format: 'yyyy-MM-dd HH:mm'); + + @override + List get props => throw UnimplementedError(); + +} diff --git a/lib/models/express_package/express_package_list_model.g.dart b/lib/models/express_package/express_package_list_model.g.dart new file mode 100644 index 00000000..430c0e09 --- /dev/null +++ b/lib/models/express_package/express_package_list_model.g.dart @@ -0,0 +1,22 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'express_package_list_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +ExpressPackageListModel _$ExpressPackageListModelFromJson( + Map json) { + return ExpressPackageListModel( + id: json['id'] as int, + code: json['code'] as String, + addresseeName: json['addresseeName'] as String, + addresseeTel: json['addresseeTel'] as String, + address: json['address'] as String, + status: json['status'] as int, + receiveDate: json['receiveDate'] as String?, + createDate: json['createDate'] as String, + placePosition: json['placePosition'] as String, + ); +} diff --git a/lib/pages/express_packages/express_package_card.dart b/lib/pages/express_packages/express_package_card.dart index 702f4f36..cba4cfec 100644 --- a/lib/pages/express_packages/express_package_card.dart +++ b/lib/pages/express_packages/express_package_card.dart @@ -1,3 +1,4 @@ +import 'package:aku_community/models/express_package/express_package_list_model.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -10,7 +11,9 @@ import 'package:aku_community/widget/bee_divider.dart'; class ExpressPackageCard extends StatefulWidget { final int index; - ExpressPackageCard({Key? key, required this.index}) : super(key: key); + final ExpressPackageListModel model; + ExpressPackageCard({Key? key, required this.index, required this.model}) + : super(key: key); @override _ExpressPackageCardState createState() => _ExpressPackageCardState(); @@ -30,7 +33,7 @@ class _ExpressPackageCardState extends State { Row( children: [ Text( - '3号柜7号箱', + widget.model.placePosition, style: TextStyle( fontSize: 32.sp, fontWeight: FontWeight.bold, @@ -51,17 +54,25 @@ class _ExpressPackageCardState extends State { 24.w.heightBox, ...[ _rowTile(R.ASSETS_ICONS_APPOINTMENT_ADDRESS_PNG, '包裹单号', - '131891726735'.text.size(24.sp).color(ktextSubColor).make()), - _rowTile(R.ASSETS_ICONS_APPOINTMENT_ADDRESS_PNG, '收件人', - '小蒋'.text.size(24.sp).color(ktextSubColor).make()), - _rowTile(R.ASSETS_ICONS_APPOINTMENT_ADDRESS_PNG, '联系方式', - '131891726735'.text.size(24.sp).color(ktextSubColor).make()), - _rowTile(R.ASSETS_ICONS_APPOINTMENT_ADDRESS_PNG, '配送公司', - '顺丰速递'.text.size(24.sp).color(ktextSubColor).make()), + widget.model.code.text.size(24.sp).color(ktextSubColor).make()), + _rowTile( + R.ASSETS_ICONS_APPOINTMENT_ADDRESS_PNG, + '收件人', + widget.model.addresseeName.text + .size(24.sp) + .color(ktextSubColor) + .make()), + _rowTile( + R.ASSETS_ICONS_APPOINTMENT_ADDRESS_PNG, + '联系方式', + widget.model.addresseeTel.text + .size(24.sp) + .color(ktextSubColor) + .make()), _rowTile( R.ASSETS_ICONS_APPOINTMENT_DATE_PNG, '送达时间', - '2020-04-13 11:21' + widget.model.createDateString .text .size(24.sp) .color(ktextSubColor) @@ -86,7 +97,9 @@ class _ExpressPackageCardState extends State { hoverElevation: 0, disabledElevation: 0, highlightElevation: 0, - onPressed: () {}, + onPressed: () { + + }, child: '确认领取' .text .size(24.sp) diff --git a/lib/pages/express_packages/express_package_view.dart b/lib/pages/express_packages/express_package_view.dart index 5fe827ca..b1b2cfee 100644 --- a/lib/pages/express_packages/express_package_view.dart +++ b/lib/pages/express_packages/express_package_view.dart @@ -1,8 +1,11 @@ +import 'package:aku_community/constants/api.dart'; +import 'package:aku_community/models/express_package/express_package_list_model.dart'; +import 'package:aku_community/pages/express_packages/express_package_card.dart'; +import 'package:aku_community/pages/things_page/widget/bee_list_view.dart'; import 'package:flutter/material.dart'; - +import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; - -import 'package:aku_community/pages/express_packages/express_package_card.dart'; +import 'package:velocity_x/velocity_x.dart'; class ExpressPackageView extends StatefulWidget { final int index; @@ -13,11 +16,44 @@ class ExpressPackageView extends StatefulWidget { } class _ExpressPackageViewState extends State { + late EasyRefreshController _refreshController; + @override + void initState() { + super.initState(); + _refreshController = EasyRefreshController(); + } + + @override + void dispose() { + _refreshController.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { - return ListView( - padding: EdgeInsets.symmetric(vertical: 16.w, horizontal: 32.w), - children: [ExpressPackageCard(index: widget.index)], - ); + // return ListView( + // padding: EdgeInsets.symmetric(vertical: 16.w, horizontal: 32.w), + // children: [ExpressPackageCard(index: widget.index)], + // ); + return BeeListView( + path: API.manager.expressPackageList, + controller: _refreshController, + convert: (models) { + return models.tableList + ?.map((e) => ExpressPackageListModel.fromJson(e)) + .toList() ?? + []; + }, + builder: (items) { + return ListView.separated( + padding: EdgeInsets.symmetric(vertical: 16.w, horizontal: 32.w), + itemBuilder: (context, index) { + return ExpressPackageCard(index: widget.index,model: items[index],); + }, + separatorBuilder: (_, __) { + return 16.w.heightBox; + }, + itemCount: items.length); + }); } }