From c2cf7e7f6f4c894e6020ae8a0044ff47e661bdf2 Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Wed, 20 Jan 2021 09:45:53 +0800 Subject: [PATCH] update fixed submit page --- lib/constants/api.dart | 4 + lib/model/user/fixed_submit_model.dart | 63 ++++++++ lib/pages/things_page/fixed_submit_page.dart | 146 ++++++++++++------- lib/utils/bee_map.dart | 6 +- 4 files changed, 165 insertions(+), 54 deletions(-) create mode 100644 lib/model/user/fixed_submit_model.dart diff --git a/lib/constants/api.dart b/lib/constants/api.dart index fa715e92..15d28a25 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -53,4 +53,8 @@ class _Manager { ///获取便民电话联系人列表 String get convenientPhone => '/convenientTelephone/list'; + + ///查询当前用户的报事报修信息 + String get fixedSubmit => '/user/reportRepair/list'; + } diff --git a/lib/model/user/fixed_submit_model.dart b/lib/model/user/fixed_submit_model.dart new file mode 100644 index 00000000..15148933 --- /dev/null +++ b/lib/model/user/fixed_submit_model.dart @@ -0,0 +1,63 @@ +class FixedSubmitModel { + int id; + int type; + int status; + String reportDetail; + List imgUrls; + + FixedSubmitModel( + {this.id, this.type, this.status, this.reportDetail, this.imgUrls}); + + FixedSubmitModel.fromJson(Map json) { + id = json['id']; + type = json['type']; + status = json['status']; + reportDetail = json['reportDetail']; + if (json['imgUrls'] != null) { + imgUrls = new List(); + json['imgUrls'].forEach((v) { + imgUrls.add(new ImgUrls.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['type'] = this.type; + data['status'] = this.status; + data['reportDetail'] = this.reportDetail; + if (this.imgUrls != null) { + data['imgUrls'] = this.imgUrls.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class ImgUrls { + String url; + String size; + int longs; + int paragraph; + int sort; + + ImgUrls({this.url, this.size, this.longs, this.paragraph, this.sort}); + + ImgUrls.fromJson(Map json) { + url = json['url']; + size = json['size']; + longs = json['longs']; + paragraph = json['paragraph']; + sort = json['sort']; + } + + Map toJson() { + final Map data = new Map(); + data['url'] = this.url; + data['size'] = this.size; + data['longs'] = this.longs; + data['paragraph'] = this.paragraph; + data['sort'] = this.sort; + return data; + } +} diff --git a/lib/pages/things_page/fixed_submit_page.dart b/lib/pages/things_page/fixed_submit_page.dart index a9716c17..cccbca5a 100644 --- a/lib/pages/things_page/fixed_submit_page.dart +++ b/lib/pages/things_page/fixed_submit_page.dart @@ -1,8 +1,12 @@ import 'package:akuCommunity/base/base_style.dart'; +import 'package:akuCommunity/constants/api.dart'; +import 'package:akuCommunity/model/user/fixed_submit_model.dart'; +import 'package:akuCommunity/pages/things_page/widget/bee_list_view.dart'; import 'package:akuCommunity/pages/things_page/widget/image_grid.dart'; import 'package:akuCommunity/utils/bee_map.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:velocity_x/velocity_x.dart'; import 'package:akuCommunity/extensions/num_ext.dart'; @@ -15,42 +19,37 @@ class FixedSubmitPage extends StatefulWidget { _FixedSubmitPageState createState() => _FixedSubmitPageState(); } -class FixedSubmitMode { - int tag; - int state; - String text; - List images; - FixedSubmitMode(this.tag, this.state, this.text, this.images); -} - class _FixedSubmitPageState extends State { - List _model = [ - FixedSubmitMode(1, 0, '家里的冰箱坏了,师傅赶紧来看看', [ - 'https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=466219337,2269488732&fm=15&gp=0.jpg', - 'https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=907707978,1526051881&fm=26&gp=0.jpg', - ]), - FixedSubmitMode(0, 3, '我觉得我们小区的绿化可以再多一点', [ - 'https://dss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=111636878,534819054&fm=26&gp=0.jpg', - 'https://dss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=3834533673,769780989&fm=26&gp=0.jpg', - 'https://dss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=1683501076,3787404077&fm=26&gp=0.jpg', - 'https://dss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1040644610,2290865162&fm=26&gp=0.jpg', - ]), - ]; + EasyRefreshController _easyRefreshController; + @override + void initState() { + super.initState(); + _easyRefreshController = EasyRefreshController(); + } + + @override + void dispose() { + _easyRefreshController?.dispose(); + super.dispose(); + } + Color _getColor(int state) { switch (state) { - case 0: case 1: - return kDarkPrimaryColor; case 2: case 3: + return kDarkPrimaryColor; case 4: + case 5: + case 6: + case 7: return ktextSubColor; default: return kPrimaryColor; } } - Widget _buildCard(int fixedTag, int state, String text, List images) { + Widget _buildCard(FixedSubmitModel model) { return Container( decoration: BoxDecoration( color: kForeGroundColor, borderRadius: BorderRadius.circular(8.w)), @@ -61,7 +60,7 @@ class _FixedSubmitPageState extends State { Row( children: [ BeeMap() - .fixTag[fixedTag] + .fixTag[model.type] .text .color(ktextPrimary) .bold @@ -69,9 +68,9 @@ class _FixedSubmitPageState extends State { .make(), Spacer(), BeeMap() - .fixState[state] + .fixState[model.status] .text - .color(_getColor(state)) + .color(_getColor(model.status)) .size(24.sp) .make(), ], @@ -82,9 +81,16 @@ class _FixedSubmitPageState extends State { height: 0, ), 24.hb, - text.text.color(ktextSubColor).size(28.sp).ellipsis.make(), + model.reportDetail.text + .color(ktextSubColor) + .size(28.sp) + .ellipsis + .make(), 16.hb, - images.length != 0 ? ImageGrid(images) : SizedBox(), + model.imgUrls.length != 0 + ? ImageGrid(List.generate( + model.imgUrls.length, (index) => model.imgUrls[index].url)) + : SizedBox(), ], ), ); @@ -94,32 +100,70 @@ class _FixedSubmitPageState extends State { Widget build(BuildContext context) { return BeeScaffold( title: '报事报修', + // body: Column( + // children: [ + // Expanded( + // child: ListView( + // padding: EdgeInsets.all(32.w), + // children: [ + // ..._model + // .map((e) => _buildCard(e.tag, e.state, e.text, e.images)) + // .toList() + // ].sepWidget(separate: 24.hb), + // ), + // ), + // Padding( + // padding: + // EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom), + // child: MaterialButton( + // color: kPrimaryColor, + // onPressed: () {}, + // child: '新增'.text.bold.color(ktextPrimary).size(32.sp).make(), + // minWidth: double.infinity, + // height: 98.w, + // elevation: 0, + // materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + // padding: EdgeInsets.zero, + // ), + // ) + // ], + // ), body: Column( children: [ - Expanded( - child: ListView( - padding: EdgeInsets.all(32.w), - children: [ - ..._model - .map((e) => _buildCard(e.tag, e.state, e.text, e.images)) - .toList() - ].sepWidget(separate: 24.hb), - ), - ), - Padding( - padding: - EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom), - child: MaterialButton( - color: kPrimaryColor, - onPressed: () {}, - child: '新增'.text.bold.color(ktextPrimary).size(32.sp).make(), - minWidth: double.infinity, - height: 98.w, - elevation: 0, - materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, - padding: EdgeInsets.zero, - ), + BeeListView( + controller: _easyRefreshController, + path: API.manager.fixedSubmit, + convert: (model) { + return model.tableList + .map((e) => FixedSubmitModel.fromJson(e)) + .toList(); + }, + builder: (items) { + return ListView.separated( + padding: EdgeInsets.all(32.w), + itemBuilder: (context, index) { + return _buildCard(items[index]); + }, + separatorBuilder: (context, index) { + return 24.heightBox; + }, + itemCount: items.length); + }, + ).expand(), + MaterialButton( + onPressed: () {}, + child: '新增'.text.bold.color(ktextPrimary).size(32.sp).make(), + minWidth: double.infinity, + height: 98.w, + elevation: 0, + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + padding: EdgeInsets.zero, ) + .box + .padding(EdgeInsets.only( + bottom: MediaQuery.of(context).padding.bottom)) + .color(kPrimaryColor) + .make(), ], ), ); diff --git a/lib/utils/bee_map.dart b/lib/utils/bee_map.dart index 726b48db..139ff6f1 100644 --- a/lib/utils/bee_map.dart +++ b/lib/utils/bee_map.dart @@ -1,8 +1,8 @@ class BeeMap { Map fixTag = { - 0: '公区报修', - 1: '家庭报修', + 1: '公区报修', + 2: '家庭报修', }; - Map fixState = {0: '待分配', 1: '维修中', 2: '已处理',3:'已完成',4:'已取消'}; + Map fixState = {1: '待分配', 2: '未接单', 3: '处理中',4:'已处理',5:'已完成',6:'已关闭',7:'已作废'}; }