对接 意见反馈

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

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

@ -3,13 +3,10 @@ import 'dart:io';
class InspectionPointSubmitModel {
int executePointId;
List<ExecuteCheckList> executeCheckList;
File inspectionFaceImg;
File inspectionSpaceImg;
List<String> inspectionFaceImgPath;
List<String> inspectionSpaceImgPath;
InspectionPointSubmitModel(this.executePointId, this.executeCheckList,
{this.inspectionFaceImg,
this.inspectionSpaceImg,
{
this.inspectionFaceImgPath,
this.inspectionSpaceImgPath});
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_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<InspectionPointInputPage> {
InspectionPointSubmitModel _submitModel;
InspectionQRCodeModel _model;
List<File> _selfPhotos;
List<File> _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<InspectionPointInputPage> {
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<InspectionPointInputPage> {
),
32.w.heightBox,
AkuPickImageWidget(
onChanged: (file) {
_submitModel.inspectionFaceImg = file;
onChanged: (files) {
_selfPhotos = files;
setState(() {});
},
),
@ -145,8 +149,8 @@ class _InspectionPointInputPageState extends State<InspectionPointInputPage> {
),
32.w.heightBox,
AkuPickImageWidget(
onChanged: (file) {
_submitModel.inspectionSpaceImg = file;
onChanged: (files) {
_scenePhots = files;
setState(() {});
},
)

@ -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<SettingFeedBackPage> {
List<File> _files;
List<String> _imgeUrls;
String _content;
@override
Widget build(BuildContext context) {
return AkuScaffold(
@ -35,9 +46,13 @@ class _SettingFeedBackPageState extends State<SettingFeedBackPage> {
),
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<SettingFeedBackPage> {
),
),
),
AkuPickImageWidget(
size: 202.w,
onChanged: (newFile) {
_files = newFile;
},
)
],
),
decoration: BoxDecoration(
@ -60,7 +81,21 @@ class _SettingFeedBackPageState extends State<SettingFeedBackPage> {
],
),
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,
),

@ -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;
}
}

@ -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<File> 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<AkuPickImageWidget> {
File _file;
List<File> _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(() {});
}),
)
]);
}
}

Loading…
Cancel
Save