From 0225e33f5ed6ab5905c5c38cc3564ef11bbadd38 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Mon, 25 Jan 2021 10:38:43 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=BB=BA=E8=AE=AE?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=8D=A1=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/constants/api.dart | 3 + lib/pages/property/property_index.dart | 2 +- lib/ui/manager/advice/advice_card.dart | 55 +++++++++++++ lib/ui/manager/advice/advice_page.dart | 4 +- lib/ui/manager/advice/new_advice_page.dart | 92 +++++++++++++++++----- lib/utils/network/net_util.dart | 7 +- 6 files changed, 138 insertions(+), 25 deletions(-) create mode 100644 lib/ui/manager/advice/advice_card.dart diff --git a/lib/constants/api.dart b/lib/constants/api.dart index 5c32fcc3..a721c29a 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -87,6 +87,9 @@ class _Manager { ///咨询建议/投诉表扬:查询所有的app建议咨询/投诉表扬 信息(包含条件搜索 type 【类型(1.咨询,2.建议,3.投诉,4.表扬)】) String get advice => '/user/advice/list'; + + /// 咨询建议/投诉表扬:添加建议咨询/投诉表扬 信息 + String get addAdvice => '/user/advice/insert'; } class _Upload { diff --git a/lib/pages/property/property_index.dart b/lib/pages/property/property_index.dart index 6e8f2bab..2fddb6e0 100644 --- a/lib/pages/property/property_index.dart +++ b/lib/pages/property/property_index.dart @@ -69,7 +69,7 @@ class _PropertyIndexState extends State GoodsDetoPage().to(); }), GridButton('投诉表扬', R.ASSETS_ICONS_TOOL_TSBY_PNG, - AdvicePage(type: AdviceType.SUGGESTION).to), + AdvicePage(type: AdviceType.COMPLAIN).to), GridButton('问卷调查', R.ASSETS_ICONS_TOOL_WJDC_PNG, () { QuestionnairePage().to(); }), diff --git a/lib/ui/manager/advice/advice_card.dart b/lib/ui/manager/advice/advice_card.dart new file mode 100644 index 00000000..48ab75e9 --- /dev/null +++ b/lib/ui/manager/advice/advice_card.dart @@ -0,0 +1,55 @@ +import 'package:akuCommunity/model/manager/suggestion_or_complain_model.dart'; +import 'package:akuCommunity/utils/headers.dart'; +import 'package:common_utils/common_utils.dart'; +import 'package:flutter/material.dart'; +import 'package:velocity_x/velocity_x.dart'; + +class AdviceCard extends StatefulWidget { + final SuggestionOrComplainModel model; + AdviceCard({Key key, this.model}) : super(key: key); + + @override + _AdviceCardState createState() => _AdviceCardState(); +} + +class _AdviceCardState extends State { + ///1.未反馈,2.反馈中,3.已反馈 + String get statusValue => { + 1: '未反馈', + 2: '反馈中', + 3: '已反馈', + }[widget.model.status]; + @override + Widget build(BuildContext context) { + return MaterialButton( + elevation: 0, + padding: EdgeInsets.all(24.w), + color: Colors.white, + onPressed: () {}, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8.w), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + DateUtil.formatDate( + widget.model.createDate, + format: 'yyyy年MM月dd日', + ).text.size(32.sp).black.bold.make(), + statusValue.text.size(24.sp).color(Color(0xFFFF8200)).make(), + ], + ), + Divider( + height: 50.w, + thickness: 1.w, + color: Color(0xFFE8E8E8), + ), + widget.model.content.text.size(28.w).black.make(), + ], + ), + ); + } +} diff --git a/lib/ui/manager/advice/advice_page.dart b/lib/ui/manager/advice/advice_page.dart index a2eae033..91f17431 100644 --- a/lib/ui/manager/advice/advice_page.dart +++ b/lib/ui/manager/advice/advice_page.dart @@ -1,6 +1,7 @@ import 'package:akuCommunity/constants/api.dart'; import 'package:akuCommunity/model/manager/suggestion_or_complain_model.dart'; import 'package:akuCommunity/pages/things_page/widget/bee_list_view.dart'; +import 'package:akuCommunity/ui/manager/advice/advice_card.dart'; import 'package:akuCommunity/ui/manager/advice/new_advice_page.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart'; import 'package:akuCommunity/utils/headers.dart'; @@ -94,8 +95,9 @@ class _AdvicePageState extends State with TickerProviderStateMixin { .toList(), builder: (items) { return ListView.separated( + padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 20.w), itemBuilder: (context, index) { - return SizedBox(); + return AdviceCard(model: items[index]); }, separatorBuilder: (_, __) => 20.hb, itemCount: items.length, diff --git a/lib/ui/manager/advice/new_advice_page.dart b/lib/ui/manager/advice/new_advice_page.dart index 66d3a58c..0923f932 100644 --- a/lib/ui/manager/advice/new_advice_page.dart +++ b/lib/ui/manager/advice/new_advice_page.dart @@ -1,13 +1,19 @@ import 'dart:io'; import 'package:akuCommunity/const/resource.dart'; +import 'package:akuCommunity/constants/api.dart'; import 'package:akuCommunity/ui/manager/advice/advice_page.dart'; +import 'package:akuCommunity/utils/network/base_model.dart'; +import 'package:akuCommunity/utils/network/net_util.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart'; import 'package:akuCommunity/utils/headers.dart'; import 'package:akuCommunity/widget/buttons/bottom_button.dart'; import 'package:akuCommunity/widget/picker/grid_image_picker.dart'; +import 'package:bot_toast/bot_toast.dart'; +import 'package:common_utils/common_utils.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; import 'package:velocity_x/velocity_x.dart'; class NewAdvicePage extends StatefulWidget { @@ -21,6 +27,8 @@ class NewAdvicePage extends StatefulWidget { class _NewAdvicePageState extends State { int _type = 0; List _files = []; + TextEditingController _editingController = TextEditingController(); + GlobalKey _formKey = GlobalKey(); String get title { switch (widget.type) { case AdviceType.SUGGESTION: @@ -80,6 +88,32 @@ class _NewAdvicePageState extends State { ); } + ///添加建议咨询/投诉表扬 信息 + Future addAdvice(int type, List files, String content) async { + VoidCallback cancel = BotToast.showLoading(); + List urls = + await NetUtil().uploadFiles(files, API.upload.uploadArticle); + BaseModel baseModel = await NetUtil().post( + API.manager.addAdvice, + params: { + 'type': type, + 'content': content, + 'fileUrls': urls, + }, + showMessage: true, + ); + cancel(); + if (baseModel.status) { + Get.back(); + } + } + + @override + void dispose() { + _editingController.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { return BeeScaffold.white( @@ -102,28 +136,37 @@ class _NewAdvicePageState extends State { '您要选择的类型是?'.text.size(28.sp).make(), 32.hb, [ - _buildType(0, R.ASSETS_ICONS_PROPOSAL_PNG, '建议'), + _buildType(0, R.ASSETS_ICONS_PROPOSAL_PNG, + widget.type == AdviceType.SUGGESTION ? '建议' : '投诉'), 80.wb, - _buildType(1, R.ASSETS_ICONS_CONSULT_PNG, '咨询'), + _buildType(1, R.ASSETS_ICONS_CONSULT_PNG, + widget.type == AdviceType.SUGGESTION ? '咨询' : '表扬'), ].row(), 44.hb, '请输入内容'.text.size(28.sp).make(), 24.hb, - TextField( - // controller: , - minLines: 6, - maxLines: 99, - decoration: InputDecoration( - border: OutlineInputBorder(), - isDense: true, - contentPadding: EdgeInsets.symmetric( - horizontal: 22.w, - vertical: 32.w, - ), - hintText: '您对我们的工作有什么建议吗?欢迎您提给我们宝贵的建议,谢谢', - hintStyle: TextStyle( - fontSize: 28.sp, - color: Color(0xFF999999), + Form( + key: _formKey, + child: TextFormField( + controller: _editingController, + minLines: 6, + maxLines: 99, + validator: (text) { + if (TextUtil.isEmpty(text)) return '内容不能为空'; + return null; + }, + decoration: InputDecoration( + border: OutlineInputBorder(), + isDense: true, + contentPadding: EdgeInsets.symmetric( + horizontal: 22.w, + vertical: 32.w, + ), + hintText: '您对我们的工作有什么建议吗?欢迎您提给我们宝贵的建议,谢谢', + hintStyle: TextStyle( + fontSize: 28.sp, + color: Color(0xFF999999), + ), ), ), ), @@ -138,7 +181,20 @@ class _NewAdvicePageState extends State { ], ), bottomNavi: BottomButton( - onPressed: () {}, + onPressed: () { + if (_formKey.currentState.validate()) { + int type = 1; + switch (widget.type) { + case AdviceType.SUGGESTION: + type = _type == 0 ? 2 : 1; + break; + case AdviceType.COMPLAIN: + type = _type == 0 ? 4 : 3; + break; + } + addAdvice(type, _files, _editingController.text); + } + }, child: '确认提交'.text.make(), ), ); diff --git a/lib/utils/network/net_util.dart b/lib/utils/network/net_util.dart index f10debb9..0c44a1ea 100644 --- a/lib/utils/network/net_util.dart +++ b/lib/utils/network/net_util.dart @@ -144,14 +144,11 @@ class NetUtil { Future> uploadFiles(List files, String api) async { List urls = []; - if (urls.isEmpty) { - for (var item in files) { + for (var item in files) { BaseFileModel model = await NetUtil().upload(api, item); urls.add(model.url); } - } else - return []; - + if (urls.isEmpty) return []; return urls; } From 777cdbe51bcadad98bc48e043a2895abc11ca2be Mon Sep 17 00:00:00 2001 From: laiiihz Date: Mon, 25 Jan 2021 10:52:36 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=BB=BA=E8=AE=AE?= =?UTF-8?q?=E5=8D=A1=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/ui/manager/advice/advice_card.dart | 11 ++++++++--- lib/widget/horizontal_image_view.dart | 2 ++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/ui/manager/advice/advice_card.dart b/lib/ui/manager/advice/advice_card.dart index 48ab75e9..d4c11ee6 100644 --- a/lib/ui/manager/advice/advice_card.dart +++ b/lib/ui/manager/advice/advice_card.dart @@ -1,5 +1,6 @@ import 'package:akuCommunity/model/manager/suggestion_or_complain_model.dart'; import 'package:akuCommunity/utils/headers.dart'; +import 'package:akuCommunity/widget/horizontal_image_view.dart'; import 'package:common_utils/common_utils.dart'; import 'package:flutter/material.dart'; import 'package:velocity_x/velocity_x.dart'; @@ -23,7 +24,7 @@ class _AdviceCardState extends State { Widget build(BuildContext context) { return MaterialButton( elevation: 0, - padding: EdgeInsets.all(24.w), + padding: EdgeInsets.zero, color: Colors.white, onPressed: () {}, shape: RoundedRectangleBorder( @@ -32,6 +33,7 @@ class _AdviceCardState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ + 20.hb, Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ @@ -41,13 +43,16 @@ class _AdviceCardState extends State { ).text.size(32.sp).black.bold.make(), statusValue.text.size(24.sp).color(Color(0xFFFF8200)).make(), ], - ), + ).pSymmetric(h: 28.w), Divider( + indent: 28.w, + endIndent: 28.w, height: 50.w, thickness: 1.w, color: Color(0xFFE8E8E8), ), - widget.model.content.text.size(28.w).black.make(), + widget.model.content.text.size(28.w).black.make().pSymmetric(h: 28.w), + HorizontalImageView(widget.model.imgUrls.map((e) => e.url).toList()), ], ), ); diff --git a/lib/widget/horizontal_image_view.dart b/lib/widget/horizontal_image_view.dart index dc24b105..020249db 100644 --- a/lib/widget/horizontal_image_view.dart +++ b/lib/widget/horizontal_image_view.dart @@ -1,4 +1,5 @@ import 'package:akuCommunity/constants/api.dart'; +import 'package:akuCommunity/utils/headers.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -18,6 +19,7 @@ class HorizontalImageView extends StatefulWidget { class _HorizontalImageViewState extends State { @override Widget build(BuildContext context) { + if (widget.urls.isEmpty) return 15.hb; return Container( height: 184.w + 24.w, child: ListView.builder(