Browse Source

new

wr_2024_invoice
zsw 7 months ago
parent
commit
80cb35ee66
  1. 2
      android/app/build.gradle
  2. BIN
      android/app/libs/uniMPSDK-release.aar
  3. 27
      android/app/src/main/AndroidManifest.xml
  4. 16
      android/app/src/main/kotlin/com/zsw/huixiang/HxApplication.kt
  5. 4
      android/build.gradle
  6. 6
      android/gradle.properties
  7. 7
      android/gradle/wrapper/gradle-wrapper.properties
  8. 191
      ios/Podfile.lock
  9. 44
      ios/Runner.xcodeproj/project.pbxproj
  10. 22
      ios/Runner/Info.plist
  11. 339
      lib/address/address_map_page.dart
  12. 5
      lib/community/community_view/home_class.dart
  13. 5
      lib/community/headlines/activity_top_list.dart
  14. 7
      lib/community/headlines/headlines_collection.dart
  15. 94
      lib/home/home_view/quick_order.dart
  16. 4
      lib/main.dart
  17. 26
      lib/main_page.dart
  18. 8
      lib/mine/mine_shop_details.dart
  19. 6
      lib/mine/vip_detail_page.dart
  20. 12
      lib/mine/vip_pay_code.dart
  21. 6
      lib/order/store_selector_page.dart
  22. 4
      lib/retrofit/business_api.dart
  23. 16
      lib/retrofit/data/latlng.dart
  24. 4
      lib/retrofit/data/store_info.dart
  25. 3
      lib/retrofit/min_api.dart
  26. 10
      lib/retrofit/retrofit_api.dart
  27. 20
      lib/retrofit/retrofit_api.g.dart
  28. 50
      lib/settlement/settlement.dart
  29. 27
      lib/settlement/settlement_view/distribution.dart
  30. 11
      lib/store/shopping/shopping_cart/shopping_cart_page.dart
  31. 1
      lib/store/shopping/shopping_home/classify_list.dart
  32. 1
      lib/store/shopping/shopping_home/search_page.dart
  33. 15
      lib/store/store_order.dart
  34. 4
      lib/store/store_view/shop_car.dart
  35. 77
      lib/store/store_view/store_info.dart
  36. 2412
      lib/union/location_map_page.dart
  37. 7
      lib/union/union_list.dart
  38. 62
      lib/union/union_page.dart
  39. 239
      lib/union/union_view/store_info.dart
  40. 17
      lib/utils/flutter_utils.dart
  41. 141
      lib/utils/gps_utils.dart
  42. 193
      lib/utils/location.dart
  43. 256
      pubspec.lock
  44. 9
      pubspec.yaml

2
android/app/build.gradle

@ -106,7 +106,7 @@ android {
defaultConfig {
applicationId "com.zsw.huixiang"
minSdkVersion 21
targetSdkVersion 30
targetSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName

BIN
android/app/libs/uniMPSDK-release.aar

Binary file not shown.

27
android/app/src/main/AndroidManifest.xml

@ -1,4 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.zsw.huixiang">
<!-- <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>-->
@ -36,7 +37,6 @@
<application
android:label="海峡姐妹"
android:name=".HxApplication"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
@ -102,35 +102,12 @@
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"/>
<activity
android:name="io.dcloud.PandoraEntryActivity"
android:configChanges="orientation|keyboardHidden|screenSize|mcc|mnc|fontScale|keyboard"
android:hardwareAccelerated="true"
android:launchMode="singleTask"
android:permission="com.miui.securitycenter.permission.AppPermissionsEditor"
android:screenOrientation="user"
android:theme="@style/DCloudTheme"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<action android:name="android.intent.action.VIEW" />
<data android:scheme="h56131bcf" />
</intent-filter>
</activity>
<service android:name="com.amap.api.location.APSService"/>
<meta-data
android:name="dcloud_appkey"
android:value="" />
<meta-data
android:name="com.amap.api.v2.apikey"
android:value="f39d1daa020a56f208eb2519f63e9534"/>
<meta-data
android:name="com.baidu.lbsapi.API_KEY"
android:value="cdM5EPFACARrrHRjCwUEoYuzIlfFWdYP" />
<meta-data
android:name="flutterEmbedding"
android:value="2" />

16
android/app/src/main/kotlin/com/zsw/huixiang/HxApplication.kt

@ -1,16 +0,0 @@
package com.zsw.huixiang
import android.app.Application
import com.baidu.mapapi.base.BmfMapApplication
class HxApplication : BmfMapApplication() {
override fun onCreate() {
super.onCreate()
}
}

4
android/build.gradle

@ -8,11 +8,13 @@ buildscript {
url 'https://maven.aliyun.com/repository/jcenter'
}
maven {
allowInsecureProtocol = true
url 'http://maven.aliyun.com/nexus/content/groups/public'
}
// google()
// jcenter()
maven {
allowInsecureProtocol = true
url "http://mvn.mob.com/android"
}
maven { url "https://www.jitpack.io" }
@ -43,11 +45,13 @@ allprojects {
url 'https://maven.aliyun.com/repository/jcenter'
}
maven {
allowInsecureProtocol = true
url 'http://maven.aliyun.com/nexus/content/groups/public'
}
// google()
// jcenter()
maven {
allowInsecureProtocol = true
url "http://mvn.mob.com/android"
}
maven { url "https://www.jitpack.io" }

6
android/gradle.properties

@ -1,6 +1,8 @@
#org.gradle.jvmargs=-Xmx1536M
org.gradle.jvmargs=-Xmx4096m
#org.gradle.jvmargs=-Xmx4096m
android.useAndroidX=true
android.enableJetifier=true
MobSDK.mobEnv=x
MobSDK.spEdition=FP
MobSDK.spEdition=FP
android.injected.testOnly=false
org.gradle.jvmargs=-Xmx4096m --add-exports=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED

7
android/gradle/wrapper/gradle-wrapper.properties vendored

@ -1,10 +1,5 @@
#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
#distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
#distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
systemProp.http.proxyHost=proxy.com
systemProp.http.proxyPort=8080

191
ios/Podfile.lock

@ -14,38 +14,14 @@ PODS:
- AFNetworking/Serialization (4.0.1)
- AFNetworking/UIKit (4.0.1):
- AFNetworking/NSURLSession
- BaiduMapKit/Base (6.5.1)
- BaiduMapKit/Map (6.5.1):
- BaiduMapKit/Base
- BaiduMapKit/Search (6.5.1):
- BaiduMapKit/Base
- BaiduMapKit/Utils (6.5.1):
- BaiduMapKit/Base
- BMKLocationKit (2.0.4)
- emoji_picker_flutter (0.0.1):
- Flutter
- Flutter (1.0.0)
- flutter_baidu_mapapi_base (3.1.0):
- BaiduMapKit/Utils (= 6.5.1)
- Flutter
- flutter_baidu_mapapi_map (3.1.0):
- BaiduMapKit/Map (= 6.5.1)
- Flutter
- flutter_baidu_mapapi_base
- flutter_baidu_mapapi_search (3.1.0):
- BaiduMapKit/Search (= 6.5.1)
- Flutter
- flutter_baidu_mapapi_base
- flutter_baidu_mapapi_utils (3.1.0):
- BaiduMapKit/Utils (= 6.5.1)
- Flutter
- flutter_baidu_mapapi_base
- flutter_bmflocation (2.0.1):
- BMKLocationKit (~> 2.0.4)
- Flutter
- fluwx (0.0.1):
- Flutter
- mob_sharesdk/ShareSDKPlatforms/WeChatFull
- "OpenWeChatSDK (~> 1.9.2+1)"
- geolocator (6.2.0):
- Flutter
- image_gallery_saver (1.5.0):
- Flutter
- image_pickers (0.0.1):
@ -60,103 +36,13 @@ PODS:
- mob_sharesdk/ShareSDKExtension (4.4.15):
- mob_sharesdk/ShareSDK
- MOBFoundation (>= 3.2.9)
- mob_sharesdk/ShareSDKPlatforms/DingTalk (4.4.15):
- mob_sharesdk/ShareSDK
- MOBFoundation (>= 3.2.9)
- mob_sharesdk/ShareSDKPlatforms/Douyin (4.4.15):
- mob_sharesdk/ShareSDK
- MOBFoundation (>= 3.2.9)
- mob_sharesdk/ShareSDKPlatforms/Dropbox (4.4.15):
- mob_sharesdk/ShareSDK
- MOBFoundation (>= 3.2.9)
- mob_sharesdk/ShareSDKPlatforms/Evernote (4.4.15):
- mob_sharesdk/ShareSDK
- MOBFoundation (>= 3.2.9)
- mob_sharesdk/ShareSDKPlatforms/Facebook (4.4.15):
- mob_sharesdk/ShareSDK
- MOBFoundation (>= 3.2.9)
- mob_sharesdk/ShareSDKPlatforms/Flickr (4.4.15):
- mob_sharesdk/ShareSDK
- MOBFoundation (>= 3.2.9)
- mob_sharesdk/ShareSDKPlatforms/GooglePlus (4.4.15):
- mob_sharesdk/ShareSDK
- MOBFoundation (>= 3.2.9)
- mob_sharesdk/ShareSDKPlatforms/Instagram (4.4.15):
- mob_sharesdk/ShareSDK
- MOBFoundation (>= 3.2.9)
- mob_sharesdk/ShareSDKPlatforms/Instapaper (4.4.15):
- mob_sharesdk/ShareSDK
- MOBFoundation (>= 3.2.9)
- mob_sharesdk/ShareSDKPlatforms/Kakao (4.4.15):
- mob_sharesdk/ShareSDK
- MOBFoundation (>= 3.2.9)
- mob_sharesdk/ShareSDKPlatforms/KuaiShou (4.4.15):
- mob_sharesdk/ShareSDK
- MOBFoundation (>= 3.2.9)
- mob_sharesdk/ShareSDKPlatforms/Line (4.4.15):
- mob_sharesdk/ShareSDK
- MOBFoundation (>= 3.2.9)
- mob_sharesdk/ShareSDKPlatforms/LinkedIn (4.4.15):
- mob_sharesdk/ShareSDK
- MOBFoundation (>= 3.2.9)
- mob_sharesdk/ShareSDKPlatforms/Messenger (4.4.15):
- mob_sharesdk/ShareSDK
- MOBFoundation (>= 3.2.9)
- mob_sharesdk/ShareSDKPlatforms/MingDao (4.4.15):
- mob_sharesdk/ShareSDK
- MOBFoundation (>= 3.2.9)
- mob_sharesdk/ShareSDKPlatforms/Oasis (4.4.15):
- mob_sharesdk/ShareSDK
- MOBFoundation (>= 3.2.9)
- mob_sharesdk/ShareSDKPlatforms/Pinterest (4.4.15):
- mob_sharesdk/ShareSDK
- MOBFoundation (>= 3.2.9)
- mob_sharesdk/ShareSDKPlatforms/Pocket (4.4.15):
- mob_sharesdk/ShareSDK
- MOBFoundation (>= 3.2.9)
- mob_sharesdk/ShareSDKPlatforms/QQ (4.4.15):
- mob_sharesdk/ShareSDK
- MOBFoundation (>= 3.2.9)
- mob_sharesdk/ShareSDKPlatforms/Reddit (4.4.15):
- mob_sharesdk/ShareSDK
- MOBFoundation (>= 3.2.9)
- mob_sharesdk/ShareSDKPlatforms/SinaWeibo (4.4.15):
- mob_sharesdk/ShareSDK
- MOBFoundation (>= 3.2.9)
- mob_sharesdk/ShareSDKPlatforms/SMS (4.4.15):
- mob_sharesdk/ShareSDK
- MOBFoundation (>= 3.2.9)
- mob_sharesdk/ShareSDKPlatforms/SnapChat (4.4.15):
- mob_sharesdk/ShareSDK
- MOBFoundation (>= 3.2.9)
- mob_sharesdk/ShareSDKPlatforms/Telegram (4.4.15):
- mob_sharesdk/ShareSDK
- MOBFoundation (>= 3.2.9)
- mob_sharesdk/ShareSDKPlatforms/TikTok (4.4.15):
- mob_sharesdk/ShareSDK
- MOBFoundation (>= 3.2.9)
- mob_sharesdk/ShareSDKPlatforms/Twitter (4.4.15):
- mob_sharesdk/ShareSDK
- MOBFoundation (>= 3.2.9)
- mob_sharesdk/ShareSDKPlatforms/VKontakte (4.4.15):
- mob_sharesdk/ShareSDK
- MOBFoundation (>= 3.2.9)
- mob_sharesdk/ShareSDKPlatforms/WatermelonVideo (4.4.15):
- mob_sharesdk/ShareSDK
- MOBFoundation (>= 3.2.9)
- mob_sharesdk/ShareSDKPlatforms/WeChatFull (4.4.15):
- mob_sharesdk/ShareSDK
- MOBFoundation (>= 3.2.9)
- mob_sharesdk/ShareSDKPlatforms/WeWork (4.4.15):
- mob_sharesdk/ShareSDK
- MOBFoundation (>= 3.2.9)
- mob_sharesdk/ShareSDKPlatforms/WhatsApp (4.4.15):
- mob_sharesdk/ShareSDK
- MOBFoundation (>= 3.2.9)
- mob_sharesdk/ShareSDKPlatforms/Yixin (4.4.15):
- mob_sharesdk/ShareSDK
- MOBFoundation (>= 3.2.9)
- mob_sharesdk/ShareSDKPlatforms/YouDaoNote (4.4.15):
- mob_sharesdk/ShareSDKPlatforms/WeChat_Lite (4.4.15):
- mob_sharesdk/ShareSDK
- MOBFoundation (>= 3.2.9)
- mob_sharesdk/ShareSDKUI (4.4.15):
@ -165,6 +51,7 @@ PODS:
- MOBFoundation (3.2.49)
- number_precision (0.0.1):
- Flutter
- "OpenWeChatSDK (1.9.9+1)"
- package_info (0.0.1):
- Flutter
- path_provider (0.0.1):
@ -183,39 +70,9 @@ PODS:
- Flutter
- mob_sharesdk
- mob_sharesdk/ShareSDKExtension
- mob_sharesdk/ShareSDKPlatforms/DingTalk
- mob_sharesdk/ShareSDKPlatforms/Douyin
- mob_sharesdk/ShareSDKPlatforms/Dropbox
- mob_sharesdk/ShareSDKPlatforms/Evernote
- mob_sharesdk/ShareSDKPlatforms/Facebook
- mob_sharesdk/ShareSDKPlatforms/Flickr
- mob_sharesdk/ShareSDKPlatforms/GooglePlus
- mob_sharesdk/ShareSDKPlatforms/Instagram
- mob_sharesdk/ShareSDKPlatforms/Instapaper
- mob_sharesdk/ShareSDKPlatforms/Kakao
- mob_sharesdk/ShareSDKPlatforms/KuaiShou
- mob_sharesdk/ShareSDKPlatforms/Line
- mob_sharesdk/ShareSDKPlatforms/LinkedIn
- mob_sharesdk/ShareSDKPlatforms/Messenger
- mob_sharesdk/ShareSDKPlatforms/MingDao
- mob_sharesdk/ShareSDKPlatforms/Oasis
- mob_sharesdk/ShareSDKPlatforms/Pinterest
- mob_sharesdk/ShareSDKPlatforms/Pocket
- mob_sharesdk/ShareSDKPlatforms/QQ
- mob_sharesdk/ShareSDKPlatforms/Reddit
- mob_sharesdk/ShareSDKPlatforms/SinaWeibo
- mob_sharesdk/ShareSDKPlatforms/SMS
- mob_sharesdk/ShareSDKPlatforms/SnapChat
- mob_sharesdk/ShareSDKPlatforms/Telegram
- mob_sharesdk/ShareSDKPlatforms/TikTok
- mob_sharesdk/ShareSDKPlatforms/Twitter
- mob_sharesdk/ShareSDKPlatforms/VKontakte
- mob_sharesdk/ShareSDKPlatforms/WatermelonVideo
- mob_sharesdk/ShareSDKPlatforms/WeChatFull
- mob_sharesdk/ShareSDKPlatforms/WeWork
- mob_sharesdk/ShareSDKPlatforms/WhatsApp
- mob_sharesdk/ShareSDKPlatforms/Yixin
- mob_sharesdk/ShareSDKPlatforms/YouDaoNote
- mob_sharesdk/ShareSDKPlatforms/WeChat_Lite
- mob_sharesdk/ShareSDKUI
- SSZipArchive (2.4.3)
- thumbnails (0.0.1):
@ -247,12 +104,8 @@ PODS:
DEPENDENCIES:
- emoji_picker_flutter (from `.symlinks/plugins/emoji_picker_flutter/ios`)
- Flutter (from `Flutter`)
- flutter_baidu_mapapi_base (from `.symlinks/plugins/flutter_baidu_mapapi_base/ios`)
- flutter_baidu_mapapi_map (from `.symlinks/plugins/flutter_baidu_mapapi_map/ios`)
- flutter_baidu_mapapi_search (from `.symlinks/plugins/flutter_baidu_mapapi_search/ios`)
- flutter_baidu_mapapi_utils (from `.symlinks/plugins/flutter_baidu_mapapi_utils/ios`)
- flutter_bmflocation (from `.symlinks/plugins/flutter_bmflocation/ios`)
- fluwx (from `.symlinks/plugins/fluwx/ios`)
- geolocator (from `.symlinks/plugins/geolocator/ios`)
- image_gallery_saver (from `.symlinks/plugins/image_gallery_saver/ios`)
- image_pickers (from `.symlinks/plugins/image_pickers/ios`)
- number_precision (from `.symlinks/plugins/number_precision/ios`)
@ -275,10 +128,9 @@ DEPENDENCIES:
SPEC REPOS:
https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git:
- AFNetworking
- BaiduMapKit
- BMKLocationKit
- mob_sharesdk
- MOBFoundation
- OpenWeChatSDK
- SDWebImage
- SSZipArchive
- TPNS-iOS
@ -291,18 +143,10 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/emoji_picker_flutter/ios"
Flutter:
:path: Flutter
flutter_baidu_mapapi_base:
:path: ".symlinks/plugins/flutter_baidu_mapapi_base/ios"
flutter_baidu_mapapi_map:
:path: ".symlinks/plugins/flutter_baidu_mapapi_map/ios"
flutter_baidu_mapapi_search:
:path: ".symlinks/plugins/flutter_baidu_mapapi_search/ios"
flutter_baidu_mapapi_utils:
:path: ".symlinks/plugins/flutter_baidu_mapapi_utils/ios"
flutter_bmflocation:
:path: ".symlinks/plugins/flutter_bmflocation/ios"
fluwx:
:path: ".symlinks/plugins/fluwx/ios"
geolocator:
:path: ".symlinks/plugins/geolocator/ios"
image_gallery_saver:
:path: ".symlinks/plugins/image_gallery_saver/ios"
image_pickers:
@ -340,28 +184,23 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
AFNetworking: 3bd23d814e976cd148d7d44c3ab78017b744cd58
BaiduMapKit: f227cfb43581e91466fb4f1344f655eab5788777
BMKLocationKit: 688d8e1194980b96fc9a6585c0eb42e62fbaf780
emoji_picker_flutter: df19dac03a2b39ac667dc8d1da939ef3a9e21347
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
flutter_baidu_mapapi_base: cb406be78c3a949fb58a45dc6627f139d580bd37
flutter_baidu_mapapi_map: 81c4e6e93dc668e311d9b521421deaf292390434
flutter_baidu_mapapi_search: 13a360334e91abea0bcf820546b2ef4548e42e08
flutter_baidu_mapapi_utils: f6a5d23da26b0e58f1ae9908da7ba87fd48384b1
flutter_bmflocation: 1bd73181196567fe1529f765aa4f8e2615a8a3cf
fluwx: a24006296e7ca601e8544e12bd6269497fae23e6
fluwx: 79c66b6d795ab8208262ada215d9e60388cfe492
geolocator: f5e3de65e241caba7ce3e8a618803387bda73384
image_gallery_saver: 259eab68fb271cfd57d599904f7acdc7832e7ef2
image_pickers: 25c8916d358bc9d2707cb470ba3d57497f105773
mob_sharesdk: 0698d60b3c1549a5b0bcfdec6f407439dd2960c0
MOBFoundation: 6df2684b4db4f0f5bd71b0623f82e11271bf7ac8
number_precision: 26fa2be2212f9d1429f92d667d6b0aa4df0058d8
OpenWeChatSDK: ea48e9db20645f78128db9091893910280b8e4b1
package_info: 873975fc26034f0b863a300ad47e7f1ac6c7ec62
path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c
permission_handler: ccb20a9fad0ee9b1314a52b70b76b473c5f8dab0
scan: aea35bb4aa59ccc8839c576a18cd57c7d492cc86
SDWebImage: e5cc87bf736e60f49592f307bdf9e157189298a3
shared_preferences_foundation: 986fc17f3d3251412d18b0265f9c64113a8c2472
sharesdk_plugin: b105d82bed39e1d229591999058ab1e12ff95001
sharesdk_plugin: f29a6f471ae1c253e96636d62106c3f8d793948c
SSZipArchive: fe6a26b2a54d5a0890f2567b5cc6de5caa600aef
thumbnails: bb4f4e9bb4b51c8ae4e6ad9a2fa81373f9b634ad
tobias: 2aded9b83e3663b907360a800d8e3c13284f25c5
@ -378,4 +217,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: f8bac8842dd5d4f36a3709c129ae7a2ccd5be619
COCOAPODS: 1.13.0
COCOAPODS: 1.15.2

44
ios/Runner.xcodeproj/project.pbxproj

@ -10,7 +10,6 @@
0558860326BD10CA00FB1CFE /* test.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0558860226BD10CA00FB1CFE /* test.swift */; };
05C5426F26BBE8FE00D26AC2 /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6EE8F373269581F600237A5E /* CoreLocation.framework */; };
05C5427126BBE93600D26AC2 /* AdSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 05C5427026BBE93600D26AC2 /* AdSupport.framework */; };
05C5427426BCE3AC00D26AC2 /* BMKLocationKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 05C5427326BCE3AC00D26AC2 /* BMKLocationKit.framework */; };
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
6EE8F3582695818800237A5E /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6EE8F3572695818800237A5E /* JavaScriptCore.framework */; };
@ -145,7 +144,6 @@
6EE8F35C2695819500237A5E /* CoreMedia.framework in Frameworks */,
6EE8F3582695818800237A5E /* JavaScriptCore.framework in Frameworks */,
C9444B3318AB7FB815E97950 /* libPods-Runner.a in Frameworks */,
05C5427426BCE3AC00D26AC2 /* BMKLocationKit.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -358,7 +356,6 @@
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
120EAF7195D9AB3BB1E8FA2B /* [CP] Copy Pods Resources */,
8C1FAACB8CAD66760F3893D3 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
@ -452,23 +449,6 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin\n";
};
8C1FAACB8CAD66760F3893D3 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
@ -657,6 +637,7 @@
"\"${PODS_ROOT}/Headers/Private/fluwx\"",
);
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "海峡姐妹";
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
@ -669,7 +650,7 @@
"$(PROJECT_DIR)/baidu",
"$(PROJECT_DIR)/Runner/baidu",
);
MARKETING_VERSION = 3.2.28;
MARKETING_VERSION = 3.2.29;
ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = (
"$(inherited)",
@ -677,11 +658,6 @@
"-l\"c++\"",
"-l\"image_pickers\"",
"-l\"path_provider\"",
"-l\"flutter_bmflocation\"",
"-l\"flutter_baidu_mapapi_utils\"",
"-l\"flutter_baidu_mapapi_search\"",
"-l\"flutter_baidu_mapapi_map\"",
"-l\"flutter_baidu_mapapi_base\"",
"-l\"permission_handler\"",
"-l\"sqlite3\"",
"-l\"wakelock\"",
@ -860,6 +836,7 @@
"\"${PODS_ROOT}/Headers/Private/fluwx\"",
);
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "海峡姐妹";
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
@ -872,7 +849,7 @@
"$(PROJECT_DIR)/baidu",
"$(PROJECT_DIR)/Runner/baidu",
);
MARKETING_VERSION = 3.2.28;
MARKETING_VERSION = 3.2.29;
ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = (
"$(inherited)",
@ -880,11 +857,6 @@
"-l\"c++\"",
"-l\"image_pickers\"",
"-l\"path_provider\"",
"-l\"flutter_bmflocation\"",
"-l\"flutter_baidu_mapapi_utils\"",
"-l\"flutter_baidu_mapapi_search\"",
"-l\"flutter_baidu_mapapi_map\"",
"-l\"flutter_baidu_mapapi_base\"",
"-l\"permission_handler\"",
"-l\"sqlite3\"",
"-l\"wakelock\"",
@ -954,6 +926,7 @@
"\"${PODS_ROOT}/Headers/Private/fluwx\"",
);
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "海峡姐妹";
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
@ -966,7 +939,7 @@
"$(PROJECT_DIR)/baidu",
"$(PROJECT_DIR)/Runner/baidu",
);
MARKETING_VERSION = 3.2.28;
MARKETING_VERSION = 3.2.29;
ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = (
"$(inherited)",
@ -974,11 +947,6 @@
"-l\"c++\"",
"-l\"image_pickers\"",
"-l\"path_provider\"",
"-l\"flutter_bmflocation\"",
"-l\"flutter_baidu_mapapi_utils\"",
"-l\"flutter_baidu_mapapi_search\"",
"-l\"flutter_baidu_mapapi_map\"",
"-l\"flutter_baidu_mapapi_base\"",
"-l\"permission_handler\"",
"-l\"sqlite3\"",
"-l\"wakelock\"",

22
ios/Runner/Info.plist

@ -7,7 +7,7 @@
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>一心回鄉</string>
<string>海峡姐妹</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
@ -95,9 +95,9 @@
<string>lineauth</string>
<string>line3rdp.$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<string>alipay</string>
<string>iosamap</string>
<string>qqmap</string>
<string>baidumap</string>
<string>iosamap</string>
<string>qqmap</string>
<string>baidumap</string>
</array>
<key>LSRequiresIPhoneOS</key>
<true/>
@ -136,20 +136,22 @@
<string>拍视频需要录音权限</string>
<key>NSMotionUsageDescription</key>
<string>是否允许访问运行</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>请允许App保存图片到相册</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>打开相册</string>
<key>NSSpeechRecognitionUsageDescription</key>
<string>是否允许语音识别</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>请允许App保存图片到相册</string>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
</dict>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>UIBackgroundModes</key>
<array>
<string>remote-notification</string>
<string>location</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
@ -178,11 +180,5 @@
<string>https://hx.lotus-wallet.com/app/</string>
<key>io.flutter.embedded_views_preview</key>
<string>YES</string>
<key>UIBackgroundModes</key>
<array>
<string>location</string>
</array>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
</dict>
</plist>

339
lib/address/address_map_page.dart

@ -8,16 +8,14 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.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_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_easyloading/flutter_easyloading.dart';
import 'package:geolocator/geolocator.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/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';
@ -29,23 +27,10 @@ class AddressMapPage extends StatefulWidget {
}
class _AddressMapPage extends State<AddressMapPage> {
//
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();
}
ApiService apiService;
@override
@ -55,90 +40,33 @@ class _AddressMapPage extends State<AddressMapPage> {
SharedPreferences.getInstance().then((value) => {
apiService = ApiService(Dio(),
context: context, token: value.getString('token')),
});
},);
if (aMapFlutterLocation == null) {
aMapFlutterLocation = LocationFlutterPlugin();
}
aMapFlutterLocation.singleLocationCallback(callback: (BaiduLocation result){
LocationInstance.getInstance().startLocation(context, (Position result) {
print("event: $result");
if (result != null &&
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);
if (_mapController != null) {
this.latLng = Platform.isIOS ? value : latLng;
addMarker();
_mapController.updateMapOptions(
BMFMapOptions(
center: latLng,
zoomLevel: 15,
showZoomControl: false,
showMapScaleBar: false,
rotateEnabled: false,
),
);
latLng = Position(latitude: result.latitude, longitude: result.longitude);
LocationInstance.getInstance().getAddress(result.latitude, result.longitude).then((value) {
if (value != null) {
city = value.city;
}
searchPoi(latLng);
});
saveLatLng(result);
searchPoi(latLng);
}
});
_setLocOption();
getLatLng();
startLocation();
}
/// android端和ios端定位参数
void _setLocOption() {
/// android
BaiduLocationAndroidOption androidOption = new BaiduLocationAndroidOption();
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 = new BaiduLocationIOSOption();
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 = Position();
List<Address> 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);
var addressPoi = await apiService.searchPoi("${latLng.latitude}", "${latLng.longitude}", keyWord, 20, 1);
//,;:['pois'],['entrances']
List<dynamic> poi = addressPoi['pois']??addressPoi['entrances'];
poiList = poi
@ -159,54 +87,31 @@ class _AddressMapPage extends State<AddressMapPage> {
}))
.toList();
setState(() {});
// BMFPoiNearbySearch bmfPoiNearbySearch = BMFPoiNearbySearch();
// bmfPoiNearbySearch.onGetPoiNearbySearchResult(
// callback: (BMFPoiSearchResult result, BMFSearchErrorCode errorCode) {
// // if ((DateTime.now().millisecondsSinceEpoch - time) > 2000) {
// result.poiInfoList.map((e) => print("sssssssssss:${e.toMap()}"));
// poiList = result.poiInfoList;
// print("object112221: ${poiList.length}");
// setState(() {
// time = DateTime.now().millisecondsSinceEpoch;
// });
// // }
// });
// bmfPoiNearbySearch.poiNearbySearch(BMFPoiNearbySearchOption(
// keywords: [" "],
// tags: ["小区","住宅","地标","建筑"],
// radius: 100000,
// location: latLng,
// pageSize: 20,
// pageIndex: 0,
// isRadiusLimit: true,
// ));
}
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 if (await Permission.location.isUndetermined) {
await Permission.location.request();
} else if (await PH.Permission.location.isUndetermined) {
await PH.Permission.location.request();
} else {
if (Platform.isIOS) {
//
requestDialog();
} else {
await Permission.location.request();
await PH.Permission.location.request();
}
}
}
@ -222,11 +127,12 @@ class _AddressMapPage extends State<AddressMapPage> {
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,
@ -246,8 +152,8 @@ class _AddressMapPage extends State<AddressMapPage> {
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();
}
}
@ -257,180 +163,45 @@ class _AddressMapPage extends State<AddressMapPage> {
});
}
BMFMapController _mapController;
BMFCoordinate bmfCoordinate;
void onMapCreated(BMFMapController controller) {
controller.setMapRegionDidChangeCallback(callback: (status) {
BMFMapStatus bmfMapStatus = status;
print("status: ${bmfMapStatus.toMap()}");
if (bmfCoordinate != null &&
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() {
if (latLng == null) return;
if (bmfMarker == null && _mapController != null) {
print("map_wid: ${MediaQuery.of(context).size.width}");
print("map_hei: ${MediaQuery.of(context).size.height}");
Position latLng;
bmfMarker = BMFMarker(
position: latLng,
screenPointToLock: BMFPoint(
(Platform.isIOS
? MediaQuery.of(context).size.width
: window.physicalSize.width) /
2,
Platform.isIOS
? MediaQuery.of(context).size.height
: window.physicalSize.height / 4),
isLockedToScreen: true,
centerOffset: BMFPoint(0.5, 0.7),
enabled: false,
icon: "assets/image/icon_address_location.webp",
draggable: false,
);
_mapController.addMarker(bmfMarker);
}
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 {
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(() {
if (_mapController != null) {
_mapController.updateMapOptions(
BMFMapOptions(
center: BMFCoordinate(
double.tryParse(value.getString("latitude")),
double.tryParse(value.getString("longitude")),
),
zoomLevel: 15,
showZoomControl: false,
showMapScaleBar: false,
rotateEnabled: false,
),
);
}
})
});
}
BMFMapWidget map;
BMFCoordinate center = BMFCoordinate(30.553111, 114.342366);
@override
Widget build(BuildContext context) {
return Scaffold(
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<OneSequenceGestureRecognizer>>[
// Factory<OneSequenceGestureRecognizer>(
// () => 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: 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(
@ -501,14 +272,16 @@ class _AddressMapPage extends State<AddressMapPage> {
padding: EdgeInsets.fromLTRB(10, 6, 16, 6),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(4)),
borderRadius: BorderRadius.all(
Radius.circular(4),
),
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(12),
offset: Offset(0, 3),
blurRadius: 14,
spreadRadius: 0,
)
),
],
),
child: Row(

5
lib/community/community_view/home_class.dart

@ -1,9 +1,10 @@
import 'package:flutter/cupertino.dart';
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/retrofit/data/collect_class_list.dart';
import 'package:huixiang/retrofit/data/course_list.dart';
import 'package:huixiang/retrofit/data/latlng.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/view_widget/custom_image.dart';
@ -23,7 +24,7 @@ class HomeClass extends StatefulWidget {
class _HomeClass extends State<HomeClass> {
ApiService apiService;
BMFCoordinate latLng;
Position latLng;
final TextEditingController editingController = TextEditingController();

5
lib/community/headlines/activity_top_list.dart

@ -1,9 +1,10 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.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/retrofit/data/article.dart';
import 'package:huixiang/retrofit/data/latlng.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/view_widget/custom_image.dart';
@ -22,7 +23,7 @@ class ActivityTopList extends StatefulWidget {
class _ActivityTopList extends State<ActivityTopList> {
ApiService apiService;
BMFCoordinate latLng;
Position latLng;
final TextEditingController editingController = TextEditingController();

7
lib/community/headlines/headlines_collection.dart

@ -1,16 +1,13 @@
import 'package:flutter/cupertino.dart';
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/retrofit/data/article.dart';
import 'package:huixiang/retrofit/data/collect_class_list.dart';
import 'package:huixiang/retrofit/data/course_list.dart';
import 'package:huixiang/retrofit/data/headlines_list.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:huixiang/view_widget/new_people_reward.dart';
class HeadlinesCollection extends StatefulWidget {
final List<HeadlinesList> headlines;
@ -26,7 +23,7 @@ class HeadlinesCollection extends StatefulWidget {
class _HeadlinesCollection extends State<HeadlinesCollection> {
ApiService apiService;
BMFCoordinate latLng;
Position latLng;
final TextEditingController editingController = TextEditingController();

94
lib/home/home_view/quick_order.dart

@ -1,13 +1,11 @@
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/store/scan.dart';
import 'package:huixiang/retrofit/data/latlng.dart';
import 'package:huixiang/utils/location.dart';
import 'package:huixiang/retrofit/data/base_data.dart';
import 'package:huixiang/retrofit/data/store.dart';
@ -19,7 +17,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 {
@ -32,9 +30,9 @@ class QuickOrder extends StatefulWidget {
class _QuickOrder extends State<QuickOrder> {
ApiService apiService;
List<Store> storeList;
BMFCoordinate latLng;
Position latLng;
BMFMapController _mapController;
// BMFMapController _mapController;
final TextEditingController editingController = TextEditingController();
@override
@ -45,11 +43,8 @@ class _QuickOrder extends State<QuickOrder> {
}
///
queryStore(latitude, longitude, province, city, district, searchKey) async {
queryStore(latitude, longitude, searchKey) async {
BaseData<List<Store>> baseData = await apiService.queryStore({
// "city": city,
// "district": district,
// "province": province,
"latitude": latitude,
"longitude": longitude,
"searchKey": searchKey
@ -68,74 +63,61 @@ class _QuickOrder extends State<QuickOrder> {
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")),
double.tryParse(value.getString("longitude"))),
latLng = Position(
latitude: double.tryParse(value.getString("latitude")),
longitude: double.tryParse(value.getString("longitude")),
),
queryStore(
value.getString("latitude"),
value.getString("longitude"),
value.getString("province"),
value.getString("city"),
value.getString("district"),
editingController.text,
),
setState(() {
if (_mapController != null) {
_mapController.updateMapOptions(BMFMapOptions(
center: latLng,
zoomLevel: 15,
));
}
// if (_mapController != null) {
// _mapController.updateMapOptions(BMFMapOptions(
// center: latLng,
// zoomLevel: 15,
// ));
// }
})
}
else
{
queryStore("", "", "", "", "", editingController.text),
queryStore("", "", editingController.text),
}
},
);
}
startLocation() async {
Location.getInstance().startLocation(context, (BaiduLocation result){
LocationInstance.getInstance().startLocation(context, (Position result){
if (result != null &&
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.getInstance().stopLocation();
latLng = Position(
latitude: result.latitude,
longitude: result.longitude,
);
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);
if (_mapController != null)
_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}");
@ -363,7 +345,7 @@ class _QuickOrder extends State<QuickOrder> {
///
toScan() async {
if (await Permission.camera.isPermanentlyDenied) {
if (await PH.Permission.camera.isPermanentlyDenied) {
showCupertinoDialog(
context: context,
builder: (context) {
@ -374,13 +356,13 @@ class _QuickOrder extends State<QuickOrder> {
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
@ -407,7 +389,7 @@ class _QuickOrder extends State<QuickOrder> {
);
}
} else {
await Permission.camera.request();
await PH.Permission.camera.request();
}
}
}

4
lib/main.dart

@ -351,8 +351,8 @@ Map<String, WidgetBuilder> routers = <String, WidgetBuilder>{
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}) =>

26
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';
@ -241,19 +239,19 @@ class _MainPage extends State<MainPage> with WidgetsBindingObserver {
);
SharesdkPlugin.regist(shareSDKRegister);
LocationFlutterPlugin myLocPlugin = LocationFlutterPlugin();
// 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);
}
// 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(

8
lib/mine/mine_shop_details.dart

@ -1,8 +1,7 @@
import 'package:barcode_widget/barcode_widget.dart';
import 'package:dio/dio.dart';
import 'package:flutter/material.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/retrofit/data/base_data.dart';
import 'package:huixiang/retrofit/data/page.dart';
@ -13,7 +12,6 @@ import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/store/scan.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/location.dart';
import 'package:huixiang/utils/painter_bg.dart';
import 'package:huixiang/view_widget/classic_header.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:huixiang/view_widget/my_appbar.dart';
@ -45,7 +43,7 @@ class _MineShopDetails extends State<MineShopDetails> {
super.dispose();
refreshController.dispose();
consumeRefreshController.dispose();
Location.getInstance().stopLocation();
LocationInstance.getInstance().stopLocation();
}
@override
@ -89,7 +87,7 @@ class _MineShopDetails extends State<MineShopDetails> {
startLocation() async {
// EasyLoading.show(status: S.current.zhengzaijiazai);
Location.getInstance().startLocation(context, (BaiduLocation result){
LocationInstance.getInstance().startLocation(context, (Position result){
if (result != null &&
result.latitude != null &&
result.longitude != null) {

6
lib/mine/vip_detail_page.dart

@ -1,8 +1,8 @@
import 'package:barcode_widget/barcode_widget.dart';
import 'package:dio/dio.dart';
import 'package:flutter/material.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/retrofit/data/base_data.dart';
import 'package:huixiang/retrofit/data/product.dart';
@ -37,7 +37,7 @@ class _VipDetailPage extends State<VipDetailPage> {
void dispose() {
super.dispose();
refreshController.dispose();
Location.getInstance().stopLocation();
LocationInstance.getInstance().stopLocation();
}
@override
@ -51,7 +51,7 @@ class _VipDetailPage extends State<VipDetailPage> {
startLocation() async {
// EasyLoading.show(status: S.current.zhengzaijiazai);
Location.getInstance().startLocation(context, (BaiduLocation result) {
LocationInstance.getInstance().startLocation(context, (Position result) {
if (result != null &&
result.latitude != null &&
result.longitude != null) {

12
lib/mine/vip_pay_code.dart

@ -1,30 +1,18 @@
import 'dart:async';
import 'dart:convert';
import 'package:barcode_widget/barcode_widget.dart';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bmflocation/flutter_bmflocation.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/data/base_data.dart';
import 'package:huixiang/retrofit/data/product.dart';
import 'package:huixiang/retrofit/data/vip_card.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/store/scan.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/location.dart';
import 'package:huixiang/utils/painter_bg.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:huixiang/view_widget/my_appbar.dart';
import 'package:huixiang/view_widget/my_footer.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:qr_flutter/qr_flutter.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../retrofit/data/user_info.dart';
import '../view_widget/classic_header.dart';
class VipPayCode extends StatefulWidget {
@override

6
lib/order/store_selector_page.dart

@ -1,13 +1,7 @@
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_baidu_mapapi_base/flutter_baidu_mapapi_base.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/generated/l10n.dart';
import 'package:huixiang/retrofit/data/base_data.dart';

4
lib/retrofit/business_api.dart

@ -2,7 +2,7 @@ import 'dart:convert';
import 'dart:io';
import 'package:dio/dio.dart';
import 'package:dio_log/interceptor/dio_log_interceptor.dart';
// import 'package:dio_log/interceptor/dio_log_interceptor.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
@ -95,7 +95,7 @@ abstract class BusinessApiService {
responseType: ResponseType.json,
baseUrl: baseUrl,
);
dio.interceptors.add(DioLogInterceptor());
// dio.interceptors.add(DioLogInterceptor());
dio.interceptors.add(
InterceptorsWrapper(onRequest: (RequestOptions options) {
debugPrint("\n======================= 请求数据 =======================");

16
lib/retrofit/data/latlng.dart

@ -0,0 +1,16 @@
//
// class Latlng {
//
//
// /// Latitude in degrees
// final double latitude;
//
// /// Longitude, in degrees
// final double longitude;
//
//
// Latlng(this.latitude, this.longitude);
//
// }

4
lib/retrofit/data/store_info.dart

@ -125,7 +125,7 @@ class StoreInfo {
'couponVOList': this.couponVOList,
'createTime': this.createTime,
'createUser': this.createUser,
'deliveryInfo': this.deliveryInfo.toJson(),
'deliveryInfo': this.deliveryInfo != null ? this.deliveryInfo.toJson() : null,
'pickupType':this.pickupType.toJson(),
'district': this.district,
'headMobile': this.headMobile,
@ -150,7 +150,7 @@ class StoreInfo {
'remark': this.remark,
'shipAddress': this.shipAddress,
'storeName': this.storeName,
'storeTable': this.storeTable.toJson(),
'storeTable': this.storeTable != null ? this.storeTable.toJson() : null,
'tenantCode': this.tenantCode,
'updateTime': this.updateTime,
'updateUser': this.updateUser,

3
lib/retrofit/min_api.dart

@ -27,8 +27,9 @@ import 'data/shopping_home_config.dart';
part 'min_api.g.dart';
const localBaseUrl = "http://192.168.10.78:8765/app/";///
// const localBaseUrl = "http://192.168.10.54:8765/app/";///
// const localBaseUrl = "http://pos-test.api.lotus-wallet.com/app/";///
const localBaseUrl = "https://pos.api.lotus-wallet.com/app/";///线
const serviceBaseUrl = "https://pos.api.lotus-wallet.com/app/";///线

10
lib/retrofit/retrofit_api.dart

@ -66,8 +66,9 @@ import 'data/wx_pay.dart';
part 'retrofit_api.g.dart';
const localBaseUrl = "http://192.168.10.54:8766/app/";///
// const localBaseUrl = "http://192.168.10.54:8766/app/";///
// const localBaseUrl = "http://platform.test.api.lotus-wallet.com/app/";///
const localBaseUrl = "https://pos.platform.lotus-wallet.com/app/";///线
const serviceBaseUrl = "https://pos.platform.lotus-wallet.com/app/";///线
const ipBaseUrl = "http://whois.pconline.com.cn";
@ -183,11 +184,14 @@ abstract class ApiService {
@Part(name: "folderId") int folderId, bool isVideo);
///
@GET(
"https://restapi.amap.com/v3/place/around?key=542b46afa8e4b88fe1eb3c4d0ba0872f&location={lat},{lng}&keywords={keywords}&offset={size}&page={page}&extensions=all")
@GET("https://restapi.amap.com/v3/place/around?key=542b46afa8e4b88fe1eb3c4d0ba0872f&location={lat},{lng}&keywords={keywords}&offset={size}&page={page}&extensions=all")
Future<dynamic> 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<dynamic> geocodeRegeo(@Path("lat") String lat, @Path("lng") String lng);
///
@POST("/auth/platform/memberLogin")
Future<BaseData> memberLogin(@Body() Map<String, dynamic> param);

20
lib/retrofit/retrofit_api.g.dart

@ -72,6 +72,26 @@ class _ApiService implements ApiService {
return value;
}
@override
Future<dynamic> geocodeRegeo(lat, lng) async {
ArgumentError.checkNotNull(lat, 'lat');
ArgumentError.checkNotNull(lng, 'lng');
const _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _data = <String, dynamic>{};
final _result = await _dio.request(
'https://restapi.amap.com/v3/geocode/regeo?key=542b46afa8e4b88fe1eb3c4d0ba0872f&location=${lng},${lat}&extensions=base',
queryParameters: queryParameters,
options: RequestOptions(
method: 'GET',
headers: <String, dynamic>{},
extra: _extra,
baseUrl: baseUrl),
data: _data);
final value = _result.data;
return value;
}
@override
Future<BaseData> memberLogin(param) async {
ArgumentError.checkNotNull(param, 'param');

50
lib/settlement/settlement.dart

@ -5,17 +5,17 @@ import 'package:dio/dio.dart';
import 'package:flutter/cupertino.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_baidu_mapapi_utils/flutter_baidu_mapapi_utils.dart';
import 'package:flutter_datetime_picker/flutter_datetime_picker.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/generated/l10n.dart';
import 'package:huixiang/retrofit/data/activity_details.dart';
import 'package:huixiang/retrofit/data/address.dart';
import 'package:huixiang/retrofit/data/base_data.dart';
import 'package:huixiang/retrofit/data/down_order.dart';
import 'package:huixiang/retrofit/data/latlng.dart';
import 'package:huixiang/retrofit/data/launch_join_act.dart';
import 'package:huixiang/retrofit/data/miNiDetail.dart';
import 'package:huixiang/retrofit/data/min_order_info.dart';
@ -401,9 +401,9 @@ class _Settlement extends State<Settlement> {
BaseData<List<Address>> baseDate =
await minService.queryAddress().catchError((error) {});
BMFCoordinate bmfCoordinate = BMFCoordinate(
double.tryParse(storeInfo.latitude),
double.tryParse(storeInfo.longitude),
Position bmfCoordinate = Position(
latitude: double.tryParse(storeInfo.latitude),
longitude: double.tryParse(storeInfo.longitude),
);
if (baseDate != null && baseDate.isSuccess) {
setState(() {
@ -411,26 +411,26 @@ class _Settlement extends State<Settlement> {
});
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);
Position coordinate = Position( // COMMON->BD09LL
longitude: double.tryParse(address.longitude),
latitude: double.tryParse(address.latitude),
);
Position coordinate1 = Position(// COMMON->BD09LL
longitude: double.tryParse(address1.longitude),
latitude: double.tryParse(address1.latitude),
);
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;
}

27
lib/settlement/settlement_view/distribution.dart

@ -1,11 +1,9 @@
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_bmflocation/flutter_bmflocation.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:geolocator/geolocator.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/data/address.dart';
import 'package:huixiang/retrofit/data/latlng.dart';
import 'package:huixiang/retrofit/data/store_info.dart';
import 'package:huixiang/utils/flutter_utils.dart';
import 'package:huixiang/utils/font_weight.dart';
@ -44,7 +42,7 @@ class _DistributionMode extends State<DistributionMode> {
"assets/svg/dingdan_wuliu.svg",
];
BMFCoordinate myLatLng;
Position myLatLng;
String distance = "0";
int selectedBtn = 0;
@ -57,24 +55,29 @@ class _DistributionMode extends State<DistributionMode> {
///
void startLocation() async {
Location.getInstance().startLocation(context, (BaiduLocation result) {
LocationInstance.getInstance().startLocation(context, (Position result) {
if (result != null &&
result.latitude != null &&
result.longitude != null) {
print("location: $result");
myLatLng = BMFCoordinate(result.latitude, result.longitude);
myLatLng = Position(latitude: result.latitude, longitude: result.longitude);
calculate();
Location.getInstance().stopLocation();
LocationInstance.getInstance().stopLocation();
}
});
}
calculate() async {
BMFCoordinate bmfCoordinate = BMFCoordinate(
double.tryParse(widget.storeInfo.latitude),
double.tryParse(widget.storeInfo.longitude),
Position bmfCoordinate = Position(
latitude: double.tryParse(widget.storeInfo.latitude),
longitude: double.tryParse(widget.storeInfo.longitude),
);
distance = await AppUtils.calculateDistance(bmfCoordinate, myLatLng);
distance = "${Geolocator.distanceBetween(
bmfCoordinate.latitude,
bmfCoordinate.longitude,
myLatLng.latitude,
myLatLng.longitude,
)}";
setState(() {});
}

11
lib/store/shopping/shopping_cart/shopping_cart_page.dart

@ -112,13 +112,14 @@ class _ShoppingCartPage extends State<ShoppingCartPage>
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) {
setState(() {
queryShopCar();
});
queryShopCar();
refreshController.refreshCompleted();
} else {
queryShopCar();
refreshController.refreshFailed();
}
refreshController.refreshFailed();
}
final SwiperController controller = SwiperController();

1
lib/store/shopping/shopping_home/classify_list.dart

@ -1,6 +1,5 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart';
import 'package:huixiang/retrofit/data/shopping_home_config.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/font_weight.dart';

1
lib/store/shopping/shopping_home/search_page.dart

@ -1,6 +1,5 @@
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
import 'package:huixiang/retrofit/data/base_data.dart';

15
lib/store/store_order.dart

@ -912,8 +912,21 @@ class _StoreOrderPage extends State<StoreOrderPage>
if (shopCartKey != null) {
shopCartKey.currentState.setState(() {});
}
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;
}

4
lib/store/store_view/shop_car.dart

@ -80,7 +80,9 @@ class _ShopCar extends State<ShopCar> {
),
InkWell(
onTap: () {
widget.shopingCar.shoppingCartSkuItemList.clear();
if (widget.shopingCar.shoppingCartSkuItemList != null) {
widget.shopingCar.shoppingCartSkuItemList.clear();
}
state(() {});
widget.clearShopCar();
},

77
lib/store/store_view/store_info.dart

@ -1,10 +1,14 @@
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/generated/l10n.dart';
import 'package:huixiang/retrofit/data/store_info.dart';
import 'package:huixiang/utils/flutter_utils.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:huixiang/utils/location.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:huixiang/view_widget/round_button.dart';
import 'package:url_launcher/url_launcher.dart';
@ -168,15 +172,7 @@ class _StoreInfoView extends State<StoreInfoView> {
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
},
);
showMapSelect();
},
child:Container(
color: Colors.transparent,
@ -193,15 +189,7 @@ class _StoreInfoView extends State<StoreInfoView> {
behavior: HitTestBehavior.opaque,
onTap: () {
if(widget.storeInfo.longitude != null && widget.storeInfo.latitude != null){
Navigator.of(context).pushNamed(
'/router/location_map',
arguments: {
"lat": widget.storeInfo.latitude,
"lng": widget.storeInfo.longitude,
"storeInfo":widget.storeInfo,
"distance":widget.distance
},
);
showMapSelect();
}else{
return;
}
@ -307,4 +295,57 @@ class _StoreInfoView extends State<StoreInfoView> {
))
.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,
);
}
});
});
}
}

2412
lib/union/location_map_page.dart

File diff suppressed because it is too large Load Diff

7
lib/union/union_list.dart

@ -1,10 +1,11 @@
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_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/retrofit/data/latlng.dart';
import 'package:huixiang/retrofit/data/store.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/view_widget/custom_image.dart';
@ -23,7 +24,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;
@ -39,7 +40,7 @@ class UnionList extends StatefulWidget {
class _UnionList extends State<UnionList> with AutomaticKeepAliveClientMixin {
ApiService apiService;
List<Store> storeList;
BMFCoordinate latLng;
Position latLng;
final RefreshController _refreshController = RefreshController();
int networkStatus = 0;

62
lib/union/union_page.dart

@ -4,11 +4,12 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.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/retrofit/data/address.dart';
import 'package:huixiang/retrofit/data/ip_data.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/union/union_list.dart';
@ -19,7 +20,6 @@ import 'package:permission_handler/permission_handler.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:flutter/rendering.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 '../view_widget/location_tips.dart';
@ -44,7 +44,7 @@ class UnionPageState extends State<UnionPage>
final TextEditingController editingController = TextEditingController();
bool isKeyBoardShow = false;
TabController tabController;
BMFCoordinate latLng;
Position latLng;
String areaName;
List<GlobalKey> _allKey = [];
bool _isShowLocalTips = false;
@ -58,9 +58,9 @@ class UnionPageState extends State<UnionPage>
void dispose() {
super.dispose();
WidgetsBinding.instance.removeObserver(this);
if (Location.getInstance() != null &&
Location.getInstance().aMapFlutterLocation != null)
Location.getInstance().aMapFlutterLocation.stopLocation();
// if (LocationInstance.getInstance() != null &&
// LocationInstance.getInstance().location != null)
// LocationInstance.getInstance().location.stopLocation();
}
@override
@ -117,30 +117,27 @@ class UnionPageState extends State<UnionPage>
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.getInstance().stopLocation();
});
powerFlag = await Location.getInstance().startLocation(context,
(BaiduLocation result) async {
powerFlag = await LocationInstance.getInstance().startLocation(context,
(Position result) async {
if (result != null &&
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.getInstance().stopLocation();
latLng = Position(
latitude: result.latitude,
longitude: result.longitude,
);
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();
}
@ -159,7 +156,7 @@ class UnionPageState extends State<UnionPage>
}
}
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}");
@ -175,14 +172,18 @@ class UnionPageState extends State<UnionPage>
tempLatLng.containsKey("province") &&
tempLatLng.containsKey("city") &&
tempLatLng.containsKey("district")) {
latLng = BMFCoordinate(double.tryParse(tempLatLng.getString("latitude")),
double.tryParse(tempLatLng.getString("longitude")));
latLng = Position(
latitude: double.tryParse(tempLatLng.getString("latitude")),
longitude: double.tryParse(tempLatLng.getString("longitude")),
);
}
}
queryIpInfo() async {
EasyLoading.show(
status: S.current.zhengzaijiazai, maskType: EasyLoadingMaskType.black);
status: S.current.zhengzaijiazai,
maskType: EasyLoadingMaskType.black,
);
try {
ApiService apiIpService = ApiService(Dio(), context: context, isIp: true);
IpData baseData = await apiIpService.getIpInfo().catchError((onError) {});
@ -197,8 +198,9 @@ class UnionPageState extends State<UnionPage>
loadFinish({bool showLoading = true}) {
if (showLoading)
EasyLoading.show(
status: S.current.zhengzaijiazai,
maskType: EasyLoadingMaskType.black);
status: S.current.zhengzaijiazai,
maskType: EasyLoadingMaskType.black,
);
_allKey = [GlobalKey(), GlobalKey(), GlobalKey(), GlobalKey()];
setState(() {});
}

239
lib/union/union_view/store_info.dart

@ -1,10 +1,14 @@
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/flutter_swiper.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/data/store_info.dart';
import 'package:huixiang/utils/flutter_utils.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/location.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:huixiang/view_widget/round_button.dart';
@ -108,10 +112,10 @@ class _StoreInfos extends State<StoreInfos> {
S.of(context).yingyeshijian(widget.storeInfo == null
? ""
: (widget.storeInfo.openStartTime == null &&
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(":"))}"),
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,
@ -144,12 +148,7 @@ class _StoreInfos extends State<StoreInfos> {
widget.storeInfo.longitude == null ||
widget.storeInfo.latitude == "" ||
widget.storeInfo.longitude == "") return;
Navigator.of(context)
.pushNamed('/router/location_map', arguments: {
"lat": widget.storeInfo.latitude,
"lng": widget.storeInfo.longitude,
"storeName": widget.storeInfo.storeName,
});
showMapSelect();
},
child: Image.asset(
"assets/image/icon_union_location.webp",
@ -177,175 +176,6 @@ class _StoreInfos extends State<StoreInfos> {
],
),
);
// return AspectRatio(
// aspectRatio: 1,
// child: Container(
// margin: EdgeInsets.fromLTRB(16, 20, 16, 8),
// padding: EdgeInsets.fromLTRB(10, 20, 10, 14),
// decoration: BoxDecoration(
// color: Colors.white,
// borderRadius: BorderRadius.circular(8),
// boxShadow: [
// BoxShadow(
// color: Colors.black.withAlpha(25),
// offset: Offset(0, 1),
// blurRadius: 12,
// spreadRadius: 0,
// ),
// ],
// ),
// child: Column(
// mainAxisAlignment: MainAxisAlignment.spaceAround,
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// AspectRatio(
// aspectRatio: 1.8,
// child: buildSwiper(),
// ),
// Expanded(
// child: Container(
// margin: EdgeInsets.only(
// left: 10.w,
// right: 10.w,
// top: 16.h,
// ),
// child: Column(
// mainAxisAlignment:
// MainAxisAlignment.spaceBetween,
// crossAxisAlignment:
// CrossAxisAlignment.start,
// children: [
// Row(
// children: [
// Expanded(
// child: Container(
// alignment:
// Alignment.centerLeft,
// child: Text(
// widget.storeInfo != null
// ? widget.storeInfo.storeName
// : "",
// overflow: TextOverflow.ellipsis,
// style: TextStyle(
// fontSize: 16.sp,
// color: Colors.black,
// fontWeight: MyFontWeight.medium,
// ),
// ),
// ),
// ),
// Text(
// S.of(context).ren(
// widget.storeInfo != null
// ? widget.storeInfo
// .perCapitaConsumption
// : "",
// ),
// overflow: TextOverflow.ellipsis,
// style: TextStyle(
// fontSize: 14.sp,
// fontWeight: MyFontWeight.regular,
// color: Color(0xFF353535),
// ),
// ),
// ],
// ),
// Text(
// widget.storeInfo != null
// ? widget.storeInfo.address
// : "",
// maxLines: 2,
// textAlign: TextAlign.justify,
// style: TextStyle(
// color: Color(0xFF353535),
// fontWeight: MyFontWeight.regular,
// fontSize: 12.sp,
// ),
// ),
// Row(
// children: itemServer(
// widget.storeInfo != null
// ? widget.storeInfo.businessService
// : "",
// ),
// ),
// Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// crossAxisAlignment: CrossAxisAlignment.end,
// children: [
// Expanded(
// child: Text(
// S.of(context).yingyeshijian(widget.storeInfo ==
// null
// ? ""
// : (widget.storeInfo.openStartTime ==
// null &&
// 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,
// fontSize: 12.sp,
// ),
// ),
// ),
// SizedBox(
// width: 16.w,
// ),
// InkWell(
// onTap: () {
// if (widget.storeInfo == null ||
// widget.storeInfo.latitude ==
// null ||
// widget.storeInfo.longitude ==
// null ||
// widget.storeInfo.latitude == "" ||
// widget.storeInfo.longitude == "")
// return;
// Navigator.of(context).pushNamed(
// '/router/location_map',
// arguments: {
// "lat": widget.storeInfo.latitude,
// "lng":
// widget.storeInfo.longitude,
// "storeName":
// widget.storeInfo.storeName,
// });
// },
// child: Image.asset(
// "assets/image/icon_union_location.webp",
// width: 24.w,
// height: 24.h,
// ),
// ),
// SizedBox(
// width: 16.w,
// ),
// InkWell(
// onTap: () {
// showCallMobile();
// },
// child: Image.asset(
// "assets/image/icon_union_call.webp",
// width: 24,
// height: 24,
// ),
// ),
// ],
// ),
// ],
// ),
// ),
// flex: 1,
// ),
// ],
// ),
// ),
// );
}
Widget buildSwiper() {
@ -444,4 +274,55 @@ class _StoreInfos extends State<StoreInfos> {
throw 'Could not launch $url';
}
}
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,
);
}
});
});
}
}

17
lib/utils/flutter_utils.dart

@ -3,20 +3,10 @@ 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<String> calculateDistance(
BMFCoordinate bmfCoordinate, BMFCoordinate myLatLng, {bool isMi = false}) async {
double mi =
await BMFCalculateUtils.getLocationDistance(bmfCoordinate, myLatLng);
NumberFormat numberFormat = NumberFormat("#.#");
return "${numberFormat.format(mi / (isMi ? 1 :1000))}";
}
///
@ -78,13 +68,6 @@ class AppUtils {
return resString;
}
///()
static Future<BMFCoordinate> 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(

141
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<num> 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<num> 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<num> gcj02_To_Gps84(num lat, num lon) {
List<num> 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<num> 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<num> gps = [tempLat, tempLon];
return gps;
}
/// * (GCJ-02) (BD-09) * * BD-09 GCJ-02
/// @param lat
/// @param lon
/// @return
static List<num> 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<num> gps = [tempLat, tempLon];
return gps;
}
/// gps84转为bd09
///
/// @param lat
/// @param lon
/// @return
static List<num> gps84_To_bd09(num lat, num lon) {
List<num> gcj02 = gps84_To_Gcj02(lat, lon);
List<num> bd09 = gcj02_To_Bd09(gcj02[0], gcj02[1]);
return bd09;
}
static List<num> bd09_To_gps84(num lat, num lon) {
List<num> gcj02 = bd09_To_Gcj02(lat, lon);
List<num> 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));
}
}

193
lib/utils/location.dart

@ -1,112 +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/data/address.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 '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
// 00
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;
class LocationInstance {
static LocationInstance _instance;
Location._internal() {
aMapFlutterLocation = LocationFlutterPlugin();
}
LocationInstance._internal() {}
static Location getInstance() {
static LocationInstance getInstance() {
if (_instance == null) {
_instance = Location._internal();
_instance = LocationInstance._internal();
}
return _instance;
}
LocationFlutterPlugin aMapFlutterLocation;
Future<bool> startLocation(
context, Function(BaiduLocation result) locationCallback) async {
aMapFlutterLocation.prepareLoc(
initAndroidOptions().getMap(), initIOSOptions().getMap());
var permissionStatus = await Permission.location.status;
if (!permissionStatus.isGranted) {
if (permissionStatus.isUndetermined)
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() {
if (aMapFlutterLocation != null) aMapFlutterLocation.stopLocation();
}
void stopLocation() {}
enableLocation(context) {
showCupertinoDialog(
@ -119,10 +67,12 @@ class Location {
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();
Geolocator.openLocationSettings();
// startLocation();
}
},
@ -132,7 +82,7 @@ class Location {
);
}
requestDialog(context, Function(BaiduLocation result) locationCallback) {
requestDialog(context, Function(Position result) locationCallback) {
showCupertinoDialog(
context: context,
builder: (context) {
@ -143,8 +93,11 @@ class Location {
S.of(context).kaiqiquanxian,
(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);
}
}
@ -218,7 +171,7 @@ class Location {
);
},
);
await Permission.location.request();
Geolocator.requestPermission();
Navigator.of(context).pop();
}
@ -292,8 +245,11 @@ class Location {
),
),
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,
@ -325,4 +281,45 @@ class Location {
},
);
}
///线
static Future<String> 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<Latlng> coordConvert(Latlng latLng) async {
// return BMFCalculateUtils.coordConvert(
// coordinate: latLng,
// fromType: BMF_COORD_TYPE.COMMON,
// toType: BMF_COORD_TYPE.BD09LL);
// }
Future<Address> 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;
}
}

256
pubspec.lock

File diff suppressed because it is too large Load Diff

9
pubspec.yaml

@ -41,18 +41,15 @@ dependencies:
permission_handler: ^5.0.1+1
flutter_bmflocation: 3.2.1
flutter_baidu_mapapi_base: 3.2.0
flutter_baidu_mapapi_map: 3.2.1
flutter_baidu_mapapi_search: 3.2.0
flutter_baidu_mapapi_utils: 3.2.0
geolocator: ^6.2.1
# location: ^3.2.4
dio: ^3.0.10
rxdart: ^0.26.0
retrofit: ^1.3.4+1
json_annotation: ^3.1.1
logger: ^2.0.2+1
dio_log: ^1.3.5
# dio_log: ^1.3.5
pin_input_text_field: ^4.1.2
android_intent_plus: ^1.0.2

Loading…
Cancel
Save