From c9dbb25a529574555a0b8735016976bda98bbd9a Mon Sep 17 00:00:00 2001 From: w-R <953969641@qq.com> Date: Sat, 16 Apr 2022 20:45:51 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A4=BE=E7=BE=A4=E5=86=85=E5=AE=B9=E6=9B=B4?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/community/community_list.dart | 2 +- .../community_view/community_dynamic.dart | 11 ++++-- lib/login/login_page.dart | 5 +-- lib/retrofit/min_api.dart | 19 +++++------ lib/retrofit/min_api.g.dart | 2 +- lib/retrofit/retrofit_api.dart | 15 ++++---- lib/retrofit/retrofit_api.g.dart | 2 +- lib/utils/flutter_utils.dart | 34 +++++++++++++++++++ 8 files changed, 63 insertions(+), 27 deletions(-) diff --git a/lib/community/community_list.dart b/lib/community/community_list.dart index efb1990f..dd6e4558 100644 --- a/lib/community/community_list.dart +++ b/lib/community/community_list.dart @@ -361,7 +361,7 @@ class _CommunityList extends State { ), Text( comments.subject ?? "", - maxLines: 5, + maxLines: 10, overflow: TextOverflow.ellipsis, style: TextStyle( color: Color(0xFF1A1A1A), diff --git a/lib/community/community_view/community_dynamic.dart b/lib/community/community_view/community_dynamic.dart index b682b2fe..52bcd4a2 100644 --- a/lib/community/community_view/community_dynamic.dart +++ b/lib/community/community_view/community_dynamic.dart @@ -295,15 +295,22 @@ class _CommunityDynamic extends State { SizedBox( height: 12.h, ), - Text( + widget.isList ? Text( widget?.article?.mainTitle ?? "", - maxLines: 5, + maxLines:5, overflow: TextOverflow.ellipsis, style: TextStyle( color: Color(0xFF1A1A1A), fontWeight: MyFontWeight.regular, fontSize: 15.sp, ), + ) :Text( + widget?.article?.mainTitle ?? "", + style: TextStyle( + color: Color(0xFF1A1A1A), + fontWeight: MyFontWeight.regular, + fontSize: 15.sp, + ), ), buildMedia(widget?.article?.content), SizedBox( diff --git a/lib/login/login_page.dart b/lib/login/login_page.dart index fd4098f3..23671846 100644 --- a/lib/login/login_page.dart +++ b/lib/login/login_page.dart @@ -11,6 +11,7 @@ import 'package:huixiang/retrofit/data/login_info.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/retrofit/data/user_entity.dart'; import 'package:huixiang/utils/event_type.dart'; +import 'package:huixiang/utils/flutter_utils.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/border_text.dart'; import 'package:flutter/cupertino.dart'; @@ -326,8 +327,8 @@ class _MyLoginPageState extends State with TickerProviderStateMixin { }; EasyLoading.show(status: S.of(context).zhengzaijiazai); BaseData value = await client.memberLogin(param).catchError((error) { - print(error); - SmartDialog.showToast("$error", alignment: Alignment.center); + print(error.message); + SmartDialog.showToast(AppUtils.dioErrorTypeToString(error.type), alignment: Alignment.center); }); // EasyLoading.show(status: S.of(context).zhengzaijiazai); Future.delayed(Duration(seconds:2), () { diff --git a/lib/retrofit/min_api.dart b/lib/retrofit/min_api.dart index 52b6c742..33adbca6 100644 --- a/lib/retrofit/min_api.dart +++ b/lib/retrofit/min_api.dart @@ -22,25 +22,22 @@ import 'data/shoppingCart.dart'; part 'min_api.g.dart'; // const base_url = "https://pos.api.lotus-wallet.com/app/"; ///正式 -// const baseUrl = "https://pos.api.lotus-wallet.com/app/"; ///正式 - // const base_url = "http://user.prod.kunqi.lotus-wallet.com/app/"; ///222 -// const baseUrl = "http://user.prod.kunqi.lotus-wallet.com/app/"; ///222 - -const base_url = "http://192.168.10.236:8765/app/";///费韬 -const baseUrl = "http://192.168.10.236:8765/app/";///费韬 - // const base_url = "http://192.168.10.132:8765/app/";///詹云久 -// const baseUrl = "http://192.168.10.132:8765/app/";///詹云久 +// const base_url = "http://192.168.10.236:8766/app/"; ///费韬 + // const base_url = "http://192.168.10.37:8766/app/"; -// const baseUrl = "http://192.168.10.37:8766/app/"; + +const localBaseUrl = "https://pos.api.lotus-wallet.com/app/";///本地 +const serviceBaseUrl = "https://pos.api.lotus-wallet.com/app/";///线上 + ///调用小程序的接口 -@RestApi(baseUrl: baseUrl) +@RestApi(baseUrl: localBaseUrl) abstract class MinApiService { factory MinApiService( Dio dio, { @@ -122,7 +119,7 @@ abstract class MinApiService { ); if (kReleaseMode) { - baseUrl = base_url; + baseUrl = serviceBaseUrl; } return _MinApiService(dio, baseUrl: baseUrl); } diff --git a/lib/retrofit/min_api.g.dart b/lib/retrofit/min_api.g.dart index 6533df56..0e6494d9 100644 --- a/lib/retrofit/min_api.g.dart +++ b/lib/retrofit/min_api.g.dart @@ -9,7 +9,7 @@ part of 'min_api.dart'; class _MinApiService implements MinApiService { _MinApiService(this._dio, {this.baseUrl}) { ArgumentError.checkNotNull(_dio, '_dio'); - baseUrl ??= 'http://192.168.10.236:8765/app/'; + baseUrl ??= kReleaseMode?serviceBaseUrl:localBaseUrl; } final Dio _dio; diff --git a/lib/retrofit/retrofit_api.dart b/lib/retrofit/retrofit_api.dart index 0f291c5b..751209d3 100644 --- a/lib/retrofit/retrofit_api.dart +++ b/lib/retrofit/retrofit_api.dart @@ -59,22 +59,19 @@ import 'data/vip_rule_details.dart'; part 'retrofit_api.g.dart'; // const base_url = "https://pos.platform.lotus-wallet.com/app/"; ///正式 -// const baseUrl = "https://pos.platform.lotus-wallet.com/app/"; ///正式 // const base_url = "http://platform.prod.kunqi.lotus-wallet.com/app/"; ///222 -// const baseUrl = "http://platform.prod.kunqi.lotus-wallet.com/app/"; ///222 -const base_url = "http://192.168.10.236:8766/app/"; ///费韬 -const baseUrl = "http://192.168.10.236:8766/app/"; ///费韬 +// const base_url = "http://192.168.10.236:8766/app/"; ///费韬 // const base_url = "http://192.168.10.37:8766/app/"; -// const baseUrl = "http://192.168.10.37:8766/app/"; - // const base_url = "http://192.168.10.132:8766/app/";///詹云久 -// const baseUrl = "http://192.168.10.132:8766/app/";///詹云久 -@RestApi(baseUrl: baseUrl) +const localBaseUrl = "https://pos.platform.lotus-wallet.com/app/";///本地 +const serviceBaseUrl = "https://pos.platform.lotus-wallet.com/app/";///线上 + +@RestApi(baseUrl: localBaseUrl) abstract class ApiService { factory ApiService( Dio dio, { @@ -147,7 +144,7 @@ abstract class ApiService { ); if (kReleaseMode) { - baseUrl = base_url; + baseUrl = serviceBaseUrl; } return _ApiService(dio, baseUrl: baseUrl); } diff --git a/lib/retrofit/retrofit_api.g.dart b/lib/retrofit/retrofit_api.g.dart index 52368cde..68536369 100644 --- a/lib/retrofit/retrofit_api.g.dart +++ b/lib/retrofit/retrofit_api.g.dart @@ -9,7 +9,7 @@ part of 'retrofit_api.dart'; class _ApiService implements ApiService { _ApiService(this._dio, {this.baseUrl}) { ArgumentError.checkNotNull(_dio, '_dio'); - baseUrl ??= 'http://192.168.10.236:8766/app/'; + baseUrl ??= kReleaseMode?serviceBaseUrl:localBaseUrl; } final Dio _dio; diff --git a/lib/utils/flutter_utils.dart b/lib/utils/flutter_utils.dart index 7e08db55..47711755 100644 --- a/lib/utils/flutter_utils.dart +++ b/lib/utils/flutter_utils.dart @@ -1,5 +1,6 @@ import 'dart:io'; +import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart'; import 'package:flutter_baidu_mapapi_utils/flutter_baidu_mapapi_utils.dart'; @@ -178,4 +179,37 @@ class AppUtils { } } } + + static String dioErrorTypeToString(DioErrorType type){ + String errorStr = ""; + switch(type){ + case DioErrorType.CANCEL:{ + errorStr = "取消请求"; + break; + } + case DioErrorType.CONNECT_TIMEOUT:{ + errorStr = "链接超时"; + break; + } + case DioErrorType.RECEIVE_TIMEOUT:{ + errorStr = "响应超时"; + break; + } + case DioErrorType.SEND_TIMEOUT:{ + errorStr = "请求超时"; + break; + } + case DioErrorType.RESPONSE:{ + errorStr = "服务器异常"; + break; + } + case DioErrorType.DEFAULT: + default:{ + errorStr = "请求异常"; + break; + } + } + errorStr += ",请检查手机网络是否正常"; + return errorStr; + } }