From 4394139404bf8a976c8b6e587c8ea0664edad8c0 Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Mon, 1 Feb 2021 10:27:42 +0800 Subject: [PATCH] =?UTF-8?q?update=20goods=20borrow=20page=20=E5=AF=B9?= =?UTF-8?q?=E6=8E=A5=20=E5=80=9F=E8=BF=98=E7=AE=A1=E7=90=86=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/constants/api.dart | 6 + .../goods_manage_page/goods_manage_page.dart | 133 ++++++++-------- .../mine_goods_page/mine_goods_page.dart | 150 +++++++----------- lib/pages/manager_func.dart | 1 + lib/utils/bee_map.dart | 8 +- 5 files changed, 132 insertions(+), 166 deletions(-) diff --git a/lib/constants/api.dart b/lib/constants/api.dart index 86d9534b..4517dca6 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -130,6 +130,12 @@ class _Manager { ///物品出户:app批量删除物品出户信息 String get articleOutDelete => '/user/articleOut/falseDelete'; + + ///借还管理:查询所有可借物品信息 + String get articleBorrow => '/user/articleBorrow/list'; + + ///借还管理:查询该用户的所有物品借还信息 + String get articleBorrowMylist => '/user/articleBorrow/myList'; } class _Community { diff --git a/lib/pages/goods_manage_page/goods_manage_page.dart b/lib/pages/goods_manage_page/goods_manage_page.dart index 356b6df7..12f69d72 100644 --- a/lib/pages/goods_manage_page/goods_manage_page.dart +++ b/lib/pages/goods_manage_page/goods_manage_page.dart @@ -1,6 +1,12 @@ // Flutter imports: +import 'package:akuCommunity/constants/api.dart'; +import 'package:akuCommunity/model/manager/article_borrow_model.dart'; +import 'package:akuCommunity/pages/goods_manage_page/mine_goods_page/mine_goods_page.dart'; +import 'package:akuCommunity/pages/things_page/widget/bee_list_view.dart'; +import 'package:akuCommunity/widget/buttons/bottom_button.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; // Package imports: import 'package:velocity_x/velocity_x.dart'; @@ -8,8 +14,7 @@ import 'package:velocity_x/velocity_x.dart'; // Project imports: import 'package:akuCommunity/utils/headers.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart'; -import 'package:akuCommunity/widget/bottom_button.dart'; -import 'package:akuCommunity/widget/cached_image_wrapper.dart'; +import 'package:akuCommunity/const/resource.dart'; class GoodsManagePage extends StatefulWidget { GoodsManagePage({Key key}) : super(key: key); @@ -19,46 +24,9 @@ class GoodsManagePage extends StatefulWidget { } class _GoodsManagePageState extends State { - List> _listGoods = [ - { - 'imagePath': - 'https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=409315131,2212208097&fm=26&gp=0.jpg', - 'title': '榔头', - 'goodsNum': 4 - }, - { - 'imagePath': - 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1600315000206&di=d63920cce862ea3143b94f5efd9ee48f&imgtype=0&src=http%3A%2F%2Fimg009.hc360.cn%2Fy3%2FM06%2F97%2F52%2FwKhQh1T9gwqEG8-EAAAAADtr0hA725.jpg', - 'title': '梯子', - 'goodsNum': 2 - }, - { - 'imagePath': - 'https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=742033541,898484766&fm=26&gp=0.jpg', - 'title': '电钻', - 'goodsNum': 10 - }, - { - 'imagePath': - 'https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=655760492,2421981969&fm=26&gp=0.jpg', - 'title': '多功能螺丝刀', - 'goodsNum': 7 - }, - { - 'imagePath': - 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1600315263467&di=87b7fa8cd8bc03f5bd320f29efd00418&imgtype=0&src=http%3A%2F%2Ftu.ossfiles.cn%3A9186%2Fgroup3%2FM00%2F08%2FB6%2FrBpVfl8H3XuAOUA-AAFkF36vtNY168.jpg', - 'title': '手电筒', - 'goodsNum': 5 - }, - { - 'imagePath': - 'https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1922842359,3407397182&fm=26&gp=0.jpg', - 'title': '胶带', - 'goodsNum': 6 - } - ]; + EasyRefreshController _easyRefreshController; - Container _goodsCard(String imagePath, title, int goodsNum) { + Container _goodsCard(ArticleBorrowModel model) { return Container( margin: EdgeInsets.only( top: 20.w, @@ -73,28 +41,28 @@ class _GoodsManagePageState extends State { ), decoration: BoxDecoration( color: Colors.white, - borderRadius: BorderRadius.all(Radius.circular(6)), + borderRadius: BorderRadius.all(Radius.circular(6.w)), ), child: Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( + height: 120.w, + width: 160.w, margin: EdgeInsets.only(right: 20.w), child: ClipRRect( - child: CachedImageWrapper( - url: imagePath, - width: 160.w, - height: 120.w, - ), - ), + child: FadeInImage.assetNetwork( + placeholder: R.ASSETS_IMAGES_LOGO_PNG, + image: API.image( + model.imgUrls.isEmpty ? '' : model.imgUrls.first.url))), ), Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: [ Text( - '物品名称:$title', + '物品名称:${model.name}', style: TextStyle( fontSize: 28.sp, color: Color(0xff4a4b51), @@ -102,7 +70,7 @@ class _GoodsManagePageState extends State { ), SizedBox(height: 20.w), Text( - '数量剩余:$goodsNum个', + '数量剩余:${model.quantity}', style: TextStyle( fontSize: 24.sp, color: Color(0xff999999), @@ -121,31 +89,56 @@ class _GoodsManagePageState extends State { title: '借还管理', actions: [ InkWell( - onTap: () {}, + onTap: () { + MineGoodsPage().to(); + }, child: Container( padding: EdgeInsets.fromLTRB(32.w, 28.w, 32.w, 20.w), alignment: Alignment.center, child: '我的借还物品'.text.black.size(28.sp).make())) ], - body: Stack( - children: [ - Column( - children: _listGoods - .map((item) => _goodsCard( - item['imagePath'], - item['title'], - item['goodsNum'], - )) - .toList(), - ), - Positioned( - bottom: 0, - child: BottomButton( - title: '扫一扫出借', - fun: () {}, - ), - ), - ], + // body: Stack( + // children: [ + // Column( + // children: _listGoods + // .map((item) => _goodsCard( + // item['imagePath'], + // item['title'], + // item['goodsNum'], + // )) + // .toList(), + // ), + // Positioned( + // bottom: 0, + // child: BottomButton( + // title: '扫一扫出借', + // fun: () {}, + // ), + // ), + // ], + // ), + + body: BeeListView( + path: API.manager.articleBorrow, + controller: _easyRefreshController, + convert: (models) { + return models.tableList + .map((e) => ArticleBorrowModel.fromJson(e)) + .toList(); + }, + builder: (items) { + return ListView.separated( + itemBuilder: (context, index) { + return _goodsCard(items[index]); + }, + separatorBuilder: (_, __) { + return 16.w.heightBox; + }, + itemCount: items.length); + }), + bottomNavi: BottomButton( + child: '扫一扫出借'.text.black.size(32.sp).bold.make(), + onPressed: () {}, ), ); } diff --git a/lib/pages/goods_manage_page/mine_goods_page/mine_goods_page.dart b/lib/pages/goods_manage_page/mine_goods_page/mine_goods_page.dart index f51e7e55..5e84ef71 100644 --- a/lib/pages/goods_manage_page/mine_goods_page/mine_goods_page.dart +++ b/lib/pages/goods_manage_page/mine_goods_page/mine_goods_page.dart @@ -1,9 +1,11 @@ // Flutter imports: +import 'package:akuCommunity/constants/api.dart'; +import 'package:akuCommunity/model/manager/mine_goods_model.dart'; +import 'package:akuCommunity/pages/things_page/widget/bee_list_view.dart'; +import 'package:akuCommunity/utils/bee_map.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; - -// Package imports: -import 'package:pull_to_refresh/pull_to_refresh.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; // Project imports: import 'package:akuCommunity/utils/headers.dart'; @@ -17,76 +19,18 @@ class MineGoodsPage extends StatefulWidget { } class _MineGoodsPageState extends State { - List> _listGoods = [ - { - 'title': '榔头', - 'goodsNum': 6, - 'borrowTime': '2020.09.18 12:00', - 'timeLength': '7', - 'status': '未还' - }, - { - 'title': '梯子', - 'goodsNum': 1, - 'borrowTime': '2020.08.28 12:00', - 'timeLength': '3', - 'status': '已还' - }, - { - 'title': '电钻', - 'goodsNum': 1, - 'borrowTime': '2020.07.04 12:00', - 'timeLength': '6', - 'status': '未还' - }, - { - 'title': '多功能螺丝刀', - 'goodsNum': 4, - 'borrowTime': '2020.04.06 12:00', - 'timeLength': '4', - 'status': '已还' - }, - { - 'title': '手电筒', - 'goodsNum': 2, - 'borrowTime': '2020.02.19 12:00', - 'timeLength': '2', - 'status': '已还' - }, - { - 'title': '胶带', - 'goodsNum': 3, - 'borrowTime': '2020.01.14 12:00', - 'timeLength': '8', - 'status': '未还' - }, - ]; - - RefreshController _refreshController = - RefreshController(initialRefresh: false); + EasyRefreshController _controller; @override void initState() { super.initState(); - } - - void _onRefresh() async { - await Future.delayed(Duration(milliseconds: 1500)); - - _refreshController.refreshCompleted(); - } - - void _onLoading() async { - await Future.delayed(Duration(milliseconds: 1500)); - - if (mounted) setState(() {}); - _refreshController.loadComplete(); + _controller = EasyRefreshController(); } @override void dispose() { super.dispose(); - _refreshController.dispose(); + _controller.dispose(); } InkWell _frmLoss() { @@ -109,8 +53,15 @@ class _MineGoodsPageState extends State { ); } - Container _goodsCard( - String title, borrowTime, timeLength, status, int goodsNum) { + String _getDatelength(int date) { + if (date >= 24) { + return '${date / 24}' + '${date % 24}'; + } else { + return '$date'; + } + } + + Container _goodsCard(MineGoodsModel model) { return Container( margin: EdgeInsets.only( top: 20.w, @@ -136,7 +87,7 @@ class _MineGoodsPageState extends State { mainAxisAlignment: MainAxisAlignment.start, children: [ Text( - '物品名称:$title', + '物品名称:${model.name}', style: TextStyle( fontSize: 28.sp, color: Color(0xff4a4b51), @@ -145,7 +96,7 @@ class _MineGoodsPageState extends State { Container( margin: EdgeInsets.only(top: 16.w), child: Text( - '借还数量:$goodsNum个', + '借还数量:10个', style: TextStyle( fontSize: 24.sp, color: Color(0xff333333), @@ -155,7 +106,7 @@ class _MineGoodsPageState extends State { Container( margin: EdgeInsets.only(top: 16.w), child: Text( - '借用时间: $borrowTime', + '借用时间: ${model.beginDate}', style: TextStyle( fontSize: 24.sp, color: Color(0xff999999), @@ -165,7 +116,7 @@ class _MineGoodsPageState extends State { Container( margin: EdgeInsets.only(top: 16.w), child: Text( - '借用时长: $timeLength日', + '借用时长: ${_getDatelength(model.borrowDate)}', style: TextStyle( fontSize: 24.sp, color: Color(0xff999999), @@ -178,7 +129,7 @@ class _MineGoodsPageState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( - '借用状态: $status', + '借用状态: ${BeeMap.borrowStatus}', style: TextStyle( fontSize: 24.sp, color: Color(0xff999999), @@ -190,11 +141,11 @@ class _MineGoodsPageState extends State { ), SizedBox(height: 12.w), Divider(color: Color(0xfff9f9f9)), - status == '未还' + model.borrowStatus == 1 ? Container( margin: EdgeInsets.only(bottom: 9.w), child: Text( - '温馨提示:您的物品已借用$timeLength天,如果用完,请及时归还', + '温馨提示:您的物品已借用${_getDatelength(model.borrowDate)},如果用完,请及时归还', style: TextStyle( fontSize: 22.sp, color: Color(0xff999999), @@ -214,26 +165,39 @@ class _MineGoodsPageState extends State { Widget build(BuildContext context) { return BeeScaffold( title: '我的借还物品', - body: RefreshConfiguration( - child: SmartRefresher( - controller: _refreshController, - header: WaterDropHeader(), - footer: ClassicFooter(), - onRefresh: _onRefresh, - onLoading: _onLoading, - enablePullUp: true, - child: ListView.builder( - itemBuilder: (BuildContext context, int index) => _goodsCard( - _listGoods[index]['title'], - _listGoods[index]['borrowTime'], - _listGoods[index]['timeLength'], - _listGoods[index]['status'], - _listGoods[index]['goodsNum'], - ), - itemCount: _listGoods.length, - ), - ), - ), + // body: RefreshConfiguration( + // child: SmartRefresher( + // controller: _refreshController, + // header: WaterDropHeader(), + // footer: ClassicFooter(), + // onRefresh: _onRefresh, + // onLoading: _onLoading, + // enablePullUp: true, + // child: ListView.builder( + // itemBuilder: (BuildContext context, int index) => _goodsCard( + // _listGoods[index]['title'], + // _listGoods[index]['borrowTime'], + // _listGoods[index]['timeLength'], + // _listGoods[index]['status'], + // _listGoods[index]['goodsNum'], + // ), + // itemCount: _listGoods.length, + // ), + // ), + // ), + body: BeeListView( + path: API.manager.articleBorrowMylist, + controller: _controller, + convert: (model) { + return model.tableList + .map((e) => MineGoodsModel.fromJson(e)) + .toList(); + }, + builder: (items) { + return ListView.builder(itemBuilder: (context, index) { + return _goodsCard(items[index]); + }); + }), ); } } diff --git a/lib/pages/manager_func.dart b/lib/pages/manager_func.dart index 9c418fe9..1b86ea40 100644 --- a/lib/pages/manager_func.dart +++ b/lib/pages/manager_func.dart @@ -147,4 +147,5 @@ class ManagerFunc { ); return baseModel; } + } diff --git a/lib/utils/bee_map.dart b/lib/utils/bee_map.dart index 25c21f30..c5a54dc2 100644 --- a/lib/utils/bee_map.dart +++ b/lib/utils/bee_map.dart @@ -32,8 +32,10 @@ class BeeMap { 2: '50kg-100kg', 3: '> 100kg', }; - Map goodsOutApproach={ - 1:'自己搬运', - 2:'搬家公司', + Map goodsOutApproach = { + 1: '自己搬运', + 2: '搬家公司', }; + + static Map borrowStatus = {1: '出借中', 2: '已归还'}; }