update goods borrow page

对接 借还管理查询接口
hmxc
张萌 4 years ago
parent 6d9f8f40fb
commit 4394139404

@ -130,6 +130,12 @@ class _Manager {
///app ///app
String get articleOutDelete => '/user/articleOut/falseDelete'; String get articleOutDelete => '/user/articleOut/falseDelete';
///
String get articleBorrow => '/user/articleBorrow/list';
///
String get articleBorrowMylist => '/user/articleBorrow/myList';
} }
class _Community { class _Community {

@ -1,6 +1,12 @@
// Flutter imports: // 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/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
// Package imports: // Package imports:
import 'package:velocity_x/velocity_x.dart'; import 'package:velocity_x/velocity_x.dart';
@ -8,8 +14,7 @@ import 'package:velocity_x/velocity_x.dart';
// Project imports: // Project imports:
import 'package:akuCommunity/utils/headers.dart'; import 'package:akuCommunity/utils/headers.dart';
import 'package:akuCommunity/widget/bee_scaffold.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart';
import 'package:akuCommunity/widget/bottom_button.dart'; import 'package:akuCommunity/const/resource.dart';
import 'package:akuCommunity/widget/cached_image_wrapper.dart';
class GoodsManagePage extends StatefulWidget { class GoodsManagePage extends StatefulWidget {
GoodsManagePage({Key key}) : super(key: key); GoodsManagePage({Key key}) : super(key: key);
@ -19,46 +24,9 @@ class GoodsManagePage extends StatefulWidget {
} }
class _GoodsManagePageState extends State<GoodsManagePage> { class _GoodsManagePageState extends State<GoodsManagePage> {
List<Map<String, dynamic>> _listGoods = [ EasyRefreshController _easyRefreshController;
{
'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
}
];
Container _goodsCard(String imagePath, title, int goodsNum) { Container _goodsCard(ArticleBorrowModel model) {
return Container( return Container(
margin: EdgeInsets.only( margin: EdgeInsets.only(
top: 20.w, top: 20.w,
@ -73,28 +41,28 @@ class _GoodsManagePageState extends State<GoodsManagePage> {
), ),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(6)), borderRadius: BorderRadius.all(Radius.circular(6.w)),
), ),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Container( Container(
height: 120.w,
width: 160.w,
margin: EdgeInsets.only(right: 20.w), margin: EdgeInsets.only(right: 20.w),
child: ClipRRect( child: ClipRRect(
child: CachedImageWrapper( child: FadeInImage.assetNetwork(
url: imagePath, placeholder: R.ASSETS_IMAGES_LOGO_PNG,
width: 160.w, image: API.image(
height: 120.w, model.imgUrls.isEmpty ? '' : model.imgUrls.first.url))),
),
),
), ),
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
Text( Text(
'物品名称:$title', '物品名称:${model.name}',
style: TextStyle( style: TextStyle(
fontSize: 28.sp, fontSize: 28.sp,
color: Color(0xff4a4b51), color: Color(0xff4a4b51),
@ -102,7 +70,7 @@ class _GoodsManagePageState extends State<GoodsManagePage> {
), ),
SizedBox(height: 20.w), SizedBox(height: 20.w),
Text( Text(
'数量剩余:$goodsNum', '数量剩余:${model.quantity}',
style: TextStyle( style: TextStyle(
fontSize: 24.sp, fontSize: 24.sp,
color: Color(0xff999999), color: Color(0xff999999),
@ -121,31 +89,56 @@ class _GoodsManagePageState extends State<GoodsManagePage> {
title: '借还管理', title: '借还管理',
actions: [ actions: [
InkWell( InkWell(
onTap: () {}, onTap: () {
MineGoodsPage().to();
},
child: Container( child: Container(
padding: EdgeInsets.fromLTRB(32.w, 28.w, 32.w, 20.w), padding: EdgeInsets.fromLTRB(32.w, 28.w, 32.w, 20.w),
alignment: Alignment.center, alignment: Alignment.center,
child: '我的借还物品'.text.black.size(28.sp).make())) child: '我的借还物品'.text.black.size(28.sp).make()))
], ],
body: Stack( // body: Stack(
children: [ // children: [
Column( // Column(
children: _listGoods // children: _listGoods
.map((item) => _goodsCard( // .map((item) => _goodsCard(
item['imagePath'], // item['imagePath'],
item['title'], // item['title'],
item['goodsNum'], // item['goodsNum'],
)) // ))
.toList(), // .toList(),
), // ),
Positioned( // Positioned(
bottom: 0, // bottom: 0,
child: BottomButton( // child: BottomButton(
title: '扫一扫出借', // title: '扫一扫出借',
fun: () {}, // 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: () {},
), ),
); );
} }

@ -1,9 +1,11 @@
// Flutter imports: // 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/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
// Package imports:
import 'package:pull_to_refresh/pull_to_refresh.dart';
// Project imports: // Project imports:
import 'package:akuCommunity/utils/headers.dart'; import 'package:akuCommunity/utils/headers.dart';
@ -17,76 +19,18 @@ class MineGoodsPage extends StatefulWidget {
} }
class _MineGoodsPageState extends State<MineGoodsPage> { class _MineGoodsPageState extends State<MineGoodsPage> {
List<Map<String, dynamic>> _listGoods = [ EasyRefreshController _controller;
{
'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);
@override @override
void initState() { void initState() {
super.initState(); super.initState();
} _controller = EasyRefreshController();
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();
} }
@override @override
void dispose() { void dispose() {
super.dispose(); super.dispose();
_refreshController.dispose(); _controller.dispose();
} }
InkWell _frmLoss() { InkWell _frmLoss() {
@ -109,8 +53,15 @@ class _MineGoodsPageState extends State<MineGoodsPage> {
); );
} }
Container _goodsCard( String _getDatelength(int date) {
String title, borrowTime, timeLength, status, int goodsNum) { if (date >= 24) {
return '${date / 24}' + '${date % 24}';
} else {
return '$date';
}
}
Container _goodsCard(MineGoodsModel model) {
return Container( return Container(
margin: EdgeInsets.only( margin: EdgeInsets.only(
top: 20.w, top: 20.w,
@ -136,7 +87,7 @@ class _MineGoodsPageState extends State<MineGoodsPage> {
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
Text( Text(
'物品名称:$title', '物品名称:${model.name}',
style: TextStyle( style: TextStyle(
fontSize: 28.sp, fontSize: 28.sp,
color: Color(0xff4a4b51), color: Color(0xff4a4b51),
@ -145,7 +96,7 @@ class _MineGoodsPageState extends State<MineGoodsPage> {
Container( Container(
margin: EdgeInsets.only(top: 16.w), margin: EdgeInsets.only(top: 16.w),
child: Text( child: Text(
'借还数量:$goodsNum', '借还数量:10',
style: TextStyle( style: TextStyle(
fontSize: 24.sp, fontSize: 24.sp,
color: Color(0xff333333), color: Color(0xff333333),
@ -155,7 +106,7 @@ class _MineGoodsPageState extends State<MineGoodsPage> {
Container( Container(
margin: EdgeInsets.only(top: 16.w), margin: EdgeInsets.only(top: 16.w),
child: Text( child: Text(
'借用时间: $borrowTime', '借用时间: ${model.beginDate}',
style: TextStyle( style: TextStyle(
fontSize: 24.sp, fontSize: 24.sp,
color: Color(0xff999999), color: Color(0xff999999),
@ -165,7 +116,7 @@ class _MineGoodsPageState extends State<MineGoodsPage> {
Container( Container(
margin: EdgeInsets.only(top: 16.w), margin: EdgeInsets.only(top: 16.w),
child: Text( child: Text(
'借用时长: $timeLength', '借用时长: ${_getDatelength(model.borrowDate)}',
style: TextStyle( style: TextStyle(
fontSize: 24.sp, fontSize: 24.sp,
color: Color(0xff999999), color: Color(0xff999999),
@ -178,7 +129,7 @@ class _MineGoodsPageState extends State<MineGoodsPage> {
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text( Text(
'借用状态: $status', '借用状态: ${BeeMap.borrowStatus}',
style: TextStyle( style: TextStyle(
fontSize: 24.sp, fontSize: 24.sp,
color: Color(0xff999999), color: Color(0xff999999),
@ -190,11 +141,11 @@ class _MineGoodsPageState extends State<MineGoodsPage> {
), ),
SizedBox(height: 12.w), SizedBox(height: 12.w),
Divider(color: Color(0xfff9f9f9)), Divider(color: Color(0xfff9f9f9)),
status == '未还' model.borrowStatus == 1
? Container( ? Container(
margin: EdgeInsets.only(bottom: 9.w), margin: EdgeInsets.only(bottom: 9.w),
child: Text( child: Text(
'温馨提示:您的物品已借用$timeLength天,如果用完,请及时归还', '温馨提示:您的物品已借用${_getDatelength(model.borrowDate)},如果用完,请及时归还',
style: TextStyle( style: TextStyle(
fontSize: 22.sp, fontSize: 22.sp,
color: Color(0xff999999), color: Color(0xff999999),
@ -214,26 +165,39 @@ class _MineGoodsPageState extends State<MineGoodsPage> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BeeScaffold( return BeeScaffold(
title: '我的借还物品', title: '我的借还物品',
body: RefreshConfiguration( // body: RefreshConfiguration(
child: SmartRefresher( // child: SmartRefresher(
controller: _refreshController, // controller: _refreshController,
header: WaterDropHeader(), // header: WaterDropHeader(),
footer: ClassicFooter(), // footer: ClassicFooter(),
onRefresh: _onRefresh, // onRefresh: _onRefresh,
onLoading: _onLoading, // onLoading: _onLoading,
enablePullUp: true, // enablePullUp: true,
child: ListView.builder( // child: ListView.builder(
itemBuilder: (BuildContext context, int index) => _goodsCard( // itemBuilder: (BuildContext context, int index) => _goodsCard(
_listGoods[index]['title'], // _listGoods[index]['title'],
_listGoods[index]['borrowTime'], // _listGoods[index]['borrowTime'],
_listGoods[index]['timeLength'], // _listGoods[index]['timeLength'],
_listGoods[index]['status'], // _listGoods[index]['status'],
_listGoods[index]['goodsNum'], // _listGoods[index]['goodsNum'],
), // ),
itemCount: _listGoods.length, // 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]);
});
}),
); );
} }
} }

@ -147,4 +147,5 @@ class ManagerFunc {
); );
return baseModel; return baseModel;
} }
} }

@ -32,8 +32,10 @@ class BeeMap {
2: '50kg-100kg', 2: '50kg-100kg',
3: '> 100kg', 3: '> 100kg',
}; };
Map<int,String> goodsOutApproach={ Map<int, String> goodsOutApproach = {
1:'自己搬运', 1: '自己搬运',
2:'搬家公司', 2: '搬家公司',
}; };
static Map<int, String> borrowStatus = {1: '出借中', 2: '已归还'};
} }

Loading…
Cancel
Save