对接 意见反馈

对接 意见反馈照片上传
修改添加照片组件 支持添加多张
hmxc
张萌 4 years ago
parent c99b553dfa
commit a1c941044c

@ -47,6 +47,9 @@ class _User {
/// ///
String get updateAvatar => '/user/personalData/updateHeadPortrait'; String get updateAvatar => '/user/personalData/updateHeadPortrait';
///app
String get feedbackSubmit => '/user/feedback/submit';
} }
class _Manage { class _Manage {
@ -203,6 +206,9 @@ class _Upload {
/// ///
String get uploadInspectionFace => '/user/upload/uploadInspectionFace'; String get uploadInspectionFace => '/user/upload/uploadInspectionFace';
///
String get uploadAdvices => '/user/upload/uploadAdvice';
} }
class _Message { class _Message {

@ -3,13 +3,10 @@ import 'dart:io';
class InspectionPointSubmitModel { class InspectionPointSubmitModel {
int executePointId; int executePointId;
List<ExecuteCheckList> executeCheckList; List<ExecuteCheckList> executeCheckList;
File inspectionFaceImg;
File inspectionSpaceImg;
List<String> inspectionFaceImgPath; List<String> inspectionFaceImgPath;
List<String> inspectionSpaceImgPath; List<String> inspectionSpaceImgPath;
InspectionPointSubmitModel(this.executePointId, this.executeCheckList, InspectionPointSubmitModel(this.executePointId, this.executeCheckList,
{this.inspectionFaceImg, {
this.inspectionSpaceImg,
this.inspectionFaceImgPath, this.inspectionFaceImgPath,
this.inspectionSpaceImgPath}); this.inspectionSpaceImgPath});
Map<String, dynamic> executeCheckListToJson() { Map<String, dynamic> executeCheckListToJson() {

@ -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_point_submit_model.dart';
import 'package:aku_community_manager/models/manager/inspection/inspection_qrcode_model.dart'; import 'package:aku_community_manager/models/manager/inspection/inspection_qrcode_model.dart';
import 'package:aku_community_manager/style/app_style.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/app_widgets/aku_single_check_button.dart';
import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.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/base_model.dart';
import 'package:aku_community_manager/utils/network/net_util.dart';
import 'package:aku_ui/aku_ui.dart'; import 'package:aku_ui/aku_ui.dart';
import 'package:bot_toast/bot_toast.dart'; import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -28,9 +32,11 @@ class InspectionPointInputPage extends StatefulWidget {
class _InspectionPointInputPageState extends State<InspectionPointInputPage> { class _InspectionPointInputPageState extends State<InspectionPointInputPage> {
InspectionPointSubmitModel _submitModel; InspectionPointSubmitModel _submitModel;
InspectionQRCodeModel _model; InspectionQRCodeModel _model;
List<File> _selfPhotos;
List<File> _scenePhots;
bool get canSubmit { bool get canSubmit {
if (_submitModel.inspectionFaceImg == null && if (_selfPhotos == null &&
_submitModel.inspectionSpaceImg == null) { _scenePhots == null) {
return false; return false;
} else { } else {
if (_submitModel.executeCheckList.isNotEmpty) { if (_submitModel.executeCheckList.isNotEmpty) {
@ -79,13 +85,11 @@ class _InspectionPointInputPageState extends State<InspectionPointInputPage> {
bottom: AkuButton( bottom: AkuButton(
onPressed: canSubmit onPressed: canSubmit
? () async { ? () async {
_submitModel.inspectionFaceImgPath.add( _submitModel.inspectionFaceImgPath = await NetUtil()
await ManageFunc.uploadFace( .uploadFiles(_selfPhotos, API.upload.uploadInspectionFace);
_submitModel.inspectionFaceImg));
_submitModel.inspectionSpaceImgPath.add( _submitModel.inspectionSpaceImgPath = await NetUtil()
await ManageFunc.uploadSpace( .uploadFiles(_scenePhots, API.upload.uploadInspectionSpace);
_submitModel.inspectionSpaceImg));
BaseModel baseModel = BaseModel baseModel =
await ManageFunc.getSubmitPoint(_submitModel); await ManageFunc.getSubmitPoint(_submitModel);
if (baseModel.status) { if (baseModel.status) {
@ -121,8 +125,8 @@ class _InspectionPointInputPageState extends State<InspectionPointInputPage> {
), ),
32.w.heightBox, 32.w.heightBox,
AkuPickImageWidget( AkuPickImageWidget(
onChanged: (file) { onChanged: (files) {
_submitModel.inspectionFaceImg = file; _selfPhotos = files;
setState(() {}); setState(() {});
}, },
), ),
@ -145,8 +149,8 @@ class _InspectionPointInputPageState extends State<InspectionPointInputPage> {
), ),
32.w.heightBox, 32.w.heightBox,
AkuPickImageWidget( AkuPickImageWidget(
onChanged: (file) { onChanged: (files) {
_submitModel.inspectionSpaceImg = file; _scenePhots = files;
setState(() {}); setState(() {});
}, },
) )

@ -1,4 +1,11 @@
// Flutter imports: // 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'; import 'package:flutter/material.dart';
// Package imports: // 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/style/app_style.dart';
import 'package:aku_community_manager/tools/screen_tool.dart'; import 'package:aku_community_manager/tools/screen_tool.dart';
import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart';
import 'package:get/get.dart';
class SettingFeedBackPage extends StatefulWidget { class SettingFeedBackPage extends StatefulWidget {
SettingFeedBackPage({Key key}) : super(key: key); SettingFeedBackPage({Key key}) : super(key: key);
@ -17,6 +25,9 @@ class SettingFeedBackPage extends StatefulWidget {
} }
class _SettingFeedBackPageState extends State<SettingFeedBackPage> { class _SettingFeedBackPageState extends State<SettingFeedBackPage> {
List<File> _files;
List<String> _imgeUrls;
String _content;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return AkuScaffold( return AkuScaffold(
@ -35,9 +46,13 @@ class _SettingFeedBackPageState extends State<SettingFeedBackPage> {
), ),
padding: EdgeInsets.all(24.w), padding: EdgeInsets.all(24.w),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
TextField( TextField(
onChanged: (value) {
_content = value;
},
minLines: 5, minLines: 5,
maxLines: 99, maxLines: 99,
decoration: InputDecoration( decoration: InputDecoration(
@ -50,6 +65,12 @@ class _SettingFeedBackPageState extends State<SettingFeedBackPage> {
), ),
), ),
), ),
AkuPickImageWidget(
size: 202.w,
onChanged: (newFile) {
_files = newFile;
},
)
], ],
), ),
decoration: BoxDecoration( decoration: BoxDecoration(
@ -60,7 +81,21 @@ class _SettingFeedBackPageState extends State<SettingFeedBackPage> {
], ],
), ),
bottom: AkuMaterialButton( 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('提交'), child: Text('提交'),
color: AppStyle.minorColor, color: AppStyle.minorColor,
), ),

@ -2,7 +2,6 @@ import 'dart:io';
import 'package:aku_community_manager/const/api.dart'; 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/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_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_model.dart';
import 'package:aku_community_manager/models/manager/inspection/inspection_point_submit_model.dart'; import 'package:aku_community_manager/models/manager/inspection/inspection_point_submit_model.dart';
@ -92,16 +91,4 @@ class ManageFunc {
}); });
return baseModel; 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;
}
} }

@ -8,10 +8,11 @@ import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:aku_community_manager/const/resource.dart'; import 'package:aku_community_manager/const/resource.dart';
import 'package:velocity_x/velocity_x.dart'; import 'package:velocity_x/velocity_x.dart';
import 'package:aku_community_manager/utils/extension/list_extension.dart';
class AkuPickImageWidget extends StatefulWidget { class AkuPickImageWidget extends StatefulWidget {
final double size; final double size;
final Function(File file) onChanged; final Function(List<File> files) onChanged;
AkuPickImageWidget({Key key, this.size, this.onChanged}) : super(key: key); AkuPickImageWidget({Key key, this.size, this.onChanged}) : super(key: key);
@override @override
@ -19,44 +20,20 @@ class AkuPickImageWidget extends StatefulWidget {
} }
class _AkuPickImageWidgetState extends State<AkuPickImageWidget> { class _AkuPickImageWidgetState extends State<AkuPickImageWidget> {
File _file; List<File> _files = [];
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return _file != null return Row(
? Stack(children: [ children: [
Container( ..._files?.map((e) => showImage(e))?.toList(),
width: widget.size ?? 160.w, GestureDetector(
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 { onTap: () async {
await akuPickImage().then((value) => _file = File(value.path)); await akuPickImage().then(
widget.onChanged(_file); (value) => _files.add(
File(value.path),
),
);
widget.onChanged(_files);
setState(() {}); setState(() {});
}, },
child: DottedBorder( child: DottedBorder(
@ -84,6 +61,40 @@ class _AkuPickImageWidgetState extends State<AkuPickImageWidget> {
), ),
), ),
).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(() {});
}),
)
]);
}
} }

Loading…
Cancel
Save