diff --git a/lib/community/community_child_page.dart b/lib/community/community_child_page.dart index 76c67f54..702480d2 100644 --- a/lib/community/community_child_page.dart +++ b/lib/community/community_child_page.dart @@ -177,8 +177,11 @@ class CommunityChildPageState extends State with AutomaticKe text: "目前暂无添加关注,可在推荐中关注自己喜欢的人哦~", fontSize: 16.sp, margin: EdgeInsets.only(top: 120.h,left: 60.w,right: 60.w), - ):ListView.builder( + ) + : + ListView.builder( controller: sc, + shrinkWrap: true, itemBuilder: (context, position) { return InkWell( child: CommunityDynamic( diff --git a/lib/community/community_view/community_dynamic.dart b/lib/community/community_view/community_dynamic.dart index ac2b0921..04388a99 100644 --- a/lib/community/community_view/community_dynamic.dart +++ b/lib/community/community_view/community_dynamic.dart @@ -67,15 +67,6 @@ class _CommunityDynamic extends State { @override void initState() { super.initState(); - SharedPreferences.getInstance().then( - (value) => { - apiService = ApiService( - Dio(), - context: context, - token: value.getString('token'), - ), - }, - ); initVideo(); } @@ -120,6 +111,14 @@ class _CommunityDynamic extends State { ///关注/取关会员 _vipFollow(followId, isFollow) async { + if (apiService == null) { + SharedPreferences value = await SharedPreferences.getInstance(); + apiService = ApiService( + Dio(), + context: context, + token: value.getString("token"), + ); + } BaseData baseData = await apiService.follow(followId); if (baseData != null && baseData.isSuccess) { widget.exitFull(); @@ -133,6 +132,14 @@ class _CommunityDynamic extends State { ///删除动态 _deleteDynamic(id) async { + if (apiService == null) { + SharedPreferences value = await SharedPreferences.getInstance(); + apiService = ApiService( + Dio(), + context: context, + token: value.getString("token"), + ); + } BaseData baseData = await apiService.deleteTrend(id); if (baseData != null && baseData.isSuccess) { widget.exitFull(); diff --git a/lib/home/home_view/discount_zone.dart b/lib/home/home_view/discount_zone.dart index d97c2306..2aef255f 100644 --- a/lib/home/home_view/discount_zone.dart +++ b/lib/home/home_view/discount_zone.dart @@ -120,7 +120,7 @@ class _DiscountZone extends State { color: Color(0xFFFFA607), ), ):Text( - "有效期至 ${coupon.useEndTime.substring(0, coupon.useEndTime.indexOf(" "))}", + "发放时间: ${coupon.useEndTime.substring(0, coupon.publishStartTime.indexOf(" "))}", maxLines:1, overflow: TextOverflow.ellipsis, style: TextStyle( diff --git a/lib/home/home_view/home_recommend_goods.dart b/lib/home/home_view/home_recommend_goods.dart index e29ebde8..06a03197 100644 --- a/lib/home/home_view/home_recommend_goods.dart +++ b/lib/home/home_view/home_recommend_goods.dart @@ -41,7 +41,7 @@ class _HomeRecommendGoods extends State { mainAxisAlignment: MainAxisAlignment.start, children: [ Container( - height: 235.h, + height: 260.h, decoration: BoxDecoration( borderRadius: BorderRadius.circular(6), color: Colors.white, @@ -92,8 +92,8 @@ class _HomeRecommendGoods extends State { commodityZone?.productImg ?? "", fit: BoxFit.contain, radius: BorderRadius.circular(4.r), - width: 158.w, - height: 158.h, + width: 158, + height: 158, errorSrc: "assets/image/default_2_1.webp", fadeSrc: "assets/image/default_2_1.webp", ), diff --git a/lib/home/home_view/top_selling_list.dart b/lib/home/home_view/top_selling_list.dart index d5cbdb74..853ca4a1 100644 --- a/lib/home/home_view/top_selling_list.dart +++ b/lib/home/home_view/top_selling_list.dart @@ -147,15 +147,15 @@ class _TopSellingList extends State { goodList.productImg ?? "", fit: BoxFit.cover, radius: BorderRadius.circular(4), - width: 54.w, - height: 54.h, + width: 54, + height: 54, errorSrc: "assets/image/default_2_1.webp", fadeSrc: "assets/image/default_2_1.webp", ), Image.asset( index == 0 ? "assets/image/ranking1.webp" :(index == 1 ? "assets/image/ranking2.webp": "assets/image/ranking3.webp"), - width: 25.w, - height: 25.h, + width: 25, + height: 25, fit: BoxFit.cover, ), ], diff --git a/lib/main_page.dart b/lib/main_page.dart index d1274ac5..5b4f313e 100644 --- a/lib/main_page.dart +++ b/lib/main_page.dart @@ -356,7 +356,7 @@ class _MainPage extends State with WidgetsBindingObserver { // baseData.data.appLastVersion = "1.0.4"; // baseData.data.appLastVersionUp = "1.0.1"; if(AppUtils.versionCompare(packageInfo.version,baseData.data?.appLastVersion) - && AppUtils.versionCompare(value.getString("appLastVersion"),baseData.data?.appLastVersion)){ + && AppUtils.versionCompare(value.getString("appLastVersion")??"1.0.0",baseData.data?.appLastVersion)){ showDialog( context: context, barrierDismissible: false, diff --git a/lib/mine/mine_page.dart b/lib/mine/mine_page.dart index c621b1fa..8f983dfe 100644 --- a/lib/mine/mine_page.dart +++ b/lib/mine/mine_page.dart @@ -245,7 +245,7 @@ class MinePageState extends State with AutomaticKeepAliveClientMixin { ), ), Container( - margin: EdgeInsets.only(top: 258 .h), + margin: EdgeInsets.only(top: 258.h), child: Column( children: [ ///我的订单 diff --git a/lib/union/union_list.dart b/lib/union/union_list.dart index d4b91c6e..ad9d7866 100644 --- a/lib/union/union_list.dart +++ b/lib/union/union_list.dart @@ -238,6 +238,7 @@ class _UnionList extends State { ], )), + if(store.distance != null) Container( width: 59.w, height: 18.h, diff --git a/lib/union/union_page.dart b/lib/union/union_page.dart index 319c63f1..fc13e9ad 100644 --- a/lib/union/union_page.dart +++ b/lib/union/union_page.dart @@ -110,6 +110,7 @@ class UnionPageState extends State } }); + getLatLng(); startLocation(false); } diff --git a/lib/utils/flutter_utils.dart b/lib/utils/flutter_utils.dart index 8363dd19..372e858e 100644 --- a/lib/utils/flutter_utils.dart +++ b/lib/utils/flutter_utils.dart @@ -8,36 +8,39 @@ import 'package:intl/intl.dart'; import 'package:path_provider/path_provider.dart'; class AppUtils { - ///计算距离(当前位置到店位置直线距离) - static Future calculateDistance(BMFCoordinate bmfCoordinate, BMFCoordinate myLatLng) async { - double mi = await BMFCalculateUtils.getLocationDistance(bmfCoordinate, myLatLng); + static Future calculateDistance( + BMFCoordinate bmfCoordinate, BMFCoordinate myLatLng) async { + double mi = + await BMFCalculateUtils.getLocationDistance(bmfCoordinate, myLatLng); NumberFormat numberFormat = NumberFormat("#.#"); return "${numberFormat.format(mi / 1000)}"; } ///版本号 - static bool versionCompare(String localVersion,String serverVersion){ - try{ + static bool versionCompare(String localVersion, String serverVersion) { + try { var localVersionArr = localVersion.split("."); var serverVersionArr = serverVersion.split("."); - if((int.tryParse(localVersionArr[0]) < int.tryParse(serverVersionArr[0])) - || (int.tryParse(localVersionArr[1]) < int.tryParse(serverVersionArr[1])) - || (int.tryParse(localVersionArr[2]) < int.tryParse(serverVersionArr[2]))) - return true; - }catch(ex){ } - return false; - } - - static String trimEnd(String resString,String char){ - while(resString.endsWith(char)){ - resString = resString.substring(0,resString.length - 1); + if (int.tryParse(localVersionArr[0]) > int.tryParse(serverVersionArr[0])) + return false; + if (int.tryParse(localVersionArr[1]) > int.tryParse(serverVersionArr[1])) + return false; + if (int.tryParse(localVersionArr[2]) > int.tryParse(serverVersionArr[2])) + return false; + } catch (ex) {} + return true; + } + + static String trimEnd(String resString, String char) { + while (resString.endsWith(char)) { + resString = resString.substring(0, resString.length - 1); } return resString; } ///金额保留整数/后两位 - static String calculateDouble(double res){ + static String calculateDouble(double res) { String resString = res.toStringAsFixed(2); resString = trimEnd(resString, "0"); resString = trimEnd(resString, "."); @@ -57,10 +60,9 @@ class AppUtils { return exp.hasMatch(mobile); } - static String phoneEncode(String phone){ - if(phone == null || phone.length != 11) - return phone; - return phone.substring(0,3) + "****" + phone.substring(phone.length-4); + static String phoneEncode(String phone) { + if (phone == null || phone.length != 11) return phone; + return phone.substring(0, 3) + "****" + phone.substring(phone.length - 4); } static double textScale(context) { @@ -193,34 +195,40 @@ class AppUtils { } } - static String dioErrorTypeToString(DioErrorType type){ + 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; - } + 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; - } + default: + { + errorStr = "请求异常"; + break; + } } errorStr += ",请检查手机网络是否正常"; return errorStr; @@ -228,8 +236,7 @@ class AppUtils { static String textSubStr(String input, int length) { length -= 1; - if(length < 0 || input.length < length) - return input; - return "${input.substring(0,length)}..."; + if (length < 0 || input.length < length) return input; + return "${input.substring(0, length)}..."; } } diff --git a/lib/view_widget/custom_image.dart b/lib/view_widget/custom_image.dart index 35aca8c4..8f626306 100644 --- a/lib/view_widget/custom_image.dart +++ b/lib/view_widget/custom_image.dart @@ -54,7 +54,7 @@ class MImage extends StatelessWidget { MediaQuery.of(context).size.height:constraints.constrainHeight()) * scaleIndex).toInt(); ///压缩图片 if ((src??"").startsWith("http")) { - if(!noCompress) + if(noCompress) imageUrl = src; else imageUrl = "$src?imageView2/1/w/${_w}/h/${_h}/format/jpg/q/75";