From b52d235d93dd3aaa0974edaf9e914174904f6d52 Mon Sep 17 00:00:00 2001 From: PH2 <1293456824@qq.com> Date: Mon, 16 Nov 2020 16:02:41 +0800 Subject: [PATCH 1/3] =?UTF-8?q?1=E3=80=81=E7=99=BB=E5=BD=95=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E7=9A=84=E7=99=BB=E5=BD=95=E6=8C=89=E9=92=AEbug=202?= =?UTF-8?q?=E3=80=81=E6=89=BE=E4=B8=8D=E5=88=B0=E6=A8=A1=E5=9D=97=E4=B8=8D?= =?UTF-8?q?=E6=98=BE=E7=A4=BAtoast?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../account/login_account_page.dart | 1 + lib/util/net_util.dart | 24 ++++++++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/lib/pages/login_page/account/login_account_page.dart b/lib/pages/login_page/account/login_account_page.dart index 4ff4c8e..7765b14 100644 --- a/lib/pages/login_page/account/login_account_page.dart +++ b/lib/pages/login_page/account/login_account_page.dart @@ -106,6 +106,7 @@ class _LoginAccountPageContianerState extends State i setState(() { _useVcode = !_useVcode; + _canSubmit = false; }); // 清除缓存 if (_useVcode) { diff --git a/lib/util/net_util.dart b/lib/util/net_util.dart index a0bf7f2..cfd40ca 100644 --- a/lib/util/net_util.dart +++ b/lib/util/net_util.dart @@ -94,7 +94,7 @@ class NetUtil { } /// 同步请求 - static Future post(String path, {Map params, Map queryParameters, NetMethod method = NetMethod.POST, bool cache = false}) async { + static Future post(String path, {Map params, Map queryParameters, NetMethod method = NetMethod.POST, bool cache = false, bool showToast = true}) async { if (params == null) { params = {}; } @@ -131,12 +131,18 @@ class NetUtil { // 缓存返回的数据 } else { Logger.error('error: ' + result[GlobalConfig.HTTP_RESPONSE_KEY_MSG]); - if (result[GlobalConfig.HTTP_RESPONSE_KEY_CODE] != 401000) { - Fluttertoast.showToast( - msg: result[GlobalConfig.HTTP_RESPONSE_KEY_MSG], - toastLength: Toast.LENGTH_SHORT, - gravity: ToastGravity.BOTTOM, - ); + /// + /// 401000 验证用户失败(不提示Toast) + /// 404004 没有找到对应模块(跳空页面,不提示toast) + /// + if (result[GlobalConfig.HTTP_RESPONSE_KEY_CODE] != 401000 && result[GlobalConfig.HTTP_RESPONSE_KEY_CODE] != 404004) { + if(showToast) { + Fluttertoast.showToast( + msg: result[GlobalConfig.HTTP_RESPONSE_KEY_MSG], + toastLength: Toast.LENGTH_SHORT, + gravity: ToastGravity.BOTTOM, + ); + } } // 退出登陆 @@ -159,7 +165,7 @@ class NetUtil { } /// 异步请求 - static void request(String path, {NetMethod method = NetMethod.GET, Map params,Map queryParameters, OnSuccess onSuccess, OnError onError, OnCache onCache}) async { + static void request(String path, {NetMethod method = NetMethod.GET, Map params,Map queryParameters, OnSuccess onSuccess, OnError onError, OnCache onCache, bool showToast = true}) async { if (params == null) { params = {}; } @@ -172,7 +178,7 @@ class NetUtil { } try { - Map result = await NetUtil.post(path, method: method, params: params, queryParameters: queryParameters); + Map result = await NetUtil.post(path, method: method, params: params, queryParameters: queryParameters, showToast: showToast); // TODO 解密? if (isSuccess(result)) { if (onSuccess != null) { From 534449b46dd898bb12e8a65f392c0ee6ba52f81b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=8D=8E=E8=BD=A9?= <646903573@qq.com> Date: Mon, 16 Nov 2020 16:26:12 +0800 Subject: [PATCH 2/3] =?UTF-8?q?1.=E4=BC=98=E5=8C=96=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E9=A2=84=E8=A7=88=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/pubspec.yaml | 8 ++-- lib/util/photo_preview/photo_preview.dart | 58 ++++++++++++++++------- 2 files changed, 45 insertions(+), 21 deletions(-) diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 477f21d..747f386 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -20,10 +20,10 @@ dev_dependencies: zhiying_comm: path: ../ - flutter_alibc: - git: - ref: 0.0.1 - url: http://192.168.0.138:3000/FnuoOS_ZhiYing/zhiying_flutter_alibc.git +# flutter_alibc: +# git: +# ref: 0.0.1 +# url: http://192.168.0.138:3000/FnuoOS_ZhiYing/zhiying_flutter_alibc.git # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec diff --git a/lib/util/photo_preview/photo_preview.dart b/lib/util/photo_preview/photo_preview.dart index 78f15bd..4e4d6f8 100644 --- a/lib/util/photo_preview/photo_preview.dart +++ b/lib/util/photo_preview/photo_preview.dart @@ -1,5 +1,6 @@ import 'dart:io'; import 'package:flutter/material.dart'; +import 'package:loading_indicator/loading_indicator.dart'; import 'package:photo_view/photo_view.dart'; import 'package:photo_view/photo_view_gallery.dart'; @@ -9,16 +10,25 @@ import 'package:zhiying_comm/zhiying_comm.dart'; class PhotoPreview extends StatefulWidget { List previewImageDatas; int index; + String heroTagSuffix; - PhotoPreview({Key key, this.previewImageDatas, this.index = 0}) + PhotoPreview( + {Key key, + this.previewImageDatas, + this.index = 0, + this.heroTagSuffix = ""}) : super(key: key); PhotoPreview._showPhotoViewByData( - {Key key, this.previewImageDatas, this.index}) - : super(key: key); + {Key key, + this.previewImageDatas, + this.index = 0, + this.heroTagSuffix = ""}) + : super(key: key) { + } PhotoPreview._showPhotoViewByImages( - {Key key, List images, this.index}) + {Key key, List images, this.index = 0, this.heroTagSuffix = ""}) : super(key: key) { if (images != null) { previewImageDatas = List(); @@ -32,21 +42,23 @@ class PhotoPreview extends StatefulWidget { ///显示类型的一些预览 static showPhotoPreview( BuildContext context, List previewImageDatas, - {int currentIndex = 0}) { + {int currentIndex = 0, String heroTagSuffix}) { Navigator.of(context).push(new FadeRoute( page: PhotoPreview._showPhotoViewByData( previewImageDatas: previewImageDatas, index: currentIndex, + heroTagSuffix: heroTagSuffix, ))); } ///显示仅仅是一组list类型的图片预览 static showPhotoPreviewByimages(BuildContext context, List images, - {int currentIndex = 0}) { + {int currentIndex = 0, String heroTagSuffix = ""}) { Navigator.of(context).push(new FadeRoute( page: PhotoPreview._showPhotoViewByImages( images: images, index: currentIndex, + heroTagSuffix: heroTagSuffix, ))); } @@ -71,7 +83,7 @@ class _PhotoPreviewState extends State { images: widget.previewImageDatas, index: widget.index, controller: pageController, - heroTag: "", + heroTagSuffix: widget.heroTagSuffix ?? "", )); } } @@ -100,7 +112,7 @@ enum PreviewImageType { class PhotoViewGalleryScreen extends StatefulWidget { List images = []; int index = 0; - String heroTag; + String heroTagSuffix; PageController controller; PhotoViewGalleryScreen( @@ -108,7 +120,7 @@ class PhotoViewGalleryScreen extends StatefulWidget { @required this.images, this.index, this.controller, - this.heroTag}) + this.heroTagSuffix}) : super(key: key) { controller = PageController(initialPage: index); } @@ -143,8 +155,10 @@ class _PhotoViewGalleryScreenState extends State { builder: (BuildContext context, int index) { return PhotoViewGalleryPageOptions( imageProvider: _buildPage(context, index), - heroAttributes: widget.heroTag.isNotEmpty - ? PhotoViewHeroAttributes(tag: widget.heroTag) + heroAttributes: widget.heroTagSuffix.isNotEmpty + ? PhotoViewHeroAttributes( + tag: (widget.images[index].data ?? "") + + widget.heroTagSuffix) : null, ); }, @@ -152,6 +166,19 @@ class _PhotoViewGalleryScreenState extends State { loadFailedChild: Container( child: Text("加载失败"), ), + loadingBuilder: (context,event){ + return Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + width: 48, + constraints: BoxConstraints(maxWidth: 48,maxHeight: 48), + height: 48, + child: LoadingIndicator(indicatorType: Indicator.ballSpinFadeLoader,color: Colors.white,) + ), + ], + ); + }, backgroundDecoration: BoxDecoration(color: Colors.black), pageController: widget.controller, enableRotation: true, @@ -220,12 +247,9 @@ class FadeRoute extends PageRouteBuilder { Animation secondaryAnimation, Widget child, ) => - ScaleTransition( - scale: animation, - child: FadeTransition( - opacity: animation, - child: child, - ), + FadeTransition( + opacity: animation, + child: child, ), ); } From 41d71767ca097270b03172d8116e61d03a36c52b Mon Sep 17 00:00:00 2001 From: PH2 <1293456824@qq.com> Date: Tue, 17 Nov 2020 15:32:10 +0800 Subject: [PATCH 3/3] =?UTF-8?q?1=E3=80=81=E7=99=BB=E5=BD=95=E7=9A=84?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=8D=8F=E8=AE=AE=E8=B7=B3=E8=BD=AC=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/login_page/account/login_account_page.dart | 1 + lib/pages/login_page/login_page.dart | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/pages/login_page/account/login_account_page.dart b/lib/pages/login_page/account/login_account_page.dart index 7765b14..22910d9 100644 --- a/lib/pages/login_page/account/login_account_page.dart +++ b/lib/pages/login_page/account/login_account_page.dart @@ -129,6 +129,7 @@ class _LoginAccountPageContianerState extends State i void _openAgreement(String url) { if (!EmptyUtil.isEmpty(url)) { print('打开协议$url'); + RouterUtil.openWebview(url, context); } } diff --git a/lib/pages/login_page/login_page.dart b/lib/pages/login_page/login_page.dart index ca9078a..ed67e28 100644 --- a/lib/pages/login_page/login_page.dart +++ b/lib/pages/login_page/login_page.dart @@ -65,6 +65,7 @@ class _LoginPageContainerState extends State { void _jumpUserAgreement(String url) { if(!EmptyUtil.isEmpty(url)) { print('协议'); + RouterUtil.openWebview(url, context); } }