From 4617d6241c5a0a20986c0e0959605a726ec90404 Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Fri, 22 Jan 2021 18:08:03 +0800 Subject: [PATCH] update fixed submit module --- lib/constants/api.dart | 3 + lib/pages/manager_func.dart | 2 + lib/pages/things_page/fixed_submit_page.dart | 88 ++++++++++++------- .../widget/add_fixed_submit_page.dart | 44 +++++----- lib/utils/network/net_util.dart | 13 +++ lib/widget/horizontal_image_view.dart | 15 ++-- lib/widget/picker/grid_image_picker.dart | 7 +- 7 files changed, 107 insertions(+), 65 deletions(-) diff --git a/lib/constants/api.dart b/lib/constants/api.dart index 8ee04810..97e612de 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -92,4 +92,7 @@ class _Upload { ///上传头像 String get uploadAvatar => '/user/upload/appHeadSculpture'; + + ///上传报事报修信息 报事报修照片 + String get uploadRepair => '/user/upload/uploadRepair'; } diff --git a/lib/pages/manager_func.dart b/lib/pages/manager_func.dart index 02860aa4..22026628 100644 --- a/lib/pages/manager_func.dart +++ b/lib/pages/manager_func.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:akuCommunity/constants/api.dart'; import 'package:akuCommunity/utils/network/base_model.dart'; import 'package:akuCommunity/utils/network/net_util.dart'; diff --git a/lib/pages/things_page/fixed_submit_page.dart b/lib/pages/things_page/fixed_submit_page.dart index 60cb13be..1a68d7c4 100644 --- a/lib/pages/things_page/fixed_submit_page.dart +++ b/lib/pages/things_page/fixed_submit_page.dart @@ -78,7 +78,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, @@ -86,44 +86,59 @@ class _FixedSubmitPageState extends State { width: 686.w, decoration: BoxDecoration( color: kForeGroundColor, borderRadius: BorderRadius.circular(8.w)), - padding: EdgeInsets.symmetric(horizontal: 24.w, vertical: 24.w), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Row( - children: [ - BeeMap() - .fixTag[model.type] - .text - .color(ktextPrimary) - .bold - .size(32.sp) - .make(), - Spacer(), - BeeMap() - .fixState[model.status] - .text - .color(_getColor(model.status)) - .size(24.sp) - .make(), - ], + Padding( + padding: EdgeInsets.fromLTRB(24.w, 24.w, 24.w, 0), + child: Row( + children: [ + BeeMap() + .fixTag[model.type] + .text + .color(ktextPrimary) + .bold + .size(32.sp) + .make(), + Spacer(), + BeeMap() + .fixState[model.status] + .text + .color(_getColor(model.status)) + .size(24.sp) + .make(), + ], + ), ), 24.hb, - Divider( - thickness: 1.w, - height: 0, + Padding( + padding: EdgeInsets.symmetric( + horizontal: 24.w, + ), + child: Divider( + thickness: 1.w, + height: 0, + ), ), 24.hb, - model.reportDetail.text - .color(ktextSubColor) - .size(28.sp) - .ellipsis - .make(), - 16.hb, - model.imgUrls.length != 0 - ? HorizontalImageView(List.generate( - model.imgUrls.length, (index) => model.imgUrls[index].url)) - : SizedBox(), + Padding( + padding: EdgeInsets.symmetric( + horizontal: 24.w, + ), + child: model.reportDetail.text + .color(ktextSubColor) + .size(28.sp) + .ellipsis + .make(), + ), + // 16.hb, + Padding( + padding: EdgeInsets.only(left: 8.w), + child: model.imgUrls.length != 0 + ? HorizontalImageView(List.generate(model.imgUrls.length, + (index) => model.imgUrls[index].url)) + : SizedBox(), + ), ], ), ), @@ -157,10 +172,17 @@ class _FixedSubmitPageState extends State { }, ), CupertinoDialogAction( - child: '删除订单'.text.color(Color(0xFFFF8200)).size(34.sp).bold.isIntrinsic.make(), + child: '删除订单' + .text + .color(Color(0xFFFF8200)) + .size(34.sp) + .bold + .isIntrinsic + .make(), onPressed: () { ManagerFunc.reportRepairDelete(_selected); Get.back(); + _selected.clear(); _easyRefreshController.callRefresh(); }, ) diff --git a/lib/pages/things_page/widget/add_fixed_submit_page.dart b/lib/pages/things_page/widget/add_fixed_submit_page.dart index 5496c338..9ec02801 100644 --- a/lib/pages/things_page/widget/add_fixed_submit_page.dart +++ b/lib/pages/things_page/widget/add_fixed_submit_page.dart @@ -1,9 +1,16 @@ +import 'dart:io'; + import 'package:akuCommunity/base/base_style.dart'; +import 'package:akuCommunity/constants/api.dart'; import 'package:akuCommunity/pages/manager_func.dart'; import 'package:akuCommunity/pages/things_page/widget/finish_fixed_submit_page.dart'; import 'package:akuCommunity/provider/user_provider.dart'; +import 'package:akuCommunity/utils/network/base_model.dart'; +import 'package:akuCommunity/utils/network/net_util.dart'; import 'package:akuCommunity/widget/bee_divider.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart'; +import 'package:akuCommunity/widget/picker/grid_image_picker.dart'; +import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; @@ -25,6 +32,7 @@ class _AddFixedSubmitPageState extends State { String reportText; List _buttons = ['公区保修', '家庭维修']; int _selectType; + List _files; @override void initState() { super.initState(); @@ -170,26 +178,9 @@ class _AddFixedSubmitPageState extends State { children: [ '添加图片信息(${0}/9)'.text.black.size(28.sp).make(), 24.w.heightBox, - Row( - children: [ - InkWell( - onTap: () {}, - child: Container( - alignment: Alignment.center, - width: 218.w, - height: 218.w, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(8.w), - border: Border.all(color: Color(0xFF979797), width: 1.w), - ), - child: Icon( - CupertinoIcons.plus, - size: 80.w, - color:Color(0xFFD8D8D8) , - )), - ), - ], - ), + GridImagePicker(onChange: (files) { + _files = files; + }) ], ), ); @@ -217,10 +208,15 @@ class _AddFixedSubmitPageState extends State { MaterialButton( minWidth: double.infinity, height: 98.w, - onPressed: () { - ManagerFunc.reportRepairInsert( - _selectType + 1, _textEditingController.text, []); - FinishFixedSubmitPage().to(); + onPressed: () async { + List urls = + await NetUtil().uploadFiles(_files, API.upload.uploadRepair); + BaseModel baseModel = await ManagerFunc.reportRepairInsert( + _selectType + 1, _textEditingController.text, urls); + if (baseModel.status) { + FinishFixedSubmitPage().to(); + } else + BotToast.showText(text: baseModel.message); }, child: '确认提交'.text.black.bold.size(32.sp).make(), color: kPrimaryColor, diff --git a/lib/utils/network/net_util.dart b/lib/utils/network/net_util.dart index d7e95334..f10debb9 100644 --- a/lib/utils/network/net_util.dart +++ b/lib/utils/network/net_util.dart @@ -142,6 +142,19 @@ class NetUtil { return BaseFileModel.err(); } + Future> uploadFiles(List files, String api) async { + List urls = []; + if (urls.isEmpty) { + for (var item in files) { + BaseFileModel model = await NetUtil().upload(api, item); + urls.add(model.url); + } + } else + return []; + + return urls; + } + _parseErr(DioError err) { _logger.v({ 'type': err.type.toString(), diff --git a/lib/widget/horizontal_image_view.dart b/lib/widget/horizontal_image_view.dart index a712766c..dc24b105 100644 --- a/lib/widget/horizontal_image_view.dart +++ b/lib/widget/horizontal_image_view.dart @@ -25,15 +25,16 @@ class _HorizontalImageViewState extends State { itemBuilder: (context, index) { return Padding( padding: EdgeInsets.all(16.w), - // child: ClipRRect( - // borderRadius: BorderRadius.circular(8.w), - // child: FadeInImage.assetNetwork( - // placeholder: R.ASSETS_IMAGES_DRAWINGS_PNG, - // image: API.resource + widget.urls[index], - // ), - // ), + child: ClipRRect( + borderRadius: BorderRadius.circular(8.w), + child: FadeInImage.assetNetwork( + placeholder: R.ASSETS_ICONS_PROPOSAL_PNG, + image: API.image(widget.urls[index]), + ), + ), ); }, + itemCount: widget.urls.length, ), ); } diff --git a/lib/widget/picker/grid_image_picker.dart b/lib/widget/picker/grid_image_picker.dart index 49e8c42f..6353db73 100644 --- a/lib/widget/picker/grid_image_picker.dart +++ b/lib/widget/picker/grid_image_picker.dart @@ -106,7 +106,12 @@ class _GridImagePickerState extends State { mainAxisSpacing: 16.w, ), itemBuilder: (context, index) { - if (index == 0) return _buildSelect(); + if (index == 0) { + if (_files.length >= 9) { + return _buildItem(_files[8]); + } else + return _buildSelect(); + } return _buildItem(_files[index - 1]); }, itemCount: displayLength,