12 Commits

3 changed files with 38 additions and 17 deletions
+11 -1
View File
@@ -103,6 +103,12 @@ class HttpUtils {
// value: response.headers["authorization"]![0]);
// }
if (isShowLoading) EasyLoading.dismiss();
///转化结果
Map<String, dynamic> map = response.data;
if (map.keys.contains('code') && map['code'] == 401) {
response.data = {'resultCode': 'FAIL', 'resultMsg': '请重新登录'};
}
netResult = NetResult(
headers: response.headers,
result: response.data,
@@ -189,6 +195,7 @@ class HttpUtils {
}
if (resultCode.toUpperCase() == "UNLOGIN") {
ToastUtils.showToast(msg: map['resultMsg']);
unLoginAction?.call();
return;
}
@@ -230,7 +237,10 @@ class HttpUtils {
ToastUtils.showToast(msg: '服务响应超时');
break;
case DioExceptionType.unknown:
ToastUtils.showToast(msg: error.message);
ToastUtils.showToast(
msg: (error.message == '' || error.message?.isEmpty == true)
? '请重新登录'
: error.message);
break;
case DioExceptionType.badResponse:
try {
+6 -3
View File
@@ -133,9 +133,12 @@ class _UploadImagesState extends State<UploadImages> {
}) {
return GestureDetector(
onTap: () => widget.oneTap?.call(index),
child: CustomerImagesNetworking(
imageUrl: imageUrl,
fit: widget.fit ?? BoxFit.cover,
child: ClipRRect(
borderRadius: BorderRadiusGeometry.circular(20.r),
child: CustomerImagesNetworking(
imageUrl: imageUrl,
fit: widget.fit ?? BoxFit.cover,
),
),
);
}
+21 -13
View File
@@ -96,22 +96,30 @@ class CustomerImagesNetworking extends StatelessWidget {
@override
Widget build(BuildContext context) {
String? sizeParams = '';
int tempHeight = 300;
int tempWidth = 300;
if (height != null) {
sizeParams = '?x-oss-process=image/resize,h_$tempHeight,w_$tempHeight';
}
if (width != null) {
tempWidth = width!.toInt() <= 300 ? 300 : width!.toInt();
sizeParams = '?x-oss-process=image/resize,h_$tempWidth,w_$tempWidth';
}
String sizeParams = '';
const defaultResizeSize = 2048;
if (height != null && width != null) {
tempHeight = height!.toInt() <= 300 ? 300 : height!.toInt();
sizeParams = '?x-oss-process=image/resize,h_$tempHeight,w_$tempWidth';
final h = height!.toInt() <= defaultResizeSize
? defaultResizeSize
: height!.toInt();
final w = width!.toInt() <= defaultResizeSize
? defaultResizeSize
: width!.toInt();
sizeParams = 'x-oss-process=image/resize,h_$h,w_$w';
} else if (width != null) {
final w = width!.toInt() <= defaultResizeSize
? defaultResizeSize
: width!.toInt();
sizeParams = 'x-oss-process=image/resize,h_$w,w_$w';
} else if (height != null) {
final h = height!.toInt() <= defaultResizeSize
? defaultResizeSize
: height!.toInt();
sizeParams = 'x-oss-process=image/resize,h_$h,w_$h';
}
final separator = imageUrl.contains('?') ? '&' : '?';
return CachedNetworkImage(
imageUrl: imageUrl + sizeParams,
imageUrl: imageUrl.isEmpty ? imageUrl : '$imageUrl$separator$sizeParams',
width: width,
height: height,
fit: fit,