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] =?UTF-8?q?1=E3=80=81=E7=99=BB=E5=BD=95=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E7=9A=84=E7=99=BB=E5=BD=95=E6=8C=89=E9=92=AEbug=202=E3=80=81?= =?UTF-8?q?=E6=89=BE=E4=B8=8D=E5=88=B0=E6=A8=A1=E5=9D=97=E4=B8=8D=E6=98=BE?= =?UTF-8?q?=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) {