update goods borrow page

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

@ -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 {

@ -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<GoodsManagePage> {
List<Map<String, dynamic>> _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<GoodsManagePage> {
),
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<GoodsManagePage> {
),
SizedBox(height: 20.w),
Text(
'数量剩余:$goodsNum',
'数量剩余:${model.quantity}',
style: TextStyle(
fontSize: 24.sp,
color: Color(0xff999999),
@ -121,31 +89,56 @@ class _GoodsManagePageState extends State<GoodsManagePage> {
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: () {},
),
);
}

@ -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<MineGoodsPage> {
List<Map<String, dynamic>> _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<MineGoodsPage> {
);
}
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<MineGoodsPage> {
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
'物品名称:$title',
'物品名称:${model.name}',
style: TextStyle(
fontSize: 28.sp,
color: Color(0xff4a4b51),
@ -145,7 +96,7 @@ class _MineGoodsPageState extends State<MineGoodsPage> {
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<MineGoodsPage> {
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<MineGoodsPage> {
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<MineGoodsPage> {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'借用状态: $status',
'借用状态: ${BeeMap.borrowStatus}',
style: TextStyle(
fontSize: 24.sp,
color: Color(0xff999999),
@ -190,11 +141,11 @@ class _MineGoodsPageState extends State<MineGoodsPage> {
),
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<MineGoodsPage> {
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]);
});
}),
);
}
}

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

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

Loading…
Cancel
Save