diff --git a/lib/constants/api.dart b/lib/constants/api.dart index 68572bfe..4bf44669 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -90,8 +90,12 @@ class _Manager { ///报事报修:app根据用户id和报事报修主键id查询报事报修详情(报修信息详情) String get reportRepairFindBYLD => '/user/reportRepair/findById'; + /// 咨询建议/投诉表扬:添加建议咨询/投诉表扬 信息 String get addAdvice => '/user/advice/insert'; + + ///建议详情 + String get adviceDetail => '/user/advice/findAdviceDetailByAdviceId'; } class _Upload { diff --git a/lib/pages/community/widget/trend_card.dart b/lib/pages/community/widget/trend_card.dart index eb85b937..659eeb23 100644 --- a/lib/pages/community/widget/trend_card.dart +++ b/lib/pages/community/widget/trend_card.dart @@ -1,6 +1,6 @@ import 'dart:ui'; import 'package:akuCommunity/base/base_style.dart'; -import 'package:akuCommunity/widget/horizontal_image_view.dart'; +import 'package:akuCommunity/widget/views/horizontal_image_view.dart'; import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; diff --git a/lib/pages/goods_details/widget/goods_comments_card.dart b/lib/pages/goods_details/widget/goods_comments_card.dart index 3206d26f..4963b6c1 100644 --- a/lib/pages/goods_details/widget/goods_comments_card.dart +++ b/lib/pages/goods_details/widget/goods_comments_card.dart @@ -1,4 +1,4 @@ -import 'package:akuCommunity/widget/horizontal_image_view.dart'; +import 'package:akuCommunity/widget/views/horizontal_image_view.dart'; import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter_icons/flutter_icons.dart'; diff --git a/lib/pages/things_page/fixed_submit_page.dart b/lib/pages/things_page/fixed_submit_page.dart index cac0cd42..f95e05d0 100644 --- a/lib/pages/things_page/fixed_submit_page.dart +++ b/lib/pages/things_page/fixed_submit_page.dart @@ -8,7 +8,7 @@ import 'package:akuCommunity/pages/things_page/widget/fixed_check_box.dart'; import 'package:akuCommunity/provider/user_provider.dart'; import 'package:akuCommunity/utils/bee_map.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart'; -import 'package:akuCommunity/widget/horizontal_image_view.dart'; +import 'package:akuCommunity/widget/views/horizontal_image_view.dart'; import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; diff --git a/lib/pages/things_page/things_detail_page/things_detail_page.dart b/lib/pages/things_page/things_detail_page/things_detail_page.dart index fb553faa..ec5702b0 100644 --- a/lib/pages/things_page/things_detail_page/things_detail_page.dart +++ b/lib/pages/things_page/things_detail_page/things_detail_page.dart @@ -1,6 +1,6 @@ import 'package:akuCommunity/pages/things_page/things_evaluate_page/things_evaluate_page.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart'; -import 'package:akuCommunity/widget/horizontal_image_view.dart'; +import 'package:akuCommunity/widget/views/horizontal_image_view.dart'; import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:akuCommunity/utils/headers.dart'; diff --git a/lib/pages/things_page/widget/things_card.dart b/lib/pages/things_page/widget/things_card.dart index af30c4a1..81a6766a 100644 --- a/lib/pages/things_page/widget/things_card.dart +++ b/lib/pages/things_page/widget/things_card.dart @@ -1,5 +1,5 @@ import 'package:akuCommunity/pages/things_page/things_detail_page/things_detail_page.dart'; -import 'package:akuCommunity/widget/horizontal_image_view.dart'; +import 'package:akuCommunity/widget/views/horizontal_image_view.dart'; import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:akuCommunity/utils/headers.dart'; diff --git a/lib/ui/manager/advice/advice_card.dart b/lib/ui/manager/advice/advice_card.dart index ea6bfb73..dbdb1214 100644 --- a/lib/ui/manager/advice/advice_card.dart +++ b/lib/ui/manager/advice/advice_card.dart @@ -1,7 +1,7 @@ import 'package:akuCommunity/model/manager/suggestion_or_complain_model.dart'; import 'package:akuCommunity/ui/manager/advice/advice_detail_page.dart'; import 'package:akuCommunity/utils/headers.dart'; -import 'package:akuCommunity/widget/horizontal_image_view.dart'; +import 'package:akuCommunity/widget/views/horizontal_image_view.dart'; import 'package:common_utils/common_utils.dart'; import 'package:flutter/material.dart'; import 'package:velocity_x/velocity_x.dart'; @@ -27,7 +27,7 @@ class _AdviceCardState extends State { elevation: 0, padding: EdgeInsets.zero, color: Colors.white, - onPressed: AdviceDetailPage(type: widget.model.type).to, + onPressed: AdviceDetailPage(model: widget.model).to, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(8.w), ), diff --git a/lib/ui/manager/advice/advice_detail_page.dart b/lib/ui/manager/advice/advice_detail_page.dart index 8f7695e9..47984121 100644 --- a/lib/ui/manager/advice/advice_detail_page.dart +++ b/lib/ui/manager/advice/advice_detail_page.dart @@ -1,16 +1,21 @@ +import 'package:akuCommunity/base/base_style.dart'; +import 'package:akuCommunity/constants/api.dart'; import 'package:akuCommunity/model/manager/advice_detail_model.dart'; -import 'package:akuCommunity/ui/manager/advice/advice_page.dart'; +import 'package:akuCommunity/model/manager/suggestion_or_complain_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/views/bee_grid_image_view.dart'; +import 'package:common_utils/common_utils.dart'; +import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:shimmer/shimmer.dart'; import 'package:velocity_x/velocity_x.dart'; class AdviceDetailPage extends StatefulWidget { - final int type; - AdviceDetailPage({Key key, @required this.type}) : super(key: key); + final SuggestionOrComplainModel model; + AdviceDetailPage({Key key, @required this.model}) : super(key: key); @override _AdviceDetailPageState createState() => _AdviceDetailPageState(); @@ -21,7 +26,7 @@ class _AdviceDetailPageState extends State { EasyRefreshController _refreshController = EasyRefreshController(); AdviceDetailModel _model; String get adviceValue { - switch (widget.type) { + switch (widget.model.type) { case 1: return '咨询'; case 2: @@ -35,28 +40,42 @@ class _AdviceDetailPageState extends State { } _buildShimmer() { - return Shimmer.fromColors( - child: Padding( - padding: EdgeInsets.all(32.w), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - VxBox().height(53.w).width(152.w).color(Colors.white).make(), - 30.hb, - VxBox().height(40.w).width(600.w).color(Colors.white).make(), - 24.hb, - VxBox().height(33.w).width(263.w).color(Colors.white).make(), - 50.hb, - VxBox().height(53.w).width(152.w).color(Colors.white).make(), - 30.hb, - VxBox().height(40.w).width(600.w).color(Colors.white).make(), - 24.hb, - VxBox().height(33.w).width(263.w).color(Colors.white).make(), - ], - ), + return Padding( + padding: EdgeInsets.all(32.w), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Shimmer.fromColors( + baseColor: Colors.black12, + highlightColor: Colors.white10, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + VxBox().height(53.w).width(152.w).color(Colors.white).make(), + 30.hb, + VxBox().height(40.w).width(600.w).color(Colors.white).make(), + 24.hb, + VxBox().height(33.w).width(263.w).color(Colors.white).make(), + 50.hb, + VxBox().height(53.w).width(152.w).color(Colors.white).make(), + 30.hb, + VxBox().height(40.w).width(600.w).color(Colors.white).make(), + 24.hb, + VxBox().height(33.w).width(263.w).color(Colors.white).make(), + ], + ), + ), + Divider( + height: 50.w, + thickness: 1.w, + color: Color(0xFFD8D8D8), + ), + BeeGridImageView( + urls: widget.model.imgUrls.map((e) => e.url).toList(), + padding: EdgeInsets.only(right: 100.w), + ), + ], ), - baseColor: Colors.black12, - highlightColor: Colors.white10, ); } @@ -66,10 +85,34 @@ class _AdviceDetailPageState extends State { children: [ '您的$adviceValue'.text.black.bold.size(38.sp).make(), 30.hb, + _model.appAdviceDetailVo.appAdviceVo.content.text + .color(ktextSubColor) + .size(28.sp) + .make(), + 24.hb, + DateUtil.formatDate( + _model.appAdviceDetailVo.appAdviceVo.date, + format: 'yyyy年MM月dd日 HH:mm', + ).text.make(), + Divider( + height: 50.w, + thickness: 1.w, + color: Color(0xFFD8D8D8), + ), + BeeGridImageView( + urls: widget.model.imgUrls.map((e) => e.url).toList(), + padding: EdgeInsets.only(right: 100.w), + ), ], ); } + @override + void dispose() { + _refreshController?.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { return BeeScaffold( @@ -80,8 +123,13 @@ class _AdviceDetailPageState extends State { controller: _refreshController, header: MaterialHeader(), onRefresh: () async { + Response res = await NetUtil().dio.get( + API.manager.adviceDetail, + queryParameters: {'adviceId': widget.model.id}, + ); + _model = AdviceDetailModel.fromJson(res.data); _loading = false; - setState(() {}); + if (mounted) setState(() {}); }, ), ); diff --git a/lib/ui/manager/advice/advice_page.dart b/lib/ui/manager/advice/advice_page.dart index dbdc9dc5..a9c0b07f 100644 --- a/lib/ui/manager/advice/advice_page.dart +++ b/lib/ui/manager/advice/advice_page.dart @@ -112,16 +112,18 @@ class _AdvicePageState extends State with TickerProviderStateMixin { bottomNavi: BottomButton( onPressed: () async { bool needRefresh = await Get.to(NewAdvicePage(type: widget.type)); - if (needRefresh == true) _refreshController.callRefresh(); - Get.dialog(CupertinoAlertDialog( - title: '您的信息已提交,我们会尽快回复您,祝您生活愉快'.text.isIntrinsic.make(), - actions: [ - CupertinoDialogAction( - child: '确定'.text.color(Color(0xFFFF8200)).isIntrinsic.make(), - onPressed: Get.back, - ), - ], - )); + if (needRefresh == true) { + _refreshController.callRefresh(); + Get.dialog(CupertinoAlertDialog( + title: '您的信息已提交,我们会尽快回复您,祝您生活愉快'.text.isIntrinsic.make(), + actions: [ + CupertinoDialogAction( + child: '确定'.text.color(Color(0xFFFF8200)).isIntrinsic.make(), + onPressed: Get.back, + ), + ], + )); + } }, child: Text('新增'), ), diff --git a/lib/utils/network/net_util.dart b/lib/utils/network/net_util.dart index 942bc99c..8c3fe6ee 100644 --- a/lib/utils/network/net_util.dart +++ b/lib/utils/network/net_util.dart @@ -37,6 +37,23 @@ class NetUtil { headers: {}, ); if (_dio == null) _dio = Dio(options); + dio.interceptors.add(InterceptorsWrapper( + onRequest: (RequestOptions options) async => options, + onResponse: (Response response) async { + _logger.v({ + 'path': response.request.path, + 'header': response.request.headers, + 'params': response.request.queryParameters, + 'data': response.data, + }); + LoggerData.addData(response); + return response; + }, + onError: (DioError error) async { + _parseErr(error); + return error; + }, + )); } ///call auth after login @@ -55,13 +72,6 @@ class NetUtil { }) async { try { Response res = await _dio.get(path, queryParameters: params); - _logger.v({ - 'path': res.request.path, - 'header': res.request.headers, - 'params': res.request.queryParameters, - 'data': res.data, - }); - LoggerData.addData(res); BaseModel baseModel = BaseModel.fromJson(res.data); _parseRequestError(baseModel, showMessage: showMessage); return baseModel; @@ -83,13 +93,7 @@ class NetUtil { }) async { try { Response res = await _dio.post(path, data: params); - _logger.v({ - 'path': res.request.path, - 'header': res.request.headers, - 'params': res.request.queryParameters, - 'data': res.data, - }); - LoggerData.addData(res); + BaseModel baseModel = BaseModel.fromJson(res.data); _parseRequestError(baseModel, showMessage: showMessage); @@ -127,17 +131,10 @@ class NetUtil { data: FormData.fromMap({ 'file': await MultipartFile.fromFile(file.path), })); - _logger.v({ - 'path': res.request.path, - 'header': res.request.headers, - 'params': res.request.queryParameters, - 'data': res.data, - }); - LoggerData.addData(res); BaseFileModel baseListModel = BaseFileModel.fromJson(res.data); return baseListModel; } on DioError catch (e) { - _parseErr(e); + print(e); } return BaseFileModel.err(); } diff --git a/lib/widget/picker/bee_image_preview.dart b/lib/widget/picker/bee_image_preview.dart index 4534954c..d5473f51 100644 --- a/lib/widget/picker/bee_image_preview.dart +++ b/lib/widget/picker/bee_image_preview.dart @@ -1,4 +1,5 @@ import 'dart:io'; +import 'dart:ui'; import 'package:akuCommunity/const/resource.dart'; import 'package:akuCommunity/constants/api.dart'; @@ -43,10 +44,13 @@ class _BeeImagePreviewState extends State { onTap: Get.back, child: Scaffold( backgroundColor: Colors.black54, - body: Center( - child: InteractiveViewer( - minScale: 0.2, - child: image, + body: BackdropFilter( + filter: ImageFilter.blur(sigmaX: 5, sigmaY: 5), + child: Center( + child: InteractiveViewer( + minScale: 0.2, + child: image, + ), ), ), ), diff --git a/lib/widget/views/bee_grid_image_view.dart b/lib/widget/views/bee_grid_image_view.dart new file mode 100644 index 00000000..4d64afbf --- /dev/null +++ b/lib/widget/views/bee_grid_image_view.dart @@ -0,0 +1,54 @@ +import 'package:akuCommunity/const/resource.dart'; +import 'package:akuCommunity/constants/api.dart'; +import 'package:akuCommunity/utils/headers.dart'; +import 'package:akuCommunity/widget/picker/bee_image_preview.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +class BeeGridImageView extends StatelessWidget { + final List urls; + final EdgeInsetsGeometry padding; + const BeeGridImageView({ + Key key, + @required this.urls, + this.padding = EdgeInsets.zero, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return GridView.builder( + padding: padding, + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 3, + crossAxisSpacing: 16.w, + mainAxisSpacing: 16.w, + ), + itemBuilder: (context, index) { + return GestureDetector( + onTap: () { + Get.to( + BeeImagePreview.path(path: urls[index]), + opaque: false, + ); + }, + child: Hero( + tag: urls[index], + child: ClipRRect( + borderRadius: BorderRadius.circular(8.w), + child: FadeInImage.assetNetwork( + height: 184.w, + width: 184.w, + placeholder: R.ASSETS_IMAGES_LOGO_PNG, + image: API.image(urls[index]), + fit: BoxFit.cover, + ), + ), + ), + ); + }, + itemCount: urls.length, + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + ); + } +} diff --git a/lib/widget/horizontal_image_view.dart b/lib/widget/views/horizontal_image_view.dart similarity index 60% rename from lib/widget/horizontal_image_view.dart rename to lib/widget/views/horizontal_image_view.dart index 66a51641..bc78eaf6 100644 --- a/lib/widget/horizontal_image_view.dart +++ b/lib/widget/views/horizontal_image_view.dart @@ -7,21 +7,16 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:akuCommunity/const/resource.dart'; import 'package:get/get.dart'; -class HorizontalImageView extends StatefulWidget { +class HorizontalImageView extends StatelessWidget { final List urls; HorizontalImageView( this.urls, { Key key, }) : super(key: key); - @override - _HorizontalImageViewState createState() => _HorizontalImageViewState(); -} - -class _HorizontalImageViewState extends State { @override Widget build(BuildContext context) { - if (widget.urls.isEmpty) return 15.hb; + if (urls.isEmpty) return 15.hb; return Container( height: 184.w + 32.w, child: ListView.separated( @@ -29,29 +24,29 @@ class _HorizontalImageViewState extends State { separatorBuilder: (_, __) => 16.wb, scrollDirection: Axis.horizontal, itemBuilder: (context, index) { - return ClipRRect( - borderRadius: BorderRadius.circular(8.w), - child: GestureDetector( - onTap: () { - Get.to( - BeeImagePreview.path(path: widget.urls[index]), - opaque: false, - ); - }, - child: Hero( - tag: widget.urls[index], + return GestureDetector( + onTap: () { + Get.to( + BeeImagePreview.path(path: urls[index]), + opaque: false, + ); + }, + child: Hero( + tag: urls[index], + child: ClipRRect( + borderRadius: BorderRadius.circular(8.w), child: FadeInImage.assetNetwork( height: 184.w, width: 184.w, placeholder: R.ASSETS_IMAGES_LOGO_PNG, - image: API.image(widget.urls[index]), + image: API.image(urls[index]), fit: BoxFit.cover, ), ), ), ); }, - itemCount: widget.urls.length, + itemCount: urls.length, ), ); }