From 02126387f4ca3d5ac5601ed0708615bca95c47be Mon Sep 17 00:00:00 2001 From: wurong <953969641@qq.com> Date: Thu, 18 Jul 2024 13:37:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=A8=E5=B1=80=E5=AE=9A=E4=BD=8D=E6=9B=B4?= =?UTF-8?q?=E6=94=B9=EF=BC=8C=E7=99=BE=E5=BA=A6=E6=94=B9=E7=94=A8=E9=AB=98?= =?UTF-8?q?=E5=BE=B7=E5=9C=B0=E5=9B=BE=EF=BC=9B=20=E9=97=A8=E5=BA=97?= =?UTF-8?q?=E5=88=97=E8=A1=A8ui=E8=B0=83=E6=95=B4=EF=BC=9B=20=E7=A6=8F?= =?UTF-8?q?=E5=88=A9=E4=B8=AD=E5=BF=83=E9=A1=B5=E9=9D=A2=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E8=AF=B7=E6=B1=82=E5=BC=82=E5=B8=B8=E5=A4=84?= =?UTF-8?q?=E7=90=86=EF=BC=9B=20=E9=82=80=E8=AF=B7=E5=A5=BD=E5=8F=8B?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=8E=A5=E5=8F=A3=E6=95=B0=E6=8D=AE=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86=EF=BC=9B=20?= =?UTF-8?q?=E5=85=85=E5=80=BC=E9=A1=B5=E9=9D=A2=E6=8E=A5=E5=8F=A3=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E8=AF=B7=E6=B1=82=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86?= =?UTF-8?q?=EF=BC=9B=20=E9=A6=96=E9=A1=B5=E5=88=B7=E6=96=B0=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86=EF=BC=9B=20?= =?UTF-8?q?=E5=8A=A9=E5=86=9C=E9=A1=B5=E9=9D=A2ui=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E5=A4=84=E7=90=86=EF=BC=9B=20=E5=85=91=E6=8D=A2=E5=88=97?= =?UTF-8?q?=E8=A1=A8ui=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86=EF=BC=9B=20tabu?= =?UTF-8?q?i=E5=BC=82=E5=B8=B8=E9=83=A8=E5=88=86=E6=9B=B4=E6=94=B9?= =?UTF-8?q?=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/image/2x/disenable_seletor.png | Bin 0 -> 8327 bytes assets/image/3x/disenable_seletor.png | Bin 0 -> 8327 bytes assets/image/disenable_seletor.png | Bin 0 -> 8327 bytes lib/address/address_map_page.dart | 470 ++-- lib/community/community_list.dart | 2 +- lib/community/community_page.dart | 3 - lib/community/community_view/home_class.dart | 4 +- .../headlines/activity_top_list.dart | 6 +- .../headlines/headlines_collection.dart | 4 +- lib/home/help_farmers/help_farmers_page.dart | 4 + lib/home/home_page.dart | 13 +- lib/home/home_view/discount_zone.dart | 8 +- lib/home/home_view/quick_order.dart | 109 +- .../points_mall_view/points_goods_title.dart | 3 + lib/home/welfare_exchange.dart | 4 +- lib/home/welfare_page.dart | 131 +- lib/main.dart | 4 +- lib/main_page.dart | 28 +- lib/mine/mine_shop_details.dart | 12 +- lib/mine/recharge_page.dart | 11 +- lib/mine/vip_detail_page.dart | 13 +- lib/order/exchange_history_page.dart | 2 +- lib/order/exchange_order_page.dart | 2 +- lib/qr/invite_friends.dart | 447 ++-- lib/retrofit/min_api.g.dart | 4 +- lib/retrofit/retrofit_api.dart | 10 +- lib/retrofit/retrofit_api.g.dart | 31 +- lib/settlement/settlement.dart | 595 +++-- .../settlement_view/distribution.dart | 85 +- .../shopping_cart/shopping_cart_page.dart | 13 +- lib/store/store_order.dart | 19 +- lib/store/store_view/shop_car.dart | 7 +- lib/store/store_view/store_info.dart | 97 +- lib/union/location_map_page.dart | 2336 ++++++++--------- lib/union/union_list.dart | 6 +- lib/union/union_page.dart | 345 +-- lib/union/union_view/store_info.dart | 178 +- lib/utils/flutter_utils.dart | 37 +- lib/utils/gps_utils.dart | 141 + lib/utils/location.dart | 206 +- lib/utils/upload_async.dart | 13 +- lib/vip/vip_page.dart | 1 + lib/web/web_page.dart | 17 +- lib/web/web_view/comment_list.dart | 16 +- lib/web/web_view/web_header.dart | 4 +- pubspec.lock | 96 +- pubspec.yaml | 7 +- 47 files changed, 3007 insertions(+), 2537 deletions(-) create mode 100644 assets/image/2x/disenable_seletor.png create mode 100644 assets/image/3x/disenable_seletor.png create mode 100644 assets/image/disenable_seletor.png create mode 100644 lib/utils/gps_utils.dart diff --git a/assets/image/2x/disenable_seletor.png b/assets/image/2x/disenable_seletor.png new file mode 100644 index 0000000000000000000000000000000000000000..b1971772021ef1136d6a1f7490a1069d03657cb7 GIT binary patch literal 8327 zcmX9^XCPbe+a^MTB0*6zMyb7bsl7*y+G_7rTWzsNNeQ+6?5Z7mt5SQ{p0$iqNg?pUG^>_Li9P5^@b zXde$BJP@K9jFe>VzTQ9lsWjfba1it^|Gip$pS0+@!eIXu4`AHrEKyqNVmmtWbgYzY zSIze5g$xlz$I}bq!Yg4C|Lrc!KDy8k5!80+&l!QV7UmJ(7<&bJA|RHu7CVso34Bud zB}GNWCb#*TUvJ(fOsGi5NqYdN_Aii)jg5klfIOn;+0YLJkXfG1K#V_wPKk!eHBUyC zzReS^N5=TI!R>5qcOowj=92m=)cca8rErNiJt+c@T2eVlrpXo8QQ#{HjJs%xz5_;; z0mx?U%bv}VX=5B5oT%T0N}i2hfvl5m#}|M|EFg5-Ij(wY-^s#lv%=&A$wsn5}Y#Jg&e6E0TT*Z`*U(3aiz-Prz zkrmYSKqc3UKRI^oEM@~r9^cg`$D6#A^P<7B%T>uSkv48p=ni_4#?^^BJ0HucFz+BR zo`JCptgp|W8yQ`T*>=))BmFOdkZsO~PTSJ%apV^vxY(@CUY$bU< zc+j5y_1l#K^xviJ6j>I<7n8sRG^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# zeQ||q#LIt@v9%BE4A93(^2Ee@(aS#wc4F!EA3myVrCK@*Q49m0J{55SRwz-DgRxOV zFF5F9kGwJ@!_Lm4qod<{;pDkPN^2Wmwo7z>7myEqDP)tUN`!jqk-0Gw<7-uHJd8yr z`r)81E@W<71>T~^?F65-tSo!PVwMIexxw#Kj@x{7HR^_Df7SpY{CQ)x<45MnI=%-| z;NsY+!h;mPF1imMQn_LzFhmOIf@G&>R2s~*`i-MBXbDN64i{yd+CL=NB8|0two#8b zjVJRiEG>PKlSAn`@Rt!Hx{yI^+1thvd`8wAZ|QvPAnYQ7S~fsAZtfYgE|frHD8#9< ztG3TEy4r|;3@^%+m?6)L9fE-oq#oEpovQzo4{n8dT=4*?tWns9X|Ofn1Y>RJHs%#l zk)%uq#9;jiOYxL)Hev&2T=GUH(SWy1B~B`&J8$|NgS%&{+RAYG z#4`sx-&YF5u2F0RX$fqejB(B++(7aG(Vr=o5zgayqC>B`((Rs&g=~v7kDj+b=bV|easT)-E+Whki;FQKfdgp^K@MnkC}zl5;6(O#xr^&5#Nz#t zOpQuD5ny-)1|DI}{Ai!OBNQ8 z*36hHtCMZ@6{}0#+!H~O3#o}UZlb1K;(Y}DfQcJn)URz$`}y(4RDFEYUy^*%NH|*-^j^i`oi{> z(XW{4*~EJ_MI!n$a#&#IEBu#l3Nn^-VTj29z8-Wqs$?a-3KXfw8F9j>pf3;{F=;D% zJ~{p-o9py%Ol=4D7(RdHykw2*%3r>b=>qt?cji}EcN(YhxPw!cAwPfkd0C%mN=88J z1eO9fR!8s4`_YJZ*Td5<_|P8)2tIxb;MTwF_T1JyBJ|fBKz|_997q_I!7C$hL)9HD uH?Kj%$<5*DwDfNOvuQa%DMjz!1ExNNpj=Yvn=bkS7|QY*a#b?su>S+#bkrjN literal 0 HcmV?d00001 diff --git a/assets/image/3x/disenable_seletor.png b/assets/image/3x/disenable_seletor.png new file mode 100644 index 0000000000000000000000000000000000000000..b1971772021ef1136d6a1f7490a1069d03657cb7 GIT bin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G z#4`sx-&YF5u2F0RX$fqejB(B++(7aG(Vr=o5zgayqC>B`((Rs&g=~v7kDj+b=bV|easT)-E+Whki;FQKfdgp^K@MnkC}zl5;6(O#xr^&5#Nz#t zOpQuD5ny-)1|DI}{Ai!OBNQ8 z*36hHtCMZ@6{}0#+!H~O3#o}UZlb1K;(Y}DfQcJn)URz$`}y(4RDFEYUy^*%NH|*-^j^i`oi{> z(XW{4*~EJ_MI!n$a#&#IEBu#l3Nn^-VTj29z8-Wqs$?a-3KXfw8F9j>pf3;{F=;D% zJ~{p-o9py%Ol=4D7(RdHykw2*%3r>b=>qt?cji}EcN(YhxPw!cAwPfkd0C%mN=88J z1eO9fR!8s4`_YJZ*Td5<_|P8)2tIxb;MTwF_T1JyBJ|fBKz|_997q_I!7C$hL)9HD uH?Kj%$<5*DwDfNOvuQa%DMjz!1ExNNpj=Yvn=bkS7|QY*a#b?su>S+#bkrjN literal 0 HcmV?d00001 diff --git a/assets/image/disenable_seletor.png b/assets/image/disenable_seletor.png new file mode 100644 index 0000000000000000000000000000000000000000..b1971772021ef1136d6a1f7490a1069d03657cb7 GIT binary patch literal 8327 zcmX9^XCPbe+a^MTB0*6zMyb7bsl7*y+G_7rTWzsNNeQ+6?5Z7mt5SQ{p0$iqNg?pUG^>_Li9P5^@b zXde$BJP@K9jFe>VzTQ9lsWjfba1it^|Gip$pS0+@!eIXu4`AHrEKyqNVmmtWbgYzY zSIze5g$xlz$I}bq!Yg4C|Lrc!KDy8k5!80+&l!QV7UmJ(7<&bJA|RHu7CVso34Bud zB}GNWCb#*TUvJ(fOsGi5NqYdN_Aii)jg5klfIOn;+0YLJkXfG1K#V_wPKk!eHBUyC zzReS^N5=TI!R>5qcOowj=92m=)cca8rErNiJt+c@T2eVlrpXo8QQ#{HjJs%xz5_;; z0mx?U%bv}VX=5B5oT%T0N}i2hfvl5m#}|M|EFg5-Ij(wY-^s#lv%=&A$wsn5}Y#Jg&e6E0TT*Z`*U(3aiz-Prz zkrmYSKqc3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=bkS7|QY*a#b?su>S+#bkrjN literal 0 HcmV?d00001 diff --git a/lib/address/address_map_page.dart b/lib/address/address_map_page.dart index c369d302..06fa0d5e 100644 --- a/lib/address/address_map_page.dart +++ b/lib/address/address_map_page.dart @@ -1,23 +1,23 @@ import 'dart:io'; import 'dart:ui'; -import 'package:android_intent_plus/android_intent.dart'; import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; +import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart'; -import 'package:flutter_baidu_mapapi_map/flutter_baidu_mapapi_map.dart'; -import 'package:flutter_baidu_mapapi_utils/flutter_baidu_mapapi_utils.dart'; -import 'package:flutter_bmflocation/flutter_bmflocation.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; +import 'package:geolocator/geolocator.dart'; import 'package:huixiang/generated/l10n.dart'; -import 'package:huixiang/data/address.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; +import 'package:huixiang/utils/location.dart'; import 'package:huixiang/view_widget/request_permission.dart'; -import 'package:permission_handler/permission_handler.dart'; +import 'package:permission_handler/permission_handler.dart' as PH; import 'package:shared_preferences/shared_preferences.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import '../data/address.dart'; + class AddressMapPage extends StatefulWidget { @override State createState() { @@ -26,22 +26,22 @@ class AddressMapPage extends StatefulWidget { } class _AddressMapPage extends State { - //加载自定义地图样式 - void _loadCustomData() async { - setState(() { - _mapController?.setCustomMapStyle('assets/map_style/chatian.sty', 0); - }); - } - - LocationFlutterPlugin? aMapFlutterLocation; + // //加载自定义地图样式 + // void _loadCustomData() async { + // setState(() { + // _mapController?.setCustomMapStyle('assets/map_style/chatian.sty', 0); + // }); + // } + + // LocationFlutterPlugin? aMapFlutterLocation; String city = "武汉市"; String keyWord = ""; - @override - void dispose() { - super.dispose(); - aMapFlutterLocation?.stopLocation(); - } + // @override + // void dispose() { + // super.dispose(); + // aMapFlutterLocation?.stopLocation(); + // } ApiService? apiService; @@ -53,84 +53,83 @@ class _AddressMapPage extends State { apiService = ApiService(Dio(), context: context, token: value.getString('token')), }); - aMapFlutterLocation?.singleLocationCallback(callback: (BaiduLocation result){ + LocationInstance.getInstance().startLocation(context, (Position? result) { print("event: $result"); - if (result.latitude != null && - result.longitude != null) { - city = "${result.city}"; - BMFCoordinate latLng = BMFCoordinate(result.latitude!, result.longitude!); - BMFCalculateUtils.coordConvert( - coordinate: latLng, - fromType: BMF_COORD_TYPE.COMMON, - toType: BMF_COORD_TYPE.BD09LL) - .then((value) { - saveLatLng(value); - this.latLng = Platform.isIOS ? value : latLng; - addMarker(); - _mapController?.updateMapOptions( - BMFMapOptions( - center: latLng, - zoomLevel: 15, - showZoomControl: false, - showMapScaleBar: false, - rotateEnabled: false, - ), - ); - searchPoi(latLng); + if (result?.latitude != null && result?.longitude != null) { + latLng = Position( + latitude: result!.latitude, + longitude: result.longitude, + timestamp: DateTime.now(), + accuracy: 0, + altitude: 0, + heading: 0, + speed: 0, + speedAccuracy: 0); + LocationInstance.getInstance() + .getAddress(result.latitude, result.longitude) + ?.then((value) { + if (value != null) { + city = value.city ?? ""; + } }); + saveLatLng(result); + searchPoi(latLng); } }); - _setLocOption(); - - getLatLng(); + // _setLocOption(); + // + // getLatLng(); startLocation(); } - /// 设置android端和ios端定位参数 - void _setLocOption() { - /// android 端设置定位参数 - BaiduLocationAndroidOption androidOption = BaiduLocationAndroidOption(coordType: BMFLocationCoordType.gcj02); - androidOption.setCoorType("GCJ02"); // 设置返回的位置坐标系类型 - androidOption.setIsNeedAltitude(true); // 设置是否需要返回海拔高度信息 - androidOption.setIsNeedAddress(true); // 设置是否需要返回地址信息 - androidOption.setIsNeedLocationPoiList(true); // 设置是否需要返回周边poi信息 - androidOption.setIsNeedNewVersionRgc(true); // 设置是否需要返回最新版本rgc信息 - androidOption.setIsNeedLocationDescribe(true); // 设置是否需要返回位置描述 - androidOption.setOpenGps(true); // 设置是否需要使用gps - androidOption.setLocationMode(BMFLocationMode.hightAccuracy); // 设置定位模式 - androidOption.setScanspan(0); // 设置发起定位请求时间间隔 - androidOption.setCoordType(BMFLocationCoordType.gcj02); - - Map androidMap = androidOption.getMap(); - - /// ios 端设置定位参数 - BaiduLocationIOSOption iosOption = BaiduLocationIOSOption(coordType: BMFLocationCoordType.gcj02); - iosOption.setIsNeedNewVersionRgc(true); // 设置是否需要返回最新版本rgc信息 - iosOption.setBMKLocationCoordinateType( - "BMKLocationCoordinateTypeGCJ02"); // 设置返回的位置坐标系类型 - iosOption.setActivityType(BMFActivityType.automotiveNavigation); // 设置应用位置类型 - iosOption.setLocationTimeout(10); // 设置位置获取超时时间 - iosOption.setDesiredAccuracy(BMFDesiredAccuracy.best); // 设置预期精度参数 - iosOption.setReGeocodeTimeout(10); // 设置获取地址信息超时时间 - iosOption.setDistanceFilter(1000); // 设置定位最小更新距离 - iosOption.setAllowsBackgroundLocationUpdates(true); // 是否允许后台定位 - iosOption.setPauseLocUpdateAutomatically(true); // 定位是否会被系统自动暂停 - iosOption.coordType = BMFLocationCoordType.gcj02; - - Map iosMap = iosOption.getMap(); - - aMapFlutterLocation?.prepareLoc(androidMap, iosMap); - } - + // /// 设置android端和ios端定位参数 + // void _setLocOption() { + // /// android 端设置定位参数 + // BaiduLocationAndroidOption androidOption = + // BaiduLocationAndroidOption(coordType: BMFLocationCoordType.gcj02); + // androidOption.setCoorType("GCJ02"); // 设置返回的位置坐标系类型 + // androidOption.setIsNeedAltitude(true); // 设置是否需要返回海拔高度信息 + // androidOption.setIsNeedAddress(true); // 设置是否需要返回地址信息 + // androidOption.setIsNeedLocationPoiList(true); // 设置是否需要返回周边poi信息 + // androidOption.setIsNeedNewVersionRgc(true); // 设置是否需要返回最新版本rgc信息 + // androidOption.setIsNeedLocationDescribe(true); // 设置是否需要返回位置描述 + // androidOption.setOpenGps(true); // 设置是否需要使用gps + // androidOption.setLocationMode(BMFLocationMode.hightAccuracy); // 设置定位模式 + // androidOption.setScanspan(0); // 设置发起定位请求时间间隔 + // androidOption.setCoordType(BMFLocationCoordType.gcj02); + // + // Map androidMap = androidOption.getMap(); + // + // /// ios 端设置定位参数 + // BaiduLocationIOSOption iosOption = + // BaiduLocationIOSOption(coordType: BMFLocationCoordType.gcj02); + // iosOption.setIsNeedNewVersionRgc(true); // 设置是否需要返回最新版本rgc信息 + // iosOption.setBMKLocationCoordinateType( + // "BMKLocationCoordinateTypeGCJ02"); // 设置返回的位置坐标系类型 + // iosOption.setActivityType(BMFActivityType.automotiveNavigation); // 设置应用位置类型 + // iosOption.setLocationTimeout(10); // 设置位置获取超时时间 + // iosOption.setDesiredAccuracy(BMFDesiredAccuracy.best); // 设置预期精度参数 + // iosOption.setReGeocodeTimeout(10); // 设置获取地址信息超时时间 + // iosOption.setDistanceFilter(1000); // 设置定位最小更新距离 + // iosOption.setAllowsBackgroundLocationUpdates(true); // 是否允许后台定位 + // iosOption.setPauseLocUpdateAutomatically(true); // 定位是否会被系统自动暂停 + // iosOption.coordType = BMFLocationCoordType.gcj02; + // + // Map iosMap = iosOption.getMap(); + // + // aMapFlutterLocation?.prepareLoc(androidMap, iosMap); + // } + + Position? center; List
? poiList; - searchPoi(BMFCoordinate? latLng) async { + searchPoi(Position? latLng) async { keyWord = textEditingController.text; print("keyWord: ${keyWord}"); var addressPoi = await apiService?.searchPoi( "${latLng?.latitude}", "${latLng?.longitude}", keyWord, 20, 1); //如果定位列表无法显示,可以考虑数据是否不在当前字段里面;例:原数据放在['pois']里面,后改成了数据放在['entrances']里面 - List poi = addressPoi['pois']??addressPoi['entrances']; + List poi = addressPoi['pois'] ?? addressPoi['entrances']; poiList = poi .map((e) => Address.fromJson({ "address": e["address"] is List ? "" : e["address"], @@ -176,25 +175,28 @@ class _AddressMapPage extends State { int time = 0; startLocation() async { - if (!(await Permission.locationWhenInUse.serviceStatus.isEnabled)) { + if (!(await PH.Permission.locationWhenInUse.serviceStatus.isEnabled)) { enableLocation(); return; } - - if (await Permission.location.isPermanentlyDenied) { + if (await PH.Permission.location.isPermanentlyDenied) { requestDialog(); - } else if (await Permission.location.isGranted) { + } else if (await PH.Permission.location.isGranted) { // EasyLoading.show(status: S.of(context).zhengzaijiazai); - aMapFlutterLocation?.startLocation(); + center = await Geolocator.getCurrentPosition(); Future.delayed(Duration(seconds: 6), () { EasyLoading.dismiss(); }); - } else { + } + // else if (await PH.Permission.location.) { + // await PH.Permission.location.request(); + // } + else { if (Platform.isIOS) { //去设置中心 requestDialog(); } else { - await Permission.location.request(); + await PH.Permission.location.request(); } } } @@ -210,11 +212,12 @@ class _AddressMapPage extends State { S.of(context).dakaidingwei, (result) async { if (result) { - final AndroidIntent intent = AndroidIntent( - action: 'action_location_source_settings', - package: "com.zsw.huixiang"); - await intent.launch(); + // final AndroidIntent intent = AndroidIntent( + // action: 'action_location_source_settings', + // package: "com.zsw.huixiang"); + // await intent.launch(); // startLocation(); + Geolocator.openLocationSettings(); } }, heightRatioWithWidth: 0.82, @@ -234,8 +237,8 @@ class _AddressMapPage extends State { S.of(context).kaiqiquanxian, (result) async { if (result) { - await openAppSettings(); - if (await Permission.location.isGranted) { + await PH.openAppSettings(); + if (await PH.Permission.location.isGranted) { startLocation(); } } @@ -245,77 +248,78 @@ class _AddressMapPage extends State { }); } - BMFMapController? _mapController; - BMFCoordinate? bmfCoordinate; - - void onMapCreated(BMFMapController controller) { - controller.setMapRegionDidChangeCallback(callback: (status) { - BMFMapStatus bmfMapStatus = status; - print("status: ${bmfMapStatus.toMap()}"); - if (bmfCoordinate?.longitude == status.targetGeoPt?.longitude && - bmfCoordinate?.latitude == status.targetGeoPt?.latitude) { - if ((DateTime.now().millisecondsSinceEpoch - time) > 1000) { - center = status.targetGeoPt; - searchPoi(center); - time = DateTime.now().millisecondsSinceEpoch; - } - } else { - bmfCoordinate = status.targetGeoPt; - } - }); - - setState(() { - _mapController = controller; - _mapController?.showUserLocation(true); - _loadCustomData(); - addMarker(); - }); - } - - BMFCoordinate? latLng; - BMFMarker? bmfMarker; - - addMarker() { - bmfMarker?.updateIsLockedToScreen( - true, - BMFPoint( - (Platform.isIOS - ? MediaQuery.of(context).size.width - : window.physicalSize.width) / - 2, - (Platform.isIOS - ? MediaQuery.of(context).size.height - : window.physicalSize.height) / - 4)); - } - - saveLatLng(BMFCoordinate? latLng) async { + // BMFMapController? _mapController; + // BMFCoordinate? bmfCoordinate; + + // void onMapCreated(BMFMapController controller) { + // controller.setMapRegionDidChangeCallback(callback: (status) { + // BMFMapStatus bmfMapStatus = status; + // print("status: ${bmfMapStatus.toMap()}"); + // if (bmfCoordinate?.longitude == status.targetGeoPt?.longitude && + // bmfCoordinate?.latitude == status.targetGeoPt?.latitude) { + // if ((DateTime.now().millisecondsSinceEpoch - time) > 1000) { + // center = status.targetGeoPt; + // searchPoi(center); + // time = DateTime.now().millisecondsSinceEpoch; + // } + // } else { + // bmfCoordinate = status.targetGeoPt; + // } + // }); + // + // setState(() { + // _mapController = controller; + // _mapController?.showUserLocation(true); + // _loadCustomData(); + // addMarker(); + // }); + // } + + Position? latLng; + + // BMFMarker? bmfMarker; + + // addMarker() { + // bmfMarker?.updateIsLockedToScreen( + // true, + // BMFPoint( + // (Platform.isIOS + // ? MediaQuery.of(context).size.width + // : window.physicalSize.width) / + // 2, + // (Platform.isIOS + // ? MediaQuery.of(context).size.height + // : window.physicalSize.height) / + // 4)); + // } + + saveLatLng(Position? latLng) async { SharedPreferences prefs = await SharedPreferences.getInstance(); await prefs.setString("latitude", "${latLng?.latitude}"); await prefs.setString("longitude", "${latLng?.longitude}"); } - getLatLng() async { - SharedPreferences.getInstance().then((value) => { - setState(() { - _mapController?.updateMapOptions( - BMFMapOptions( - center: BMFCoordinate( - double.tryParse("${value.getString("latitude")}") ?? 0, - double.tryParse("${value.getString("longitude")}") ?? 0, - ), - zoomLevel: 15, - showZoomControl: false, - showMapScaleBar: false, - rotateEnabled: false, - ), - ); - }) - }); - } - - BMFMapWidget? map; - BMFCoordinate? center = BMFCoordinate(30.553111, 114.342366); + // getLatLng() async { + // SharedPreferences.getInstance().then((value) => { + // setState(() { + // _mapController?.updateMapOptions( + // BMFMapOptions( + // center: BMFCoordinate( + // double.tryParse("${value.getString("latitude")}") ?? 0, + // double.tryParse("${value.getString("longitude")}") ?? 0, + // ), + // zoomLevel: 15, + // showZoomControl: false, + // showMapScaleBar: false, + // rotateEnabled: false, + // ), + // ); + // }) + // }); + // } + // + // BMFMapWidget? map; + // BMFCoordinate? center = BMFCoordinate(30.553111, 114.342366); @override Widget build(BuildContext context) { @@ -323,76 +327,76 @@ class _AddressMapPage extends State { body: Column( children: [ searchWidget(), - Expanded( - child: Stack( - children: [ - Container( - child: BMFMapWidget( - mapOptions: BMFMapOptions( - center: BMFCoordinate(30.553111, 114.342366), - zoomLevel: 15, - showZoomControl: false, - showMapScaleBar: false, - rotateEnabled: false, - ), - onBMFMapCreated: onMapCreated, - // onCameraMoveEnd: (cameraPosition) { - // center = cameraPosition.target; - // searchPoi(center); - // }, - // onCameraMove: (cameraPosition) { - // center = cameraPosition.target; - // setState(() {}); - // }, - // markers: [Marker(position: center)].toSet(), - // touchPoiEnabled: true, - // scrollGesturesEnabled: true, - // customStyleOptions: _customStyleOptions, - // gestureRecognizers: >[ - // Factory( - // () => EagerGestureRecognizer()) - // ].toSet(), - ), - ), - // Center( - // child: IgnorePointer( - // child: Container( - // margin: EdgeInsets.only(bottom: 44.h), - // child: Image.asset( - // "assets/image/icon_address_location.webp", - // width: 66.w, - // height: 75.h, - // ), - // ), - // ), - // ), - Positioned( - right: 17, - bottom: 16, - child: InkWell( - onTap: () { - startLocation(); - }, - child: Container( - width: 32, - height: 32, - padding: EdgeInsets.all(8), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(16), - color: Colors.white, - ), - child: Image.asset( - "assets/image/icon_address_location_action.webp", - width: 16.w, - height: 16.h, - ), - ), - ), - ), - ], - ), - flex: 1, - ), + // Expanded( + // child: Stack( + // children: [ + // Container( + // child: BMFMapWidget( + // mapOptions: BMFMapOptions( + // center: BMFCoordinate(30.553111, 114.342366), + // zoomLevel: 15, + // showZoomControl: false, + // showMapScaleBar: false, + // rotateEnabled: false, + // ), + // onBMFMapCreated: onMapCreated, + // // onCameraMoveEnd: (cameraPosition) { + // // center = cameraPosition.target; + // // searchPoi(center); + // // }, + // // onCameraMove: (cameraPosition) { + // // center = cameraPosition.target; + // // setState(() {}); + // // }, + // // markers: [Marker(position: center)].toSet(), + // // touchPoiEnabled: true, + // // scrollGesturesEnabled: true, + // // customStyleOptions: _customStyleOptions, + // // gestureRecognizers: >[ + // // Factory( + // // () => EagerGestureRecognizer()) + // // ].toSet(), + // ), + // ), + // // Center( + // // child: IgnorePointer( + // // child: Container( + // // margin: EdgeInsets.only(bottom: 44.h), + // // child: Image.asset( + // // "assets/image/icon_address_location.webp", + // // width: 66.w, + // // height: 75.h, + // // ), + // // ), + // // ), + // // ), + // Positioned( + // right: 17, + // bottom: 16, + // child: InkWell( + // onTap: () { + // startLocation(); + // }, + // child: Container( + // width: 32, + // height: 32, + // padding: EdgeInsets.all(8), + // decoration: BoxDecoration( + // borderRadius: BorderRadius.circular(16), + // color: Colors.white, + // ), + // child: Image.asset( + // "assets/image/icon_address_location_action.webp", + // width: 16.w, + // height: 16.h, + // ), + // ), + // ), + // ), + // ], + // ), + // flex: 1, + // ), Expanded( child: Container( child: ListView.separated( diff --git a/lib/community/community_list.dart b/lib/community/community_list.dart index e1aa4e87..2d820861 100644 --- a/lib/community/community_list.dart +++ b/lib/community/community_list.dart @@ -38,8 +38,8 @@ class _CommunityList extends State { @override void initState() { super.initState(); - SharedPreferences.getInstance().then((value) => { + if(apiService != null) apiService = ApiService(Dio(), context: context, token: value.getString("token")), }); diff --git a/lib/community/community_page.dart b/lib/community/community_page.dart index 7db30152..e204040c 100644 --- a/lib/community/community_page.dart +++ b/lib/community/community_page.dart @@ -1,10 +1,7 @@ import 'dart:ui'; import 'package:flutter/material.dart'; -import 'package:flutter_svg/svg.dart'; -import 'package:get/get.dart'; import 'package:huixiang/community/community_child_page.dart'; -import 'package:huixiang/view_widget/my_appbar.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:huixiang/view_widget/my_tab.dart'; diff --git a/lib/community/community_view/home_class.dart b/lib/community/community_view/home_class.dart index 607e0b67..f5bad18d 100644 --- a/lib/community/community_view/home_class.dart +++ b/lib/community/community_view/home_class.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart'; +import 'package:geolocator/geolocator.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/data/collect_class.dart'; import 'package:huixiang/data/course.dart'; @@ -22,7 +22,7 @@ class HomeClass extends StatefulWidget { class _HomeClass extends State { ApiService? apiService; - BMFCoordinate? latLng; + Position? latLng; final TextEditingController editingController = TextEditingController(); diff --git a/lib/community/headlines/activity_top_list.dart b/lib/community/headlines/activity_top_list.dart index 8deaef5a..274bcf5e 100644 --- a/lib/community/headlines/activity_top_list.dart +++ b/lib/community/headlines/activity_top_list.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart'; +import 'package:geolocator/geolocator.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/data/article.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; @@ -20,7 +20,7 @@ class ActivityTopList extends StatefulWidget { class _ActivityTopList extends State { ApiService? apiService; - BMFCoordinate? latLng; + Position? latLng; final TextEditingController editingController = TextEditingController(); @@ -38,7 +38,7 @@ class _ActivityTopList extends State { scrollDirection: Axis.horizontal, physics: BouncingScrollPhysics(), padding: EdgeInsets.symmetric(horizontal: 10), - itemCount: widget.articleTop?.length ?? 0, + itemCount: widget.articleTop.length ?? 0, itemBuilder: (context, position) { return GestureDetector( onTap: () { diff --git a/lib/community/headlines/headlines_collection.dart b/lib/community/headlines/headlines_collection.dart index b1559c8c..a8048029 100644 --- a/lib/community/headlines/headlines_collection.dart +++ b/lib/community/headlines/headlines_collection.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart'; +import 'package:geolocator/geolocator.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/data/article.dart'; import 'package:huixiang/data/headlines.dart'; @@ -22,7 +22,7 @@ class HeadlinesCollection extends StatefulWidget { class _HeadlinesCollection extends State { ApiService? apiService; - BMFCoordinate? latLng; + Position? latLng; final TextEditingController editingController = TextEditingController(); diff --git a/lib/home/help_farmers/help_farmers_page.dart b/lib/home/help_farmers/help_farmers_page.dart index 4ee1a421..fea9a197 100644 --- a/lib/home/help_farmers/help_farmers_page.dart +++ b/lib/home/help_farmers/help_farmers_page.dart @@ -126,6 +126,10 @@ class _HelpFarmersPage extends State { isScrollable: true, //可滚动 indicatorColor: Colors.white, + //tab排放方向 + tabAlignment:TabAlignment.start, + //去掉底部线条 + dividerHeight: 0, labelColor: Colors.white, labelStyle: TextStyle( fontSize: 16.sp, diff --git a/lib/home/home_page.dart b/lib/home/home_page.dart index f3fc789d..9c7e0459 100644 --- a/lib/home/home_page.dart +++ b/lib/home/home_page.dart @@ -175,6 +175,8 @@ class HomePageState extends State with AutomaticKeepAliveClientMixin { "model": {"type": "HOME_PAGE"}, }).catchError((onError) { dioErrorType = onError.type; + refreshController.loadFailed(); + refreshController.refreshFailed(); }); if (baseData?.isSuccess ?? false) { bannerData = baseData?.data?.records ?? []; @@ -209,7 +211,7 @@ class HomePageState extends State with AutomaticKeepAliveClientMixin { SmartDialog.showToast(toastText, alignment: Alignment.center); } - refreshController.refreshFailed(); + if (refreshController.isRefresh) refreshController.refreshCompleted(); if (mounted) setState(() {}); } } @@ -322,6 +324,15 @@ class HomePageState extends State with AutomaticKeepAliveClientMixin { ///核销用户优惠券 queryWiped(memberCouponId) async { + if (apiService == null) { + SharedPreferences.getInstance().then((value) { + apiService = ApiService( + Dio(), + context: context, + token: value.getString("token"), + ); + }); + } BaseData? baseData = await apiService?.wiped(memberCouponId).catchError((onError) {}); if (baseData?.isSuccess ?? false) { SmartDialog.showToast("核销成功", alignment: Alignment.center); diff --git a/lib/home/home_view/discount_zone.dart b/lib/home/home_view/discount_zone.dart index ca66c1e1..3864bb8c 100644 --- a/lib/home/home_view/discount_zone.dart +++ b/lib/home/home_view/discount_zone.dart @@ -62,7 +62,7 @@ class _DiscountZone extends State { ),), if(widget.coupon.length != 0) Container( - height: 108.h, + height: 109.h, margin: EdgeInsets.only(top: 16.h), child: ListView.builder( scrollDirection: Axis.horizontal, @@ -178,17 +178,17 @@ class _DiscountZone extends State { mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ - Container( + Expanded(child: Container( padding: EdgeInsets.only(bottom:10.h,top: 7.h,left: 12.w), child: Text( S.of(context).duihuanquan, style: TextStyle( - fontSize: 26.sp, + fontSize: 24.sp, fontWeight: MyFontWeight.semi_bold, color: coupon.status == 3 ? Color(0xFFB3B3B3):Color(0xFF32A060), ), ), - ), + )), Text( S.of(context).xianshangshiyong, style: TextStyle( diff --git a/lib/home/home_view/quick_order.dart b/lib/home/home_view/quick_order.dart index 95602056..aacaf9f2 100644 --- a/lib/home/home_view/quick_order.dart +++ b/lib/home/home_view/quick_order.dart @@ -1,11 +1,8 @@ import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart'; -import 'package:flutter_baidu_mapapi_map/flutter_baidu_mapapi_map.dart'; -import 'package:flutter_baidu_mapapi_utils/flutter_baidu_mapapi_utils.dart'; -import 'package:flutter_bmflocation/flutter_bmflocation.dart'; import 'package:flutter_svg/flutter_svg.dart'; +import 'package:geolocator/geolocator.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/utils/location.dart'; import 'package:huixiang/data/base_data.dart'; @@ -18,7 +15,7 @@ import 'package:huixiang/view_widget/item_title.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:huixiang/view_widget/request_permission.dart'; import 'package:huixiang/view_widget/round_button.dart'; -import 'package:permission_handler/permission_handler.dart'; +import 'package:permission_handler/permission_handler.dart' as PH; import 'package:shared_preferences/shared_preferences.dart'; class QuickOrder extends StatefulWidget { @@ -31,9 +28,9 @@ class QuickOrder extends StatefulWidget { class _QuickOrder extends State { ApiService? apiService; List? storeList; - BMFCoordinate? latLng; + Position? latLng; - BMFMapController? _mapController; + // BMFMapController? _mapController; final TextEditingController editingController = TextEditingController(); @override @@ -44,7 +41,7 @@ class _QuickOrder extends State { } ///门店列表 - queryStore(latitude, longitude, province, city, district, searchKey) async { + queryStore(latitude, longitude, searchKey) async { BaseData>? baseData = await apiService?.queryStore({ // "city": city, // "district": district, @@ -52,7 +49,9 @@ class _QuickOrder extends State { "latitude": latitude, "longitude": longitude, "searchKey": searchKey - }).catchError((error) {}); + }).catchError((error) { + + }); if (baseData?.isSuccess ?? false) { storeList = baseData!.data; } @@ -67,70 +66,76 @@ class _QuickOrder extends State { token: value.getString('token'), showLoading: false), if (value.containsKey("latitude") && - value.containsKey("longitude") && - value.containsKey("province") && - value.containsKey("city") && - value.containsKey("district")) + value.containsKey("longitude") ) { - latLng = BMFCoordinate(double.tryParse("${value.getString("latitude")}") ?? 0, - double.tryParse("${value.getString("longitude")}") ?? 0), + latLng = Position( + latitude: double.tryParse(value.getString("latitude") ??"")!, + longitude: double.tryParse(value.getString("longitude") ?? "")!, + timestamp: DateTime.now(), + accuracy: 0, + altitude: 0, + heading: 0, + speed: 0, + speedAccuracy: 0 + ), queryStore( value.getString("latitude"), value.getString("longitude"), - value.getString("province"), - value.getString("city"), - value.getString("district"), editingController.text, ), setState(() { - _mapController?.updateMapOptions( - BMFMapOptions( - center: latLng, - zoomLevel: 15, - )); + // _mapController?.updateMapOptions( + // BMFMapOptions( + // center: latLng, + // zoomLevel: 15, + // )); }) } else { - queryStore("", "", "", "", "", editingController.text), + queryStore("", "", editingController.text), } }, ); } startLocation() async { - Location.instance.startLocation(context, (BaiduLocation result){ - if (result.latitude != null && - result.longitude != null) { + LocationInstance.getInstance().startLocation(context, (Position? result){ + if (result?.latitude != null && + result?.longitude != null) { print("location: $result"); - latLng = BMFCoordinate(result.latitude!, result.longitude!); - BMFCalculateUtils.coordConvert( - coordinate: latLng!, - fromType: BMF_COORD_TYPE.BD09LL, - toType: BMF_COORD_TYPE.COMMON) - .then((value) { - this.latLng = value!; - saveLatLng(value!, result.province, result.city, result.district); - print("union: Location result ${value.latitude} " - "${value.longitude}"); - Location.instance.stopLocation(); + latLng = Position( + latitude: result?.latitude??0, + longitude: result?.longitude ?? 0, + timestamp: DateTime.now(), + accuracy: 0, + altitude: 0, + heading: 0, + speed: 0, + speedAccuracy: 0 + ); + LocationInstance.getInstance().getAddress(latLng!.latitude, latLng!.longitude)?.then((r) { + if (r != null) { + saveLatLng(latLng!, r.province, r.city, r.area); + } + + LocationInstance.getInstance().stopLocation(); queryStore( - "${value.latitude}", - "${value.longitude}", - result.province, - result.city, - result.district, + "${latLng?.latitude}", + "${latLng?.longitude}", editingController.text); - _mapController?.updateMapOptions(BMFMapOptions( - center: value, - zoomLevel: 15, - )); + // _mapController?.updateMapOptions(BMFMapOptions( + // center: value, + // zoomLevel: 15, + // ) + // ); + return r; }); } }).then((value) {}); } - saveLatLng(BMFCoordinate latLng, province, city, district) async { + saveLatLng(Position latLng, province, city, district) async { SharedPreferences prefs = await SharedPreferences.getInstance(); await prefs.setString("latitude", "${latLng.latitude}"); await prefs.setString("longitude", "${latLng.longitude}"); @@ -358,7 +363,7 @@ class _QuickOrder extends State { ///扫码 toScan() async { - if (await Permission.camera.isPermanentlyDenied) { + if (await PH.Permission.camera.isPermanentlyDenied) { showCupertinoDialog( context: context, builder: (context) { @@ -369,13 +374,13 @@ class _QuickOrder extends State { S.of(context).kaiqiquanxian, (result) async { if (result) { - await openAppSettings(); + await PH.openAppSettings(); } }, heightRatioWithWidth: 0.82, ); }); - } else if (await Permission.camera.isGranted) { + } else if (await PH.Permission.camera.isGranted) { // http://pos.app.gznl.top/placeorder/?tableId=1315903669597634560&tenantCode=1166&shopId=1300372027722432512 // 新版桌子码跳转 // http://miniscan.lotus-wallet.com/placeorder?tenant_code=1194&table_id=1669609340031467520&store_id=1637659387134738432 @@ -402,7 +407,7 @@ class _QuickOrder extends State { ); } } else { - await Permission.camera.request(); + await PH.Permission.camera.request(); } } } diff --git a/lib/home/points_mall_view/points_goods_title.dart b/lib/home/points_mall_view/points_goods_title.dart index ff38a2c8..10edce32 100644 --- a/lib/home/points_mall_view/points_goods_title.dart +++ b/lib/home/points_mall_view/points_goods_title.dart @@ -86,6 +86,9 @@ class _PointsGoodsTitle extends State isScrollable: true, //可滚动 indicatorColor: Color(0xff39B54A), + tabAlignment:TabAlignment.start, + dividerHeight: 0, + dividerColor: Colors.transparent, labelColor: Color(0xff32A060), labelStyle: TextStyle( fontSize: 14.sp, diff --git a/lib/home/welfare_exchange.dart b/lib/home/welfare_exchange.dart index 1df4db69..86f758a0 100644 --- a/lib/home/welfare_exchange.dart +++ b/lib/home/welfare_exchange.dart @@ -230,6 +230,8 @@ class _WelfareExchange extends State //可滚动 indicatorColor: Color(0xff39B54A), labelColor: Color(0xff32A060), + dividerHeight: 0, + tabAlignment:TabAlignment.start, labelStyle: TextStyle( fontSize: 14.sp, fontWeight: FontWeight.bold, @@ -366,7 +368,7 @@ class _WelfareExchange extends State ) : Container( margin: EdgeInsets.only(left: 15.w), - height: 50.h, + height: 62.h, child: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.start, diff --git a/lib/home/welfare_page.dart b/lib/home/welfare_page.dart index 0b99abd7..f3085534 100644 --- a/lib/home/welfare_page.dart +++ b/lib/home/welfare_page.dart @@ -1,4 +1,4 @@ - +import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; @@ -21,6 +21,7 @@ import 'package:huixiang/view_widget/no_data_view.dart'; import 'package:huixiang/view_widget/receive_success.dart'; import 'package:huixiang/view_widget/selector_store_dialog.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; +import 'package:shared_preferences/shared_preferences.dart'; import '../view_widget/settlement_tips_dialog.dart'; @@ -49,7 +50,16 @@ class _WelfarePage extends State { @override void initState() { super.initState(); - _onRefresh(); + if (apiService == null) { + SharedPreferences.getInstance().then((value) { + apiService = ApiService( + Dio(), + context: context, + token: value.getString("token"), + ); + _onRefresh(); + }); + } } queryGoods() async { @@ -336,7 +346,7 @@ class _WelfarePage extends State { ///优惠券列表 Widget weekCoupon(Coupon cop) { return Container( - height: 95.h, + height: 101.h, width: double.infinity, margin: EdgeInsets.only(bottom: 10), padding: EdgeInsets.symmetric(horizontal: 12), @@ -351,54 +361,54 @@ class _WelfarePage extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Expanded( - child: Container( - margin: EdgeInsets.only(top: 12, bottom: 12), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - cop.couponName ?? "", - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 14.sp, - fontWeight: MyFontWeight.semi_bold, - color: Color(0xFF0D0D0D), + child: Container( + margin: EdgeInsets.only(top: 12, bottom: 12), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + cop.couponName ?? "", + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 14.sp, + fontWeight: MyFontWeight.semi_bold, + color: Color(0xFF0D0D0D), + ), ), - ), - SizedBox( - height: 12, - ), - (cop.status == 0) - ? Text( - "发放时间: ${cop.publishStartTime ?? ""}", - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: cop.status == 3 - ? Color(0xFFB3B3B3) - : Color(0xFF4D4D4D), - ), - ) - : Text( - "有效期至 ${cop.useEndTime ?? ""}", - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: cop.status == 3 - ? Color(0xFFB3B3B3) - : Color(0xFF4D4D4D), - ), - ) - ], + SizedBox( + height: 12, + ), + (cop.status == 0) + ? Text( + "发放时间: ${cop.publishStartTime ?? ""}", + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: cop.status == 3 + ? Color(0xFFB3B3B3) + : Color(0xFF4D4D4D), + ), + ) + : Text( + "有效期至 ${cop.useEndTime ?? ""}", + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: cop.status == 3 + ? Color(0xFFB3B3B3) + : Color(0xFF4D4D4D), + ), + ) + ], + ), ), ), - ), Column( // mainAxisAlignment: MainAxisAlignment.start, // crossAxisAlignment: CrossAxisAlignment.end, @@ -475,7 +485,8 @@ class _WelfarePage extends State { style: TextStyle( fontSize: 22.sp, fontWeight: MyFontWeight.semi_bold, - color: cop.status == 3 ? Color(0xFFB3B3B3) : Color(0xff32A060), + color: + cop.status == 3 ? Color(0xFFB3B3B3) : Color(0xff32A060), ), ), ], @@ -506,7 +517,8 @@ class _WelfarePage extends State { style: TextStyle( fontSize: 26.sp, fontWeight: MyFontWeight.semi_bold, - color: cop.status == 3 ? Color(0xFFB3B3B3) : Color(0xff32A060), + color: + cop.status == 3 ? Color(0xFFB3B3B3) : Color(0xff32A060), ), ), ], @@ -537,7 +549,8 @@ class _WelfarePage extends State { style: TextStyle( fontSize: 16.sp, fontWeight: MyFontWeight.medium, - color: cop.status == 3 ? Color(0xFFB3B3B3) : Color(0xff32A060), + color: + cop.status == 3 ? Color(0xFFB3B3B3) : Color(0xff32A060), ), ), SizedBox( @@ -550,7 +563,8 @@ class _WelfarePage extends State { style: TextStyle( fontSize: 24.sp, fontWeight: FontWeight.bold, - color: cop.status == 3 ? Color(0xFFB3B3B3) : Color(0xff32A060), + color: + cop.status == 3 ? Color(0xFFB3B3B3) : Color(0xff32A060), ), ), ], @@ -574,7 +588,8 @@ class _WelfarePage extends State { style: TextStyle( fontSize: 30.sp, fontWeight: MyFontWeight.semi_bold, - color: cop.status == 3 ? Color(0xFFB3B3B3) : Color(0xff32A060), + color: + cop.status == 3 ? Color(0xFFB3B3B3) : Color(0xff32A060), ), ), SizedBox( @@ -585,7 +600,8 @@ class _WelfarePage extends State { style: TextStyle( fontSize: 16.sp, fontWeight: MyFontWeight.semi_bold, - color: cop.status == 3 ? Color(0xFFB3B3B3) : Color(0xff32A060), + color: + cop.status == 3 ? Color(0xFFB3B3B3) : Color(0xff32A060), ), ), ], @@ -672,9 +688,9 @@ class _WelfarePage extends State { showAlertDialog(); } else { SmartDialog.show( - clickBgDismissTemp: false, + clickBgDismissTemp: false, widget: SettlementTips( - () {}, + () {}, text: "${baseData?.msg}", )); } @@ -915,8 +931,7 @@ class _WelfarePage extends State { } else if (goodsPrice.onePrice != "0") { return S.of(context).jifen_("${goodsPrice.onePrice}"); } else if ((goodsPrice.onePrice == "0") && - ((goodsPrice.price != "0") || - (goodsPrice.money != "0.00"))) { + ((goodsPrice.price != "0") || (goodsPrice.money != "0.00"))) { return (goodsPrice.price == "0" ? "" : S.of(context).jifen_("${goodsPrice.price}")) + diff --git a/lib/main.dart b/lib/main.dart index 597cd0ec..7256e3fc 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -395,8 +395,8 @@ Map routers = { VipBalancePage(arguments: arguments), '/router/exchange_order_details': (context, {arguments}) => ExchangeOrderDetailPage(), - '/router/location_map': (context, {arguments}) => - LocationMap(arguments: arguments), + // '/router/location_map': (context, {arguments}) => + // LocationMap(arguments: arguments), '/router/settlement': (context, {arguments}) => Settlement(arguments: arguments), '/router/integral_detailed_page': (context, {arguments}) => diff --git a/lib/main_page.dart b/lib/main_page.dart index a4beb3c4..62dd0c26 100644 --- a/lib/main_page.dart +++ b/lib/main_page.dart @@ -3,8 +3,6 @@ import 'dart:io'; import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart'; -import 'package:flutter_bmflocation/flutter_bmflocation.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:flutter_svg/flutter_svg.dart'; @@ -245,19 +243,19 @@ class _MainPage extends State with WidgetsBindingObserver { ); SharesdkPlugin.regist(shareSDKRegister); - LocationFlutterPlugin myLocPlugin = LocationFlutterPlugin(); - // // 设置是否隐私政策 - myLocPlugin.setAgreePrivacy(true); - BMFMapSDK.setAgreePrivacy(true); - if (Platform.isIOS) { - myLocPlugin.authAK("ylW2QPlsbERkho7jOgU4GQSeawmdUIoR"); - BMFMapSDK.setApiKeyAndCoordType( - 'ylW2QPlsbERkho7jOgU4GQSeawmdUIoR', - BMF_COORD_TYPE.BD09LL, - ); - } else if (Platform.isAndroid) { - BMFMapSDK.setCoordType(BMF_COORD_TYPE.BD09LL); - } + // LocationFlutterPlugin myLocPlugin = LocationFlutterPlugin(); + // // // 设置是否隐私政策 + // myLocPlugin.setAgreePrivacy(true); + // BMFMapSDK.setAgreePrivacy(true); + // if (Platform.isIOS) { + // myLocPlugin.authAK("ylW2QPlsbERkho7jOgU4GQSeawmdUIoR"); + // BMFMapSDK.setApiKeyAndCoordType( + // 'ylW2QPlsbERkho7jOgU4GQSeawmdUIoR', + // BMF_COORD_TYPE.BD09LL, + // ); + // } else if (Platform.isAndroid) { + // BMFMapSDK.setCoordType(BMF_COORD_TYPE.BD09LL); + // } // if (Platform.isAndroid) { // xgFlutterPlugin.getXgAndroidApi().addNativeEventHandler( diff --git a/lib/mine/mine_shop_details.dart b/lib/mine/mine_shop_details.dart index 602af0b2..56163bc1 100644 --- a/lib/mine/mine_shop_details.dart +++ b/lib/mine/mine_shop_details.dart @@ -1,8 +1,8 @@ import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:flutter_bmflocation/flutter_bmflocation.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; +import 'package:geolocator/geolocator.dart'; import 'package:huixiang/data/store.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/data/base_data.dart'; @@ -44,7 +44,7 @@ class _MineShopDetails extends State { super.dispose(); refreshController.dispose(); consumeRefreshController.dispose(); - Location.instance.stopLocation(); + LocationInstance.getInstance().stopLocation(); } @override @@ -85,10 +85,10 @@ class _MineShopDetails extends State { startLocation() async { // EasyLoading.show(status: S.current.zhengzaijiazai); - Location.instance.startLocation(context, (BaiduLocation result){ - if (result.latitude != null && - result.longitude != null) { - vipDetail(result.latitude, result.longitude); + LocationInstance.getInstance().startLocation(context, (Position? result){ + if (result?.latitude != null && + result?.longitude != null) { + vipDetail(result?.latitude, result?.longitude); } else { EasyLoading.dismiss(); } diff --git a/lib/mine/recharge_page.dart b/lib/mine/recharge_page.dart index 05561699..038e17cd 100644 --- a/lib/mine/recharge_page.dart +++ b/lib/mine/recharge_page.dart @@ -1,5 +1,6 @@ import 'dart:io'; +import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; @@ -57,7 +58,13 @@ class _RechargePage extends State { @override void initState() { super.initState(); - _onRefresh(); + SharedPreferences.getInstance().then((value) => { + apiService = ApiService(Dio(), + context: context, + token: value.getString("token"), + showLoading: false), + _onRefresh() + }); fluwx.addSubscriber((event) async { print("payCallback: ${event.errCode}"); if (event.errCode == 0) { @@ -133,7 +140,7 @@ class _RechargePage extends State { _onRefresh() async { EasyLoading.show(status: S.current.zhengzaijiazai, maskType: EasyLoadingMaskType.black); - SharedPreferences value = await SharedPreferences.getInstance(); + // SharedPreferences value = await SharedPreferences.getInstance(); queryBenefitList(); queryRuleDetails(); queryRechargeActList(); diff --git a/lib/mine/vip_detail_page.dart b/lib/mine/vip_detail_page.dart index 658ca8e5..5389fa00 100644 --- a/lib/mine/vip_detail_page.dart +++ b/lib/mine/vip_detail_page.dart @@ -1,12 +1,11 @@ import 'package:barcode_widget/barcode_widget.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:flutter_bmflocation/flutter_bmflocation.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; +import 'package:geolocator/geolocator.dart'; import 'package:huixiang/data/store.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/data/base_data.dart'; -import 'package:huixiang/data/product.dart'; import 'package:huixiang/data/vip_card.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/store/scan.dart'; @@ -38,7 +37,7 @@ class _VipDetailPage extends State { void dispose() { super.dispose(); refreshController.dispose(); - Location.instance.stopLocation(); + LocationInstance.getInstance().stopLocation(); } @override @@ -52,10 +51,10 @@ class _VipDetailPage extends State { startLocation() async { // EasyLoading.show(status: S.current.zhengzaijiazai); - Location.instance.startLocation(context, (BaiduLocation result) { - if (result.latitude != null && - result.longitude != null) { - vipDetail(result.latitude, result.longitude); + LocationInstance.getInstance().startLocation(context, (Position? result) { + if (result?.latitude != null && + result?.longitude != null) { + vipDetail(result?.latitude, result?.longitude); } else { EasyLoading.dismiss(); } diff --git a/lib/order/exchange_history_page.dart b/lib/order/exchange_history_page.dart index 92099512..383eeb00 100644 --- a/lib/order/exchange_history_page.dart +++ b/lib/order/exchange_history_page.dart @@ -445,7 +445,7 @@ class _ExchangeHistoryList extends State ), Expanded( child: SizedBox( - height: 66.h, + // height: 66.h, child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, diff --git a/lib/order/exchange_order_page.dart b/lib/order/exchange_order_page.dart index 90194916..3f661b5e 100644 --- a/lib/order/exchange_order_page.dart +++ b/lib/order/exchange_order_page.dart @@ -984,7 +984,7 @@ class _ExchangeOrderPage extends State { Align( alignment: Alignment.bottomCenter, child: Container( - height: 54.h, + height: 60.h, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(45), diff --git a/lib/qr/invite_friends.dart b/lib/qr/invite_friends.dart index f26591bc..5aba621f 100644 --- a/lib/qr/invite_friends.dart +++ b/lib/qr/invite_friends.dart @@ -1,5 +1,6 @@ import 'dart:convert'; +import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:huixiang/generated/l10n.dart'; @@ -45,6 +46,11 @@ class _InviteFriends extends State { phone = UserInfo.fromJson(jsonDecode(user!)).inviteCode; setState(() {}); } + if(apiService != null) + apiService = ApiService(Dio(), + context: context, + token: value.getString('token'), + showLoading: false); queryUserInfo(); queryInviteMember(); }); @@ -52,7 +58,8 @@ class _InviteFriends extends State { ///邀请记录 queryInviteMember() async { - BaseData>? baseData = await apiService?.inviteMemberList({ + BaseData>? baseData = + await apiService?.inviteMemberList({ "searchKey": "", "pageNum": 1, "pageSize": 100, @@ -60,7 +67,8 @@ class _InviteFriends extends State { refreshController.refreshFailed(); }); if (baseData?.isSuccess ?? false) { - if (baseData!.data != null && (baseData.data!.list?.isNotEmpty ?? false)) { + if (baseData!.data != null && + (baseData.data!.list?.isNotEmpty ?? false)) { if (pageNum == 1) { invitationList.clear(); } @@ -76,7 +84,8 @@ class _InviteFriends extends State { ///查询用户信息 queryUserInfo() async { - BaseData? baseDate = await apiService?.queryInfo().catchError((onError) { + BaseData? baseDate = + await apiService?.queryInfo().catchError((onError) { refreshController.refreshFailed(); }); if (baseDate?.isSuccess ?? false) { @@ -84,7 +93,7 @@ class _InviteFriends extends State { userInfo = baseDate!.data; }); SharedPreferences.getInstance().then( - (value) => { + (value) => { value.setString('user', jsonEncode(baseDate!.data)), }, ); @@ -95,109 +104,107 @@ class _InviteFriends extends State { EasyLoading.dismiss(); } - _onRefresh(){ + _onRefresh() { queryUserInfo(); queryInviteMember(); } @override Widget build(BuildContext context) { - return Stack( - children: [ - Scaffold( - backgroundColor: Color(0xFFF9FAF7), - appBar: AppBar( - backgroundColor: Colors.white, - leading: GestureDetector( - child: Icon( - Icons.clear, - color: Colors.black, - ), - onTap: () { - Navigator.of(context).pop(); - }), - title: Text( - S.of(context).yaoqinghaoyou, - style: TextStyle( - fontWeight: MyFontWeight.semi_bold, - fontSize: 17.sp, - color: Color(0xFF000000), + return Scaffold( + backgroundColor: Colors.white, + appBar: AppBar( + shadowColor: Colors.white, + backgroundColor: Colors.white, + leading: GestureDetector( + child: Icon( + Icons.clear, + color: Colors.black, ), + onTap: () { + Navigator.of(context).pop(); + }), + title: Text( + S.of(context).yaoqinghaoyou, + style: TextStyle( + fontWeight: MyFontWeight.semi_bold, + fontSize: 17.sp, + color: Color(0xFF000000), ), - centerTitle: true, - elevation: 0.0, - // actions: [ - // GestureDetector( - // child: Container( - // margin: EdgeInsets.only(right: 14), - // padding:EdgeInsets.only(left:70,right: 20), - // child: Icon( - // Icons.more_horiz, - // color: Colors.black, - // ), - // ), - // onTap: () { - // // Navigator.of(context).pop(); - // // share(); - // }) - // ], ), - body: SmartRefresher( - controller: refreshController, - enablePullDown: true, - enablePullUp: false, - header: MyHeader(), - footer: CustomFooter( - builder: (context, mode) { - return MyFooter(mode); - }, - ), - onRefresh: () { - setState(() { - _onRefresh(); - }); - }, + centerTitle: true, + elevation: 0.0, + //滑动时颜色不变 + scrolledUnderElevation: 0.0 + // actions: [ + // GestureDetector( + // child: Container( + // margin: EdgeInsets.only(right: 14), + // padding:EdgeInsets.only(left:70,right: 20), + // child: Icon( + // Icons.more_horiz, + // color: Colors.black, + // ), + // ), + // onTap: () { + // // Navigator.of(context).pop(); + // // share(); + // }) + // ], + ), + body: SmartRefresher( + controller: refreshController, + enablePullDown: true, + enablePullUp: false, + header: MyHeader(), + footer: CustomFooter( + builder: (context, mode) { + return MyFooter(mode); + }, + ), + onRefresh: () { + setState(() { + _onRefresh(); + }); + }, + physics: BouncingScrollPhysics(), + scrollController: scrollController, + child: Container( + child: SingleChildScrollView( physics: BouncingScrollPhysics(), - scrollController: scrollController, - child: Container( - child: SingleChildScrollView( - physics: BouncingScrollPhysics(), - child: Column( - children: [ - invite(), - - activityRule(), - - achievement(), - - mineInvite(), - ], - ), - ), + child: Column( + children: [ + invite(), + activityRule(), + achievement(), + mineInvite(), + ], ), ), ), - ], + ), ); } ///邀请图 - Widget invite(){ + Widget invite() { return Container( - width:double.infinity, + width: double.infinity, height: 370.h, - margin: EdgeInsets.only(bottom:20.h), - child:Column( + margin: EdgeInsets.only(bottom: 20.h), + child: Column( children: [ Image.asset( "assets/image/invite_friends.webp", height: 300.h, - width:double.infinity, + width: double.infinity, fit: BoxFit.fill, ), - SizedBox(height: 12.h,), + SizedBox( + height: 12.h, + ), GestureDetector( - onTap: (){ + onTap: () { widgetToUrl(); }, child: Container( @@ -207,7 +214,7 @@ class _InviteFriends extends State { borderRadius: BorderRadius.circular(26), color: Color(0xFF32A060), ), - margin: EdgeInsets.symmetric(horizontal:14.w), + margin: EdgeInsets.symmetric(horizontal: 14.w), child: Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, @@ -215,10 +222,12 @@ class _InviteFriends extends State { Image.asset( "assets/image/wx.webp", height: 20, - width:20, + width: 20, fit: BoxFit.fill, ), - SizedBox(width:4.w,), + SizedBox( + width: 4.w, + ), Text( "邀请微信好友", style: TextStyle( @@ -237,45 +246,47 @@ class _InviteFriends extends State { } ///活动规则 - Widget activityRule(){ + Widget activityRule() { return Container( - width:double.infinity, + width: double.infinity, decoration: BoxDecoration( - borderRadius: BorderRadius.circular(6), - color: Color(0xFFFFFFFF), - ), - margin: EdgeInsets.only(bottom:12.h,left:14.h,right: 14.h), + borderRadius: BorderRadius.circular(6), + color: Color(0xFFFFFFFF), + ), + margin: EdgeInsets.only(bottom: 12.h, left: 14.h, right: 14.h), padding: EdgeInsets.all(6), - child:Column( + child: Column( // mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( - decoration: BoxDecoration( - image: DecorationImage( - fit: BoxFit.cover, - image: AssetImage("assets/image/invite_bj.webp"), - ), - ), - height: 54.h, - width:double.infinity, - alignment: Alignment.center, - child: Text( - S.of(context).huodongguize, - style: TextStyle( - fontWeight: MyFontWeight.semi_bold, - fontSize: 16.sp, - color: Color(0xFF32A060), + decoration: BoxDecoration( + image: DecorationImage( + fit: BoxFit.cover, + image: AssetImage("assets/image/invite_bj.webp"), + ), ), - ) + height: 54.h, + width: double.infinity, + alignment: Alignment.center, + child: Text( + S.of(context).huodongguize, + style: TextStyle( + fontWeight: MyFontWeight.semi_bold, + fontSize: 16.sp, + color: Color(0xFF32A060), + ), + )), + SizedBox( + height: 17.h, ), - SizedBox(height: 17.h,), IntrinsicHeight( child: Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ - Expanded(child: Column( + Expanded( + child: Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceAround, @@ -288,7 +299,7 @@ class _InviteFriends extends State { fit: BoxFit.cover, ), Container( - width:50.w, + width: 50.w, child: Flex( children: List.generate(8, (_) { return SizedBox( @@ -296,7 +307,7 @@ class _InviteFriends extends State { height: 1, child: DecoratedBox( decoration: - BoxDecoration(color: Color(0xFF32A060)), + BoxDecoration(color: Color(0xFF32A060)), ), ); }), @@ -324,7 +335,8 @@ class _InviteFriends extends State { width: 3.w, height: 1.h, child: DecoratedBox( - decoration: BoxDecoration(color: Colors.white), + decoration: + BoxDecoration(color: Colors.white), ), ); }), @@ -340,9 +352,8 @@ class _InviteFriends extends State { crossAxisAlignment: CrossAxisAlignment.center, children: [ Container( - width:50.w, - child: - Text( + width: 50.w, + child: Text( "分享链接给好友", style: TextStyle( fontSize: 12.sp, @@ -360,7 +371,8 @@ class _InviteFriends extends State { width: 3.w, height: 1.h, child: DecoratedBox( - decoration: BoxDecoration(color: Colors.white), + decoration: + BoxDecoration(color: Colors.white), ), ); }), @@ -372,7 +384,8 @@ class _InviteFriends extends State { ), ], )), - Expanded(child: Column( + Expanded( + child: Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceAround, @@ -393,7 +406,7 @@ class _InviteFriends extends State { height: 1.w, child: DecoratedBox( decoration: - BoxDecoration(color: Color(0xFF32A060)), + BoxDecoration(color: Color(0xFF32A060)), ), ); }), @@ -421,7 +434,8 @@ class _InviteFriends extends State { width: 3.w, height: 1.h, child: DecoratedBox( - decoration: BoxDecoration(color: Colors.white), + decoration: + BoxDecoration(color: Colors.white), ), ); }), @@ -437,9 +451,8 @@ class _InviteFriends extends State { crossAxisAlignment: CrossAxisAlignment.center, children: [ Container( - width:50.w, - child: - Text( + width: 50.w, + child: Text( "好友注册并获得10元优惠券", style: TextStyle( fontSize: 12.sp, @@ -457,7 +470,8 @@ class _InviteFriends extends State { width: 3.w, height: 1.h, child: DecoratedBox( - decoration: BoxDecoration(color: Colors.white), + decoration: + BoxDecoration(color: Colors.white), ), ); }), @@ -469,7 +483,8 @@ class _InviteFriends extends State { ), ], )), - Expanded(child: Column( + Expanded( + child: Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceAround, @@ -490,7 +505,7 @@ class _InviteFriends extends State { height: 1.h, child: DecoratedBox( decoration: - BoxDecoration(color: Color(0xFF32A060)), + BoxDecoration(color: Color(0xFF32A060)), ), ); }), @@ -518,7 +533,8 @@ class _InviteFriends extends State { width: 3.w, height: 1.h, child: DecoratedBox( - decoration: BoxDecoration(color: Colors.white), + decoration: + BoxDecoration(color: Colors.white), ), ); }), @@ -535,8 +551,7 @@ class _InviteFriends extends State { children: [ Container( width: 50.w, - child: - Text( + child: Text( "好友完成首单", style: TextStyle( fontSize: 12.sp, @@ -554,7 +569,8 @@ class _InviteFriends extends State { width: 3.w, height: 1.h, child: DecoratedBox( - decoration: BoxDecoration(color: Colors.white), + decoration: + BoxDecoration(color: Colors.white), ), ); }), @@ -583,8 +599,7 @@ class _InviteFriends extends State { SizedBox(height: 8.h), Container( width: 50.w, - child: - Text( + child: Text( "邀请达成获得奖励", style: TextStyle( fontSize: 12.sp, @@ -595,8 +610,7 @@ class _InviteFriends extends State { ), ) ], - ) - , + ), ], ), ), @@ -606,17 +620,17 @@ class _InviteFriends extends State { } ///我的成就 - Widget achievement(){ + Widget achievement() { return Container( - width:double.infinity, + width: double.infinity, height: 150.h, decoration: BoxDecoration( - borderRadius: BorderRadius.circular(6), - color: Color(0xFFFFFFFF), - ), - margin: EdgeInsets.only(bottom:12.h,left:14.h,right: 14.h), - padding: EdgeInsets.only(top: 6.h,left: 6,right: 6,bottom: 16.h), - child:Column( + borderRadius: BorderRadius.circular(6), + color: Color(0xFFFFFFFF), + ), + margin: EdgeInsets.only(bottom: 12.h, left: 14.h, right: 14.h), + padding: EdgeInsets.only(top: 6.h, left: 6, right: 6, bottom: 16.h), + child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -628,7 +642,7 @@ class _InviteFriends extends State { ), ), height: 54.h, - width:double.infinity, + width: double.infinity, alignment: Alignment.center, child: Text( S.of(context).wodechengjiu, @@ -637,11 +651,11 @@ class _InviteFriends extends State { fontSize: 16.sp, color: Color(0xFF32A060), ), - ) - ), + )), Row( children: [ - Expanded(child:Column( + Expanded( + child: Column( children: [ Text( "${userInfo?.todayInviteNumber ?? 0}", @@ -651,7 +665,9 @@ class _InviteFriends extends State { color: Color(0xFF000000), ), ), - SizedBox(height: 5.h,), + SizedBox( + height: 5.h, + ), Text( "今日邀请", style: TextStyle( @@ -662,7 +678,8 @@ class _InviteFriends extends State { ) ], )), - Expanded(child:Column( + Expanded( + child: Column( children: [ Text( "${userInfo?.inviteNumber ?? 0}", @@ -672,7 +689,9 @@ class _InviteFriends extends State { color: Color(0xFF000000), ), ), - SizedBox(height: 5.h,), + SizedBox( + height: 5.h, + ), Text( "累积邀请", style: TextStyle( @@ -691,16 +710,16 @@ class _InviteFriends extends State { } ///我的邀请 - Widget mineInvite(){ + Widget mineInvite() { return Container( - width:double.infinity, + width: double.infinity, decoration: BoxDecoration( - borderRadius: BorderRadius.circular(6), - color: Color(0xFFFFFFFF), - ), - margin: EdgeInsets.only(bottom:12.h,left:14.h,right: 14.h), - padding: EdgeInsets.only(top: 6.h,left: 6,right: 6), - child:Column( + borderRadius: BorderRadius.circular(6), + color: Color(0xFFFFFFFF), + ), + margin: EdgeInsets.only(bottom: 12.h, left: 14.h, right: 14.h), + padding: EdgeInsets.only(top: 6.h, left: 6, right: 6), + child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -712,7 +731,7 @@ class _InviteFriends extends State { ), ), height: 54.h, - width:double.infinity, + width: double.infinity, alignment: Alignment.center, child: Text( S.of(context).wodeyaoqing, @@ -721,75 +740,80 @@ class _InviteFriends extends State { fontSize: 16.sp, color: Color(0xFF32A060), ), - ) + )), + SizedBox( + height: 12.h, ), - SizedBox(height:12.h,), - Padding(padding:EdgeInsets.symmetric(horizontal: 6.w), - child: - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - S.of(context).shoujihao, - style: TextStyle( - fontWeight: MyFontWeight.semi_bold, - fontSize:14.sp, - color: Color(0xFF000000), + Padding( + padding: EdgeInsets.symmetric(horizontal: 6.w), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + S.of(context).shoujihao, + style: TextStyle( + fontWeight: MyFontWeight.semi_bold, + fontSize: 14.sp, + color: Color(0xFF000000), + ), ), - ), - Text( - "注册时间", - style: TextStyle( - fontWeight: MyFontWeight.semi_bold, - fontSize:14.sp, - color: Color(0xFF000000), + Text( + "注册时间", + style: TextStyle( + fontWeight: MyFontWeight.semi_bold, + fontSize: 14.sp, + color: Color(0xFF000000), + ), ), - ), - ],),), - SizedBox(height:12.h,), + ], + ), + ), + SizedBox( + height: 12.h, + ), (invitationList.length == 0) ? NoDataView( - src: "assets/image/ding_dan.webp", - isShowBtn: false, - text:"还没有邀请记录哦~", - fontSize: 16.sp, - margin: EdgeInsets.only(top: 120.h), - ):ListView.builder( - padding: EdgeInsets.zero, - itemCount:invitationList.length, - scrollDirection: Axis.vertical, - shrinkWrap: true, - physics: NeverScrollableScrollPhysics(), - itemBuilder: (context, position) { - return GestureDetector( - onTap: () { - }, - child: mineInviteItem(invitationList[position]), - ); - }, - ), + src: "assets/image/ding_dan.webp", + isShowBtn: false, + text: "还没有邀请记录哦~", + fontSize: 16.sp, + margin: EdgeInsets.only(top: 120.h), + ) + : ListView.builder( + padding: EdgeInsets.zero, + itemCount: invitationList.length, + scrollDirection: Axis.vertical, + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + itemBuilder: (context, position) { + return GestureDetector( + onTap: () {}, + child: mineInviteItem(invitationList[position]), + ); + }, + ), ], ), ); } - Widget mineInviteItem(Invitation invitationList){ + Widget mineInviteItem(Invitation invitationList) { return Container( - child:Column( + child: Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( - AppUtils.phoneEncode(invitationList.phone ?? ""), - style: TextStyle( - color: Color(0xFF000000), - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, + AppUtils.phoneEncode(invitationList.phone ?? ""), + style: TextStyle( + color: Color(0xFF000000), + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + ), ), - ), Text( invitationList.createTime ?? "", style: TextStyle( @@ -831,13 +855,12 @@ class _InviteFriends extends State { SSDKContentTypes.webpage, ); SharesdkPlugin.share(ShareSDKPlatforms.wechatSession, params, - (state, userData, contentEntity, error) { - print("share!$state"); - }); + (state, userData, contentEntity, error) { + print("share!$state"); + }); } String buildShareUrl() { return "https://hx.lotus-wallet.com/invite.html?invite=${phone}"; } - } diff --git a/lib/retrofit/min_api.g.dart b/lib/retrofit/min_api.g.dart index 208cce14..49ea78ac 100644 --- a/lib/retrofit/min_api.g.dart +++ b/lib/retrofit/min_api.g.dart @@ -13,7 +13,9 @@ class _MinApiService implements MinApiService { this._dio, { this.baseUrl, }) { - baseUrl ??= 'http://192.168.10.54:8765/app/'; + // baseUrl ??= 'http://192.168.10.54:8765/app/'; + + baseUrl ??= kReleaseMode?serviceBaseUrl:localBaseUrl; } final Dio _dio; diff --git a/lib/retrofit/retrofit_api.dart b/lib/retrofit/retrofit_api.dart index 687a1c4f..76aaba10 100644 --- a/lib/retrofit/retrofit_api.dart +++ b/lib/retrofit/retrofit_api.dart @@ -76,7 +76,7 @@ abstract class ApiService { factory ApiService( Dio dio, { String? baseUrl, - required BuildContext context, + BuildContext? context, String? token, bool showLoading = false, bool isIp = false, @@ -103,7 +103,7 @@ abstract class ApiService { debugPrint("method = ${options.method.toString()}"); debugPrint("url = ${options.uri.toString()}"); debugPrint("headers = ${options.headers}"); - if (showLoading && !EasyLoading.isShow) { + if (context != null && showLoading && !EasyLoading.isShow) { //是否显示loading EasyLoading.show( status: S.of(context).zhengzaijiazai, @@ -129,7 +129,7 @@ abstract class ApiService { if (response.data is Map) { Map map = response.data; if (map["code"] == 40005 || map["code"] == 40001) { - if (!LoginTipsDialog().isShow) { + if (context != null && !LoginTipsDialog().isShow) { print("show: ${LoginTipsDialog().isShow}"); LoginTipsDialog().show(context); } @@ -182,6 +182,10 @@ abstract class ApiService { @GET("https://restapi.amap.com/v3/place/around?key=542b46afa8e4b88fe1eb3c4d0ba0872f&location={lat},{lng}&keywords={keywords}&offset={size}&page={page}&extensions=all") Future searchPoi(@Path("lat") String lat, @Path("lng") String lng, @Path("keywords") String keywords, int size, int page); + /// 逆地理编码 + @GET("https://restapi.amap.com/v3/geocode/regeo?key=542b46afa8e4b88fe1eb3c4d0ba0872f&location={lat},{lng}&extensions=base") + Future geocodeRegeo(@Path("lat") String lat, @Path("lng") String lng); + /// 用户登录 @POST("/auth/platform/memberLogin") Future?> memberLogin(@Body() Map param); diff --git a/lib/retrofit/retrofit_api.g.dart b/lib/retrofit/retrofit_api.g.dart index 26a37c2d..a8c620d2 100644 --- a/lib/retrofit/retrofit_api.g.dart +++ b/lib/retrofit/retrofit_api.g.dart @@ -13,7 +13,7 @@ class _ApiService implements ApiService { this._dio, { this.baseUrl, }) { - baseUrl ??= 'http://192.168.10.54:8766/app/'; + baseUrl ??= kReleaseMode ? serviceBaseUrl : localBaseUrl; } final Dio _dio; @@ -95,6 +95,35 @@ class _ApiService implements ApiService { return value; } + @override + Future geocodeRegeo( + String lat, + String lng, + ) async { + final _extra = {}; + final queryParameters = {}; + final _headers = {}; + const Map? _data = null; + final _result = await _dio.fetch(_setStreamType(Options( + method: 'GET', + headers: _headers, + extra: _extra, + ) + .compose( + _dio.options, + 'https://restapi.amap.com/v3/geocode/regeo?key=542b46afa8e4b88fe1eb3c4d0ba0872f&location=${lng},${lat}&extensions=base', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + )))); + final value = _result.data; + return value; + } + @override Future?> memberLogin(Map param) async { final _extra = {}; diff --git a/lib/settlement/settlement.dart b/lib/settlement/settlement.dart index 04afad59..b6d3ec91 100644 --- a/lib/settlement/settlement.dart +++ b/lib/settlement/settlement.dart @@ -4,11 +4,13 @@ import 'dart:io'; import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:flutter_datetime_picker_plus/src/datetime_picker_theme.dart' as picker_theme; +import 'package:flutter_datetime_picker_plus/src/datetime_picker_theme.dart' + as picker_theme; import 'package:flutter_datetime_picker_plus/flutter_datetime_picker_plus.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:fluwx/fluwx.dart'; +import 'package:geolocator/geolocator.dart'; import 'package:huixiang/data/settle_order_info.dart'; import 'package:huixiang/data/shopping_cart.dart'; import 'package:huixiang/data/subscribe_param.dart'; @@ -72,13 +74,13 @@ class _Settlement extends State { String? actProductId; String? actProductSkuId; ActivityDetails? activityDetails; - BargainType bargainType = BargainType.BargainZBug; + BargainType? bargainType = BargainType.BargainZBug; LaunchJoinAct? launchJoinAct; String? skuPrice1; - JoinActivity joinA = JoinActivity.GoJoin; + JoinActivity? joinA = JoinActivity.GoJoin; String? bargainOrderId; String? productSkuId; - int count1 = 0; + int? count1 = 0; String? productId; bool orderButton = false; bool useVipPriceSelect = true; @@ -140,7 +142,9 @@ class _Settlement extends State { storeId: storeId, showLoading: false); queryMemberInfo(); - if (widget.arguments["pid"] != null && widget.arguments["pid"] != "" && tableId <= 0) { + if (widget.arguments["pid"] != null && + widget.arguments["pid"] != "" && + tableId <= 0) { queryOrderInfo( address != null ? address!.id : null, ((storeInfo?.pickupType?.dineInTakeStatus ?? false) == true && @@ -161,7 +165,9 @@ class _Settlement extends State { count1, payChannel, tableId); - } else if ( widget.arguments["cid"] != null && widget.arguments["cid"] != "" && tableId <= 0) { + } else if (widget.arguments["cid"] != null && + widget.arguments["cid"] != "" && + tableId <= 0) { queryOrderInfo( address != null ? address!.id : null, ((storeInfo?.pickupType?.dineInTakeStatus ?? false) == true && @@ -170,7 +176,7 @@ class _Settlement extends State { selectedBtn != 2) ? diningStatus : selectedBtn, - widget.arguments["cid"]??0, + widget.arguments["cid"] ?? 0, 0, productId ?? 0, productSkuId ?? "", @@ -228,7 +234,9 @@ class _Settlement extends State { payChannel, tableId) async { try { - EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black); + EasyLoading.show( + status: S.current.zhengzaijiazai, + maskType: EasyLoadingMaskType.black); BaseData? baseData = await minService?.getOrderInfo({ "addressId": addressId, @@ -328,7 +336,8 @@ class _Settlement extends State { ///查看订单详情 queryOrderDetails(id) async { - EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black); + EasyLoading.show( + status: S.current.zhengzaijiazai, maskType: EasyLoadingMaskType.black); BaseData? baseData = await minService?.getOrderDetails({ "id": pageType != null ? widget.arguments["orderId"] : id ?? parentId, }).catchError((error) {}); @@ -347,7 +356,7 @@ class _Settlement extends State { ///取消优惠券 queryCancelMemberCoupon(orderId) async { BaseData? baseData = - await minService?.cancelMemberCoupon(orderId).catchError((error) {}); + await minService?.cancelMemberCoupon(orderId).catchError((error) {}); if (baseData?.isSuccess ?? false) { queryOrderDetails(parentId); // SmartDialog.showToast(baseData.data, alignment: Alignment.center); @@ -374,90 +383,112 @@ class _Settlement extends State { setState(() { this.selectedBtn = selectedBtn; }); - queryOrderInfo( - address?.id, - ((storeInfo?.pickupType?.dineInTakeStatus ?? false) == true && - (subscribeParam?.isEnableSubscribe ?? false) == false && - selectedBtn != 1 && - selectedBtn != 2) - ? diningStatus - : selectedBtn, - null, - 0, - productId ?? null, - productSkuId ?? "", - actProductId ?? "", - actProductSkuId ?? "", - "AUTO", - // useVipPriceSelect, - // useBenefitSelect, - count1, - payChannel, - tableId); - return; - // BaseData> baseDate = - // await minService?.queryAddress().catchError((error) {}); - // - // BMFCoordinate bmfCoordinate = BMFCoordinate( - // double.tryParse(storeInfo.latitude), - // double.tryParse(storeInfo.longitude), - // ); - // if (baseDate.isSuccess) { - // setState(() { - // address = baseDate.data[0]; - // }); - // for (int i = 1; i < baseDate.data.length; i++) { - // Address address1 = baseDate.data[i]; - // - // BMFCoordinate coordinate = await BMFCalculateUtils.coordConvert( - // coordinate: BMFCoordinate( - // double.tryParse(address.longitude), - // double.tryParse(address.latitude), - // ), - // fromType: BMF_COORD_TYPE.COMMON, - // toType: BMF_COORD_TYPE.BD09LL); - // BMFCoordinate coordinate1 = await BMFCalculateUtils.coordConvert( - // coordinate: BMFCoordinate( - // double.tryParse(address1.longitude), - // double.tryParse(address1.latitude), - // ), - // fromType: BMF_COORD_TYPE.COMMON, - // toType: BMF_COORD_TYPE.BD09LL); - // - // double mi = await BMFCalculateUtils.getLocationDistance( - // bmfCoordinate, coordinate); - // double mi1 = await BMFCalculateUtils.getLocationDistance( - // bmfCoordinate, coordinate1); - // if (mi1 < mi) { - // address = address1; - // } - // } - // await queryOrderInfo( - // address.id, - // ((storeInfo.pickupType.dineInTakeStatus ?? false) == true && - // (subscribeParam.isEnableSubscribe ?? false) == false && - // selectedBtn != 1 && - // selectedBtn != 2) - // ? diningStatus - // : selectedBtn, - // null, - // 0, - // productId ?? null, - // productSkuId ?? "", - // actProductId ?? "", - // actProductSkuId ?? "", - // "AUTO", - // // useVipPriceSelect, - // // useBenefitSelect, - // count1, - // payChannel, - // tableId); - // } + if (address != null) { + queryOrderInfo( + address?.id, + ((storeInfo?.pickupType?.dineInTakeStatus ?? false) == true && + (subscribeParam?.isEnableSubscribe ?? false) == false && + selectedBtn != 1 && + selectedBtn != 2) + ? diningStatus + : selectedBtn, + null, + 0, + productId ?? null, + productSkuId ?? "", + actProductId ?? "", + actProductSkuId ?? "", + "AUTO", + // useVipPriceSelect, + // useBenefitSelect, + count1, + payChannel, + tableId); + return; + } + BaseData>? baseDate = + await minService?.queryAddress().catchError((error) {}); + + Position? bmfCoordinate = Position( + latitude: double.tryParse(storeInfo?.latitude ?? "")!, + longitude: double.tryParse(storeInfo?.longitude ?? "")!, + timestamp: DateTime.now(), + accuracy: 0, + altitude: 0, + heading: 0, + speed: 0, + speedAccuracy: 0); + if (baseDate != null && + (baseDate.isSuccess ?? false) && + (baseDate.data ?? []).isNotEmpty) { + setState(() { + address = baseDate.data![0]; + }); + for (int i = 1; i < baseDate.data!.length; i++) { + Address? address1 = baseDate.data![i]; + Position? coordinate = Position( + // COMMON->BD09LL + longitude: double.tryParse(address?.longitude ?? "")!, + latitude: double.tryParse(address?.latitude ?? "")!, + timestamp: DateTime.now(), + accuracy: 0, + altitude: 0, + heading: 0, + speed: 0, + speedAccuracy: 0); + Position? coordinate1 = Position( + // COMMON->BD09LL + longitude: double.tryParse(address1.longitude ?? "")!, + latitude: double.tryParse(address1.latitude ?? "")!, + timestamp: DateTime.now(), + accuracy: 0, + altitude: 0, + heading: 0, + speed: 0, + speedAccuracy: 0); + double mi = Geolocator.distanceBetween( + bmfCoordinate.latitude, + bmfCoordinate.longitude, + coordinate.latitude, + coordinate.longitude, + ); + double mi1 = Geolocator.distanceBetween( + bmfCoordinate.latitude, + bmfCoordinate.longitude, + coordinate1.latitude, + coordinate1.longitude, + ); + if (mi1 < mi) { + address = address1; + } + } + await queryOrderInfo( + address?.id, + ((storeInfo?.pickupType?.dineInTakeStatus ?? false) == true && + (subscribeParam?.isEnableSubscribe ?? false) == false && + selectedBtn != 1 && + selectedBtn != 2) + ? diningStatus + : selectedBtn, + null, + 0, + productId ?? null, + productSkuId ?? "", + actProductId ?? "", + actProductSkuId ?? "", + "AUTO", + // useVipPriceSelect, + // useBenefitSelect, + count1, + payChannel, + tableId); + } } ///选择收货地址 selectedAddress(String addId) async { - BaseData>? baseDate = await minService?.queryAddress().catchError((error) {}); + BaseData>? baseDate = + await minService?.queryAddress().catchError((error) {}); if (baseDate?.isSuccess ?? false) { setState(() { baseDate!.data?.forEach((element) { @@ -553,7 +584,8 @@ class _Settlement extends State { ///小程序下单 queryPlaceOrderFirst() async { try { - EasyLoading.show(status: S.current.zhengzaijiazai, + EasyLoading.show( + status: S.current.zhengzaijiazai, maskType: EasyLoadingMaskType.black); // for (int i = 0; i < settleOrderInfo.orderProductList.length; i++) { // settleOrderInfo.orderProductList.forEach((element1) { @@ -573,21 +605,20 @@ class _Settlement extends State { placeOrderFirst?.cartSum = settleOrderInfo?.price; placeOrderFirst?.addressId = address == null ? null : address!.id; placeOrderFirst?.isSubscribe = - ((subscribeParam?.isEnableSubscribe ?? false) == true) - ? true - : false; //是否预约 - placeOrderFirst?.isTakeOut = ((storeInfo?.pickupType?.dineInTakeStatus ?? false) && - !(subscribeParam?.isEnableSubscribe ?? false) && - selectedBtn != 1 && - selectedBtn != 2) - ? diningStatus - : selectedBtn; + ((subscribeParam?.isEnableSubscribe ?? false) == true) + ? true + : false; //是否预约 + placeOrderFirst?.isTakeOut = + ((storeInfo?.pickupType?.dineInTakeStatus ?? false) && + !(subscribeParam?.isEnableSubscribe ?? false) && + selectedBtn != 1 && + selectedBtn != 2) + ? diningStatus + : selectedBtn; placeOrderFirst?.notes = remakers + (reservationTime ?? "") + ((subscribeParam?.isEnableSubscribe ?? false) == true - ? "预约门店:${((subscribeParam?.stores?.length ?? 0) == 1 - ? (subscribeParam?.stores?[0]) - : (subscribeStoresName ?? ""))}" + ? "预约门店:${((subscribeParam?.stores?.length ?? 0) == 1 ? (subscribeParam?.stores?[0]) : (subscribeStoresName ?? ""))}" : ""); placeOrderFirst?.numberOfPeople = "$numberOfPeople"; placeOrderFirst?.orderSource = 2; @@ -598,32 +629,41 @@ class _Settlement extends State { placeOrderFirst?.payChannel = ((placeOrderFirst?.cartSum == "0.00") ? payChannel = 0 : ((tableId > 0 - ? (minOrderInfo?.isRaise ?? false) - : (settleOrderInfo?.isRaise ?? false)) - ? 7 - : payChannel)); + ? (minOrderInfo?.isRaise ?? false) + : (settleOrderInfo?.isRaise ?? false)) + ? 7 + : payChannel)); placeOrderFirst?.promotionInfoDTO = PromotionInfoDTOBean(); - placeOrderFirst?.promotionInfoDTO?.promotionId = (tableId <= 0) ? (promotion?.id ?? "") : ""; + placeOrderFirst?.promotionInfoDTO?.promotionId = + (tableId <= 0) ? (promotion?.id ?? "") : ""; // : widget.arguments["pid"] ?? ""; - placeOrderFirst?.promotionInfoDTO?.couponId = (tableId <= 0) ? (couponListBean?.id ?? "") : ""; + placeOrderFirst?.promotionInfoDTO?.couponId = + (tableId <= 0) ? (couponListBean?.id ?? "") : ""; // : widget.arguments["cid"] ?? ""; // placeOrderFirst.promotionInfoDTO.useVipPrice = (settleOrderInfo.isRaise || payChannel == 5 || ((payChannel == 4 && (settleOrderInfo.usePlateMoney == false))) ) ? false : useVipPriceSelect; // placeOrderFirst.promotionInfoDTO.useBenefit = (settleOrderInfo.isRaise || payChannel == 5 || ((payChannel == 4 && settleOrderInfo.usePlateMoney == false))) ? false : useBenefitSelect; - placeOrderFirst?.promotionInfoDTO?.discountType = (!placeOrder) ? "AUTO" : settleOrderInfo?.discountType ?? ""; - placeOrderFirst?.recMobile = (mobile?.isNotEmpty ?? false) ? mobile! : storeInfo!.headMobile; - placeOrderFirst?.shoppingCartSkuItemList = settleOrderInfo!.orderProductList; + placeOrderFirst?.promotionInfoDTO?.discountType = + (!placeOrder) ? "AUTO" : settleOrderInfo?.discountType ?? ""; + placeOrderFirst?.recMobile = + (mobile?.isNotEmpty ?? false) ? mobile! : storeInfo!.headMobile; + placeOrderFirst?.shoppingCartSkuItemList = + settleOrderInfo!.orderProductList; placeOrderFirst?.skuItemDTOList = []; placeOrderFirst?.source = 1; placeOrderFirst?.storeId = storeInfo!.id; placeOrderFirst?.subcribeTime = subTime ?? ""; //预约时间 placeOrderFirst?.tableId = "$tableId"; - for (int i = 0; i < (shopCarGoods?.shoppingCartSkuItemList?.length ?? 0); i++) { - placeOrderFirst?.shoppingCartSkuItemList?[i].setMealDataList = shopCarGoods!.shoppingCartSkuItemList?[i].setMealDataList; + for (int i = 0; + i < (shopCarGoods?.shoppingCartSkuItemList?.length ?? 0); + i++) { + placeOrderFirst?.shoppingCartSkuItemList?[i].setMealDataList = + shopCarGoods!.shoppingCartSkuItemList?[i].setMealDataList; } if (tableId == 0) { ///正常的商店下单 - BaseData? baseData = await minService?.placeOrderFirst(placeOrderFirst!.toJson()) + BaseData? baseData = await minService + ?.placeOrderFirst(placeOrderFirst!.toJson()) .catchError((error) { print("error: $error"); }); @@ -633,7 +673,8 @@ class _Settlement extends State { await querySettlement(); } else { // orderButton = false; - SmartDialog.showToast(baseData?.msg ?? "", alignment: Alignment.center); + SmartDialog.showToast(baseData?.msg ?? "", + alignment: Alignment.center); } } else { ///火锅店下单, 等待结算 @@ -645,13 +686,15 @@ class _Settlement extends State { } else { if (parentId == "") { // 下单 - baseData = await minService?.placeOrderFirst(placeOrderFirst!.toJson()) + baseData = await minService + ?.placeOrderFirst(placeOrderFirst!.toJson()) .catchError((error) { print("error: $error"); }); } else { //加菜 - baseData = await minService?.addOrder(placeOrderFirst!.toJson()) + baseData = await minService + ?.addOrder(placeOrderFirst!.toJson()) .catchError((error) { print("error: $error"); }); @@ -668,22 +711,25 @@ class _Settlement extends State { } } else { // orderButton = false; - SmartDialog.showToast(baseData?.msg ?? "", alignment: Alignment.center); + SmartDialog.showToast(baseData?.msg ?? "", + alignment: Alignment.center); } } - }finally{ + } finally { EasyLoading.dismiss(); } } - ///结算 querySettlement() async { if (placeOrderFirst == null || minOrderInfo == null || downOrder == null) { return; } - placeOrderFirst?.id = ((parentId?.isNotEmpty ?? false) ? parentId : downOrder?.id); - placeOrderFirst?.orderProductVOList = ((downOrder == null) ? minOrderInfo!.orderProductVOList : downOrder!.orderProductVOList); + placeOrderFirst?.id = + ((parentId?.isNotEmpty ?? false) ? parentId : downOrder?.id); + placeOrderFirst?.orderProductVOList = ((downOrder == null) + ? minOrderInfo!.orderProductVOList + : downOrder!.orderProductVOList); if (placeOrderFirst?.payChannel == 1) { if (Platform.isAndroid) { @@ -694,7 +740,8 @@ class _Settlement extends State { await Min.initialize(); } } - BaseData? baseData = await minService?.settlementWx(placeOrderFirst!.toJson()) + BaseData? baseData = await minService + ?.settlementWx(placeOrderFirst!.toJson()) .catchError((error) { print(error); }); @@ -710,25 +757,25 @@ class _Settlement extends State { universalLink: "https://hx.lotus-wallet.com/app/", ); fluwx.pay( - which: Payment( - appId: wxPay.appId!, - partnerId: wxPay.partnerId!, - prepayId: wxPay.prepayId!, - packageValue: wxPay.packageValue!, - nonceStr: wxPay.nonceStr!, - timestamp: int.tryParse(wxPay.timeStamp!) ?? 0, - sign: wxPay.sign!, - ) - ); - }else{ + which: Payment( + appId: wxPay.appId!, + partnerId: wxPay.partnerId!, + prepayId: wxPay.prepayId!, + packageValue: wxPay.packageValue!, + nonceStr: wxPay.nonceStr!, + timestamp: int.tryParse(wxPay.timeStamp!) ?? 0, + sign: wxPay.sign!, + )); + } else { EasyLoading.dismiss(); SmartDialog.showToast("${baseData?.msg}", alignment: Alignment.center); - Future.delayed(Duration(seconds:2), () { + Future.delayed(Duration(seconds: 2), () { toOrderDetails(placeOrderFirst!.id); }); } } else { - BaseData? baseData = await minService?.settlementApi(placeOrderFirst!.toJson()) + BaseData? baseData = await minService + ?.settlementApi(placeOrderFirst!.toJson()) .catchError((error) { print(error); }); @@ -761,7 +808,8 @@ class _Settlement extends State { } } BaseData? baseData = await minService?.actPay({ - "orderId": bargainOrderId != null ? bargainOrderId! : launchJoinAct?.orderId, + "orderId": + bargainOrderId != null ? bargainOrderId! : launchJoinAct?.orderId, "payChannel": placeOrderFirst!.payChannel }).catchError((error) { print(error); @@ -777,31 +825,34 @@ class _Settlement extends State { universalLink: "https://hx.lotus-wallet.com/app/", ); fluwx.pay( - which: Payment( - appId: wxPay.appId!, - partnerId: wxPay.partnerId!, - prepayId: wxPay.prepayId!, - packageValue: wxPay.packageValue!, - nonceStr: wxPay.nonceStr!, - timestamp: int.tryParse(wxPay.timeStamp!) ?? 0, - sign: wxPay.sign!, - ) - ); + which: Payment( + appId: wxPay.appId!, + partnerId: wxPay.partnerId!, + prepayId: wxPay.prepayId!, + packageValue: wxPay.packageValue!, + nonceStr: wxPay.nonceStr!, + timestamp: int.tryParse(wxPay.timeStamp!) ?? 0, + sign: wxPay.sign!, + )); } } else { BaseData? baseData = await minService?.actPay({ - "orderId": bargainOrderId != null ? bargainOrderId : launchJoinAct?.orderId, + "orderId": + bargainOrderId != null ? bargainOrderId : launchJoinAct?.orderId, "payChannel": payChannel }).catchError((error) { print(error); }); if (baseData?.isSuccess ?? false) { - toOrderDetails(bargainOrderId != null ? bargainOrderId! : launchJoinAct?.orderId); + toOrderDetails( + bargainOrderId != null ? bargainOrderId! : launchJoinAct?.orderId); } else { SmartDialog.show( widget: SettlementTips( () { - toOrderDetails(bargainOrderId != null ? bargainOrderId! : launchJoinAct?.orderId); + toOrderDetails(bargainOrderId != null + ? bargainOrderId! + : launchJoinAct?.orderId); }, text: "${baseData?.msg}", )); @@ -875,14 +926,19 @@ class _Settlement extends State { child: Column( children: [ DistributionMode( - (addressId, isTake, memberCouponId, orderId, String? promotionId) { + (addressId, isTake, memberCouponId, orderId, + String? promotionId) { setState(() { this.selectedBtn = 0; }); queryOrderInfo( addressId, - ((storeInfo?.pickupType?.dineInTakeStatus ?? false) && - (subscribeParam?.isEnableSubscribe ?? false) && + ((storeInfo?.pickupType + ?.dineInTakeStatus ?? + false) && + (subscribeParam + ?.isEnableSubscribe ?? + false) && selectedBtn != 1 && selectedBtn != 2) ? diningStatus @@ -913,8 +969,10 @@ class _Settlement extends State { ), ///堂食/打包 - if ((storeInfo?.pickupType?.dineInTakeStatus ?? false) && - !(subscribeParam?.isEnableSubscribe ?? false) && + if ((storeInfo?.pickupType?.dineInTakeStatus ?? + false) && + !(subscribeParam?.isEnableSubscribe ?? + false) && selectedBtn != 1 && selectedBtn != 2) takeStatus(), @@ -944,8 +1002,10 @@ class _Settlement extends State { ///会员优惠选择 if ((settleOrderInfo != null || - minOrderInfo != null) && (placeOrder && tableId <= 0 && - !(settleOrderInfo?.isRaise ?? false))) + minOrderInfo != null) && + (placeOrder && + tableId <= 0 && + !(settleOrderInfo?.isRaise ?? false))) VipDiscountsSelect( vipSelectCheck, settleOrderInfo, @@ -973,7 +1033,8 @@ class _Settlement extends State { "remake": remakers }).then((value) => { setState(() { - if (value != null) remakers = value as String; + if (value != null) + remakers = value as String; }) }); }, @@ -1074,11 +1135,12 @@ class _Settlement extends State { // return; // } else // orderButton = true; - if (((subscribeParam?.isEnableSubscribe ?? false)) && + if (((subscribeParam?.isEnableSubscribe ?? + false)) && (((subscribeParam?.stores?.length == 1 - ? subscribeParam?.stores![0] - : subscribeStoresName) == - null))) { + ? subscribeParam?.stores![0] + : subscribeStoresName) == + null))) { SmartDialog.showToast( (reservationTime == null) ? S.of(context).qingxuanzeyuyeushijian @@ -1271,10 +1333,12 @@ class _Settlement extends State { borderRadius: BorderRadius.all(Radius.circular(6)), border: Border.all( width: diningStatus == 3 ? 2.w : 1.w, - color: diningStatus == 3 ? Color(0xFF32A060) : Color(0xFFDEDEDE), + color: + diningStatus == 3 ? Color(0xFF32A060) : Color(0xFFDEDEDE), style: BorderStyle.solid, ), - color: diningStatus == 3 ? Color(0xFFEEFFF5) : Color(0xFFFFFFFF), + color: + diningStatus == 3 ? Color(0xFFEEFFF5) : Color(0xFFFFFFFF), ), padding: EdgeInsets.only(top: 11.h, bottom: 14.h), child: Row( @@ -1489,8 +1553,7 @@ class _Settlement extends State { } int couponCount() { - if (settleOrderInfo?.couponList?.isEmpty ?? true) - return 0; + if (settleOrderInfo?.couponList?.isEmpty ?? true) return 0; int count = 0; settleOrderInfo!.couponList?.forEach((element) { if (element.tenantCode == "") { @@ -1530,13 +1593,19 @@ class _Settlement extends State { selectedBtn != 2) ? diningStatus : selectedBtn, - ((couponBean.id??0) == 0 && (promotion?.id ?? productId ?? 0) !=0) ? 0: couponBean.id, + ((couponBean.id ?? 0) == 0 && (promotion?.id ?? productId ?? 0) != 0) + ? 0 + : couponBean.id, 0, - ((couponBean.id??0) == 0 && (promotion?.id ?? productId ?? 0) !=0) ? promotion?.id ?? productId :0, + ((couponBean.id ?? 0) == 0 && (promotion?.id ?? productId ?? 0) != 0) + ? promotion?.id ?? productId + : 0, productSkuId ?? "", actProductId ?? "", actProductSkuId ?? "", - (couponBean.id ?? 0) == 0 ? ((promotion?.id ?? productId ?? 0) !=0 ? "ACTIVITY":"AUTO") : "COUPON", + (couponBean.id ?? 0) == 0 + ? ((promotion?.id ?? productId ?? 0) != 0 ? "ACTIVITY" : "AUTO") + : "COUPON", // useVipPriceSelect, // useBenefitSelect, count1, @@ -1570,13 +1639,21 @@ class _Settlement extends State { selectedBtn != 2) ? diningStatus : selectedBtn, - (((pro.id ?? 0) ?? (productId ?? 0)) == 0 && (couponListBean?.id ??0) != 0)?couponListBean?.id:0, + (((pro.id ?? 0) ?? (productId ?? 0)) == 0 && + (couponListBean?.id ?? 0) != 0) + ? couponListBean?.id + : 0, 0, - (((pro.id ?? 0) ?? (productId ?? 0)) == 0 && (couponListBean?.id ??0) != 0) ? 0 :((pro.id ?? 0) ?? productId), + (((pro.id ?? 0) ?? (productId ?? 0)) == 0 && + (couponListBean?.id ?? 0) != 0) + ? 0 + : ((pro.id ?? 0) ?? productId), productSkuId ?? "", actProductId ?? "", actProductSkuId ?? "", - (((pro.id ?? 0) ?? (productId ?? 0)) == 0 ? ((couponListBean?.id ??0) != 0 ? "COUPON":"AUTO") : "ACTIVITY"), + (((pro.id ?? 0) ?? (productId ?? 0)) == 0 + ? ((couponListBean?.id ?? 0) != 0 ? "COUPON" : "AUTO") + : "ACTIVITY"), // useVipPriceSelect, // useBenefitSelect, count1, @@ -1586,7 +1663,9 @@ class _Settlement extends State { ///立即预约时间选择 showDateSelector() { - var minTime = DateTime.now().isAfter(DateTime.tryParse(subscribeParam?.subscribeStartTime ?? "") ?? DateTime.now()) + var minTime = DateTime.now().isAfter( + DateTime.tryParse(subscribeParam?.subscribeStartTime ?? "") ?? + DateTime.now()) ? DateTime.now() : DateTime.tryParse(subscribeParam?.subscribeStartTime ?? ""); DatePicker.showDateTimePicker(context, @@ -1614,32 +1693,32 @@ class _Settlement extends State { ///预约店铺 showAlertDialog() { showModalBottomSheet( - builder: (BuildContext context) { - return StatefulBuilder(builder: (context, state) { - return Container( - width: double.infinity, - height: 300.h, - padding: EdgeInsets.symmetric( - horizontal: 14.w, - vertical: 16.h, - ), - decoration: new BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.only( - topLeft: Radius.circular(8), - topRight: Radius.circular(8), - ), + builder: (BuildContext context) { + return StatefulBuilder(builder: (context, state) { + return Container( + width: double.infinity, + height: 300.h, + padding: EdgeInsets.symmetric( + horizontal: 14.w, + vertical: 16.h, + ), + decoration: new BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(8), + topRight: Radius.circular(8), ), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Expanded( - child: Container( + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded( + child: Container( alignment: Alignment.center, margin: EdgeInsets.symmetric(vertical: 5.h), child: Text( @@ -1650,72 +1729,74 @@ class _Settlement extends State { color: Color(0xFF353535), ), ), - ),), - GestureDetector( + ), + ), + GestureDetector( + onTap: () { + setState(() { + Navigator.of(context).pop(); + }); + }, + child: Icon( + Icons.clear, + color: Colors.black, + size: 18, + ), + ), + // SizedBox(width:4.w), + ], + ), + Expanded( + child: ListView.builder( + itemCount: subscribeParam?.stores?.length ?? 0, + itemBuilder: (context, position) { + return GestureDetector( onTap: () { - setState(() { - Navigator.of(context).pop(); + state(() { + storesIndex = position; }); }, - child: Icon( - Icons.clear, - color: Colors.black, - size: 18, - ), - ), - // SizedBox(width:4.w), - ], + child: storesNameItem(position), + ); + }, ), - Expanded( - child: ListView.builder( - itemCount: subscribeParam?.stores?.length ?? 0, - itemBuilder: (context, position) { - return GestureDetector( - onTap: () { - state(() { - storesIndex = position; - }); - }, - child: storesNameItem(position), - ); - }, + ), + GestureDetector( + onTap: () { + setState(() { + subscribeStoresName = + subscribeParam?.stores?[storesIndex]; + }); + Navigator.of(context).pop(); + }, + child: Container( + width: double.infinity, + height: 40.h, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(100), + color: Color(0xFF32A060), ), - ), - GestureDetector( - onTap: () { - setState(() { - subscribeStoresName = subscribeParam?.stores?[storesIndex]; - }); - Navigator.of(context).pop(); - }, - child: Container( - width: double.infinity, - height: 40.h, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(100), - color: Color(0xFF32A060), - ), - alignment: Alignment.center, - margin: EdgeInsets.only( - bottom: 10.h, - ), - child: Text( - S.of(context).queding, - style: TextStyle( - fontWeight: MyFontWeight.bold, - fontSize: 16.sp, - color: Color(0xFFFFFFFF), - ), + alignment: Alignment.center, + margin: EdgeInsets.only( + bottom: 10.h, + ), + child: Text( + S.of(context).queding, + style: TextStyle( + fontWeight: MyFontWeight.bold, + fontSize: 16.sp, + color: Color(0xFFFFFFFF), ), ), ), - ], - ), - ); - }); - }, - backgroundColor: Colors.transparent, - context: context, + ), + ], + ), + ); + }); + }, + backgroundColor: Colors.transparent, + context: context, ); } diff --git a/lib/settlement/settlement_view/distribution.dart b/lib/settlement/settlement_view/distribution.dart index 4b71400f..5104d763 100644 --- a/lib/settlement/settlement_view/distribution.dart +++ b/lib/settlement/settlement_view/distribution.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; -import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart'; -import 'package:flutter_bmflocation/flutter_bmflocation.dart'; import 'package:flutter_svg/flutter_svg.dart'; +import 'package:geolocator/geolocator.dart'; import 'package:huixiang/data/address.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/data/store_info.dart'; @@ -42,7 +41,7 @@ class _DistributionMode extends State { "assets/svg/dingdan_wuliu.svg", ]; - BMFCoordinate? myLatLng; + Position? myLatLng; String distance = "0"; int selectedBtn = 0; @@ -55,28 +54,41 @@ class _DistributionMode extends State { ///定位获取当前的位置 void startLocation() async { - Location.instance.startLocation(context, (BaiduLocation result) { - if (result.latitude != null && - result.longitude != null) { + LocationInstance.getInstance().startLocation(context, (Position? result) { + if (result?.latitude != null && result?.longitude != null) { print("location: $result"); - myLatLng = BMFCoordinate(result.latitude!, result.longitude!); + myLatLng = Position( + latitude: result?.latitude ?? 0, + longitude: result?.longitude ?? 0, + timestamp: DateTime.now(), + accuracy: 0, + altitude: 0, + heading: 0, + speed: 0, + speedAccuracy: 0); calculate(); - Location.instance.stopLocation(); + LocationInstance.getInstance().stopLocation(); } }); } calculate() async { - if (widget.storeInfo == null) { - return; - } - BMFCoordinate bmfCoordinate = BMFCoordinate( - double.tryParse("${widget.storeInfo!.latitude}") ?? 0, - double.tryParse("${widget.storeInfo!.longitude}") ?? 0, + Position? bmfCoordinate = Position( + latitude: double.tryParse(widget.storeInfo?.latitude ?? "")!, + longitude: double.tryParse(widget.storeInfo?.longitude ?? "")!, + timestamp: DateTime.now(), + accuracy: 0, + altitude: 0, + heading: 0, + speed: 0, + speedAccuracy: 0 ); - if (myLatLng != null) { - distance = await AppUtils.calculateDistance(bmfCoordinate, myLatLng!); - } + distance = "${Geolocator.distanceBetween( + bmfCoordinate.latitude, + bmfCoordinate.longitude, + myLatLng!.latitude, + myLatLng!.longitude, + )}"; setState(() {}); } @@ -126,7 +138,8 @@ class _DistributionMode extends State { onTap: () { setState(() { selectedBtn = 0; - widget.queryOrderInfo(null, selectedBtn, null, 0, null); + widget.queryOrderInfo( + null, selectedBtn, null, 0, null); }); }, child: Container( @@ -161,7 +174,10 @@ class _DistributionMode extends State { height: 50.h, alignment: Alignment.center, child: Text( - (widget.storeInfo?.pickupType?.takeawayStatus ?? false) ? "" :S.of(context).waimaipeisong, + (widget.storeInfo?.pickupType?.takeawayStatus ?? + false) + ? "" + : S.of(context).waimaipeisong, style: TextStyle( fontSize: 14.sp, fontWeight: MyFontWeight.regular, @@ -189,7 +205,11 @@ class _DistributionMode extends State { height: 50.h, alignment: Alignment.center, child: Text( - (widget.storeInfo?.pickupType?.expressDeliveryStatus ?? false) ? "" :S.of(context).kuaidiwuliu, + (widget.storeInfo?.pickupType + ?.expressDeliveryStatus ?? + false) + ? "" + : S.of(context).kuaidiwuliu, style: TextStyle( fontSize: 14.sp, fontWeight: MyFontWeight.regular, @@ -205,14 +225,16 @@ class _DistributionMode extends State { selectedBtn == 0 ? Container( width: double.infinity, - padding: EdgeInsets.only(left: 16.w, right: 16.w, top: 15.h), + padding: + EdgeInsets.only(left: 16.w, right: 16.w, top: 15.h), child: Column( children: [ Row( children: [ Expanded( child: Column( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.max, children: [ @@ -270,9 +292,7 @@ class _DistributionMode extends State { 100) .toInt() / 100.0)) - : "距离您${(widget.distance ?? 0) > 1000 ? - "${((widget.distance ?? 0) / 1000 * 100).toInt() / 100.0}km" - : S.of(context).mi(((widget.distance ?? 0) * 100).toInt() / 100.0)}", + : "距离您${(widget.distance ?? 0) > 1000 ? "${((widget.distance ?? 0) / 1000 * 100).toInt() / 100.0}km" : S.of(context).mi(((widget.distance ?? 0) * 100).toInt() / 100.0)}", // distance.length > 3 // ? "${distance}km" // : "距离您${distance}km", @@ -311,7 +331,8 @@ class _DistributionMode extends State { }, child: Container( width: double.infinity, - padding: EdgeInsets.only(left: 16.w, right: 16.w, top: 15.h), + padding: + EdgeInsets.only(left: 16.w, right: 16.w, top: 15.h), child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, @@ -321,10 +342,14 @@ class _DistributionMode extends State { crossAxisAlignment: CrossAxisAlignment.center, children: [ Image.asset( - (widget.storeInfo?.pickupType?.expressDeliveryStatus ?? false) ? "assets/image/order_wl.webp":"assets/image/icon_permission_location.webp", - height: 24.h, - width: 24.w, - ), + (widget.storeInfo?.pickupType + ?.expressDeliveryStatus ?? + false) + ? "assets/image/order_wl.webp" + : "assets/image/icon_permission_location.webp", + height: 24.h, + width: 24.w, + ), SizedBox(width: 5), Text( widget.address?.username ?? "", diff --git a/lib/store/shopping/shopping_cart/shopping_cart_page.dart b/lib/store/shopping/shopping_cart/shopping_cart_page.dart index 478b73fb..692517bb 100644 --- a/lib/store/shopping/shopping_cart/shopping_cart_page.dart +++ b/lib/store/shopping/shopping_cart/shopping_cart_page.dart @@ -101,13 +101,16 @@ class _ShoppingCartPage extends State cartSkuItem?.selected = selected; shopCarTemp["selected"] = selected; shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem?.toJson()]; - BaseData? baseDate = await minService?.shoppingCartSingle(shopCarTemp); + BaseData? baseDate = await minService?.shoppingCartSingle(shopCarTemp).catchError((error){}); if (baseDate?.isSuccess ?? false) { - setState(() { - queryShopCar(); - }); + // setState(() { + queryShopCar(); + // }); + refreshController.refreshCompleted(); + } else { + queryShopCar(); + refreshController.refreshFailed(); } - refreshController.refreshFailed(); } final SwiperController controller = SwiperController(); diff --git a/lib/store/store_order.dart b/lib/store/store_order.dart index 967b8608..0c4debf0 100644 --- a/lib/store/store_order.dart +++ b/lib/store/store_order.dart @@ -910,9 +910,24 @@ class _StoreOrderPage extends State await minService?.shoppingCartSingle(shopCarTemp); if (baseDate?.isSuccess ?? false) { this.shopCarGoods = await queryShopCar(); - shopCartKey.currentState?.setState(() {}); - setState(() {}); + if (shopCartKey != null) { + shopCartKey.currentState?.setState(() {}); + } + }else { + this.shopCarGoods = await queryShopCar(); + if (shopCartKey != null) { + shopCartKey.currentState?.setState(() {}); + } + if (baseDate != null + && baseDate.msg != null + && baseDate.msg != "") { + SmartDialog.showToast( + "${baseDate.msg}", + alignment: Alignment.center, + ); + } } + setState(() {}); return this.shopCarGoods; } diff --git a/lib/store/store_view/shop_car.dart b/lib/store/store_view/shop_car.dart index 12629bbe..3ae2d065 100644 --- a/lib/store/store_view/shop_car.dart +++ b/lib/store/store_view/shop_car.dart @@ -78,7 +78,12 @@ class _ShopCar extends State { ), InkWell( onTap: () { - widget.shopingCar?.shoppingCartSkuItemList?.clear(); + // widget.shopingCar?.shoppingCartSkuItemList?.clear(); + // state(() {}); + // widget.clearShopCar(); + if (widget.shopingCar?.shoppingCartSkuItemList != null) { + widget.shopingCar?.shoppingCartSkuItemList?.clear(); + } state(() {}); widget.clearShopCar(); }, diff --git a/lib/store/store_view/store_info.dart b/lib/store/store_view/store_info.dart index 4efd4516..43c05b2f 100644 --- a/lib/store/store_view/store_info.dart +++ b/lib/store/store_view/store_info.dart @@ -1,5 +1,8 @@ +import 'dart:io'; + import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:huixiang/data/store_info.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/utils/flutter_utils.dart'; @@ -9,6 +12,8 @@ import 'package:huixiang/view_widget/custom_image.dart'; import 'package:huixiang/view_widget/round_button.dart'; import 'package:url_launcher/url_launcher.dart'; +import '../../utils/location.dart'; + class StoreInfoView extends StatefulWidget { final StoreInfo? storeInfo; final double? distance; @@ -161,15 +166,16 @@ class _StoreInfoView extends State { GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { - Navigator.of(context).pushNamed( - '/router/location_map', - arguments: { - "lat": widget.storeInfo?.latitude, - "lng": widget.storeInfo?.longitude, - "storeInfo":widget.storeInfo, - "distance":widget.distance - }, - ); + // Navigator.of(context).pushNamed( + // '/router/location_map', + // arguments: { + // "lat": widget.storeInfo?.latitude, + // "lng": widget.storeInfo?.longitude, + // "storeInfo":widget.storeInfo, + // "distance":widget.distance + // }, + // ); + showMapSelect(); }, child: Container( color: Colors.transparent, @@ -185,15 +191,16 @@ class _StoreInfoView extends State { child: GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { - Navigator.of(context).pushNamed( - '/router/location_map', - arguments: { - "lat": widget.storeInfo?.latitude, - "lng": widget.storeInfo?.longitude, - "storeInfo":widget.storeInfo, - "distance":widget.distance - }, - ); + // Navigator.of(context).pushNamed( + // '/router/location_map', + // arguments: { + // "lat": widget.storeInfo?.latitude, + // "lng": widget.storeInfo?.longitude, + // "storeInfo":widget.storeInfo, + // "distance":widget.distance + // }, + // ); + showMapSelect(); }, child:Padding( padding: EdgeInsets.only(bottom: 8.h,), @@ -295,4 +302,58 @@ class _StoreInfoView extends State { )) .toList(); } + + + ///地图选择 + showMapSelect() { + showCupertinoModalPopup( + context: context, + builder: (context) { + return CupertinoActionSheet( + actions: [ + CupertinoActionSheetAction( + child: Text( + "使用高德地图导航", + style: TextStyle( + fontWeight: MyFontWeight.regular, + ), + ), + onPressed: () { + onOpenBaiduMap(); + Navigator.of(context).pop(); + }, + isDefaultAction: true, + isDestructiveAction: false, + ), + ], + cancelButton: CupertinoActionSheetAction( + onPressed: () { + Navigator.of(context).pop(); + }, + child: Text(S.of(context).quxiao, + style: TextStyle( + color: Colors.blue, + ),), + isDestructiveAction: true, + ), + ); + }); + } + + ///检测是否安装高德地图 + void onOpenBaiduMap() async { + LocationInstance.getInstance().startLocation(context, (locationData) { + String url = "${Platform.isIOS ? 'ios' : 'android'}amap://path?sourceApplication=haixia&sid=" + "&slat=${locationData?.latitude.toStringAsFixed(8)}&slon=${locationData?.longitude.toStringAsFixed(8)}&sname=&did=&dlat=${widget.storeInfo?.latitude}&dlon=${widget.storeInfo?.longitude}&dname=&dev=0&t=0"; + launch(url).then((value) { + if (!value) { + SmartDialog.showToast( + "未检测到安装高德地图", + alignment: Alignment.center, + ); + } + }); + }); + } + } diff --git a/lib/union/location_map_page.dart b/lib/union/location_map_page.dart index 22404700..c6421707 100644 --- a/lib/union/location_map_page.dart +++ b/lib/union/location_map_page.dart @@ -1,1168 +1,1168 @@ -import 'dart:io'; -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart'; -import 'package:flutter_baidu_mapapi_map/flutter_baidu_mapapi_map.dart'; -import 'package:flutter_baidu_mapapi_search/flutter_baidu_mapapi_search.dart'; -import 'package:flutter_baidu_mapapi_utils/flutter_baidu_mapapi_utils.dart'; -import 'package:flutter_bmflocation/flutter_bmflocation.dart'; -import 'package:flutter_easyloading/flutter_easyloading.dart'; -import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; -import 'package:huixiang/utils/flutter_utils.dart'; -import 'package:huixiang/utils/font_weight.dart'; -import 'package:huixiang/utils/location.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:permission_handler/permission_handler.dart'; -import 'package:url_launcher/url_launcher.dart'; - -import '../generated/l10n.dart'; -import '../data/store_info.dart'; -import '../view_widget/custom_image.dart'; -import '../view_widget/location_tips.dart'; -import '../view_widget/round_button.dart'; - -class LocationMap extends StatefulWidget { - final Map? arguments; - - LocationMap({this.arguments}); - - @override - State createState() { - return _LocationMap(); - } -} - -class _LocationMap extends State with WidgetsBindingObserver { - StoreInfo? storeInfo; - int navigationState = 0; - double? distance; - int navigationType = 0; - bool positionSorta = false; - String? myAddress; - String? myCity; - String? hours; - String? minutes; - String? polylineId; - bool _isShowLocalTips = false; - - @override - void initState() { - super.initState(); - WidgetsBinding.instance.addObserver(this); - storeInfo = widget.arguments?["storeInfo"]; - distance = widget.arguments?["distance"]; - getLocation(); - } - - void getLocation() async { - bool powerFlag = false; - try { - Future.delayed(Duration(seconds: 5), () { - Location.instance.stopLocation(); - }); - powerFlag = await Location.instance.startLocation(context, - (BaiduLocation result) { - if (result.latitude != null && - result.longitude != null) { - print("location: $result"); - myLatLng = BMFCoordinate(result.latitude!, result.longitude!); - myAddress = result.locationDetail; - myCity = result.city; - // AppUtils.coordConvert(myLatLng).then((value) { - // this.myLatLng = value; - locationShow(); - // }); - Location.instance.stopLocation(); - } - }); - } finally { - if (!powerFlag) { - if (await Permission.locationWhenInUse.status.isGranted) { - getLocation(); - } else { - _isShowLocalTips = true; - } - // else { - // SmartDialog.showToast("您定位服务未开启,请前往系统设置中开启定位服务", - // alignment: Alignment.center); - // } - } - setState(() {}); - } - } - - locationShow() { - BMFLocation location = BMFLocation( - coordinate: myLatLng, - altitude: 0, - horizontalAccuracy: 5, - verticalAccuracy: -1.0, - speed: -1.0, - course: -1.0, - ); - BMFUserLocation userLocation = BMFUserLocation( - location: location, - ); - setState(() { - _mapController?.updateLocationData(userLocation); - }); - } - - @override - void dispose() { - WidgetsBinding.instance.removeObserver(this); - Location.instance.stopLocation(); - super.dispose(); - } - - @override - void didChangeAppLifecycleState(AppLifecycleState state) { - if (state == AppLifecycleState.resumed) { - // 处理应用程序切换回前台的逻辑 - permissionSettings(); - } else if (state == AppLifecycleState.paused) { - // 处理应用程序切换到后台的逻辑 - } - } - - void permissionSettings() async { - if (_isShowLocalTips && await Permission.location.isGranted) { - _isShowLocalTips = false; - getLocation(); - } - } - - @override - Widget build(BuildContext context) { - return Scaffold( - // appBar: MyAppBar( - // background: Color(0xFFF7F7F7), - // title: widget.arguments["storeName"], - // titleColor: Colors.black87, - // titleSize: 18.sp, - // leadingColor: Colors.black, - // ), - body: Stack( - children: [ - Stack( - children: [ - Column( - children: [ - Expanded( - child: Container( - //BMFMapWidget 组件会自动默认沾满全屏,并且挡住所有遮盖物 ,BMFTextureMapWidget不会强制遮盖其他控件。 - child: (Platform.isAndroid) - ? BMFTextureMapWidget( - mapOptions: BMFMapOptions( - center: BMFCoordinate( - double.tryParse(widget.arguments?["lat"]) ?? 0, - double.tryParse(widget.arguments?["lng"]) ?? 0, - ), - showZoomControl: false, - showMapScaleBar: false, - rotateEnabled: false, - zoomLevel: 15, - ), - onBMFMapCreated: onMapCreated, - ) - : BMFMapWidget( - mapOptions: BMFMapOptions( - center: BMFCoordinate( - double.tryParse(widget.arguments?["lat"]) ?? 0, - double.tryParse(widget.arguments?["lng"]) ?? 0, - ), - showZoomControl: false, - showMapScaleBar: false, - rotateEnabled: false, - zoomLevel: 15, - ), - onBMFMapCreated: onMapCreated, - )), - flex: 3, - ), - navigationState == 0 - ? Container( - height: 253.h, - padding: EdgeInsets.only( - top: 16.h, left: 16.w, right: 28.w, - ), - decoration: BoxDecoration( - color: Colors.white, - boxShadow: [ - BoxShadow( - color: Color(0x08213303), - offset: Offset(0, 2), - blurRadius: 4, - spreadRadius: 0, - ), - ], - borderRadius: BorderRadius.vertical( - top: Radius.circular(8), - ), - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - child: Row( - children: [ - Expanded( - child: Column( - children: [ - Text( - storeInfo?.storeName ?? "", - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 20.sp, - color: Color(0xFF0D0D0D), - fontWeight: MyFontWeight.medium, - ), - ), - Row( - children: [ - Text( - S.of(context).ren(storeInfo!.perCapitaConsumption ?? ""), - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 12.sp, - fontWeight: - MyFontWeight.regular, - color: Color(0xFF4D4D4D), - ), - ), - SizedBox( - width: 20.w, - ), - ]..addAll(itemServer(storeInfo!.businessService ?? "")), - ), - Text( - S.of(context).yingyeshijian(storeInfo == null - ? "" - : (storeInfo?.openStartTime == null && - storeInfo?.openEndTime == - null) - ? S.of(context).quantian - : "${storeInfo?.openStartTime!.substring(0, storeInfo?.openStartTime!.lastIndexOf(":"))} " - "- ${storeInfo?.openEndTime!.substring(0, storeInfo?.openEndTime!.lastIndexOf(":"))}"), - style: TextStyle( - color: Color(0xFF4D4D4D), - fontWeight: MyFontWeight.medium, - fontSize: 12.sp, - ), - ), - ], - mainAxisAlignment: - MainAxisAlignment.spaceAround, - crossAxisAlignment: - CrossAxisAlignment.start, - ), - ), - MImage( - storeInfo!.logo ?? "", - width: 72.h, - height: 72.h, - fit: BoxFit.cover, - errorSrc: "assets/image/default_1.webp", - fadeSrc: "assets/image/default_1.webp", - ), - ], - ), - ), - Padding( - padding: EdgeInsets.only(bottom: 32.h), - child: Text( - "${storeInfo != null ? storeInfo!.address : ""}", - maxLines: 2, - textAlign: TextAlign.justify, - style: TextStyle( - color: Color(0xFF353535), - fontWeight: MyFontWeight.regular, - fontSize: 12.sp, - ), - ), - ), - GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: () { - navigationState = 1; - if ((distance ?? 0) < 500) - navigationType = 1; - else if ((distance ?? 0) < 1500) - navigationType = 2; - else - navigationType = 4; - navigationPosition(); - }, - child: Container( - alignment: Alignment.center, - width: double.infinity, - padding: EdgeInsets.symmetric(vertical: 10.h), - margin: EdgeInsets.only(bottom: 30.h), - decoration: BoxDecoration( - color: Color(0xFF32A060), - borderRadius: BorderRadius.circular(23), - ), - child: Text( - "到这去", - style: TextStyle( - fontSize: 20.sp, - color: Colors.white, - fontWeight: MyFontWeight.medium, - ), - ), - ), - ) - ], - ), - ) - : navigationDistance(), - ], - ), - navigationState == 0 - ? GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: () { - Navigator.of(context).pop(); - }, - child: Container( - height: 56.h, - margin: EdgeInsets.only( - top: MediaQuery.of(context).padding.top + 16.h, - left: 14.w, - right: 14.w), - padding: EdgeInsets.only(left: 12.w, right: 21.w), - decoration: BoxDecoration( - color: Colors.white, - boxShadow: [ - BoxShadow( - color: Color(0x08213303), - offset: Offset(0, 2), - blurRadius: 4, - spreadRadius: 0, - ), - ], - borderRadius: BorderRadius.circular(6), - ), - child: Row( - children: [ - Icon( - Icons.arrow_back_ios, - color: Color(0xFF353535), - size: 24, - ), - Expanded( - child: Text( - storeInfo?.storeName ?? "", - overflow: TextOverflow.ellipsis, - style: TextStyle( - color: Color(0xFF0D0D0D), - fontSize: 18.sp, - fontWeight: MyFontWeight.regular, - ), - )) - ], - ), - ), - ) - : navigationBox(), - ], - ), - if (_isShowLocalTips) - Padding( - padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top), - child: LocationTips(() { - setState(() { - _isShowLocalTips = false; - }); - }), - ) - ], - ), - ); - } - - void onOpenBaiduMap() async { - launch( - "baidumap://map/marker?location=${storeInfo?.latitude},${storeInfo?.longitude}&title=${storeInfo?.storeName}&content=${storeInfo?.storeName}&traffic=on&src=andr.baidu.openAPIdemo&coord_type=gcj02"); - } - - //調取百度地圖APP - void onOpenBaiduMapRoute() async { - // 我的位置 - BMFCoordinate startCoord = BMFCoordinate( - positionSorta == false - ? myLatLng!.latitude - : latLng!.latitude, - positionSorta == false - ? myLatLng!.longitude - : latLng!.longitude); - String startName = ((positionSorta == false) ? "我的位置" : "终点"); - // 去的位置 - String endName = ((positionSorta == false) ? "终点" : "我的位置"); - BMFCoordinate endCoord = BMFCoordinate( - positionSorta == false - ? latLng!.latitude - : myLatLng!.latitude, - positionSorta == false - ? latLng!.longitude - : myLatLng!.longitude); - BMFOpenRouteOption routeOption = BMFOpenRouteOption( - startCoord: startCoord, - startName: startName, - endCoord: endCoord, - endName: endName, - routeType: navigationType == 1 - ? BMFOpenRouteType.WalkingRoute - : navigationType == 2 - ? BMFOpenRouteType.WalkingRoute - : navigationType == 3 - ? BMFOpenRouteType.TransitRoute - : BMFOpenRouteType.DrivingRoute, - appScheme: 'baidumapsdk_flutter://mapsdk.baidu.com', - // 指定返回自定义scheme - isSupportWeb: true); - BMFOpenErrorCode? flag = await BMFOpenMapUtils.openBaiduMapRoute(routeOption); - print('open - route - errorCode = $flag'); - } - - updateMapLine(List coordinates, int? needHours, int? needMinutes, double? needDistance) { - try { - //刪除之前的創建的點和綫 - _mapController?.cleanAllMarkers(); - if (polylineId != null) { - _mapController?.removeOverlay(polylineId!); - } - - /// 创建polyline - BMFPolyline colorsPolyline = BMFPolyline( - // id: polylineOptions.hashCode.toString(), - coordinates: coordinates, - indexs: [0], - textures: [ - navigationType != 4 - ? 'assets/image/traffic_texture_unknown.png' - : 'assets/image/traffic_texture_smooth.png' - ], - width: Platform.isAndroid ? 16 : 10, - lineDashType: BMFLineDashType.LineDashTypeNone, - lineCapType: BMFLineCapType.LineCapButt, - lineJoinType: BMFLineJoinType.LineJoinRound); - polylineId = colorsPolyline.id; - - /// 添加polyline - _mapController?.addPolyline(colorsPolyline); - var startBmfMarker = BMFMarker.icon( - position: BMFCoordinate( - coordinates.first.latitude, coordinates.first.longitude), - centerOffset: BMFPoint(0.5, 0.7), - enabled: false, - icon: "assets/image/icon_start.png", - draggable: false, - ); - _mapController?.addMarker(startBmfMarker); - - var terminalBmfMarker = BMFMarker.icon( - position: BMFCoordinate( - coordinates.last.latitude, coordinates.last.longitude), - centerOffset: BMFPoint(0.5, 0.7), - enabled: false, - icon: "assets/image/icon_end.png", - draggable: false, - ); - _mapController?.addMarker(terminalBmfMarker); - - double maxLatitude = 0, - minLatitude = 0, - maxLongitude = 0, - minLongitude = 0; - coordinates.forEach((element) { - if (element.latitude > maxLatitude) maxLatitude = element.latitude; - if (minLatitude == 0) - minLatitude = element.latitude; - else if (element.latitude < minLatitude) minLatitude = element.latitude; - - if (element.longitude > maxLongitude) maxLongitude = element.longitude; - if (minLongitude == 0) - minLongitude = element.longitude; - else if (element.longitude < minLongitude) - minLongitude = element.longitude; - }); - _mapController?.setVisibleMapBounds( - BMFCoordinateBounds( - northeast: BMFCoordinate( - maxLatitude + ((maxLatitude - minLatitude) * 0.8), - maxLongitude + ((maxLongitude - minLongitude) / 2)), - southwest: BMFCoordinate( - minLatitude - ((maxLatitude - minLatitude) * 0.2), - minLongitude - ((maxLongitude - minLongitude) / 2))), - true); - - hours = needHours == 0 ? "" : "$needHours小时"; - minutes = needMinutes == 0 ? "" : "$needMinutes分钟"; - distance = needDistance; - } finally { - setState(() {}); - EasyLoading.dismiss(); - } - } - - navigationPosition() async { - EasyLoading.show( - status: S.current.zhengzaijiazai, maskType: EasyLoadingMaskType.black); - BMFPlanNode from = BMFPlanNode( - cityName: positionSorta == false ? myCity : (storeInfo?.city ?? ""), - name: positionSorta == false ? myAddress : storeInfo?.address ?? "", - pt: positionSorta == false - ? BMFCoordinate(myLatLng?.latitude ?? 0, myLatLng?.longitude ?? 0) - : latLng); - BMFPlanNode to = BMFPlanNode( - // cityName: positionSorta == false ? (storeInfo?.city ?? "") : myCity, - // name: positionSorta == false ? (storeInfo?.address ?? "") : myAddress, - pt: positionSorta == false - ? latLng - : BMFCoordinate(myLatLng?.latitude ?? 0, myLatLng?.longitude ?? 0)); - if (navigationType == 1) { - //步行 - BMFWalkingRoutePlanOption walkingRoutePlanOption = - BMFWalkingRoutePlanOption(from: from, to: to); - // 检索实例 - BMFWalkingRouteSearch walkingRouteSearch = BMFWalkingRouteSearch(); - // 检索回调 - walkingRouteSearch.onGetWalkingRouteSearchResult(callback: - (BMFWalkingRouteResult result, BMFSearchErrorCode errorCode) async { - if (errorCode == BMFSearchErrorCode.RESULT_NOT_FOUND) { - SmartDialog.showToast("该方案暂无可用的规划路线", alignment: Alignment.center); - EasyLoading.dismiss(); - return; - } else if (errorCode != BMFSearchErrorCode.NO_ERROR) { - SmartDialog.showToast("获取路线规划失败,请稍后再试", alignment: Alignment.center); - EasyLoading.dismiss(); - return; - } - print( - '`步行检索回调 errorCode = ${errorCode} \n result = ${result.toMap()}'); - - /// 坐标点 - List coordinates = []; - result.routes?.first.steps?.forEach((e1) { - e1.points?.forEach((e2) { - coordinates.add(BMFCoordinate(e2.latitude, e2.longitude)); - }); - }); - updateMapLine( - coordinates, - result.routes?.first.duration?.hours, - result.routes?.first.duration?.minutes, - result.routes?.first.distance?.toDouble()); - }); - bool flag = - await walkingRouteSearch.walkingRouteSearch(walkingRoutePlanOption); - } else if (navigationType == 2) { - //骑行 - BMFRidingRoutePlanOption ridingRoutePlanOption = - BMFRidingRoutePlanOption(from: from, to: to); - BMFRidingRouteSearch ridingRouteSearch = BMFRidingRouteSearch(); - ridingRouteSearch.onGetRidingRouteSearchResult(callback: - (BMFRidingRouteResult result, BMFSearchErrorCode errorCode) { - if (errorCode == BMFSearchErrorCode.RESULT_NOT_FOUND) { - SmartDialog.showToast("该方案暂无可用的规划路线", alignment: Alignment.center); - EasyLoading.dismiss(); - return; - } else if (errorCode != BMFSearchErrorCode.NO_ERROR) { - SmartDialog.showToast("获取路线规划失败,请稍后再试", alignment: Alignment.center); - EasyLoading.dismiss(); - return; - } - print( - '`骑行检索回调 errorCode = ${errorCode} \n result = ${result.toMap()}'); - - /// 坐标点 - List coordinates = []; - result.routes?.first.steps?.forEach((e1) { - e1.points?.forEach((e2) { - coordinates.add(BMFCoordinate(e2.latitude, e2.longitude)); - }); - }); - updateMapLine( - coordinates, - result.routes?.first.duration?.hours, - result.routes?.first.duration?.minutes, - result.routes?.first.distance?.toDouble()); - }); -// 发起检索 - bool flag = - await ridingRouteSearch.ridingRouteSearch(ridingRoutePlanOption); - } else if (navigationType == 3) { - //公交 - BMFTransitRoutePlanOption transitRoutePlanOption = - BMFTransitRoutePlanOption(from: from, to: to, city: '武汉市'); - BMFTransitRouteSearch transitRouteSearch = BMFTransitRouteSearch(); - transitRouteSearch.onGetTransitRouteSearchResult(callback: - (BMFTransitRouteResult result, BMFSearchErrorCode errorCode) { - if (errorCode == BMFSearchErrorCode.RESULT_NOT_FOUND) { - SmartDialog.showToast("该方案暂无可用的规划路线", alignment: Alignment.center); - EasyLoading.dismiss(); - return; - } else if (errorCode != BMFSearchErrorCode.NO_ERROR) { - SmartDialog.showToast("获取路线规划失败,请稍后再试", alignment: Alignment.center); - EasyLoading.dismiss(); - return; - } - print( - '`市内公交检索回调 errorCode = ${errorCode} \n result = ${result.toMap()}'); - - /// 坐标点 - List coordinates = []; - result.routes?.first.steps?.forEach((e1) { - e1.points?.forEach((e2) { - coordinates.add(BMFCoordinate(e2.latitude, e2.longitude)); - }); - }); - updateMapLine( - coordinates, - result.routes?.first.duration?.hours, - result.routes?.first.duration?.minutes, - result.routes?.first.distance?.toDouble()); - }); -// 发起检索 - bool flag = - await transitRouteSearch.transitRouteSearch(transitRoutePlanOption); - } else { - //驾车 - BMFDrivingRoutePlanOption drivingRoutePlanOption = - BMFDrivingRoutePlanOption(from: from, to: to); - BMFDrivingRouteSearch drivingRouteSearch = BMFDrivingRouteSearch(); - drivingRouteSearch.onGetDrivingRouteSearchResult(callback: - (BMFDrivingRouteResult result, BMFSearchErrorCode errorCode) { - if (errorCode == BMFSearchErrorCode.RESULT_NOT_FOUND) { - SmartDialog.showToast("该方案暂无可用的规划路线", alignment: Alignment.center); - EasyLoading.dismiss(); - return; - } else if (errorCode != BMFSearchErrorCode.NO_ERROR) { - SmartDialog.showToast("获取路线规划失败,请稍后再试", alignment: Alignment.center); - EasyLoading.dismiss(); - return; - } - print( - '驾车检索回调 errorCode = ${errorCode} \n result = ${result.toMap()}'); - - /// 坐标点 - List coordinates = []; - result.routes?.first.steps?.forEach((e1) { - e1.points?.forEach((e2) { - coordinates.add(BMFCoordinate(e2.latitude, e2.longitude)); - }); - }); - updateMapLine( - coordinates, - result.routes?.first.duration?.hours, - result.routes?.first.duration?.minutes, - result.routes?.first.distance?.toDouble()); - }); -// 发起检索 - bool flag = - await drivingRouteSearch.dringRouteSearch(drivingRoutePlanOption); - } - } - - Widget navigationBox() { - return Container( - height: 132.h, - margin: EdgeInsets.only( - top: MediaQuery.of(context).padding.top + 16.h, - left: 14.w, - right: 14.w), - padding: EdgeInsets.only(left: 12.w, right: 18.w, top: 8.h), - decoration: BoxDecoration( - color: Colors.white, - boxShadow: [ - BoxShadow( - color: Color(0x08213303), - offset: Offset(0, 2), - blurRadius: 4, - spreadRadius: 0, - ), - ], - borderRadius: BorderRadius.circular(6), - ), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: () { - setState(() { - navigationState = 0; - }); - }, - child: Padding( - padding: EdgeInsets.only(top: 10.h, right: 10.w), - child: Icon( - Icons.arrow_back_ios, - color: Color(0xFF353535), - size: 24, - ), - ), - ), - Expanded( - child: Column( - children: [ - Container( - width: double.infinity, - decoration: BoxDecoration( - color: Color(0xFFF5F5F5), - borderRadius: BorderRadius.circular(6), - ), - padding: EdgeInsets.only( - top: 12.h, - bottom: 12.h, - left: 15.w, - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.only( - bottom: 14.h, - ), - child: Row( - children: [ - Container( - width: 4.h, - height: 4.h, - margin: EdgeInsets.only(right: 20.w), - decoration: BoxDecoration( - color: Color(0xFF32A060), - borderRadius: BorderRadius.circular(6), - ), - ), - Expanded( - child: Text( - positionSorta == false - ? "我的位置" - : (storeInfo?.storeName ?? ""), - overflow: TextOverflow.ellipsis, - style: TextStyle( - color: Color(0xFF0D0D0D), - fontSize: 14.sp, - fontWeight: MyFontWeight.semi_bold, - ), - )) - ], - ), - ), - Row( - children: [ - Container( - width: 4.h, - height: 4.h, - margin: EdgeInsets.only(right: 20.w), - decoration: BoxDecoration( - color: Color(0xFFFA5151), - borderRadius: BorderRadius.circular(6), - ), - ), - Expanded( - child: Text( - positionSorta == false - ? (storeInfo?.storeName ?? "") - : "我的位置", - overflow: TextOverflow.ellipsis, - style: TextStyle( - color: Color(0xFF0D0D0D), - fontSize: 14.sp, - fontWeight: MyFontWeight.semi_bold, - ), - )) - ], - ) - ], - )), - GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: () { - positionSorta = !positionSorta; - navigationPosition(); - }, - child: Container( - padding: EdgeInsets.only(right: 24.w), - child: Image.asset( - "assets/image/position_sort.webp", - fit: BoxFit.fill, - height: 16.h, - width: 14.w, - ), - ), - ) - ], - ), - ), - SizedBox( - height: 12.h, - ), - Row( - children: [ - Expanded( - child: GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: () { - navigationType = 4; - navigationPosition(); - }, - child: Container( - decoration: BoxDecoration( - color: navigationType == 4 - ? Color(0xFFE8FFF2) - : Colors.transparent, - borderRadius: BorderRadius.circular(23), - ), - padding: - EdgeInsets.symmetric(vertical: 5.h, horizontal: 13.w), - child: Row( - children: [ - if (navigationType == 4) - Image.asset( - "assets/image/icon_drive.webp", - fit: BoxFit.fill, - height: 16.h, - width: 14.w, - ), - Padding( - padding: EdgeInsets.only(left: 2.w), - child: Text( - "驾车", - overflow: TextOverflow.ellipsis, - style: TextStyle( - color: navigationType == 4 - ? Color(0xFF32A060) - : Colors.black, - fontSize: 12.sp, - fontWeight: MyFontWeight.medium, - ), - ), - ) - ], - ), - ), - )), - Expanded( - child: GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: () { - navigationType = 3; - navigationPosition(); - }, - child: Container( - decoration: BoxDecoration( - color: navigationType == 3 - ? Color(0xFFE8FFF2) - : Colors.transparent, - borderRadius: BorderRadius.circular(23), - ), - padding: EdgeInsets.symmetric( - vertical: 5.h, horizontal: 13.w), - child: Row( - children: [ - if (navigationType == 3) - Image.asset( - "assets/image/icon_transit.webp", - fit: BoxFit.fill, - height: 16.h, - width: 14.w, - ), - Padding( - padding: EdgeInsets.only(left: 2.w), - child: Text( - "公交", - overflow: TextOverflow.ellipsis, - style: TextStyle( - color: navigationType == 3 - ? Color(0xFF32A060) - : Colors.black, - fontSize: 12.sp, - fontWeight: MyFontWeight.medium, - ), - ), - ) - ], - ), - ))), - Expanded( - child: GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: () { - navigationType = 2; - navigationPosition(); - }, - child: Container( - decoration: BoxDecoration( - color: navigationType == 2 - ? Color(0xFFE8FFF2) - : Colors.transparent, - borderRadius: BorderRadius.circular(23), - ), - padding: EdgeInsets.symmetric( - vertical: 5.h, horizontal: 13.w), - child: Row( - children: [ - if (navigationType == 2) - Image.asset( - "assets/image/icon_by_bike.webp", - fit: BoxFit.fill, - height: 16.h, - width: 14.w, - ), - Padding( - padding: EdgeInsets.only(left: 2.w), - child: Text( - "骑行", - overflow: TextOverflow.ellipsis, - style: TextStyle( - color: navigationType == 2 - ? Color(0xFF32A060) - : Colors.black, - fontSize: 12.sp, - fontWeight: MyFontWeight.medium, - ), - ), - ) - ], - ), - ))), - Expanded( - child: GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: () { - navigationType = 1; - navigationPosition(); - }, - child: Container( - decoration: BoxDecoration( - color: navigationType == 1 - ? Color(0xFFE8FFF2) - : Colors.transparent, - borderRadius: BorderRadius.circular(23), - ), - padding: EdgeInsets.symmetric( - vertical: 5.h, horizontal: 13.w), - child: Row( - children: [ - if (navigationType == 1) - Image.asset( - "assets/image/icon_walk.webp", - fit: BoxFit.fill, - height: 16.h, - width: 14.w, - ), - Padding( - padding: EdgeInsets.only(left: 2.w), - child: Text( - "步行", - overflow: TextOverflow.ellipsis, - style: TextStyle( - color: navigationType == 1 - ? Color(0xFF32A060) - : Colors.black, - fontSize: 12.sp, - fontWeight: MyFontWeight.medium, - ), - ), - ) - ], - ), - ))), - ], - ) - ], - )) - ], - ), - ); - } - - Widget navigationDistance() { - return Container( - height: 173.h, - padding: EdgeInsets.only(top: 16.h, left: 16.w, right: 16.w), - decoration: BoxDecoration( - color: Colors.white, - boxShadow: [ - BoxShadow( - color: Color(0x08213303), - offset: Offset(0, 2), - blurRadius: 4, - spreadRadius: 0, - ), - ], - borderRadius: BorderRadius.vertical( - top: Radius.circular(8), - ), - ), - child: Column( - // mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "${navigationType == 1 ? "步行" : navigationType == 2 ? "骑行" : navigationType == 3 ? "公交" : "驾车"}${(hours ?? "") + (minutes ?? "")}", - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 20.sp, - color: Color(0xFF0D0D0D), - fontWeight: MyFontWeight.bold, - ), - ), - Padding( - padding: EdgeInsets.only(left: 40.w), - child: Text( - (distance ?? 0) > 1000 - ? S.of(context).gongli( - ((distance ?? 0) / 1000 * 100).toInt() / 100.0) - : S - .of(context) - .mi(((distance ?? 0) * 100).toInt() / 100.0), - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 20.sp, - color: Color(0xFF0D0D0D), - fontWeight: MyFontWeight.bold, - ), - ), - ), - ], - ), - ), - GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: () { - setState(() { - navigationState = 1; - showMapSelect(); - }); - }, - child: Container( - alignment: Alignment.center, - width: double.infinity, - padding: EdgeInsets.symmetric(vertical: 10.h), - margin: EdgeInsets.only(bottom: 30.h), - decoration: BoxDecoration( - color: Color(0xFF32A060), - borderRadius: BorderRadius.circular(23), - ), - child: Text( - navigationType == 1 - ? "步行导航" - : navigationType == 2 - ? "骑行导航" - : navigationType == 3 - ? "公交导航" - : "驾车导航", - style: TextStyle( - fontSize: 20.sp, - color: Colors.white, - fontWeight: MyFontWeight.medium, - ), - ), - ), - ) - ], - ), - ); - } - - showMapSelect() { - showCupertinoModalPopup( - context: context, - builder: (context) { - return CupertinoActionSheet( - actions: [ - CupertinoActionSheetAction( - child: Text( - "百度地图", - style: TextStyle( - fontWeight: MyFontWeight.regular, - ), - ), - onPressed: () { - onOpenBaiduMapRoute(); - Navigator.of(context).pop(); - }, - isDefaultAction: true, - isDestructiveAction: false, - ), - ], - cancelButton: CupertinoActionSheetAction( - onPressed: () { - Navigator.of(context).pop(); - }, - child: Text(S.of(context).quxiao, - style: TextStyle( - color: Colors.blue, - ),), - isDestructiveAction: true, - ), - ); - }); - } - - List itemServer(String businessService) { - if (businessService == "") return []; - var list = businessService.split(","); - return list - .map((e) => Container( - margin: EdgeInsets.only(right: 8.w), - child: RoundButton( - height: 17.h * AppUtils.textScale(context), - text: "$e", - backgroup: Color(0xFFFF7A1A), - padding: EdgeInsets.only( - left: 2.w, - right: 2.w, - ), - fontSize: 10.sp, - textColor: Colors.white, - ), - )) - .toList(); - } - - BMFMapController? _mapController; - BMFCoordinate? latLng; - BMFCoordinate? myLatLng; - BMFMarker? bmfMarker; - - onMapCreated(BMFMapController controller) { - _mapController = controller; - setState(() { - _mapController?.showUserLocation(true); - _mapController?.setCustomMapStyle('assets/map_style/chatian.sty', 0); - BMFUserLocationDisplayParam displayParam = BMFUserLocationDisplayParam( - locationViewOffsetX: 0, - locationViewOffsetY: 0, - accuracyCircleFillColor: Colors.red, - accuracyCircleStrokeColor: Colors.blue, - isAccuracyCircleShow: true, - locationViewImage: 'assets/image/icon_my_location.webp', - locationViewHierarchy: - BMFLocationViewHierarchy.LOCATION_VIEW_HIERARCHY_BOTTOM, - ); - _mapController?.updateLocationViewWithParam(displayParam); - addMarker(); - }); - } - - addMarker() async { - latLng = await AppUtils.coordConvert(BMFCoordinate(double.tryParse(widget.arguments?["lat"]) ?? 0, - double.tryParse(widget.arguments?["lng"]) ?? 0)); - if (latLng != null) { - _mapController?.setCenterCoordinate(latLng!, true); - } - } -} +// import 'dart:io'; +// import 'package:flutter/cupertino.dart'; +// import 'package:flutter/material.dart'; +// import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart'; +// import 'package:flutter_baidu_mapapi_map/flutter_baidu_mapapi_map.dart'; +// import 'package:flutter_baidu_mapapi_search/flutter_baidu_mapapi_search.dart'; +// import 'package:flutter_baidu_mapapi_utils/flutter_baidu_mapapi_utils.dart'; +// import 'package:flutter_bmflocation/flutter_bmflocation.dart'; +// import 'package:flutter_easyloading/flutter_easyloading.dart'; +// import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; +// import 'package:huixiang/utils/flutter_utils.dart'; +// import 'package:huixiang/utils/font_weight.dart'; +// import 'package:huixiang/utils/location.dart'; +// import 'package:flutter_screenutil/flutter_screenutil.dart'; +// import 'package:permission_handler/permission_handler.dart'; +// import 'package:url_launcher/url_launcher.dart'; +// +// import '../generated/l10n.dart'; +// import '../data/store_info.dart'; +// import '../view_widget/custom_image.dart'; +// import '../view_widget/location_tips.dart'; +// import '../view_widget/round_button.dart'; +// +// class LocationMap extends StatefulWidget { +// final Map? arguments; +// +// LocationMap({this.arguments}); +// +// @override +// State createState() { +// return _LocationMap(); +// } +// } +// +// class _LocationMap extends State with WidgetsBindingObserver { +// StoreInfo? storeInfo; +// int navigationState = 0; +// double? distance; +// int navigationType = 0; +// bool positionSorta = false; +// String? myAddress; +// String? myCity; +// String? hours; +// String? minutes; +// String? polylineId; +// bool _isShowLocalTips = false; +// +// @override +// void initState() { +// super.initState(); +// WidgetsBinding.instance.addObserver(this); +// storeInfo = widget.arguments?["storeInfo"]; +// distance = widget.arguments?["distance"]; +// getLocation(); +// } +// +// void getLocation() async { +// bool powerFlag = false; +// try { +// Future.delayed(Duration(seconds: 5), () { +// Location.instance.stopLocation(); +// }); +// powerFlag = await Location.instance.startLocation(context, +// (BaiduLocation result) { +// if (result.latitude != null && +// result.longitude != null) { +// print("location: $result"); +// myLatLng = BMFCoordinate(result.latitude!, result.longitude!); +// myAddress = result.locationDetail; +// myCity = result.city; +// // AppUtils.coordConvert(myLatLng).then((value) { +// // this.myLatLng = value; +// locationShow(); +// // }); +// Location.instance.stopLocation(); +// } +// }); +// } finally { +// if (!powerFlag) { +// if (await Permission.locationWhenInUse.status.isGranted) { +// getLocation(); +// } else { +// _isShowLocalTips = true; +// } +// // else { +// // SmartDialog.showToast("您定位服务未开启,请前往系统设置中开启定位服务", +// // alignment: Alignment.center); +// // } +// } +// setState(() {}); +// } +// } +// +// locationShow() { +// BMFLocation location = BMFLocation( +// coordinate: myLatLng, +// altitude: 0, +// horizontalAccuracy: 5, +// verticalAccuracy: -1.0, +// speed: -1.0, +// course: -1.0, +// ); +// BMFUserLocation userLocation = BMFUserLocation( +// location: location, +// ); +// setState(() { +// _mapController?.updateLocationData(userLocation); +// }); +// } +// +// @override +// void dispose() { +// WidgetsBinding.instance.removeObserver(this); +// Location.instance.stopLocation(); +// super.dispose(); +// } +// +// @override +// void didChangeAppLifecycleState(AppLifecycleState state) { +// if (state == AppLifecycleState.resumed) { +// // 处理应用程序切换回前台的逻辑 +// permissionSettings(); +// } else if (state == AppLifecycleState.paused) { +// // 处理应用程序切换到后台的逻辑 +// } +// } +// +// void permissionSettings() async { +// if (_isShowLocalTips && await Permission.location.isGranted) { +// _isShowLocalTips = false; +// getLocation(); +// } +// } +// +// @override +// Widget build(BuildContext context) { +// return Scaffold( +// // appBar: MyAppBar( +// // background: Color(0xFFF7F7F7), +// // title: widget.arguments["storeName"], +// // titleColor: Colors.black87, +// // titleSize: 18.sp, +// // leadingColor: Colors.black, +// // ), +// body: Stack( +// children: [ +// Stack( +// children: [ +// Column( +// children: [ +// Expanded( +// child: Container( +// //BMFMapWidget 组件会自动默认沾满全屏,并且挡住所有遮盖物 ,BMFTextureMapWidget不会强制遮盖其他控件。 +// child: (Platform.isAndroid) +// ? BMFTextureMapWidget( +// mapOptions: BMFMapOptions( +// center: BMFCoordinate( +// double.tryParse(widget.arguments?["lat"]) ?? 0, +// double.tryParse(widget.arguments?["lng"]) ?? 0, +// ), +// showZoomControl: false, +// showMapScaleBar: false, +// rotateEnabled: false, +// zoomLevel: 15, +// ), +// onBMFMapCreated: onMapCreated, +// ) +// : BMFMapWidget( +// mapOptions: BMFMapOptions( +// center: BMFCoordinate( +// double.tryParse(widget.arguments?["lat"]) ?? 0, +// double.tryParse(widget.arguments?["lng"]) ?? 0, +// ), +// showZoomControl: false, +// showMapScaleBar: false, +// rotateEnabled: false, +// zoomLevel: 15, +// ), +// onBMFMapCreated: onMapCreated, +// )), +// flex: 3, +// ), +// navigationState == 0 +// ? Container( +// height: 253.h, +// padding: EdgeInsets.only( +// top: 16.h, left: 16.w, right: 28.w, +// ), +// decoration: BoxDecoration( +// color: Colors.white, +// boxShadow: [ +// BoxShadow( +// color: Color(0x08213303), +// offset: Offset(0, 2), +// blurRadius: 4, +// spreadRadius: 0, +// ), +// ], +// borderRadius: BorderRadius.vertical( +// top: Radius.circular(8), +// ), +// ), +// child: Column( +// crossAxisAlignment: CrossAxisAlignment.start, +// children: [ +// Expanded( +// child: Row( +// children: [ +// Expanded( +// child: Column( +// children: [ +// Text( +// storeInfo?.storeName ?? "", +// overflow: TextOverflow.ellipsis, +// style: TextStyle( +// fontSize: 20.sp, +// color: Color(0xFF0D0D0D), +// fontWeight: MyFontWeight.medium, +// ), +// ), +// Row( +// children: [ +// Text( +// S.of(context).ren(storeInfo!.perCapitaConsumption ?? ""), +// overflow: TextOverflow.ellipsis, +// style: TextStyle( +// fontSize: 12.sp, +// fontWeight: +// MyFontWeight.regular, +// color: Color(0xFF4D4D4D), +// ), +// ), +// SizedBox( +// width: 20.w, +// ), +// ]..addAll(itemServer(storeInfo!.businessService ?? "")), +// ), +// Text( +// S.of(context).yingyeshijian(storeInfo == null +// ? "" +// : (storeInfo?.openStartTime == null && +// storeInfo?.openEndTime == +// null) +// ? S.of(context).quantian +// : "${storeInfo?.openStartTime!.substring(0, storeInfo?.openStartTime!.lastIndexOf(":"))} " +// "- ${storeInfo?.openEndTime!.substring(0, storeInfo?.openEndTime!.lastIndexOf(":"))}"), +// style: TextStyle( +// color: Color(0xFF4D4D4D), +// fontWeight: MyFontWeight.medium, +// fontSize: 12.sp, +// ), +// ), +// ], +// mainAxisAlignment: +// MainAxisAlignment.spaceAround, +// crossAxisAlignment: +// CrossAxisAlignment.start, +// ), +// ), +// MImage( +// storeInfo!.logo ?? "", +// width: 72.h, +// height: 72.h, +// fit: BoxFit.cover, +// errorSrc: "assets/image/default_1.webp", +// fadeSrc: "assets/image/default_1.webp", +// ), +// ], +// ), +// ), +// Padding( +// padding: EdgeInsets.only(bottom: 32.h), +// child: Text( +// "${storeInfo != null ? storeInfo!.address : ""}", +// maxLines: 2, +// textAlign: TextAlign.justify, +// style: TextStyle( +// color: Color(0xFF353535), +// fontWeight: MyFontWeight.regular, +// fontSize: 12.sp, +// ), +// ), +// ), +// GestureDetector( +// behavior: HitTestBehavior.opaque, +// onTap: () { +// navigationState = 1; +// if ((distance ?? 0) < 500) +// navigationType = 1; +// else if ((distance ?? 0) < 1500) +// navigationType = 2; +// else +// navigationType = 4; +// navigationPosition(); +// }, +// child: Container( +// alignment: Alignment.center, +// width: double.infinity, +// padding: EdgeInsets.symmetric(vertical: 10.h), +// margin: EdgeInsets.only(bottom: 30.h), +// decoration: BoxDecoration( +// color: Color(0xFF32A060), +// borderRadius: BorderRadius.circular(23), +// ), +// child: Text( +// "到这去", +// style: TextStyle( +// fontSize: 20.sp, +// color: Colors.white, +// fontWeight: MyFontWeight.medium, +// ), +// ), +// ), +// ) +// ], +// ), +// ) +// : navigationDistance(), +// ], +// ), +// navigationState == 0 +// ? GestureDetector( +// behavior: HitTestBehavior.opaque, +// onTap: () { +// Navigator.of(context).pop(); +// }, +// child: Container( +// height: 56.h, +// margin: EdgeInsets.only( +// top: MediaQuery.of(context).padding.top + 16.h, +// left: 14.w, +// right: 14.w), +// padding: EdgeInsets.only(left: 12.w, right: 21.w), +// decoration: BoxDecoration( +// color: Colors.white, +// boxShadow: [ +// BoxShadow( +// color: Color(0x08213303), +// offset: Offset(0, 2), +// blurRadius: 4, +// spreadRadius: 0, +// ), +// ], +// borderRadius: BorderRadius.circular(6), +// ), +// child: Row( +// children: [ +// Icon( +// Icons.arrow_back_ios, +// color: Color(0xFF353535), +// size: 24, +// ), +// Expanded( +// child: Text( +// storeInfo?.storeName ?? "", +// overflow: TextOverflow.ellipsis, +// style: TextStyle( +// color: Color(0xFF0D0D0D), +// fontSize: 18.sp, +// fontWeight: MyFontWeight.regular, +// ), +// )) +// ], +// ), +// ), +// ) +// : navigationBox(), +// ], +// ), +// if (_isShowLocalTips) +// Padding( +// padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top), +// child: LocationTips(() { +// setState(() { +// _isShowLocalTips = false; +// }); +// }), +// ) +// ], +// ), +// ); +// } +// +// void onOpenBaiduMap() async { +// launch( +// "baidumap://map/marker?location=${storeInfo?.latitude},${storeInfo?.longitude}&title=${storeInfo?.storeName}&content=${storeInfo?.storeName}&traffic=on&src=andr.baidu.openAPIdemo&coord_type=gcj02"); +// } +// +// //調取百度地圖APP +// void onOpenBaiduMapRoute() async { +// // 我的位置 +// BMFCoordinate startCoord = BMFCoordinate( +// positionSorta == false +// ? myLatLng!.latitude +// : latLng!.latitude, +// positionSorta == false +// ? myLatLng!.longitude +// : latLng!.longitude); +// String startName = ((positionSorta == false) ? "我的位置" : "终点"); +// // 去的位置 +// String endName = ((positionSorta == false) ? "终点" : "我的位置"); +// BMFCoordinate endCoord = BMFCoordinate( +// positionSorta == false +// ? latLng!.latitude +// : myLatLng!.latitude, +// positionSorta == false +// ? latLng!.longitude +// : myLatLng!.longitude); +// BMFOpenRouteOption routeOption = BMFOpenRouteOption( +// startCoord: startCoord, +// startName: startName, +// endCoord: endCoord, +// endName: endName, +// routeType: navigationType == 1 +// ? BMFOpenRouteType.WalkingRoute +// : navigationType == 2 +// ? BMFOpenRouteType.WalkingRoute +// : navigationType == 3 +// ? BMFOpenRouteType.TransitRoute +// : BMFOpenRouteType.DrivingRoute, +// appScheme: 'baidumapsdk_flutter://mapsdk.baidu.com', +// // 指定返回自定义scheme +// isSupportWeb: true); +// BMFOpenErrorCode? flag = await BMFOpenMapUtils.openBaiduMapRoute(routeOption); +// print('open - route - errorCode = $flag'); +// } +// +// updateMapLine(List coordinates, int? needHours, int? needMinutes, double? needDistance) { +// try { +// //刪除之前的創建的點和綫 +// _mapController?.cleanAllMarkers(); +// if (polylineId != null) { +// _mapController?.removeOverlay(polylineId!); +// } +// +// /// 创建polyline +// BMFPolyline colorsPolyline = BMFPolyline( +// // id: polylineOptions.hashCode.toString(), +// coordinates: coordinates, +// indexs: [0], +// textures: [ +// navigationType != 4 +// ? 'assets/image/traffic_texture_unknown.png' +// : 'assets/image/traffic_texture_smooth.png' +// ], +// width: Platform.isAndroid ? 16 : 10, +// lineDashType: BMFLineDashType.LineDashTypeNone, +// lineCapType: BMFLineCapType.LineCapButt, +// lineJoinType: BMFLineJoinType.LineJoinRound); +// polylineId = colorsPolyline.id; +// +// /// 添加polyline +// _mapController?.addPolyline(colorsPolyline); +// var startBmfMarker = BMFMarker.icon( +// position: BMFCoordinate( +// coordinates.first.latitude, coordinates.first.longitude), +// centerOffset: BMFPoint(0.5, 0.7), +// enabled: false, +// icon: "assets/image/icon_start.png", +// draggable: false, +// ); +// _mapController?.addMarker(startBmfMarker); +// +// var terminalBmfMarker = BMFMarker.icon( +// position: BMFCoordinate( +// coordinates.last.latitude, coordinates.last.longitude), +// centerOffset: BMFPoint(0.5, 0.7), +// enabled: false, +// icon: "assets/image/icon_end.png", +// draggable: false, +// ); +// _mapController?.addMarker(terminalBmfMarker); +// +// double maxLatitude = 0, +// minLatitude = 0, +// maxLongitude = 0, +// minLongitude = 0; +// coordinates.forEach((element) { +// if (element.latitude > maxLatitude) maxLatitude = element.latitude; +// if (minLatitude == 0) +// minLatitude = element.latitude; +// else if (element.latitude < minLatitude) minLatitude = element.latitude; +// +// if (element.longitude > maxLongitude) maxLongitude = element.longitude; +// if (minLongitude == 0) +// minLongitude = element.longitude; +// else if (element.longitude < minLongitude) +// minLongitude = element.longitude; +// }); +// _mapController?.setVisibleMapBounds( +// BMFCoordinateBounds( +// northeast: BMFCoordinate( +// maxLatitude + ((maxLatitude - minLatitude) * 0.8), +// maxLongitude + ((maxLongitude - minLongitude) / 2)), +// southwest: BMFCoordinate( +// minLatitude - ((maxLatitude - minLatitude) * 0.2), +// minLongitude - ((maxLongitude - minLongitude) / 2))), +// true); +// +// hours = needHours == 0 ? "" : "$needHours小时"; +// minutes = needMinutes == 0 ? "" : "$needMinutes分钟"; +// distance = needDistance; +// } finally { +// setState(() {}); +// EasyLoading.dismiss(); +// } +// } +// +// navigationPosition() async { +// EasyLoading.show( +// status: S.current.zhengzaijiazai, maskType: EasyLoadingMaskType.black); +// BMFPlanNode from = BMFPlanNode( +// cityName: positionSorta == false ? myCity : (storeInfo?.city ?? ""), +// name: positionSorta == false ? myAddress : storeInfo?.address ?? "", +// pt: positionSorta == false +// ? BMFCoordinate(myLatLng?.latitude ?? 0, myLatLng?.longitude ?? 0) +// : latLng); +// BMFPlanNode to = BMFPlanNode( +// // cityName: positionSorta == false ? (storeInfo?.city ?? "") : myCity, +// // name: positionSorta == false ? (storeInfo?.address ?? "") : myAddress, +// pt: positionSorta == false +// ? latLng +// : BMFCoordinate(myLatLng?.latitude ?? 0, myLatLng?.longitude ?? 0)); +// if (navigationType == 1) { +// //步行 +// BMFWalkingRoutePlanOption walkingRoutePlanOption = +// BMFWalkingRoutePlanOption(from: from, to: to); +// // 检索实例 +// BMFWalkingRouteSearch walkingRouteSearch = BMFWalkingRouteSearch(); +// // 检索回调 +// walkingRouteSearch.onGetWalkingRouteSearchResult(callback: +// (BMFWalkingRouteResult result, BMFSearchErrorCode errorCode) async { +// if (errorCode == BMFSearchErrorCode.RESULT_NOT_FOUND) { +// SmartDialog.showToast("该方案暂无可用的规划路线", alignment: Alignment.center); +// EasyLoading.dismiss(); +// return; +// } else if (errorCode != BMFSearchErrorCode.NO_ERROR) { +// SmartDialog.showToast("获取路线规划失败,请稍后再试", alignment: Alignment.center); +// EasyLoading.dismiss(); +// return; +// } +// print( +// '`步行检索回调 errorCode = ${errorCode} \n result = ${result.toMap()}'); +// +// /// 坐标点 +// List coordinates = []; +// result.routes?.first.steps?.forEach((e1) { +// e1.points?.forEach((e2) { +// coordinates.add(BMFCoordinate(e2.latitude, e2.longitude)); +// }); +// }); +// updateMapLine( +// coordinates, +// result.routes?.first.duration?.hours, +// result.routes?.first.duration?.minutes, +// result.routes?.first.distance?.toDouble()); +// }); +// bool flag = +// await walkingRouteSearch.walkingRouteSearch(walkingRoutePlanOption); +// } else if (navigationType == 2) { +// //骑行 +// BMFRidingRoutePlanOption ridingRoutePlanOption = +// BMFRidingRoutePlanOption(from: from, to: to); +// BMFRidingRouteSearch ridingRouteSearch = BMFRidingRouteSearch(); +// ridingRouteSearch.onGetRidingRouteSearchResult(callback: +// (BMFRidingRouteResult result, BMFSearchErrorCode errorCode) { +// if (errorCode == BMFSearchErrorCode.RESULT_NOT_FOUND) { +// SmartDialog.showToast("该方案暂无可用的规划路线", alignment: Alignment.center); +// EasyLoading.dismiss(); +// return; +// } else if (errorCode != BMFSearchErrorCode.NO_ERROR) { +// SmartDialog.showToast("获取路线规划失败,请稍后再试", alignment: Alignment.center); +// EasyLoading.dismiss(); +// return; +// } +// print( +// '`骑行检索回调 errorCode = ${errorCode} \n result = ${result.toMap()}'); +// +// /// 坐标点 +// List coordinates = []; +// result.routes?.first.steps?.forEach((e1) { +// e1.points?.forEach((e2) { +// coordinates.add(BMFCoordinate(e2.latitude, e2.longitude)); +// }); +// }); +// updateMapLine( +// coordinates, +// result.routes?.first.duration?.hours, +// result.routes?.first.duration?.minutes, +// result.routes?.first.distance?.toDouble()); +// }); +// // 发起检索 +// bool flag = +// await ridingRouteSearch.ridingRouteSearch(ridingRoutePlanOption); +// } else if (navigationType == 3) { +// //公交 +// BMFTransitRoutePlanOption transitRoutePlanOption = +// BMFTransitRoutePlanOption(from: from, to: to, city: '武汉市'); +// BMFTransitRouteSearch transitRouteSearch = BMFTransitRouteSearch(); +// transitRouteSearch.onGetTransitRouteSearchResult(callback: +// (BMFTransitRouteResult result, BMFSearchErrorCode errorCode) { +// if (errorCode == BMFSearchErrorCode.RESULT_NOT_FOUND) { +// SmartDialog.showToast("该方案暂无可用的规划路线", alignment: Alignment.center); +// EasyLoading.dismiss(); +// return; +// } else if (errorCode != BMFSearchErrorCode.NO_ERROR) { +// SmartDialog.showToast("获取路线规划失败,请稍后再试", alignment: Alignment.center); +// EasyLoading.dismiss(); +// return; +// } +// print( +// '`市内公交检索回调 errorCode = ${errorCode} \n result = ${result.toMap()}'); +// +// /// 坐标点 +// List coordinates = []; +// result.routes?.first.steps?.forEach((e1) { +// e1.points?.forEach((e2) { +// coordinates.add(BMFCoordinate(e2.latitude, e2.longitude)); +// }); +// }); +// updateMapLine( +// coordinates, +// result.routes?.first.duration?.hours, +// result.routes?.first.duration?.minutes, +// result.routes?.first.distance?.toDouble()); +// }); +// // 发起检索 +// bool flag = +// await transitRouteSearch.transitRouteSearch(transitRoutePlanOption); +// } else { +// //驾车 +// BMFDrivingRoutePlanOption drivingRoutePlanOption = +// BMFDrivingRoutePlanOption(from: from, to: to); +// BMFDrivingRouteSearch drivingRouteSearch = BMFDrivingRouteSearch(); +// drivingRouteSearch.onGetDrivingRouteSearchResult(callback: +// (BMFDrivingRouteResult result, BMFSearchErrorCode errorCode) { +// if (errorCode == BMFSearchErrorCode.RESULT_NOT_FOUND) { +// SmartDialog.showToast("该方案暂无可用的规划路线", alignment: Alignment.center); +// EasyLoading.dismiss(); +// return; +// } else if (errorCode != BMFSearchErrorCode.NO_ERROR) { +// SmartDialog.showToast("获取路线规划失败,请稍后再试", alignment: Alignment.center); +// EasyLoading.dismiss(); +// return; +// } +// print( +// '驾车检索回调 errorCode = ${errorCode} \n result = ${result.toMap()}'); +// +// /// 坐标点 +// List coordinates = []; +// result.routes?.first.steps?.forEach((e1) { +// e1.points?.forEach((e2) { +// coordinates.add(BMFCoordinate(e2.latitude, e2.longitude)); +// }); +// }); +// updateMapLine( +// coordinates, +// result.routes?.first.duration?.hours, +// result.routes?.first.duration?.minutes, +// result.routes?.first.distance?.toDouble()); +// }); +// // 发起检索 +// bool flag = +// await drivingRouteSearch.dringRouteSearch(drivingRoutePlanOption); +// } +// } +// +// Widget navigationBox() { +// return Container( +// height: 132.h, +// margin: EdgeInsets.only( +// top: MediaQuery.of(context).padding.top + 16.h, +// left: 14.w, +// right: 14.w), +// padding: EdgeInsets.only(left: 12.w, right: 18.w, top: 8.h), +// decoration: BoxDecoration( +// color: Colors.white, +// boxShadow: [ +// BoxShadow( +// color: Color(0x08213303), +// offset: Offset(0, 2), +// blurRadius: 4, +// spreadRadius: 0, +// ), +// ], +// borderRadius: BorderRadius.circular(6), +// ), +// child: Row( +// crossAxisAlignment: CrossAxisAlignment.start, +// children: [ +// GestureDetector( +// behavior: HitTestBehavior.opaque, +// onTap: () { +// setState(() { +// navigationState = 0; +// }); +// }, +// child: Padding( +// padding: EdgeInsets.only(top: 10.h, right: 10.w), +// child: Icon( +// Icons.arrow_back_ios, +// color: Color(0xFF353535), +// size: 24, +// ), +// ), +// ), +// Expanded( +// child: Column( +// children: [ +// Container( +// width: double.infinity, +// decoration: BoxDecoration( +// color: Color(0xFFF5F5F5), +// borderRadius: BorderRadius.circular(6), +// ), +// padding: EdgeInsets.only( +// top: 12.h, +// bottom: 12.h, +// left: 15.w, +// ), +// child: Row( +// mainAxisAlignment: MainAxisAlignment.center, +// children: [ +// Expanded( +// child: Column( +// crossAxisAlignment: CrossAxisAlignment.start, +// children: [ +// Padding( +// padding: EdgeInsets.only( +// bottom: 14.h, +// ), +// child: Row( +// children: [ +// Container( +// width: 4.h, +// height: 4.h, +// margin: EdgeInsets.only(right: 20.w), +// decoration: BoxDecoration( +// color: Color(0xFF32A060), +// borderRadius: BorderRadius.circular(6), +// ), +// ), +// Expanded( +// child: Text( +// positionSorta == false +// ? "我的位置" +// : (storeInfo?.storeName ?? ""), +// overflow: TextOverflow.ellipsis, +// style: TextStyle( +// color: Color(0xFF0D0D0D), +// fontSize: 14.sp, +// fontWeight: MyFontWeight.semi_bold, +// ), +// )) +// ], +// ), +// ), +// Row( +// children: [ +// Container( +// width: 4.h, +// height: 4.h, +// margin: EdgeInsets.only(right: 20.w), +// decoration: BoxDecoration( +// color: Color(0xFFFA5151), +// borderRadius: BorderRadius.circular(6), +// ), +// ), +// Expanded( +// child: Text( +// positionSorta == false +// ? (storeInfo?.storeName ?? "") +// : "我的位置", +// overflow: TextOverflow.ellipsis, +// style: TextStyle( +// color: Color(0xFF0D0D0D), +// fontSize: 14.sp, +// fontWeight: MyFontWeight.semi_bold, +// ), +// )) +// ], +// ) +// ], +// )), +// GestureDetector( +// behavior: HitTestBehavior.opaque, +// onTap: () { +// positionSorta = !positionSorta; +// navigationPosition(); +// }, +// child: Container( +// padding: EdgeInsets.only(right: 24.w), +// child: Image.asset( +// "assets/image/position_sort.webp", +// fit: BoxFit.fill, +// height: 16.h, +// width: 14.w, +// ), +// ), +// ) +// ], +// ), +// ), +// SizedBox( +// height: 12.h, +// ), +// Row( +// children: [ +// Expanded( +// child: GestureDetector( +// behavior: HitTestBehavior.opaque, +// onTap: () { +// navigationType = 4; +// navigationPosition(); +// }, +// child: Container( +// decoration: BoxDecoration( +// color: navigationType == 4 +// ? Color(0xFFE8FFF2) +// : Colors.transparent, +// borderRadius: BorderRadius.circular(23), +// ), +// padding: +// EdgeInsets.symmetric(vertical: 5.h, horizontal: 13.w), +// child: Row( +// children: [ +// if (navigationType == 4) +// Image.asset( +// "assets/image/icon_drive.webp", +// fit: BoxFit.fill, +// height: 16.h, +// width: 14.w, +// ), +// Padding( +// padding: EdgeInsets.only(left: 2.w), +// child: Text( +// "驾车", +// overflow: TextOverflow.ellipsis, +// style: TextStyle( +// color: navigationType == 4 +// ? Color(0xFF32A060) +// : Colors.black, +// fontSize: 12.sp, +// fontWeight: MyFontWeight.medium, +// ), +// ), +// ) +// ], +// ), +// ), +// )), +// Expanded( +// child: GestureDetector( +// behavior: HitTestBehavior.opaque, +// onTap: () { +// navigationType = 3; +// navigationPosition(); +// }, +// child: Container( +// decoration: BoxDecoration( +// color: navigationType == 3 +// ? Color(0xFFE8FFF2) +// : Colors.transparent, +// borderRadius: BorderRadius.circular(23), +// ), +// padding: EdgeInsets.symmetric( +// vertical: 5.h, horizontal: 13.w), +// child: Row( +// children: [ +// if (navigationType == 3) +// Image.asset( +// "assets/image/icon_transit.webp", +// fit: BoxFit.fill, +// height: 16.h, +// width: 14.w, +// ), +// Padding( +// padding: EdgeInsets.only(left: 2.w), +// child: Text( +// "公交", +// overflow: TextOverflow.ellipsis, +// style: TextStyle( +// color: navigationType == 3 +// ? Color(0xFF32A060) +// : Colors.black, +// fontSize: 12.sp, +// fontWeight: MyFontWeight.medium, +// ), +// ), +// ) +// ], +// ), +// ))), +// Expanded( +// child: GestureDetector( +// behavior: HitTestBehavior.opaque, +// onTap: () { +// navigationType = 2; +// navigationPosition(); +// }, +// child: Container( +// decoration: BoxDecoration( +// color: navigationType == 2 +// ? Color(0xFFE8FFF2) +// : Colors.transparent, +// borderRadius: BorderRadius.circular(23), +// ), +// padding: EdgeInsets.symmetric( +// vertical: 5.h, horizontal: 13.w), +// child: Row( +// children: [ +// if (navigationType == 2) +// Image.asset( +// "assets/image/icon_by_bike.webp", +// fit: BoxFit.fill, +// height: 16.h, +// width: 14.w, +// ), +// Padding( +// padding: EdgeInsets.only(left: 2.w), +// child: Text( +// "骑行", +// overflow: TextOverflow.ellipsis, +// style: TextStyle( +// color: navigationType == 2 +// ? Color(0xFF32A060) +// : Colors.black, +// fontSize: 12.sp, +// fontWeight: MyFontWeight.medium, +// ), +// ), +// ) +// ], +// ), +// ))), +// Expanded( +// child: GestureDetector( +// behavior: HitTestBehavior.opaque, +// onTap: () { +// navigationType = 1; +// navigationPosition(); +// }, +// child: Container( +// decoration: BoxDecoration( +// color: navigationType == 1 +// ? Color(0xFFE8FFF2) +// : Colors.transparent, +// borderRadius: BorderRadius.circular(23), +// ), +// padding: EdgeInsets.symmetric( +// vertical: 5.h, horizontal: 13.w), +// child: Row( +// children: [ +// if (navigationType == 1) +// Image.asset( +// "assets/image/icon_walk.webp", +// fit: BoxFit.fill, +// height: 16.h, +// width: 14.w, +// ), +// Padding( +// padding: EdgeInsets.only(left: 2.w), +// child: Text( +// "步行", +// overflow: TextOverflow.ellipsis, +// style: TextStyle( +// color: navigationType == 1 +// ? Color(0xFF32A060) +// : Colors.black, +// fontSize: 12.sp, +// fontWeight: MyFontWeight.medium, +// ), +// ), +// ) +// ], +// ), +// ))), +// ], +// ) +// ], +// )) +// ], +// ), +// ); +// } +// +// Widget navigationDistance() { +// return Container( +// height: 173.h, +// padding: EdgeInsets.only(top: 16.h, left: 16.w, right: 16.w), +// decoration: BoxDecoration( +// color: Colors.white, +// boxShadow: [ +// BoxShadow( +// color: Color(0x08213303), +// offset: Offset(0, 2), +// blurRadius: 4, +// spreadRadius: 0, +// ), +// ], +// borderRadius: BorderRadius.vertical( +// top: Radius.circular(8), +// ), +// ), +// child: Column( +// // mainAxisAlignment: MainAxisAlignment.start, +// crossAxisAlignment: CrossAxisAlignment.start, +// children: [ +// Expanded( +// child: Row( +// crossAxisAlignment: CrossAxisAlignment.start, +// children: [ +// Text( +// "${navigationType == 1 ? "步行" : navigationType == 2 ? "骑行" : navigationType == 3 ? "公交" : "驾车"}${(hours ?? "") + (minutes ?? "")}", +// overflow: TextOverflow.ellipsis, +// style: TextStyle( +// fontSize: 20.sp, +// color: Color(0xFF0D0D0D), +// fontWeight: MyFontWeight.bold, +// ), +// ), +// Padding( +// padding: EdgeInsets.only(left: 40.w), +// child: Text( +// (distance ?? 0) > 1000 +// ? S.of(context).gongli( +// ((distance ?? 0) / 1000 * 100).toInt() / 100.0) +// : S +// .of(context) +// .mi(((distance ?? 0) * 100).toInt() / 100.0), +// overflow: TextOverflow.ellipsis, +// style: TextStyle( +// fontSize: 20.sp, +// color: Color(0xFF0D0D0D), +// fontWeight: MyFontWeight.bold, +// ), +// ), +// ), +// ], +// ), +// ), +// GestureDetector( +// behavior: HitTestBehavior.opaque, +// onTap: () { +// setState(() { +// navigationState = 1; +// showMapSelect(); +// }); +// }, +// child: Container( +// alignment: Alignment.center, +// width: double.infinity, +// padding: EdgeInsets.symmetric(vertical: 10.h), +// margin: EdgeInsets.only(bottom: 30.h), +// decoration: BoxDecoration( +// color: Color(0xFF32A060), +// borderRadius: BorderRadius.circular(23), +// ), +// child: Text( +// navigationType == 1 +// ? "步行导航" +// : navigationType == 2 +// ? "骑行导航" +// : navigationType == 3 +// ? "公交导航" +// : "驾车导航", +// style: TextStyle( +// fontSize: 20.sp, +// color: Colors.white, +// fontWeight: MyFontWeight.medium, +// ), +// ), +// ), +// ) +// ], +// ), +// ); +// } +// +// showMapSelect() { +// showCupertinoModalPopup( +// context: context, +// builder: (context) { +// return CupertinoActionSheet( +// actions: [ +// CupertinoActionSheetAction( +// child: Text( +// "百度地图", +// style: TextStyle( +// fontWeight: MyFontWeight.regular, +// ), +// ), +// onPressed: () { +// onOpenBaiduMapRoute(); +// Navigator.of(context).pop(); +// }, +// isDefaultAction: true, +// isDestructiveAction: false, +// ), +// ], +// cancelButton: CupertinoActionSheetAction( +// onPressed: () { +// Navigator.of(context).pop(); +// }, +// child: Text(S.of(context).quxiao, +// style: TextStyle( +// color: Colors.blue, +// ),), +// isDestructiveAction: true, +// ), +// ); +// }); +// } +// +// List itemServer(String businessService) { +// if (businessService == "") return []; +// var list = businessService.split(","); +// return list +// .map((e) => Container( +// margin: EdgeInsets.only(right: 8.w), +// child: RoundButton( +// height: 17.h * AppUtils.textScale(context), +// text: "$e", +// backgroup: Color(0xFFFF7A1A), +// padding: EdgeInsets.only( +// left: 2.w, +// right: 2.w, +// ), +// fontSize: 10.sp, +// textColor: Colors.white, +// ), +// )) +// .toList(); +// } +// +// BMFMapController? _mapController; +// BMFCoordinate? latLng; +// BMFCoordinate? myLatLng; +// BMFMarker? bmfMarker; +// +// onMapCreated(BMFMapController controller) { +// _mapController = controller; +// setState(() { +// _mapController?.showUserLocation(true); +// _mapController?.setCustomMapStyle('assets/map_style/chatian.sty', 0); +// BMFUserLocationDisplayParam displayParam = BMFUserLocationDisplayParam( +// locationViewOffsetX: 0, +// locationViewOffsetY: 0, +// accuracyCircleFillColor: Colors.red, +// accuracyCircleStrokeColor: Colors.blue, +// isAccuracyCircleShow: true, +// locationViewImage: 'assets/image/icon_my_location.webp', +// locationViewHierarchy: +// BMFLocationViewHierarchy.LOCATION_VIEW_HIERARCHY_BOTTOM, +// ); +// _mapController?.updateLocationViewWithParam(displayParam); +// addMarker(); +// }); +// } +// +// addMarker() async { +// latLng = await AppUtils.coordConvert(BMFCoordinate(double.tryParse(widget.arguments?["lat"]) ?? 0, +// double.tryParse(widget.arguments?["lng"]) ?? 0)); +// if (latLng != null) { +// _mapController?.setCenterCoordinate(latLng!, true); +// } +// } +// } diff --git a/lib/union/union_list.dart b/lib/union/union_list.dart index 5a6f0fb4..a3802ca4 100644 --- a/lib/union/union_list.dart +++ b/lib/union/union_list.dart @@ -1,8 +1,8 @@ import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; +import 'package:geolocator/geolocator.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/data/store.dart'; import 'package:huixiang/utils/font_weight.dart'; @@ -22,7 +22,7 @@ import '../view_widget/round_button.dart'; class UnionList extends StatefulWidget { final String serviceType; - final BMFCoordinate? latLng; + final Position latLng; final String? searchKey; final String? city; @@ -38,7 +38,7 @@ class UnionList extends StatefulWidget { class _UnionList extends State with AutomaticKeepAliveClientMixin { ApiService? apiService; List? storeList; - BMFCoordinate? latLng; + Position? latLng; final RefreshController _refreshController = RefreshController(); int networkStatus = 0; diff --git a/lib/union/union_page.dart b/lib/union/union_page.dart index e212b72d..cc6d549e 100644 --- a/lib/union/union_page.dart +++ b/lib/union/union_page.dart @@ -1,9 +1,8 @@ import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_baidu_mapapi_utils/flutter_baidu_mapapi_utils.dart'; -import 'package:flutter_bmflocation/flutter_bmflocation.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; +import 'package:geolocator/geolocator.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/main.dart'; import 'package:huixiang/data/ip_data.dart'; @@ -15,9 +14,9 @@ import 'package:huixiang/view_widget/my_tab.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart'; import 'package:visibility_detector/visibility_detector.dart'; +import '../data/address.dart'; import '../view_widget/location_tips.dart'; import '../view_widget/no_data_view.dart'; @@ -40,7 +39,7 @@ class UnionPageState extends State final TextEditingController editingController = TextEditingController(); bool isKeyBoardShow = false; TabController? tabController; - BMFCoordinate? latLng; + Position? latLng; String? areaName; List _allKey = []; bool _isShowLocalTips = false; @@ -54,7 +53,7 @@ class UnionPageState extends State void dispose() { super.dispose(); WidgetsBinding.instance.removeObserver(this); - Location.instance.aMapFlutterLocation.stopLocation(); + // Location.instance.aMapFlutterLocation.stopLocation(); } @override @@ -110,29 +109,33 @@ class UnionPageState extends State getLocation({bool showLoading = true}) async { if (showLoading) EasyLoading.show( - status: S.current.zhengzaijiazai, - maskType: EasyLoadingMaskType.black, + status: S.current.zhengzaijiazai, + maskType: EasyLoadingMaskType.black, ); bool powerFlag = false; // bool finallyFlag = false; try { - Future.delayed(Duration(seconds: 5), () { - // if (!finallyFlag) - Location.instance.stopLocation(); - }); - powerFlag = await Location.instance.startLocation(context, - (BaiduLocation result) async { - if (result.latitude != null && result.longitude != null) { + powerFlag = await LocationInstance.getInstance().startLocation(context, + (Position? result) async { + if (result?.latitude != null && result?.longitude != null) { print("location: $result"); - latLng = BMFCoordinate(result.latitude!, result.longitude!); - latLng = await BMFCalculateUtils.coordConvert( - coordinate: latLng!, - fromType: BMF_COORD_TYPE.BD09LL, - toType: BMF_COORD_TYPE.COMMON); - await saveLatLng(latLng!, result.province, result.city, result.district); - print("union: Location result ${latLng!.latitude} " - "${latLng!.longitude}"); - Location.instance.stopLocation(); + latLng = Position( + latitude: result!.latitude, + longitude: result.longitude, + timestamp: DateTime.now(), + accuracy: 0, + altitude: 0, + heading: 0, + speed: 0, + speedAccuracy: 0 + ); + Address? address = await LocationInstance.getInstance() + .getAddress(result.latitude, result.longitude); + if (address != null) { + await saveLatLng( + latLng!, address.province, address.city, address.area); + } + LocationInstance.getInstance().stopLocation(); } else { await getLatLng(); } @@ -151,7 +154,7 @@ class UnionPageState extends State } } - saveLatLng(BMFCoordinate latLng, province, city, district) async { + saveLatLng(Position latLng, province, city, district) async { SharedPreferences prefs = await SharedPreferences.getInstance(); await prefs.setString("latitude", "${latLng.latitude}"); await prefs.setString("longitude", "${latLng.longitude}"); @@ -167,9 +170,16 @@ class UnionPageState extends State tempLatLng.containsKey("province") && tempLatLng.containsKey("city") && tempLatLng.containsKey("district")) { - latLng = BMFCoordinate( - double.tryParse(tempLatLng.getString("latitude") ?? "0") ?? 0, - double.tryParse(tempLatLng.getString("longitude") ?? "0") ?? 0); + latLng = Position( + latitude: double.tryParse(tempLatLng.getString("latitude") ??"")!, + longitude: double.tryParse(tempLatLng.getString("longitude")??"")!, + timestamp: DateTime.now(), + accuracy: 0, + altitude: 0, + heading: 0, + speed: 0, + speedAccuracy: 0 + ); } } @@ -205,158 +215,155 @@ class UnionPageState extends State Widget build(BuildContext context) { super.build(context); return VisibilityDetector( - key: Key('my-widget-key'), - onVisibilityChanged: (visibilityInfo) { - visiblePercentage = visibilityInfo.visibleFraction; - if (visiblePercentage == 1) permissionSettings(); + key: Key('my-widget-key'), + onVisibilityChanged: (visibilityInfo) { + visiblePercentage = visibilityInfo.visibleFraction; + if (visiblePercentage == 1) permissionSettings(); + }, + child: GestureDetector( + behavior: HitTestBehavior.translucent, + onTap: () { + FocusScope.of(context).requestFocus(FocusNode()); }, - child: GestureDetector( - behavior: HitTestBehavior.translucent, - onTap: () { - FocusScope.of(context).requestFocus(FocusNode()); - }, - child: Stack( - alignment: Alignment.bottomCenter, - children: [ - Container( - child: Column( - children: [ - Row( - children: [ - Padding( - padding: EdgeInsets.only(left: 18.w, right: 10.w), - child: GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: () { - Navigator.of(context).pushNamed( - '/router/union_select_city', - arguments: { - "cityName": areaName - }).then((value) { - if (value != null) { - areaName = "$value"; - loadFinish(); - } - }); - }, - child: Row( - children: [ - Text( - areaName ?? "", - overflow: TextOverflow.ellipsis, - maxLines: 1, - style: TextStyle( - fontSize: 14.sp, - fontWeight: FontWeight.bold, - color: Colors.white, - ), - ), - Icon( - Icons.keyboard_arrow_down, + child: Stack( + alignment: Alignment.bottomCenter, + children: [ + Container( + child: Column( + children: [ + Row( + children: [ + Padding( + padding: EdgeInsets.only(left: 18.w, right: 10.w), + child: GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + Navigator.of(context).pushNamed( + '/router/union_select_city', + arguments: { + "cityName": areaName + }).then((value) { + if (value != null) { + areaName = "$value"; + loadFinish(); + } + }); + }, + child: Row( + children: [ + Text( + areaName ?? "", + overflow: TextOverflow.ellipsis, + maxLines: 1, + style: TextStyle( + fontSize: 14.sp, + fontWeight: FontWeight.bold, color: Colors.white, - size: 24, - ) - ], - ), + ), + ), + Icon( + Icons.keyboard_arrow_down, + color: Colors.white, + size: 24, + ) + ], ), ), - Expanded(child: buildSearchItem()) - ], - ), - Align( - alignment: Alignment.centerLeft, - child: TabBar( - controller: tabController, - isScrollable: true, - //可滚动 - dividerHeight: 0, - dividerColor: Colors.transparent, - indicatorColor: Colors.white, - labelColor: Colors.white, - labelStyle: TextStyle( - fontSize: 18.sp, - fontWeight: FontWeight.bold, - ), - unselectedLabelStyle: TextStyle( - fontSize: 15.sp, - fontWeight: FontWeight.normal, - ), - //未选中文字颜色 - unselectedLabelColor: Colors.white, - indicatorSize: TabBarIndicatorSize.label, - //指示器与文字等宽 - tabs: [ - MyTab(text: S.of(context).quanbu), - MyTab(text: S.of(context).chi), - MyTab(text: S.of(context).he), - MyTab(text: S.of(context).wan), - ], ), - ), - _allKey.isEmpty - ? NoDataView( - src: "assets/image/di_zhi.webp", - isShowBtn: false, - text: "暂无店铺列表~", - fontSize: 16.sp, - margin: EdgeInsets.only(top: 120.h), - ) - : Expanded( - child: TabBarView( - controller: tabController, - children: [ - UnionList( - _allKey[0], - "", - latLng, - editingController.text, - areaName, - ), - UnionList(_allKey[1], "EATSTORE", latLng, - editingController.text, areaName), - UnionList(_allKey[2], "DRINKSTORE", latLng, - editingController.text, areaName), - UnionList(_allKey[3], "HAPPYSTORE", latLng, - editingController.text, areaName), - ], - ), - ) - ], - ), - padding: EdgeInsets.only( - top: MediaQuery.of(context).padding.top + 17.h, - ), - decoration: BoxDecoration( - gradient: LinearGradient( - begin: Alignment.topCenter, - end: Alignment.bottomCenter, - colors: [ - Color(0xFF32A060), - Color(0xFF32A060), - Colors.white, - Colors.white, - ], - stops: [ - 0, - 0.2, - 0.4, - 1 + Expanded(child: buildSearchItem()) + ], + ), + Align( + alignment: Alignment.centerLeft, + child: TabBar( + controller: tabController, + //tab排放方向 + tabAlignment:TabAlignment.start, + isScrollable: true, + //可滚动 + dividerHeight: 0, + dividerColor: Colors.transparent, + indicatorColor: Colors.white, + labelColor: Colors.white, + labelStyle: TextStyle( + fontSize: 18.sp, + fontWeight: FontWeight.bold, + ), + unselectedLabelStyle: TextStyle( + fontSize: 15.sp, + fontWeight: FontWeight.normal, + ), + //未选中文字颜色 + unselectedLabelColor: Colors.white, + indicatorSize: TabBarIndicatorSize.label, + //指示器与文字等宽 + tabs: [ + MyTab(text: S.of(context).quanbu), + MyTab(text: S.of(context).chi), + MyTab(text: S.of(context).he), + MyTab(text: S.of(context).wan), ], + ), ), + _allKey.isEmpty + ? NoDataView( + src: "assets/image/di_zhi.webp", + isShowBtn: false, + text: "暂无店铺列表~", + fontSize: 16.sp, + margin: EdgeInsets.only(top: 120.h), + ) + : Expanded( + child: TabBarView( + controller: tabController, + children: [ + UnionList( + _allKey[0], + "", + latLng!, + editingController.text, + areaName, + ), + UnionList(_allKey[1], "EATSTORE", latLng!, + editingController.text, areaName), + UnionList(_allKey[2], "DRINKSTORE", latLng!, + editingController.text, areaName), + UnionList(_allKey[3], "HAPPYSTORE", latLng!, + editingController.text, areaName), + ], + ), + ) + ], + ), + padding: EdgeInsets.only( + top: MediaQuery.of(context).padding.top + 17.h, + ), + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + colors: [ + Color(0xFF32A060), + Color(0xFF32A060), + Colors.white, + Colors.white, + ], + stops: [0, 0.2, 0.4, 1], ), ), - if (_isShowLocalTips) - Padding( - padding: EdgeInsets.only(bottom: 70.h), - child: LocationTips(() { - setState(() { - _isShowLocalTips = false; - }); - }), - ) - ], - ), + ), + if (_isShowLocalTips) + Padding( + padding: EdgeInsets.only(bottom: 70.h), + child: LocationTips(() { + setState(() { + _isShowLocalTips = false; + }); + }), + ) + ], ), + ), ); } diff --git a/lib/union/union_view/store_info.dart b/lib/union/union_view/store_info.dart index 8fcf5d7d..86c53f23 100644 --- a/lib/union/union_view/store_info.dart +++ b/lib/union/union_view/store_info.dart @@ -1,5 +1,8 @@ +import 'dart:io'; + import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:flutter_swiper_view/flutter_swiper_view.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/data/store_info.dart'; @@ -10,6 +13,8 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:huixiang/view_widget/round_button.dart'; import 'package:url_launcher/url_launcher.dart'; +import '../../utils/location.dart'; + class StoreInfos extends StatefulWidget { final StoreInfo? storeInfo; @@ -64,7 +69,9 @@ class _StoreInfos extends State { Row( children: [ Text( - S.of(context).ren(widget.storeInfo!.perCapitaConsumption ?? ""), + S + .of(context) + .ren(widget.storeInfo!.perCapitaConsumption ?? ""), overflow: TextOverflow.ellipsis, style: TextStyle( fontSize: 14.sp, @@ -76,7 +83,8 @@ class _StoreInfos extends State { width: 22.w, ), Row( - children: itemServer(widget.storeInfo?.businessService ?? ""), + children: + itemServer(widget.storeInfo?.businessService ?? ""), ), ], ), @@ -99,10 +107,11 @@ class _StoreInfos extends State { Text( S.of(context).yingyeshijian(widget.storeInfo == null ? "" - : ((widget.storeInfo!.openStartTime?.isEmpty ?? true) && (widget.storeInfo!.openEndTime?.isEmpty ?? true)) - ? S.of(context).quantian - : "${widget.storeInfo!.openStartTime!.substring(0, widget.storeInfo!.openStartTime!.lastIndexOf(":"))} " - "- ${widget.storeInfo!.openEndTime!.substring(0, widget.storeInfo!.openEndTime!.lastIndexOf(":"))}"), + : ((widget.storeInfo!.openStartTime?.isEmpty ?? true) && + widget.storeInfo?.openEndTime == null) + ? S.of(context).quantian + : "${widget.storeInfo?.openStartTime?.substring(0, widget.storeInfo?.openStartTime?.lastIndexOf(":"))} " + "- ${widget.storeInfo?.openEndTime?.substring(0, widget.storeInfo?.openEndTime?.lastIndexOf(":"))}"), style: TextStyle( color: Color(0xFF353535), fontWeight: MyFontWeight.regular, @@ -130,14 +139,12 @@ class _StoreInfos extends State { children: [ InkWell( onTap: () { - if ((widget.storeInfo?.latitude?.isEmpty ?? true)|| - (widget.storeInfo?.longitude?.isEmpty ?? true)) return; - Navigator.of(context) - .pushNamed('/router/location_map', arguments: { - "lat": widget.storeInfo!.latitude, - "lng": widget.storeInfo!.longitude, - "storeName": widget.storeInfo!.storeName, - }); + if (widget.storeInfo == null || + widget.storeInfo?.latitude == null || + widget.storeInfo?.longitude == null || + widget.storeInfo?.latitude == "" || + widget.storeInfo?.longitude == "") return; + showMapSelect(); }, child: Image.asset( "assets/image/icon_union_location.webp", @@ -338,32 +345,32 @@ class _StoreInfos extends State { Widget buildSwiper() { return Container( - child: Swiper( - pagination: SwiperPagination( - alignment: Alignment.bottomCenter, - builder: DotSwiperPaginationBuilder( - size: 8.w, - activeSize: 8.w, - space: 5.w, - activeColor: Colors.white, - color: Colors.white.withAlpha(76), - ), + child: Swiper( + pagination: SwiperPagination( + alignment: Alignment.bottomCenter, + builder: DotSwiperPaginationBuilder( + size: 8.w, + activeSize: 8.w, + space: 5.w, + activeColor: Colors.white, + color: Colors.white.withAlpha(76), + ), + ), + itemBuilder: (context, position) { + return Container( + margin: EdgeInsets.only(left: 10.w, right: 10.w), + child: MImage( + (position < (widget.storeInfo!.bannerList?.length ?? 0)) + ? (widget.storeInfo!.bannerList![position].imgUrl ?? "") + : "", + fit: BoxFit.cover, + radius: BorderRadius.circular(4), + errorSrc: "assets/image/default_2_1.webp", + fadeSrc: "assets/image/default_2_1.webp", ), - itemBuilder: (context, position) { - return Container( - margin: EdgeInsets.only(left: 10.w, right: 10.w), - child: MImage( - (position < (widget.storeInfo!.bannerList?.length ?? 0)) - ? (widget.storeInfo!.bannerList![position].imgUrl ?? "") - : "", - fit: BoxFit.cover, - radius: BorderRadius.circular(4), - errorSrc: "assets/image/default_2_1.webp", - fadeSrc: "assets/image/default_2_1.webp", - ), - ); - }, - itemCount: widget.storeInfo?.bannerList?.length ?? 1, + ); + }, + itemCount: widget.storeInfo?.bannerList?.length ?? 1, )); } @@ -389,41 +396,94 @@ class _StoreInfos extends State { } showCallMobile() { + showCupertinoModalPopup( + context: context, + builder: (context) { + return CupertinoActionSheet( + title: Text(S.of(context).bodadianhua), + actions: [ + if (widget.storeInfo?.tel?.isNotEmpty ?? false) + CupertinoActionSheetAction( + child: Text(widget.storeInfo!.tel ?? ""), + onPressed: () { + callMobile(widget.storeInfo!.tel); + Navigator.of(context).pop(); + }, + isDefaultAction: true, + isDestructiveAction: false, + ), + ], + cancelButton: CupertinoActionSheetAction( + onPressed: () { + Navigator.of(context).pop(); + }, + child: Text(S.of(context).quxiao), + isDestructiveAction: true, + ), + ); + }, + ); + } + + callMobile(mobile) async { + String url = "tel:$mobile"; + if (await canLaunch(url)) { + await launch(url); + } else { + throw 'Could not launch $url'; + } + } + + showMapSelect() { showCupertinoModalPopup( context: context, builder: (context) { return CupertinoActionSheet( - title: Text(S.of(context).bodadianhua), actions: [ - if (widget.storeInfo?.tel?.isNotEmpty ?? false) - CupertinoActionSheetAction( - child: Text(widget.storeInfo!.tel ?? ""), - onPressed: () { - callMobile(widget.storeInfo!.tel); - Navigator.of(context).pop(); - }, - isDefaultAction: true, - isDestructiveAction: false, + CupertinoActionSheetAction( + child: Text( + "使用高德地图导航", + style: TextStyle( + fontWeight: MyFontWeight.regular, + ), ), + onPressed: () { + onOpenBaiduMap(); + Navigator.of(context).pop(); + }, + isDefaultAction: true, + isDestructiveAction: false, + ), ], cancelButton: CupertinoActionSheetAction( onPressed: () { Navigator.of(context).pop(); }, - child: Text(S.of(context).quxiao), + child: Text( + S.of(context).quxiao, + style: TextStyle( + color: Colors.blue, + ), + ), isDestructiveAction: true, ), ); - }, - ); + }); } - callMobile(mobile) async { - String url = "tel:$mobile"; - if (await canLaunch(url)) { - await launch(url); - } else { - throw 'Could not launch $url'; - } + void onOpenBaiduMap() async { + LocationInstance.getInstance().startLocation(context, (locationData) { + String url = + "${Platform.isIOS ? 'ios' : 'android'}amap://path?sourceApplication=haixia&sid=" + "&slat=${locationData?.latitude.toStringAsFixed(8)}&slon=${locationData?.longitude.toStringAsFixed(8)}&sname=&did=&dlat=${widget.storeInfo?.latitude}&dlon=${widget.storeInfo?.longitude}&dname=&dev=0&t=0"; + launch(url).then((value) { + if (!value) { + SmartDialog.showToast( + "未检测到安装高德地图", + alignment: Alignment.center, + ); + } + }); + }); } } diff --git a/lib/utils/flutter_utils.dart b/lib/utils/flutter_utils.dart index 49dad985..e8aa8119 100644 --- a/lib/utils/flutter_utils.dart +++ b/lib/utils/flutter_utils.dart @@ -2,23 +2,20 @@ 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'; import 'package:intl/intl.dart'; import 'package:path_provider/path_provider.dart'; class AppUtils { - ///计算距离(当前位置到店位置直线距离) - static Future calculateDistance( - BMFCoordinate bmfCoordinate, BMFCoordinate myLatLng, {bool isMi = false}) async { - double? mi = await BMFCalculateUtils.getLocationDistance(bmfCoordinate, myLatLng); - if (mi == null) { - return "0"; - } - NumberFormat numberFormat = NumberFormat("#.#"); - return "${numberFormat.format(mi! / (isMi ? 1 :1000))}"; - } - + // ///计算距离(当前位置到店位置直线距离) + // static Future calculateDistance( + // BMFCoordinate bmfCoordinate, BMFCoordinate myLatLng, {bool isMi = false}) async { + // double? mi = await BMFCalculateUtils.getLocationDistance(bmfCoordinate, myLatLng); + // if (mi == null) { + // return "0"; + // } + // NumberFormat numberFormat = NumberFormat("#.#"); + // return "${numberFormat.format(mi! / (isMi ? 1 :1000))}"; + // } ///保留两位小数 static double stringAsFixedDouble2(double value) { @@ -82,13 +79,13 @@ class AppUtils { return resString; } - ///坐标系转换(高德转百度) - static Future coordConvert(BMFCoordinate latLng) async { - // return BMFCalculateUtils.coordConvert( - // coordinate: latLng, - // fromType: BMF_COORD_TYPE.COMMON, - // toType: BMF_COORD_TYPE.BD09LL); - } + // ///坐标系转换(高德转百度) + // static Future coordConvert(BMFCoordinate latLng) async { + // // return BMFCalculateUtils.coordConvert( + // // coordinate: latLng, + // // fromType: BMF_COORD_TYPE.COMMON, + // // toType: BMF_COORD_TYPE.BD09LL); + // } static bool isPhone(mobile) { RegExp exp = RegExp( diff --git a/lib/utils/gps_utils.dart b/lib/utils/gps_utils.dart new file mode 100644 index 00000000..a379517a --- /dev/null +++ b/lib/utils/gps_utils.dart @@ -0,0 +1,141 @@ + +import 'dart:math'; + +class GpsUtil { + static const num pi = 3.1415926535897932384626; + static const num x_pi = 3.14159265358979324 * 3000.0 / 180.0; + static const num a = 6378245.0; + static const num ee = 0.00669342162296594323; + + static num transformLat(num x, num y) { + num ret = -100.0 + + 2.0 * x + + 3.0 * y + + 0.2 * y * y + + 0.1 * x * y + + 0.2 * sqrt(x.abs()); + ret += (20.0 * sin(6.0 * x * pi) + 20.0 * sin(2.0 * x * pi)) * 2.0 / 3.0; + ret += (20.0 * sin(y * pi) + 40.0 * sin(y / 3.0 * pi)) * 2.0 / 3.0; + ret += (160.0 * sin(y / 12.0 * pi) + 320 * sin(y * pi / 30.0)) * 2.0 / 3.0; + return ret; + } + + static num transformLon(num x, num y) { + num ret = + 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * sqrt(x.abs()); + ret += (20.0 * sin(6.0 * x * pi) + 20.0 * sin(2.0 * x * pi)) * 2.0 / 3.0; + ret += (20.0 * sin(x * pi) + 40.0 * sin(x / 3.0 * pi)) * 2.0 / 3.0; + ret += + (150.0 * sin(x / 12.0 * pi) + 300.0 * sin(x / 30.0 * pi)) * 2.0 / 3.0; + return ret; + } + + static List transform(num lat, num lon) { + if (outOfChina(lat, lon)) { + return [lat, lon]; + } + num dLat = transformLat(lon - 105.0, lat - 35.0); + num dLon = transformLon(lon - 105.0, lat - 35.0); + num radLat = lat / 180.0 * pi; + num magic = sin(radLat); + magic = 1 - ee * magic * magic; + num sqrtMagic = sqrt(magic); + dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi); + dLon = (dLon * 180.0) / (a / sqrtMagic * cos(radLat) * pi); + num mgLat = lat + dLat; + num mgLon = lon + dLon; + return [mgLat, mgLon]; + } + + static bool outOfChina(num lat, num lon) { + if (lon < 72.004 || lon > 137.8347) return true; + if (lat < 0.8293 || lat > 55.8271) return true; + return false; + } + + /// 84 to 火星坐标系 (GCJ-02) World Geodetic System ==> Mars Geodetic System + /// + /// @param lat + /// @param lon + /// @return + static List gps84_To_Gcj02(num lat, num lon) { + if (outOfChina(lat, lon)) { + return [lat, lon]; + } + num dLat = transformLat(lon - 105.0, lat - 35.0); + num dLon = transformLon(lon - 105.0, lat - 35.0); + num radLat = lat / 180.0 * pi; + num magic = sin(radLat); + magic = 1 - ee * magic * magic; + num sqrtMagic = sqrt(magic); + dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi); + dLon = (dLon * 180.0) / (a / sqrtMagic * cos(radLat) * pi); + num mgLat = lat + dLat; + num mgLon = lon + dLon; + return [mgLat, mgLon]; + } + + /// * 火星坐标系 (GCJ-02) to 84 * * @param lon * @param lat * @return + static List gcj02_To_Gps84(num lat, num lon) { + List gps = transform(lat, lon); + num lontitude = lon * 2 - gps[1]; + num latitude = lat * 2 - gps[0]; + return [latitude, lontitude]; + } + + /// 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换算法 将 GCJ-02 坐标转换成 BD-09 坐标 + /// + /// @param lat + /// @param lon + static List gcj02_To_Bd09(num lat, num lon) { + num x = lon, y = lat; + num z = sqrt(x * x + y * y) + 0.00002 * sin(y * x_pi); + num theta = atan2(y, x) + 0.000003 * cos(x * x_pi); + num tempLon = z * cos(theta) + 0.0065; + num tempLat = z * sin(theta) + 0.006; + List gps = [tempLat, tempLon]; + return gps; + } + + /// * 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换算法 * * 将 BD-09 坐标转换成GCJ-02 坐标 + /// @param lat + /// @param lon + /// @return + static List bd09_To_Gcj02(num lat, num lon) { + num x = lon - 0.0065, y = lat - 0.006; + num z = sqrt(x * x + y * y) - 0.00002 * sin(y * x_pi); + num theta = atan2(y, x) - 0.000003 * cos(x * x_pi); + num tempLon = z * cos(theta); + num tempLat = z * sin(theta); + List gps = [tempLat, tempLon]; + return gps; + } + + /// 将gps84转为bd09 + /// + /// @param lat + /// @param lon + /// @return + static List gps84_To_bd09(num lat, num lon) { + List gcj02 = gps84_To_Gcj02(lat, lon); + List bd09 = gcj02_To_Bd09(gcj02[0], gcj02[1]); + return bd09; + } + + static List bd09_To_gps84(num lat, num lon) { + List gcj02 = bd09_To_Gcj02(lat, lon); + List gps84 = gcj02_To_Gps84(gcj02[0], gcj02[1]); + //保留小数点后六位 + gps84[0] = retain6(gps84[0]); + gps84[1] = retain6(gps84[1]); + return gps84; + } + + /// 保留小数点后六位 + /// + /// @param num + /// @return + static num retain6(num n) { + return num.parse(n.toStringAsFixed(6)); + } +} \ No newline at end of file diff --git a/lib/utils/location.dart b/lib/utils/location.dart index c5a14085..54836046 100644 --- a/lib/utils/location.dart +++ b/lib/utils/location.dart @@ -1,113 +1,60 @@ -import 'dart:io'; - -import 'package:android_intent_plus/android_intent.dart'; +import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_bmflocation/flutter_bmflocation.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:geolocator/geolocator.dart'; import 'package:huixiang/generated/l10n.dart'; +import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/view_widget/request_permission.dart'; -import 'package:permission_handler/permission_handler.dart'; +import 'package:intl/intl.dart'; +import 'package:permission_handler/permission_handler.dart' as PH; +import '../data/address.dart'; import 'font_weight.dart'; -BaiduLocationAndroidOption initAndroidOptions() { - BaiduLocationAndroidOption options = BaiduLocationAndroidOption( - // 定位模式,可选的模式有高精度、仅设备、仅网络。默认为高精度模式 - locationMode: BMFLocationMode.hightAccuracy, - // 是否需要返回地址信息 - isNeedAddress: true, -// 是否需要返回海拔高度信息 - isNeedAltitude: false, -// 是否需要返回周边poi信息 - isNeedLocationPoiList: false, -// 是否需要返回新版本rgc信息 - isNeedNewVersionRgc: false, -// 是否需要返回位置描述信息 - isNeedLocationDescribe: true, -// 是否使用gps - openGps: true, -// 可选,设置场景定位参数,包括签到场景、运动场景、出行场景 - locationPurpose: BMFLocationPurpose.signIn, -// 坐标系 - coordType: BMFLocationCoordType.bd09ll, -// 设置发起定位请求的间隔,int类型,单位ms -// 如果设置为0,则代表单次定位,即仅定位一次,默认为0 - scanspan: 0); - return options; -} - -BaiduLocationIOSOption initIOSOptions() { - BaiduLocationIOSOption options = BaiduLocationIOSOption( - // 坐标系 - coordType: BMFLocationCoordType.bd09ll, - // 位置获取超时时间 - locationTimeout: 10, - // 获取地址信息超时时间 - reGeocodeTimeout: 10, - // 应用位置类型 默认为automotiveNavigation - activityType: BMFActivityType.automotiveNavigation, - // 设置预期精度参数 默认为best - desiredAccuracy: BMFDesiredAccuracy.best, - // 是否需要最新版本rgc数据 - isNeedNewVersionRgc: false, - // 指定定位是否会被系统自动暂停 - pausesLocationUpdatesAutomatically: false, - // 指定是否允许后台定位, - // 允许的话是可以进行后台定位的,但需要项目配置允许后台定位,否则会报错,具体参考开发文档 - allowsBackgroundLocationUpdates: false, - // 设定定位的最小更新距离 - distanceFilter: 10, - ); - return options; -} - -class Location { - static Location? _instance; - - Location._internal() { - aMapFlutterLocation = LocationFlutterPlugin(); - } - - static Location get instance => _getInstance(); +class LocationInstance { + static LocationInstance? _instance; - factory Location() => _getInstance(); + LocationInstance._internal() {} - static Location _getInstance() { - _instance ??= Location._internal(); + static LocationInstance getInstance() { + if (_instance == null) { + _instance = LocationInstance._internal(); + } return _instance!; } - late LocationFlutterPlugin aMapFlutterLocation; - Future startLocation( - context, Function(BaiduLocation result) locationCallback) async { - aMapFlutterLocation.prepareLoc( - initAndroidOptions().getMap(), initIOSOptions().getMap()); - var permissionStatus = await Permission.location.status; - if (!permissionStatus.isGranted) { - showTipsAlertDialog(context); + context, Function(Position? locationData) locationCallback) async { + LocationPermission permissionStatus = await Geolocator.checkPermission(); + if (permissionStatus == LocationPermission.denied) { + permissionStatus = await Geolocator.requestPermission(); + } + if (permissionStatus == LocationPermission.denied) { + showTipsAlertDialog(context); + return false; + } + if (permissionStatus == LocationPermission.deniedForever) { + showTipsAlertDialog(context); return false; - } else { - aMapFlutterLocation.singleLocationCallback( - callback: (BaiduLocation result) { - locationCallback.call(result); + } + if (permissionStatus == LocationPermission.whileInUse || + permissionStatus == LocationPermission.always) { + bool isNext = true; + Future.delayed(Duration(seconds: 5), () { + if (isNext) { + EasyLoading.dismiss(); + } }); - if (Platform.isIOS) { - await aMapFlutterLocation.singleLocation({ - 'isReGeocode': true, - 'isNetworkState': true, - }); - } else if (Platform.isAndroid) { - await aMapFlutterLocation.startLocation(); - } - return true; + Position locationData = await Geolocator.getCurrentPosition(); + isNext = false; + locationCallback.call(locationData); } + return true; } - void stopLocation() { - aMapFlutterLocation.stopLocation(); - } + void stopLocation() {} enableLocation(context) { showCupertinoDialog( @@ -118,12 +65,14 @@ class Location { S.of(context).nindingweigongnengweikaiqi, S.of(context).weilexiangnintuijianfujindemendianxinxi, S.of(context).dakaidingwei, - (result) async { + (result) async { if (result) { - final AndroidIntent intent = AndroidIntent( - action: 'action_location_source_settings', - package: "com.zsw.huixiang"); - await intent.launch(); + // final AndroidIntent intent = AndroidIntent( + // action: 'action_location_source_settings', + // package: "com.zsw.huixiang", + // ); + // await intent.launch(); + Geolocator.openLocationSettings(); // startLocation(); } }, @@ -133,7 +82,7 @@ class Location { ); } - requestDialog(context, Function(BaiduLocation result) locationCallback) { + requestDialog(context, Function(Position? result) locationCallback) { showCupertinoDialog( context: context, builder: (context) { @@ -142,10 +91,13 @@ class Location { S.of(context).nindingweiquanxianweiyunxu, S.of(context).weilexiangnintuijianfujindemendianxinxi, S.of(context).kaiqiquanxian, - (result) async { + (result) async { if (result) { - await openAppSettings(); - if (await Permission.location.isGranted) { + await PH.openAppSettings(); + if ((await Geolocator.checkPermission()) == + LocationPermission.whileInUse || + (await Geolocator.checkPermission()) == + LocationPermission.always) { startLocation(context, locationCallback); } } @@ -219,7 +171,7 @@ class Location { ); }, ); - await Permission.location.request(); + Geolocator.requestPermission(); Navigator.of(context).pop(); } @@ -286,15 +238,18 @@ class Location { margin: EdgeInsets.symmetric( horizontal: 15.w, vertical: 25.h), padding: - EdgeInsets.symmetric(vertical: 2.h, horizontal: 10.w), + EdgeInsets.symmetric(vertical: 2.h, horizontal: 10.w), decoration: BoxDecoration( color: Colors.green, borderRadius: BorderRadius.circular(100), ), ), onTap: () async { - await openAppSettings(); - if (await Permission.location.isGranted) + await PH.openAppSettings(); + if ((await Geolocator.checkPermission()) == + LocationPermission.whileInUse || + (await Geolocator.checkPermission()) == + LocationPermission.always) Navigator.of(context).pop(); }, behavior: HitTestBehavior.opaque, @@ -326,4 +281,45 @@ class Location { }, ); } -} + + ///计算距离(当前位置到店位置直线距离) + static Future calculateDistance( + Position bmfCoordinate, Position myLatLng, + {bool isMi = false}) async { + double mi = Geolocator.distanceBetween( + bmfCoordinate.latitude, + bmfCoordinate.longitude, + myLatLng.latitude, + myLatLng.longitude, + ); + NumberFormat numberFormat = NumberFormat("#.#"); + return "${numberFormat.format(mi / (isMi ? 1 : 1000))}"; + } + + // ///坐标系转换(高德转百度) + // static Future coordConvert(Latlng latLng) async { + // return BMFCalculateUtils.coordConvert( + // coordinate: latLng, + // fromType: BMF_COORD_TYPE.COMMON, + // toType: BMF_COORD_TYPE.BD09LL); + // } + + Future? getAddress(double lat, double lang) async { + var result = await ApiService(Dio()).geocodeRegeo("$lat", "$lang"); + print("address_result: $result"); + if (result["status"] == 1 && + result["regeocode"] != null && + result["regeocode"]["addressComponent"] != null) { + Address address = Address.fromJson({ + "address": result["regeocode"]["formatted_address"], + "area": result['regeocode']["addressComponent"]["district"], + "city": result['regeocode']["addressComponent"]["city"], + "latitude": lat, + "longitude": lang, + "province": result['regeocode']["addressComponent"]["province"], + }); + return address; + } + return null; + } +} \ No newline at end of file diff --git a/lib/utils/upload_async.dart b/lib/utils/upload_async.dart index 5c6fca27..53e2b77e 100644 --- a/lib/utils/upload_async.dart +++ b/lib/utils/upload_async.dart @@ -152,10 +152,19 @@ class UploadAsync { thumbnail = element.thumbPath!; } else { var result = await ImageGallerySaver.saveFile( - element.path!, + file.path, isReturnPathOfIOS: true, ); - thumbnail = element.path!; + if (result["isSuccess"] == true) { + thumbnail = element.thumbPath!; + } else { + thumbnail = element.thumbPath!; + } + // var result = await ImageGallerySaver.saveFile( + // element.path!, + // isReturnPathOfIOS: true, + // ); + // thumbnail = element.path!; // thumbnail = await Thumbnails.getThumbnail( // videoFile: file.path, // imageType: ThumbFormat.JPEG, diff --git a/lib/vip/vip_page.dart b/lib/vip/vip_page.dart index 020b41bd..953d3d28 100644 --- a/lib/vip/vip_page.dart +++ b/lib/vip/vip_page.dart @@ -54,6 +54,7 @@ class _VipPageState extends State with AutomaticKeepAliveClientMixin { _refreshController.refreshCompleted(); _refreshController.loadComplete(); } else { + if(baseData?.msg != null) SmartDialog.showToast(baseData?.msg ?? "", alignment: Alignment.center); _refreshController.refreshFailed(); _refreshController.loadFailed(); diff --git a/lib/web/web_page.dart b/lib/web/web_page.dart index 24114afc..718ff1d3 100644 --- a/lib/web/web_page.dart +++ b/lib/web/web_page.dart @@ -21,6 +21,7 @@ import 'package:shared_preferences/shared_preferences.dart'; import 'package:sharesdk_plugin/sharesdk_defines.dart'; import 'package:sharesdk_plugin/sharesdk_interface.dart'; import 'package:sharesdk_plugin/sharesdk_map.dart'; +import 'package:dio/dio.dart'; class WebPage extends StatefulWidget { final Map? arguments; @@ -57,7 +58,15 @@ class _WebPage extends State with WidgetsBindingObserver { super.initState(); WidgetsBinding.instance.addObserver(this); commentFocus.addListener(_focusNodeListener); - queryHtml(); + SharedPreferences.getInstance().then((value) => { + apiService = ApiService( + Dio(), + context: context, + token: value.getString('token'), + showLoading: true + ), + queryHtml() + }); } bool isKeyBoardShow = false; @@ -129,13 +138,13 @@ class _WebPage extends State with WidgetsBindingObserver { } queryHtml() async { - SharedPreferences value = await SharedPreferences.getInstance(); + // SharedPreferences value = await SharedPreferences.getInstance(); if (widget.arguments?["activityId"] != null) { BaseData? baseData = await apiService?.activityInfo(widget.arguments!["activityId"]) .catchError((onError) {}); if (baseData?.isSuccess ?? false) { - activity = baseData!.data; + activity = baseData?.data; setState(() {}); } } @@ -143,7 +152,7 @@ class _WebPage extends State with WidgetsBindingObserver { BaseData
? baseData = await apiService?.informationInfo(widget.arguments!["articleId"]) .catchError((onError) {}); if (baseData?.isSuccess ?? false) { - article = baseData!.data; + article = baseData?.data; setState(() {}); } } diff --git a/lib/web/web_view/comment_list.dart b/lib/web/web_view/comment_list.dart index 6700c2fd..e288952d 100644 --- a/lib/web/web_view/comment_list.dart +++ b/lib/web/web_view/comment_list.dart @@ -1,3 +1,4 @@ +import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:huixiang/generated/l10n.dart'; @@ -66,7 +67,15 @@ class CommentListState extends State { @override void initState() { super.initState(); - queryMemberCommentList(); + SharedPreferences.getInstance().then((value) => { + apiService = ApiService( + Dio(), + context: context, + token: value.getString('token'), + showLoading: true + ), + queryMemberCommentList() + }); } @override @@ -111,7 +120,7 @@ class CommentListState extends State { ListView.builder( shrinkWrap: true, physics: NeverScrollableScrollPhysics(), - itemCount: memberList?.length ?? 0, + itemCount: memberList.length ?? 0, scrollDirection: Axis.vertical, itemBuilder: (context, position) { return Material( @@ -188,7 +197,6 @@ class CommentListState extends State { //评论列表 queryMemberCommentList() async { if (widget.relationalId?.isEmpty ?? true) return; - SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); BaseData>? baseData = await apiService?.memberCommentList({ "pageNum": 1, "pageSize": 100, @@ -403,7 +411,7 @@ class CommentListState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - "${member.parentUserName}:" ?? "", + "${member.parentUserName ?? ""}:", style: TextStyle( fontSize: widget.fontSize, color: Color(0xff808080), diff --git a/lib/web/web_view/web_header.dart b/lib/web/web_view/web_header.dart index 2ae1ebd9..03c97dfd 100644 --- a/lib/web/web_view/web_header.dart +++ b/lib/web/web_view/web_header.dart @@ -27,7 +27,7 @@ class _WebHeader extends State { padding: EdgeInsets.all(12), alignment: Alignment.centerLeft, child: Text( - widget.activity!.mainTitle ?? widget.article!.mainTitle ?? "", + widget.activity?.mainTitle ?? widget.article?.mainTitle ?? "", style: TextStyle( fontSize: widget.fontSize, fontWeight: FontWeight.bold, @@ -84,7 +84,7 @@ class _WebHeader extends State { width: 10.w, ), Text( - widget.activity!.createTime ?? widget.article!.createTime ?? "", + widget.activity?.createTime ?? widget.article?.createTime ?? "", style: TextStyle( fontWeight: FontWeight.normal, fontSize: widget.fontSize - 4, diff --git a/pubspec.lock b/pubspec.lock index 3db219cb..bb3bffe9 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -257,22 +257,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "0.7.10" - device_info_plus: - dependency: transitive - description: - name: device_info_plus - sha256: "77f757b789ff68e4eaf9c56d1752309bd9f7ad557cb105b938a7f8eb89e59110" - url: "https://pub.flutter-io.cn" - source: hosted - version: "9.1.2" - device_info_plus_platform_interface: - dependency: transitive - description: - name: device_info_plus_platform_interface - sha256: d3b01d5868b50ae571cd1dc6e502fc94d956b665756180f7b16ead09e836fd64 - url: "https://pub.flutter-io.cn" - source: hosted - version: "7.0.0" dio: dependency: "direct main" description: @@ -374,46 +358,6 @@ packages: description: flutter source: sdk version: "0.0.0" - flutter_baidu_mapapi_base: - dependency: "direct main" - description: - name: flutter_baidu_mapapi_base - sha256: "24926c52eb057f25a7cdacb781e5387558773aa65ee351708efd3c83468e94cf" - url: "https://pub.flutter-io.cn" - source: hosted - version: "3.7.2" - flutter_baidu_mapapi_map: - dependency: "direct main" - description: - name: flutter_baidu_mapapi_map - sha256: "28f5226538432e8e0aacd7e8828943272e0dbdc3c3a5e32fc31859a4f2dd52dc" - url: "https://pub.flutter-io.cn" - source: hosted - version: "3.7.2" - flutter_baidu_mapapi_search: - dependency: "direct main" - description: - name: flutter_baidu_mapapi_search - sha256: "82007d3afd0a0bc8469ccb2e3c85b0f3881253eb144ec5a09ed5f48ca596cce3" - url: "https://pub.flutter-io.cn" - source: hosted - version: "3.7.2" - flutter_baidu_mapapi_utils: - dependency: "direct main" - description: - name: flutter_baidu_mapapi_utils - sha256: "24486e8c10fb74b45162b5bc6315bc6fe5ea65e2b0d8be8f215ecf2a6e93e1b5" - url: "https://pub.flutter-io.cn" - source: hosted - version: "3.7.2" - flutter_bmflocation: - dependency: "direct main" - description: - name: flutter_bmflocation - sha256: "74a9d96c4e95cbcd1c8dadc0d05004c48032bda1eee6fa2dbddf9ff0cfbd94f7" - url: "https://pub.flutter-io.cn" - source: hosted - version: "3.6.0" flutter_datetime_picker_plus: dependency: "direct main" description: @@ -483,14 +427,6 @@ packages: description: flutter source: sdk version: "0.0.0" - flutter_plugin_android_lifecycle: - dependency: transitive - description: - name: flutter_plugin_android_lifecycle - sha256: "8cf40eebf5dec866a6d1956ad7b4f7016e6c0cc69847ab946833b7d43743809f" - url: "https://pub.flutter-io.cn" - source: hosted - version: "2.0.19" flutter_screenutil: dependency: "direct main" description: @@ -581,6 +517,30 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "4.0.0" + geolocator: + dependency: "direct main" + description: + name: geolocator + sha256: f659200283c62dffa4b7ea107bfe22eaa19c4490f94dc623986aad39caa1dd0d + url: "https://pub.flutter-io.cn" + source: hosted + version: "7.0.0" + geolocator_platform_interface: + dependency: transitive + description: + name: geolocator_platform_interface + sha256: "9d6f34a8a4b704d504f34acc5e52d880a7d2caedd99739902d6319179b0336d4" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.3.6" + geolocator_web: + dependency: transitive + description: + name: geolocator_web + sha256: "0b9e0ec13ce2211085cae0055b3516c975bd6cfe2878a20c8f13611f1a259855" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.0.6" get: dependency: "direct main" description: @@ -1627,14 +1587,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "5.5.0" - win32_registry: - dependency: transitive - description: - name: win32_registry - sha256: "10589e0d7f4e053f2c61023a31c9ce01146656a70b7b7f0828c0b46d7da2a9bb" - url: "https://pub.flutter-io.cn" - source: hosted - version: "1.1.3" xdg_directories: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 363bc2e8..a6a458d7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -57,11 +57,8 @@ dependencies: permission_handler: ^11.3.0 - flutter_bmflocation: ^3.6.0 - flutter_baidu_mapapi_base: ^3.6.0 - flutter_baidu_mapapi_map: ^3.6.0 - flutter_baidu_mapapi_search: ^3.6.0 - flutter_baidu_mapapi_utils: ^3.6.0 + geolocator: ^7.0.0 + # location: ^3.2.4 dio: ^5.4.1 rxdart: ^0.27.07