|
|
@@ -94,7 +94,7 @@ class NetUtil { |
|
|
|
} |
|
|
|
|
|
|
|
/// 同步请求 |
|
|
|
static Future<dynamic> post(String path, {Map<String, dynamic> params, Map<String, dynamic> queryParameters, NetMethod method = NetMethod.POST, bool cache = false}) async { |
|
|
|
static Future<dynamic> post(String path, {Map<String, dynamic> params, Map<String, dynamic> 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<String, dynamic> params,Map<String, dynamic> queryParameters, OnSuccess onSuccess, OnError onError, OnCache onCache}) async { |
|
|
|
static void request(String path, {NetMethod method = NetMethod.GET, Map<String, dynamic> params,Map<String, dynamic> 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) { |
|
|
|