From a1c941044c99aa2209d873d1b218de49aa542ce3 Mon Sep 17 00:00:00 2001 From: zhangmeng <494089941@qq.com> Date: Thu, 8 Apr 2021 16:10:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=8E=A5=20=E6=84=8F=E8=A7=81?= =?UTF-8?q?=E5=8F=8D=E9=A6=88=20=E5=AF=B9=E6=8E=A5=20=E6=84=8F=E8=A7=81?= =?UTF-8?q?=E5=8F=8D=E9=A6=88=E7=85=A7=E7=89=87=E4=B8=8A=E4=BC=A0=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B7=BB=E5=8A=A0=E7=85=A7=E7=89=87=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=20=E6=94=AF=E6=8C=81=E6=B7=BB=E5=8A=A0=E5=A4=9A?= =?UTF-8?q?=E5=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/const/api.dart | 6 + .../inspection_point_submit_model.dart | 5 +- .../inspection_point_input_page.dart | 28 ++-- lib/ui/settings/setting_feedback_page.dart | 37 ++++- lib/ui/sub_pages/manage_func.dart | 13 -- .../app_widgets/aku_pick_image_widget.dart | 135 ++++++++++-------- 6 files changed, 132 insertions(+), 92 deletions(-) diff --git a/lib/const/api.dart b/lib/const/api.dart index a443b43..969a5cc 100644 --- a/lib/const/api.dart +++ b/lib/const/api.dart @@ -47,6 +47,9 @@ class _User { ///个人资料:修改管家用户头像 String get updateAvatar => '/user/personalData/updateHeadPortrait'; + + ///意见反馈:管家app意见反馈提交(建议) + String get feedbackSubmit => '/user/feedback/submit'; } class _Manage { @@ -203,6 +206,9 @@ class _Upload { ///上传巡更人员自拍人脸 String get uploadInspectionFace => '/user/upload/uploadInspectionFace'; + + ///上传咨询建议照片 + String get uploadAdvices => '/user/upload/uploadAdvice'; } class _Message { diff --git a/lib/models/manager/inspection/inspection_point_submit_model.dart b/lib/models/manager/inspection/inspection_point_submit_model.dart index 34c4e16..3d3d7d4 100644 --- a/lib/models/manager/inspection/inspection_point_submit_model.dart +++ b/lib/models/manager/inspection/inspection_point_submit_model.dart @@ -3,13 +3,10 @@ import 'dart:io'; class InspectionPointSubmitModel { int executePointId; List executeCheckList; - File inspectionFaceImg; - File inspectionSpaceImg; List inspectionFaceImgPath; List inspectionSpaceImgPath; InspectionPointSubmitModel(this.executePointId, this.executeCheckList, - {this.inspectionFaceImg, - this.inspectionSpaceImg, + { this.inspectionFaceImgPath, this.inspectionSpaceImgPath}); Map executeCheckListToJson() { diff --git a/lib/ui/manage_pages/inspection_manage/inspection_point_input_page.dart b/lib/ui/manage_pages/inspection_manage/inspection_point_input_page.dart index bda4e8a..be49a84 100644 --- a/lib/ui/manage_pages/inspection_manage/inspection_point_input_page.dart +++ b/lib/ui/manage_pages/inspection_manage/inspection_point_input_page.dart @@ -1,3 +1,6 @@ +import 'dart:io'; + +import 'package:aku_community_manager/const/api.dart'; import 'package:aku_community_manager/models/manager/inspection/inspection_point_submit_model.dart'; import 'package:aku_community_manager/models/manager/inspection/inspection_qrcode_model.dart'; import 'package:aku_community_manager/style/app_style.dart'; @@ -7,6 +10,7 @@ import 'package:aku_community_manager/ui/widgets/app_widgets/aku_pick_image_widg import 'package:aku_community_manager/ui/widgets/app_widgets/aku_single_check_button.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; import 'package:aku_community_manager/utils/network/base_model.dart'; +import 'package:aku_community_manager/utils/network/net_util.dart'; import 'package:aku_ui/aku_ui.dart'; import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/material.dart'; @@ -28,9 +32,11 @@ class InspectionPointInputPage extends StatefulWidget { class _InspectionPointInputPageState extends State { InspectionPointSubmitModel _submitModel; InspectionQRCodeModel _model; + List _selfPhotos; + List _scenePhots; bool get canSubmit { - if (_submitModel.inspectionFaceImg == null && - _submitModel.inspectionSpaceImg == null) { + if (_selfPhotos == null && + _scenePhots == null) { return false; } else { if (_submitModel.executeCheckList.isNotEmpty) { @@ -79,13 +85,11 @@ class _InspectionPointInputPageState extends State { bottom: AkuButton( onPressed: canSubmit ? () async { - _submitModel.inspectionFaceImgPath.add( - await ManageFunc.uploadFace( - _submitModel.inspectionFaceImg)); + _submitModel.inspectionFaceImgPath = await NetUtil() + .uploadFiles(_selfPhotos, API.upload.uploadInspectionFace); - _submitModel.inspectionSpaceImgPath.add( - await ManageFunc.uploadSpace( - _submitModel.inspectionSpaceImg)); + _submitModel.inspectionSpaceImgPath = await NetUtil() + .uploadFiles(_scenePhots, API.upload.uploadInspectionSpace); BaseModel baseModel = await ManageFunc.getSubmitPoint(_submitModel); if (baseModel.status) { @@ -121,8 +125,8 @@ class _InspectionPointInputPageState extends State { ), 32.w.heightBox, AkuPickImageWidget( - onChanged: (file) { - _submitModel.inspectionFaceImg = file; + onChanged: (files) { + _selfPhotos = files; setState(() {}); }, ), @@ -145,8 +149,8 @@ class _InspectionPointInputPageState extends State { ), 32.w.heightBox, AkuPickImageWidget( - onChanged: (file) { - _submitModel.inspectionSpaceImg = file; + onChanged: (files) { + _scenePhots = files; setState(() {}); }, ) diff --git a/lib/ui/settings/setting_feedback_page.dart b/lib/ui/settings/setting_feedback_page.dart index b8027cd..e97bbab 100644 --- a/lib/ui/settings/setting_feedback_page.dart +++ b/lib/ui/settings/setting_feedback_page.dart @@ -1,4 +1,11 @@ // Flutter imports: +import 'dart:io'; + +import 'package:aku_community_manager/const/api.dart'; +import 'package:aku_community_manager/ui/widgets/app_widgets/aku_pick_image_widget.dart'; +import 'package:aku_community_manager/utils/network/base_model.dart'; +import 'package:aku_community_manager/utils/network/net_util.dart'; +import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/material.dart'; // Package imports: @@ -8,6 +15,7 @@ import 'package:aku_ui/common_widgets/aku_material_button.dart'; import 'package:aku_community_manager/style/app_style.dart'; import 'package:aku_community_manager/tools/screen_tool.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; +import 'package:get/get.dart'; class SettingFeedBackPage extends StatefulWidget { SettingFeedBackPage({Key key}) : super(key: key); @@ -17,6 +25,9 @@ class SettingFeedBackPage extends StatefulWidget { } class _SettingFeedBackPageState extends State { + List _files; + List _imgeUrls; + String _content; @override Widget build(BuildContext context) { return AkuScaffold( @@ -35,9 +46,13 @@ class _SettingFeedBackPageState extends State { ), padding: EdgeInsets.all(24.w), child: Column( + crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ TextField( + onChanged: (value) { + _content = value; + }, minLines: 5, maxLines: 99, decoration: InputDecoration( @@ -50,6 +65,12 @@ class _SettingFeedBackPageState extends State { ), ), ), + AkuPickImageWidget( + size: 202.w, + onChanged: (newFile) { + _files = newFile; + }, + ) ], ), decoration: BoxDecoration( @@ -60,7 +81,21 @@ class _SettingFeedBackPageState extends State { ], ), bottom: AkuMaterialButton( - onPressed: () {}, + onPressed: () async { + _imgeUrls = + await NetUtil().uploadFiles(_files, API.upload.uploadAdvices); + BaseModel baseModel = + await NetUtil().post(API.user.feedbackSubmit, params: { + "content": _content, + "fileUrls": _imgeUrls, + }); + if (baseModel.status) { + BotToast.showText(text: baseModel.message); + Get.back(); + } else { + BotToast.showText(text: baseModel.message); + } + }, child: Text('提交'), color: AppStyle.minorColor, ), diff --git a/lib/ui/sub_pages/manage_func.dart b/lib/ui/sub_pages/manage_func.dart index 1968a88..b530466 100644 --- a/lib/ui/sub_pages/manage_func.dart +++ b/lib/ui/sub_pages/manage_func.dart @@ -2,7 +2,6 @@ import 'dart:io'; import 'package:aku_community_manager/const/api.dart'; import 'package:aku_community_manager/models/manager/decoration/decoration_detail_model.dart'; -import 'package:aku_community_manager/models/manager/inspection/inspection_check_detail_model.dart'; import 'package:aku_community_manager/models/manager/inspection/inspection_detail_model.dart'; import 'package:aku_community_manager/models/manager/inspection/inspection_point_model.dart'; import 'package:aku_community_manager/models/manager/inspection/inspection_point_submit_model.dart'; @@ -92,16 +91,4 @@ class ManageFunc { }); return baseModel; } - - static Future uploadFace(File file) async { - BaseModel baseModel = await NetUtil() - .post(API.upload.uploadInspectionFace, params: {"file": file}); - return baseModel.data as String; - } - - static Future uploadSpace(File file) async { - BaseModel baseModel = await NetUtil() - .post(API.upload.uploadInspectionSpace, params: {"file": file}); - return baseModel.data as String; - } } diff --git a/lib/ui/widgets/app_widgets/aku_pick_image_widget.dart b/lib/ui/widgets/app_widgets/aku_pick_image_widget.dart index e630a6a..16f2f19 100644 --- a/lib/ui/widgets/app_widgets/aku_pick_image_widget.dart +++ b/lib/ui/widgets/app_widgets/aku_pick_image_widget.dart @@ -8,10 +8,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:aku_community_manager/const/resource.dart'; import 'package:velocity_x/velocity_x.dart'; +import 'package:aku_community_manager/utils/extension/list_extension.dart'; class AkuPickImageWidget extends StatefulWidget { final double size; - final Function(File file) onChanged; + final Function(List files) onChanged; AkuPickImageWidget({Key key, this.size, this.onChanged}) : super(key: key); @override @@ -19,71 +20,81 @@ class AkuPickImageWidget extends StatefulWidget { } class _AkuPickImageWidgetState extends State { - File _file; + List _files = []; @override Widget build(BuildContext context) { - return _file != null - ? Stack(children: [ - Container( + return Row( + children: [ + ..._files?.map((e) => showImage(e))?.toList(), + GestureDetector( + onTap: () async { + await akuPickImage().then( + (value) => _files.add( + File(value.path), + ), + ); + widget.onChanged(_files); + setState(() {}); + }, + child: DottedBorder( + color: Color(0xFF999999), + borderType: BorderType.RRect, + strokeWidth: 2.w, + dashPattern: [6, 3], + radius: Radius.circular(8.w), + child: Container( width: widget.size ?? 160.w, height: widget.size ?? 160.w, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(8.w), - color: kBackgroundColor), - child: Image.file(_file), - ), - Positioned( - top: 8.w, - right: 8.w, - child: Container( - width: 40.w, - height: 40.w, - child: Icon( - CupertinoIcons.xmark, - size: 20.w, - color: Colors.white, - ), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(20.w), - color: Color(0xFF000000), - ), - ).onTap(() { - _file = null; - setState(() {}); - }), - ) - ]) - : GestureDetector( - onTap: () async { - await akuPickImage().then((value) => _file = File(value.path)); - widget.onChanged(_file); - setState(() {}); - }, - child: DottedBorder( - color: Color(0xFF999999), - borderType: BorderType.RRect, - strokeWidth: 2.w, - dashPattern: [6, 3], - radius: Radius.circular(8.w), - child: Container( - width: widget.size ?? 160.w, - height: widget.size ?? 160.w, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Image.asset( - R.ASSETS_MANAGE_IC_IMAGE_PNG, - width: 60.w, - height: 60.w, - color: Color(0xFF999999), - ), - 4.w.heightBox, - '上传图片'.text.color(kTextSubColor).size(22.sp).bold.make(), - ], - ), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Image.asset( + R.ASSETS_MANAGE_IC_IMAGE_PNG, + width: 60.w, + height: 60.w, + color: Color(0xFF999999), + ), + 4.w.heightBox, + '上传图片'.text.color(kTextSubColor).size(22.sp).bold.make(), + ], ), - ).material(color: Colors.transparent), - ); + ), + ).material(color: Colors.transparent), + ) + ].sepWidget(separate: 10.w.widthBox), + ); + } + + Widget showImage(File file) { + return Stack(children: [ + Container( + width: widget.size ?? 160.w, + height: widget.size ?? 160.w, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(8.w), color: kBackgroundColor), + child: Image.file(file), + ), + Positioned( + top: 8.w, + right: 8.w, + child: Container( + width: 40.w, + height: 40.w, + child: Icon( + CupertinoIcons.xmark, + size: 20.w, + color: Colors.white, + ), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(20.w), + color: Color(0xFF000000), + ), + ).onTap(() { + _files.remove(file); + setState(() {}); + }), + ) + ]); } }