From 843f1b99c3a66e57679eed1c98721428f95ce7dc Mon Sep 17 00:00:00 2001 From: laiiihz Date: Mon, 25 Jan 2021 19:53:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=8E=A5=E8=AE=BF=E5=AE=A2=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E5=88=97=E8=A1=A8=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit remove sh*t code again. --- lib/constants/api.dart | 3 + .../manager/visitor_list_item_model.dart | 44 ++++ .../visitor_access_page.dart | 16 +- .../visitor_pass_page.dart | 207 ------------------ .../widget/record_item.dart | 116 ---------- .../widget/record_list.dart | 51 ----- lib/ui/manager/visitor/visitor_list_item.dart | 86 ++++++++ .../visitor/visitor_passport_page.dart | 45 ++++ .../manager/visitor/visitor_record_page.dart | 10 +- .../manager/visitor/visitor_record_view.dart | 54 +++++ lib/widget/bee_back_button.dart | 4 +- 11 files changed, 245 insertions(+), 391 deletions(-) create mode 100644 lib/model/manager/visitor_list_item_model.dart delete mode 100644 lib/pages/visitor_access_page/visitor_pass_page.dart delete mode 100644 lib/pages/visitor_access_page/widget/record_item.dart delete mode 100644 lib/pages/visitor_access_page/widget/record_list.dart create mode 100644 lib/ui/manager/visitor/visitor_list_item.dart create mode 100644 lib/ui/manager/visitor/visitor_passport_page.dart create mode 100644 lib/ui/manager/visitor/visitor_record_view.dart diff --git a/lib/constants/api.dart b/lib/constants/api.dart index fcf0259c..3f11be11 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -76,6 +76,9 @@ class _Manager { ///访客通行:添加填写的访客信息 String get insertVisitorInfo => '/user/visitorAccess/insertVisitorInfo'; + ///访客通行:查询访客记录信息(包含条件搜索) + String get visitorAccessList => '/user/visitorAccess/list'; + ///物品出户:查询当前用户所有的物品出户信息 String get articleOut => '/user/articleOut/list'; diff --git a/lib/model/manager/visitor_list_item_model.dart b/lib/model/manager/visitor_list_item_model.dart new file mode 100644 index 00000000..385cd8c1 --- /dev/null +++ b/lib/model/manager/visitor_list_item_model.dart @@ -0,0 +1,44 @@ +import 'package:common_utils/common_utils.dart'; + +class VisitorListItemModel { + int id; + int accessCode; + int visitorStatus; + String name; + int isDrive; + String carNum; + String effectiveTime; + + DateTime get date => DateUtil.getDateTime(effectiveTime); + + VisitorListItemModel( + {this.id, + this.accessCode, + this.visitorStatus, + this.name, + this.isDrive, + this.carNum, + this.effectiveTime}); + + VisitorListItemModel.fromJson(Map json) { + id = json['id']; + accessCode = json['accessCode']; + visitorStatus = json['visitorStatus']; + name = json['name']; + isDrive = json['isDrive']; + carNum = json['carNum']; + effectiveTime = json['effectiveTime']; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['accessCode'] = this.accessCode; + data['visitorStatus'] = this.visitorStatus; + data['name'] = this.name; + data['isDrive'] = this.isDrive; + data['carNum'] = this.carNum; + data['effectiveTime'] = this.effectiveTime; + return data; + } +} diff --git a/lib/pages/visitor_access_page/visitor_access_page.dart b/lib/pages/visitor_access_page/visitor_access_page.dart index cf5b5ed1..7bacdf1a 100644 --- a/lib/pages/visitor_access_page/visitor_access_page.dart +++ b/lib/pages/visitor_access_page/visitor_access_page.dart @@ -2,6 +2,7 @@ import 'package:akuCommunity/pages/manager_func.dart'; import 'package:akuCommunity/ui/manager/visitor/visitor_record_page.dart'; import 'package:akuCommunity/provider/user_provider.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart'; +import 'package:akuCommunity/widget/picker/bee_date_picker.dart'; import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter_datetime_picker/flutter_datetime_picker.dart'; @@ -210,17 +211,10 @@ class _VisitorAccessPageState extends State { Widget _selectTime() { return InkWell( - onTap: () { - DatePicker.showDatePicker(context, - showTitleActions: true, - minTime: DateTime(2020, 1, 1), - maxTime: DateTime(2020, 12, 31), onChanged: (date) { - print('change $date in time zone ' + - date.timeZoneOffset.inHours.toString()); - }, onConfirm: (date) { - dateTime = date; - setState(() {}); - }, currentTime: DateTime.now(), locale: LocaleType.zh); + onTap: () async { + DateTime date = await BeeDatePicker.pick(DateTime.now()); + if (date != null) dateTime = date; + setState(() {}); }, child: Container( padding: EdgeInsets.only( diff --git a/lib/pages/visitor_access_page/visitor_pass_page.dart b/lib/pages/visitor_access_page/visitor_pass_page.dart deleted file mode 100644 index d7356930..00000000 --- a/lib/pages/visitor_access_page/visitor_pass_page.dart +++ /dev/null @@ -1,207 +0,0 @@ -import 'package:akuCommunity/widget/bee_scaffold.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:flutter_icons/flutter_icons.dart'; -import 'package:akuCommunity/utils/headers.dart'; -import 'package:akuCommunity/widget/dotted_line.dart'; - -class VisitorPassPage extends StatefulWidget { - VisitorPassPage({Key key}) : super(key: key); - - @override - _VisitorPassPageState createState() => _VisitorPassPageState(); -} - -class _VisitorPassPageState extends State { - Widget _header() { - return Container( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Text( - '宁波华茂悦峰', - style: TextStyle(fontSize: 40.sp, color: Color(0xffffffff)), - ), - SizedBox(height: 10.w), - Text( - '1幢-1单元-702室', - style: TextStyle(fontSize: 26.sp, color: Color(0xffffffff)), - ), - ], - ), - ); - } - - Widget _card() { - return Container( - decoration: BoxDecoration( - color: Color(0xffffffff), - borderRadius: BorderRadius.all(Radius.circular(16.w)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.2), - offset: Offset(1.1, 1.1), - blurRadius: 10.0), - ], - ), - margin: EdgeInsets.symmetric( - horizontal: 75.w, - vertical: 32.w, - ), - padding: EdgeInsets.only( - bottom: 16.w, - left: 32.w, - right: 21.w, - top: 25.w, - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( - children: [ - Icon( - AntDesign.contacts, - size: 40.sp, - color: Color(0xff999999), - ), - SizedBox(width: 10.w), - Text( - '马成泽先生', - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontWeight: FontWeight.w600, - fontSize: 36.sp, - color: Color(0xff333333)), - ), - ], - ), - Row( - children: [ - Icon( - AntDesign.car, - size: 40.sp, - color: Color(0xff999999), - ), - SizedBox(width: 10.w), - Text( - '无车辆信息', - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontWeight: FontWeight.w600, - fontSize: 36.sp, - color: Color(0xff333333), - ), - ), - ], - ), - ], - ), - SizedBox(height: 13.w), - Text( - '有限时间:2020年6月30日', - style: TextStyle( - fontSize: 26.sp, - color: Color(0xff999999), - ), - ), - SizedBox(height: 23.w), - DottedLine(color: Color(0xfff5f5f5)), - Container( - padding: EdgeInsets.only( - top: 30.w, - bottom: 38.w, - ), - height: 389.w, - alignment: Alignment.center, - child: Column( - children: [ - Text( - '020-598-230', - style: TextStyle( - fontWeight: FontWeight.w600, - fontSize: 36.sp, - color: Color(0xff333333), - ), - ), - SizedBox(height: 11.w), - Image.asset( - 'assets/example/QR_code.png', - height: 260.w, - width: 260.w, - color: Color(0xff333333), - fit: BoxFit.fill, - ), - ], - ), - ), - DottedLine(color: Color(0xfff5f5f5)), - SizedBox(height: 16.w), - Container( - alignment: Alignment.center, - child: Text( - '进入小区时,请出示此通行证给门岗', - style: TextStyle( - fontSize: 24.sp, - color: Color(0xff999999), - ), - ), - ), - ], - ), - ); - } - - Widget _bottomButton() { - return InkWell( - onTap: () {}, - child: Container( - alignment: Alignment.center, - height: 98.w, - width: 750.w, - padding: EdgeInsets.symmetric(vertical: 26.5.w), - color: Color(0xffffc40c), - child: Text( - '发送给访客', - style: TextStyle( - fontWeight: FontWeight.w600, - fontSize: 32.sp, - color: Color(0xff333333), - ), - ), - ), - ); - } - - @override - Widget build(BuildContext context) { - return BeeScaffold( - title: '访客通行证', - body: Container( - color: Color(0xff333333), - child: Stack( - children: [ - Column( - children: [ - SizedBox(height: 192.w - kToolbarHeight), - _header(), - SizedBox(height: 32.w), - _card(), - ], - ), - Positioned( - bottom: 0, - child: _bottomButton(), - ), - ], - ), - ), - ); - } -} diff --git a/lib/pages/visitor_access_page/widget/record_item.dart b/lib/pages/visitor_access_page/widget/record_item.dart deleted file mode 100644 index fa753cc7..00000000 --- a/lib/pages/visitor_access_page/widget/record_item.dart +++ /dev/null @@ -1,116 +0,0 @@ -import 'package:akuCommunity/pages/visitor_access_page/visitor_pass_page.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:flutter_icons/flutter_icons.dart'; -import 'package:akuCommunity/utils/headers.dart'; - -class RecordItem extends StatefulWidget { - final bool isQRCode; - RecordItem({Key key, this.isQRCode}) : super(key: key); - - @override - _RecordItemState createState() => _RecordItemState(); -} - -class _RecordItemState extends State - with AutomaticKeepAliveClientMixin { - @override - bool get wantKeepAlive => true; - void recordPass() { - VisitorPassPage().to; - } - - Positioned _positionedAgain() { - return Positioned( - right: 0, - top: 16.w, - child: InkWell( - onTap: () {}, - child: Container( - alignment: Alignment.center, - decoration: BoxDecoration( - color: Color(0xffffffff), - borderRadius: BorderRadius.all(Radius.circular(36.w)), - border: Border.all(color: Color(0xffffc500), width: 3.w)), - padding: EdgeInsets.symmetric( - vertical: 11.w, - horizontal: 32.w, - ), - child: Text( - '再次邀请', - style: TextStyle( - fontWeight: FontWeight.w600, - fontSize: 24.sp, - color: Color(0xff333333), - ), - ), - ), - ), - ); - } - - Positioned _positionedQRcode() { - return Positioned( - right: 0, - top: 16.w, - child: Row( - children: [ - Icon( - AntDesign.qrcode, - size: 40.sp, - color: Color(0xff999999), - ), - SizedBox(height: 18.w), - Icon( - AntDesign.right, - size: 40.sp, - color: Color(0xff999999), - ), - ], - ), - ); - } - - @override - Widget build(BuildContext context) { - super.build(context); - return InkWell( - onTap: recordPass, - child: Container( - padding: EdgeInsets.only( - top: 32.w, - left: 32.w, - right: 32.w, - ), - color: Colors.white, - child: Stack( - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - '马成泽(浙A88888)', - style: TextStyle( - fontSize: 32.sp, - color: Color(0xff333333), - ), - ), - SizedBox(height: 8.w), - Text( - '2020年6月30日', - style: TextStyle( - fontSize: 24.sp, - color: Color(0xff999999), - ), - ), - SizedBox(height: 33.w), - Divider() - ], - ), - widget.isQRCode ? _positionedQRcode() : _positionedAgain(), - ], - ), - ), - ); - } -} diff --git a/lib/pages/visitor_access_page/widget/record_list.dart b/lib/pages/visitor_access_page/widget/record_list.dart deleted file mode 100644 index 662ddc62..00000000 --- a/lib/pages/visitor_access_page/widget/record_list.dart +++ /dev/null @@ -1,51 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:pull_to_refresh/pull_to_refresh.dart'; -import 'record_item.dart'; - -class RecordList extends StatefulWidget { - RecordList({Key key}) : super(key: key); - - @override - _RecordListState createState() => _RecordListState(); -} - -class _RecordListState extends State - with AutomaticKeepAliveClientMixin { - @override - bool get wantKeepAlive => true; - RefreshController _refreshController = - RefreshController(initialRefresh: false); - - void _onRefresh() async { - await Future.delayed(Duration(milliseconds: 1500)); - _refreshController.refreshCompleted(); - } - - void _onLoading() async { - if (mounted) setState(() {}); - _refreshController.loadComplete(); - } - - @override - Widget build(BuildContext context) { - super.build(context); - return Container( - color: Colors.white, - child: SmartRefresher( - controller: _refreshController, - header: WaterDropHeader(), - footer: ClassicFooter(), - onRefresh: _onRefresh, - onLoading: _onLoading, - enablePullUp: true, - child: ListView.builder( - itemBuilder: (context, index) => RecordItem( - isQRCode: (index % 2 == 0) ? false : true, - ), - itemCount: 6, - ), - ), - ); - } -} diff --git a/lib/ui/manager/visitor/visitor_list_item.dart b/lib/ui/manager/visitor/visitor_list_item.dart new file mode 100644 index 00000000..7fd51d46 --- /dev/null +++ b/lib/ui/manager/visitor/visitor_list_item.dart @@ -0,0 +1,86 @@ +import 'package:akuCommunity/model/manager/visitor_list_item_model.dart'; +import 'package:akuCommunity/ui/manager/visitor/visitor_passport_page.dart'; +import 'package:akuCommunity/utils/headers.dart'; +import 'package:common_utils/common_utils.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:velocity_x/velocity_x.dart'; + +class VisitorListItem extends StatefulWidget { + final VisitorListItemModel model; + VisitorListItem({Key key, @required this.model}) : super(key: key); + + @override + _VisitorListItemState createState() => _VisitorListItemState(); +} + +class _VisitorListItemState extends State { + String get _name { + StringBuffer buffer = StringBuffer(); + var name = widget.model.name; + buffer.write(name); + var car = widget.model.carNum; + if (TextUtil.isEmpty(car)) return buffer.toString(); + buffer.write('($car)'); + return buffer.toString(); + } + + bool get outDate => DateTime.now().isAfter(widget.model.date); + _buildSuffix() { + if (outDate) + return MaterialButton( + onPressed: () {}, + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 12.w), + height: 56.w, + child: '再次邀约'.text.size(24.sp).bold.make(), + shape: StadiumBorder( + side: BorderSide( + color: Color(0xFFFFC500), + width: 3.w, + ), + ), + ); + return Row( + mainAxisSize: MainAxisSize.min, + children: [ + Icon(Icons.qr_code_rounded), + 16.wb, + Icon(CupertinoIcons.chevron_forward), + ], + ); + } + + @override + Widget build(BuildContext context) { + return MaterialButton( + onPressed: () { + if (!outDate) { + VisitorPassportPage().to(); + } + }, + color: Colors.white, + elevation: 0, + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + height: 152.w, + child: Row( + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + _name.text.size(32.sp).bold.make(), + 8.hb, + DateUtil.formatDate(widget.model.date, format: 'yyyy-MM-dd') + .text + .size(24.sp) + .color(Color(0xFF999999)) + .make(), + ], + ), + Spacer(), + _buildSuffix(), + ], + ), + ); + } +} diff --git a/lib/ui/manager/visitor/visitor_passport_page.dart b/lib/ui/manager/visitor/visitor_passport_page.dart new file mode 100644 index 00000000..eb341381 --- /dev/null +++ b/lib/ui/manager/visitor/visitor_passport_page.dart @@ -0,0 +1,45 @@ +import 'package:akuCommunity/utils/headers.dart'; +import 'package:akuCommunity/widget/bee_back_button.dart'; +import 'package:flutter/material.dart'; +import 'package:velocity_x/velocity_x.dart'; + +class VisitorPassportPage extends StatefulWidget { + VisitorPassportPage({Key key}) : super(key: key); + + @override + _VisitorPassportPageState createState() => _VisitorPassportPageState(); +} + +class _VisitorPassportPageState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Color(0xFF333333), + appBar: AppBar( + leading: BeeBackButton(color: Colors.white), + backgroundColor: Color(0xFF333333), + elevation: 0, + centerTitle: true, + title: '访客通行证'.text.white.make(), + ), + body: ListView( + children: [ + 64.hb, + '宁波华茂悦峰'.text.size(40.sp).white.bold.make().centered(), + '1幢-1单元-702室'.text.size(30.sp).white.make().centered(), + 32.hb, + Container( + height: 600.w, + width: 600.w, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(16.w), + ), + // child: , + //TODO 二维码显示 + ).centered(), + ], + ), + ); + } +} diff --git a/lib/ui/manager/visitor/visitor_record_page.dart b/lib/ui/manager/visitor/visitor_record_page.dart index e5018c09..6fa08b4f 100644 --- a/lib/ui/manager/visitor/visitor_record_page.dart +++ b/lib/ui/manager/visitor/visitor_record_page.dart @@ -1,8 +1,8 @@ +import 'package:akuCommunity/ui/manager/visitor/visitor_record_view.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart'; import 'package:akuCommunity/widget/tab_bar/bee_tab_bar.dart'; import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; -import '../../../pages/visitor_access_page/widget/record_list.dart'; class VisitorRecordPage extends StatefulWidget { VisitorRecordPage({Key key}) : super(key: key); @@ -38,10 +38,10 @@ class _VisitorRecordPageState extends State ), body: TabBarView( controller: _controller, - children: List.generate( - _tabs.length, - (index) => RecordList(), - ), + children: [ + VisitorRecordView(type: 1), + VisitorRecordView(type: 2), + ], ), ); } diff --git a/lib/ui/manager/visitor/visitor_record_view.dart b/lib/ui/manager/visitor/visitor_record_view.dart new file mode 100644 index 00000000..0c926683 --- /dev/null +++ b/lib/ui/manager/visitor/visitor_record_view.dart @@ -0,0 +1,54 @@ +import 'package:akuCommunity/constants/api.dart'; +import 'package:akuCommunity/utils/headers.dart'; +import 'package:akuCommunity/model/manager/visitor_list_item_model.dart'; +import 'package:akuCommunity/pages/things_page/widget/bee_list_view.dart'; +import 'package:akuCommunity/ui/manager/visitor/visitor_list_item.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; + +class VisitorRecordView extends StatefulWidget { + ///访客状态(1.未到,2.已到) + final int type; + VisitorRecordView({Key key, @required this.type}) : super(key: key); + + @override + _VisitorRecordViewState createState() => _VisitorRecordViewState(); +} + +class _VisitorRecordViewState extends State { + EasyRefreshController _refreshController = EasyRefreshController(); + + + @override + void dispose() { + _refreshController?.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return BeeListView( + controller: _refreshController, + path: API.manager.visitorAccessList, + extraParams: {'visitorStatus': widget.type}, + convert: (model) { + return model.tableList + .map((e) => VisitorListItemModel.fromJson(e)) + .toList(); + }, + builder: (items) { + return ListView.separated( + separatorBuilder: (_, __) => Divider( + indent: 32.w, + endIndent: 32.w, + height: 1.w, + ), + itemBuilder: (context, index) { + return VisitorListItem(model: items[index]); + }, + itemCount: items.length, + ); + }, + ); + } +} diff --git a/lib/widget/bee_back_button.dart b/lib/widget/bee_back_button.dart index 505932ab..4a0a4b12 100644 --- a/lib/widget/bee_back_button.dart +++ b/lib/widget/bee_back_button.dart @@ -3,7 +3,8 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; class BeeBackButton extends StatelessWidget { - const BeeBackButton({Key key}) : super(key: key); + final Color color; + const BeeBackButton({Key key, this.color = Colors.black}) : super(key: key); @override Widget build(BuildContext context) { @@ -12,6 +13,7 @@ class BeeBackButton extends StatelessWidget { onPressed: () => Get.back(), icon: Icon( CupertinoIcons.chevron_back, + color: color, ), ) : SizedBox();