diff --git a/lib/constants/api.dart b/lib/constants/api.dart index c4b036ca..86d9534b 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -124,6 +124,12 @@ class _Manager { ///物品出户:提交物品出户信息 String get articleOutSubmit => '/user/articleOut/submit'; + + ///物品出户:查询二维码信息 + String get getQRcode => '/user/articleOut/getQRCode'; + + ///物品出户:app批量删除物品出户信息 + String get articleOutDelete => '/user/articleOut/falseDelete'; } class _Community { diff --git a/lib/model/manager/article_QR_code_model.dart b/lib/model/manager/article_QR_code_model.dart new file mode 100644 index 00000000..33421476 --- /dev/null +++ b/lib/model/manager/article_QR_code_model.dart @@ -0,0 +1,51 @@ +class ArticleQRModel { + AppArticleOutQRCodeVo appArticleOutQRCodeVo; + String message; + bool status; + + ArticleQRModel({this.appArticleOutQRCodeVo, this.message, this.status}); + + ArticleQRModel.fromJson(Map json) { + appArticleOutQRCodeVo = json['appArticleOutQRCodeVo'] != null + ? new AppArticleOutQRCodeVo.fromJson(json['appArticleOutQRCodeVo']) + : null; + message = json['message']; + status = json['status']; + } + + Map toJson() { + final Map data = new Map(); + if (this.appArticleOutQRCodeVo != null) { + data['appArticleOutQRCodeVo'] = this.appArticleOutQRCodeVo.toJson(); + } + data['message'] = this.message; + data['status'] = this.status; + return data; + } +} + +class AppArticleOutQRCodeVo { + int id; + int residentId; + String residentName; + String effectiveTime; + + AppArticleOutQRCodeVo( + {this.id, this.residentId, this.residentName, this.effectiveTime}); + + AppArticleOutQRCodeVo.fromJson(Map json) { + id = json['id']; + residentId = json['residentId']; + residentName = json['residentName']; + effectiveTime = json['effectiveTime']; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['residentId'] = this.residentId; + data['residentName'] = this.residentName; + data['effectiveTime'] = this.effectiveTime; + return data; + } +} diff --git a/lib/pages/goods_deto_page/deto_code_page/deto_code_page.dart b/lib/pages/goods_deto_page/deto_code_page/deto_code_page.dart index 87cb3a67..2dc408c9 100644 --- a/lib/pages/goods_deto_page/deto_code_page/deto_code_page.dart +++ b/lib/pages/goods_deto_page/deto_code_page/deto_code_page.dart @@ -1,9 +1,14 @@ // Flutter imports: +import 'package:akuCommunity/base/base_style.dart'; +import 'package:akuCommunity/model/manager/article_QR_code_model.dart'; +import 'package:akuCommunity/provider/user_provider.dart'; +import 'package:akuCommunity/utils/bee_parse.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; // Package imports: import 'package:flutter_icons/flutter_icons.dart'; +import 'package:provider/provider.dart'; import 'package:qr_flutter/qr_flutter.dart'; // Project imports: @@ -12,21 +17,23 @@ import 'package:akuCommunity/widget/bee_scaffold.dart'; import 'package:akuCommunity/widget/dotted_line.dart'; class DetoCodePage extends StatelessWidget { - const DetoCodePage({Key key}) : super(key: key); + final int id; + final ArticleQRModel model; + const DetoCodePage({Key key, this.id, this.model}) : super(key: key); - Widget _header() { + Widget _header(String estateName) { return Container( child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( - '宁波华茂悦峰', + kEstateName, style: TextStyle(fontSize: 40.sp, color: Color(0xffffffff)), ), SizedBox(height: 10.w), Text( - '1幢-1单元-702室', + estateName, style: TextStyle(fontSize: 26.sp, color: Color(0xffffffff)), ), ], @@ -34,7 +41,7 @@ class DetoCodePage extends StatelessWidget { ); } - Widget _card() { + Widget _card(String name, String effectiveTime) { return Container( decoration: BoxDecoration( color: Color(0xffffffff), @@ -72,7 +79,7 @@ class DetoCodePage extends StatelessWidget { ), SizedBox(width: 10.w), Text( - '马成泽先生', + '$name先生', maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle( @@ -86,7 +93,7 @@ class DetoCodePage extends StatelessWidget { ), SizedBox(height: 13.w), Text( - '有限时间:2020年6月30日', + '有效时间:$effectiveTime', style: TextStyle( fontSize: 26.sp, color: Color(0xff999999), @@ -103,18 +110,18 @@ class DetoCodePage extends StatelessWidget { 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), + // Text( + // '020-598-230', + // style: TextStyle( + // fontWeight: FontWeight.w600, + // fontSize: 36.sp, + // color: Color(0xff333333), + // ), + // ), + // SizedBox(height: 11.w), QrImage( padding: EdgeInsets.zero, - data: '智慧社区开门码', + data: model.appArticleOutQRCodeVo.id.toString(), size: 260.w, ), ], @@ -139,6 +146,7 @@ class DetoCodePage extends StatelessWidget { @override Widget build(BuildContext context) { + UserProvider userProvider = Provider.of(context); return BeeScaffold( title: '出户二维码', body: Container( @@ -148,9 +156,11 @@ class DetoCodePage extends StatelessWidget { Column( children: [ SizedBox(height: 192.w - kToolbarHeight), - _header(), + _header(BeeParse.getEstateName( + userProvider.userDetailModel.estateNames[0])), SizedBox(height: 32.w), - _card(), + _card(model.appArticleOutQRCodeVo.residentName, + model.appArticleOutQRCodeVo.effectiveTime), ], ), ], diff --git a/lib/pages/goods_deto_page/goods_deto_page.dart b/lib/pages/goods_deto_page/goods_deto_page.dart index 5b97888c..f3cd34bc 100644 --- a/lib/pages/goods_deto_page/goods_deto_page.dart +++ b/lib/pages/goods_deto_page/goods_deto_page.dart @@ -1,4 +1,7 @@ // Flutter imports: +import 'package:akuCommunity/pages/manager_func.dart'; +import 'package:akuCommunity/widget/buttons/bottom_button.dart'; +import 'package:akuCommunity/widget/buttons/radio_button.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -25,10 +28,51 @@ class GoodsDetoPage extends StatefulWidget { class _GoodsDetoPageState extends State { EasyRefreshController _refreshController = EasyRefreshController(); + List _select = []; + bool _isEdit = false; + bool _canSkew(int state) { + switch (state) { + case 1: + case 2: + case 3: + return false; + case 4: + case 5: + case 6: + case 7: + return true; + default: + return true; + } + } + + Widget _buildPositioned(GoodsOutModel model) { + return AnimatedPositioned( + bottom: 0, + top: 0, + left: (_canSkew(4) && _isEdit) ? 80.w : 0.w, + duration: Duration(milliseconds: 300), + width: 750.w, + child: GoodsInfoCard( + model: model, + ), + ); + } + @override Widget build(BuildContext context) { return BeeScaffold( title: '物品出户', + actions: [ + IconButton( + icon: _isEdit + ? '完成'.text.black.size(28.sp).make() + : '编辑'.text.black.size(28.sp).make(), + onPressed: () { + _isEdit = !_isEdit; + setState(() {}); + }) + ], body: Padding( padding: EdgeInsets.only(bottom: 98.w), child: BeeListView( @@ -42,21 +86,49 @@ class _GoodsDetoPageState extends State { builder: (items) { return ListView.builder( itemBuilder: (context, index) { - return GoodsInfoCard(); + return Stack(children: [ + GestureDetector( + onTap: () { + if (_select.contains(items[index].id)) { + _select.remove(items[index].id); + } else + _select.add(items[index].id); + setState(() {}); + }, + child: Container( + padding: EdgeInsets.symmetric( + vertical: 50.w, horizontal: 32.w), + alignment: Alignment.topLeft, + constraints: BoxConstraints( + minHeight: 631.w + 96.w, minWidth: 686.w), + child: BeeRadio( + value: items[index].id, groupValues: _select), + ), + ), + _buildPositioned(items[index]), + ]); }, itemCount: items.length, ); }, ), ), - bottomNavi: MaterialButton( - color: kPrimaryColor, - - padding: EdgeInsets.only(top:26.w ,bottom: MediaQuery.of(context).padding.bottom+26.w), - child: '新增'.text.black.size(32.sp).bold.make(), - onPressed: () { - DetoCreatePage().to(); - },), + bottomNavi: BottomButton( + onPressed: _isEdit + ? _select.isEmpty + ? null + : () async { + await ManagerFunc.articleOutDelete(_select); + _select.clear(); + _refreshController.callRefresh(); + } + : () { + DetoCreatePage().to(); + }, + child: _isEdit + ? '删除'.text.size(32.sp).bold.make() + : '新增'.text.size(32.sp).bold.make(), + ), ); } } diff --git a/lib/pages/goods_deto_page/widget/goods_info_card.dart b/lib/pages/goods_deto_page/widget/goods_info_card.dart index 9f54b7c1..f7988b0a 100644 --- a/lib/pages/goods_deto_page/widget/goods_info_card.dart +++ b/lib/pages/goods_deto_page/widget/goods_info_card.dart @@ -1,4 +1,7 @@ // Flutter imports: +import 'package:akuCommunity/base/base_style.dart'; +import 'package:akuCommunity/model/manager/goods_out_model.dart'; +import 'package:akuCommunity/utils/bee_map.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -8,11 +11,46 @@ import 'goods_info_card_button.dart'; import 'image_horizontal_list.dart'; class GoodsInfoCard extends StatelessWidget { - final List listImage; - final String status; - final List> detoInfoList; - GoodsInfoCard({Key key,this.listImage,this.status,this.detoInfoList}) : super(key: key); + final GoodsOutModel model; + GoodsInfoCard({ + Key key, + this.model, + }) : super(key: key); + Widget _builTile(String title, String text) { + return Container( + // padding: EdgeInsets.only(top: 8.w), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + title, + style: TextStyle(fontSize: 28.sp, color: Color(0xff999999)), + ), + Text( + text, + style: TextStyle(fontSize: 28.sp, color: Color(0xff333333)), + ), + ], + ), + ); + } + +Color _getColor(int state) { + switch (state) { + case 1: + case 2: + case 3: + return kDarkPrimaryColor; + case 4: + case 5: + case 6: + case 7: + return ktextSubColor; + default: + return kDangerColor; + } + } @override Widget build(BuildContext context) { return Container( @@ -41,18 +79,15 @@ class GoodsInfoCard extends StatelessWidget { blurRadius: 10.0), ], ), - padding: EdgeInsets.only( - top: 25.w, - left: 24.w, - right: 24.w), + padding: EdgeInsets.only(top: 25.w, left: 24.w, right: 24.w), child: Column( children: [ Container( padding: EdgeInsets.only(bottom: 24.w), decoration: BoxDecoration( border: Border( - bottom: BorderSide( - color: Color(0xffeeeeee), width: 0.5)), + bottom: + BorderSide(color: Color(0xffeeeeee), width: 0.5)), ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -64,13 +99,11 @@ class GoodsInfoCard extends StatelessWidget { fontSize: 32.sp, color: Color(0xff333333)), ), - Text( - status, - style: TextStyle( - fontWeight: FontWeight.w600, - fontSize: 28.sp, - color: Color(0xff333333)) - ), + Text(BeeMap().fixState[model.status], + style: TextStyle( + fontWeight: FontWeight.w600, + fontSize: 28.sp, + color: _getColor(model.status))), ], ), ), @@ -81,35 +114,16 @@ class GoodsInfoCard extends StatelessWidget { ), decoration: BoxDecoration( border: Border( - bottom: BorderSide( - color: Color(0xffeeeeee), width: 0.5)), - ), - child: Column( - children: detoInfoList - .map( - (item) => Container( - padding: EdgeInsets.only(top: 8.w), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - item['title'], - style: TextStyle( - fontSize: 28.sp, - color: Color(0xff999999)), - ), - Text( - item['content'], - style: TextStyle( - fontSize: 28.sp, - color: Color(0xff333333)), - ), - ], - ), - ), - ) - .toList(), + bottom: + BorderSide(color: Color(0xffeeeeee), width: 0.5)), ), + child: Column(children: [ + _builTile('物品重量', BeeMap().goodsOutweight[model.weight]), + _builTile('出户时间', model.expectedTime), + _builTile('物品名称', model.name), + _builTile( + '搬运方式', BeeMap().goodsOutApproach[model.approach]), + ]), ), Container( margin: EdgeInsets.only( @@ -120,22 +134,25 @@ class GoodsInfoCard extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( + alignment: Alignment.centerLeft, margin: EdgeInsets.only(bottom: 25.w), child: Text( '图片信息', style: TextStyle( - fontSize: 28.sp, - color: Color(0xff333333)), + fontSize: 28.sp, color: Color(0xff333333)), ), ), - ImageHorizontalList(imageUrl: listImage), + ImageHorizontalList(imageUrl: []), ], ), ), ], ), ), - GoodsInfoCardButton() + GoodsInfoCardButton( + id:model.id, + tel: model.movingCompanyTel, + ) ], ), ); diff --git a/lib/pages/goods_deto_page/widget/goods_info_card_button.dart b/lib/pages/goods_deto_page/widget/goods_info_card_button.dart index 8a2ba73e..0336b508 100644 --- a/lib/pages/goods_deto_page/widget/goods_info_card_button.dart +++ b/lib/pages/goods_deto_page/widget/goods_info_card_button.dart @@ -1,4 +1,8 @@ // Flutter imports: +import 'package:akuCommunity/model/manager/article_QR_code_model.dart'; +import 'package:akuCommunity/pages/manager_func.dart'; +import 'package:akuCommunity/utils/network/base_model.dart'; +import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -13,7 +17,9 @@ import 'package:akuCommunity/pages/goods_deto_page/deto_code_page/deto_code_page import 'package:akuCommunity/utils/headers.dart'; class GoodsInfoCardButton extends StatelessWidget { - GoodsInfoCardButton({Key key}) : super(key: key); + final String tel; + final int id; + GoodsInfoCardButton({Key key, this.tel, this.id}) : super(key: key); final List> _listButton = [ {'title': '查看二维码', 'icon': MaterialCommunityIcons.qrcode}, @@ -75,6 +81,7 @@ class GoodsInfoCardButton extends StatelessWidget { @override Widget build(BuildContext context) { return Container( + alignment: Alignment.center, decoration: BoxDecoration( color: Colors.white.withOpacity(0.6), borderRadius: BorderRadius.only( @@ -89,13 +96,24 @@ class GoodsInfoCardButton extends StatelessWidget { .keys .map((index) => Expanded( child: InkWell( - onTap: () { + onTap: () async { switch (_listButton[index]['title']) { case '查看二维码': - DetoCodePage().to; + ArticleQRModel _model = await ManagerFunc.getQRcode(id); + if (_model.status) { + DetoCodePage( + id: id, + model: _model + ).to(); + } else { + BotToast.showText(text: _model.message); + } break; case '搬家公司': - _showDialog(context, '0574-88467897'); + if (tel.isEmptyOrNull) { + return null; + } else + _showDialog(context, tel); break; default: } @@ -122,8 +140,7 @@ class GoodsInfoCardButton extends StatelessWidget { color: Color(0xff333333), ), Container( - margin: - EdgeInsets.only(left: 14.w), + margin: EdgeInsets.only(left: 14.w), child: Text( _listButton[index]['title'], style: TextStyle( diff --git a/lib/pages/manager_func.dart b/lib/pages/manager_func.dart index a67718e0..9c418fe9 100644 --- a/lib/pages/manager_func.dart +++ b/lib/pages/manager_func.dart @@ -1,4 +1,5 @@ // Package imports: +import 'package:akuCommunity/model/manager/article_QR_code_model.dart'; import 'package:akuCommunity/model/manager/moving_company_model.dart'; import 'package:dio/dio.dart'; import 'package:flustars/flustars.dart'; @@ -119,11 +120,31 @@ class ManagerFunc { 'weight': weight, 'approach': approach, 'movingCompanyTel': tel, - 'expectedTime': DateUtil.formatDateStr(time,format: "yyyy-MM-dd HH:mm:ss"), + 'expectedTime': + DateUtil.formatDateStr(time, format: "yyyy-MM-dd HH:mm:ss"), 'imgUrls': urls, }, showMessage: true, ); return baseModel; } + + static Future getQRcode(int id) async { + Response response = await NetUtil().dio.get( + API.manager.getQRcode, + queryParameters: { + 'articleOutId': id, + }, + ); + return ArticleQRModel.fromJson(response.data); + } + + static Future articleOutDelete(List ids) async { + BaseModel baseModel = await NetUtil().post( + API.manager.articleOutDelete, + params: {'ids': ids}, + showMessage: true, + ); + return baseModel; + } } diff --git a/lib/pages/things_page/fixed_submit_page.dart b/lib/pages/things_page/fixed_submit_page.dart index fbfbe816..064a5fa0 100644 --- a/lib/pages/things_page/fixed_submit_page.dart +++ b/lib/pages/things_page/fixed_submit_page.dart @@ -84,7 +84,7 @@ class _FixedSubmitPageState extends State { Widget _buildCard(FixedSubmitModel model) { return AnimatedPositioned( top: 0, - left: (_canSkew(4) && _isEdit) ? 55.w : 0, + left: (_canSkew(model.status) && _isEdit) ? 55.w : 0, bottom: 0, duration: Duration(milliseconds: 300), curve: Curves.easeInOutCubic, diff --git a/lib/pages/things_page/widget/fixed_check_box.dart b/lib/pages/things_page/widget/fixed_check_box.dart index dd9d875a..3972a270 100644 --- a/lib/pages/things_page/widget/fixed_check_box.dart +++ b/lib/pages/things_page/widget/fixed_check_box.dart @@ -26,7 +26,8 @@ class _FixedCheckBoxState extends State { }); widget.onChanged(_isSelected); }, - child: Container( + child: AnimatedContainer( + duration: Duration(milliseconds: 300), alignment: Alignment.center, width: 40.w, height: 40.w, @@ -36,7 +37,8 @@ class _FixedCheckBoxState extends State { width: 3.w, color: _isSelected ? kPrimaryColor : kDarkSubColor), color: Colors.transparent, ), - child: Container( + child: AnimatedContainer( + duration: Duration(milliseconds: 300), width: 24.w, height: 24.w, decoration: BoxDecoration( diff --git a/lib/ui/manager/visitor/visitor_passport_page.dart b/lib/ui/manager/visitor/visitor_passport_page.dart index ea524c4f..c0d440a0 100644 --- a/lib/ui/manager/visitor/visitor_passport_page.dart +++ b/lib/ui/manager/visitor/visitor_passport_page.dart @@ -130,7 +130,6 @@ class _VisitorPassportPageState extends State { .make(), ], ), - //TODO 二维码显示 ).centered(), ], ).box.color(Color(0xFF333333)).make(), diff --git a/lib/utils/bee_map.dart b/lib/utils/bee_map.dart index b933179d..25c21f30 100644 --- a/lib/utils/bee_map.dart +++ b/lib/utils/bee_map.dart @@ -26,4 +26,14 @@ class BeeMap { 8: '作废', 9: '取消' }; + + Map goodsOutweight = { + 1: '< 50kg', + 2: '50kg-100kg', + 3: '> 100kg', + }; + Map goodsOutApproach={ + 1:'自己搬运', + 2:'搬家公司', + }; } diff --git a/lib/widget/buttons/bottom_button.dart b/lib/widget/buttons/bottom_button.dart index 8f8cf1a3..a7940ad2 100644 --- a/lib/widget/buttons/bottom_button.dart +++ b/lib/widget/buttons/bottom_button.dart @@ -24,14 +24,10 @@ class BottomButton extends StatelessWidget { padding: EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom), child: MaterialButton( materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, - child: DefaultTextStyle( - child: child, - style: TextStyle( - color: Colors.black, - fontWeight: FontWeight.bold, - fontSize: 32.sp, - ), - ), + disabledColor: Colors.white.withOpacity(0.5), + disabledTextColor: ktextSubColor.withOpacity(0.8), + textColor: ktextPrimary, + child: child, onPressed: onPressed, color: kPrimaryColor, height: 98.w,