From a0cad315d831118316e0e81184498210670c8923 Mon Sep 17 00:00:00 2001 From: wurong <953969641@qq.com> Date: Tue, 13 Aug 2024 16:46:30 +0800 Subject: [PATCH] =?UTF-8?q?=E9=97=A8=E5=BA=97=E5=88=97=E8=A1=A8ip=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E5=AE=9A=E4=BD=8D=E5=A4=84=E7=90=86=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/retrofit/data/address.dart | 8 ++++---- lib/union/union_page.dart | 1 + lib/utils/location.dart | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/retrofit/data/address.dart b/lib/retrofit/data/address.dart index acd8494c..e571e2cb 100644 --- a/lib/retrofit/data/address.dart +++ b/lib/retrofit/data/address.dart @@ -9,8 +9,8 @@ class Address { String cityInfo; String id; bool isDefault; - String latitude; - String longitude; + dynamic latitude; + dynamic longitude; String mid; String phone; String province; @@ -24,8 +24,8 @@ class Address { ..cityInfo = json['cityInfo'] as String ..id = json['id'] as String ..isDefault = json['isDefault'] as bool - ..latitude = json['latitude'] as String - ..longitude = json['longitude'] as String + ..latitude = json['latitude'] as dynamic + ..longitude = json['longitude'] as dynamic ..mid = json['mid'] as String ..phone = json['phone'] as String ..province = json['province'] as String diff --git a/lib/union/union_page.dart b/lib/union/union_page.dart index 3772695a..45264aef 100644 --- a/lib/union/union_page.dart +++ b/lib/union/union_page.dart @@ -136,6 +136,7 @@ class UnionPageState extends State Address address = await LocationInstance.getInstance().getAddress(result.latitude, result.longitude); if (address != null) { await saveLatLng(latLng, address.province, address.city, address.area); + areaName = address.city; } LocationInstance.getInstance().stopLocation(); } else { diff --git a/lib/utils/location.dart b/lib/utils/location.dart index 5fa18eda..af53e6f0 100644 --- a/lib/utils/location.dart +++ b/lib/utils/location.dart @@ -313,7 +313,7 @@ class LocationInstance { Future
getAddress(double lat, double lang) async { var result = await ApiService(Dio()).geocodeRegeo("$lat", "$lang"); print("address_result: $result"); - if (result["status"] == 1 && + if (result["status"] == "1" && result["regeocode"] != null && result["regeocode"]["addressComponent"] != null) { Address address = Address.fromJson({