Browse Source

全局定位更改,百度改用高德地图;

门店列表ui调整;
福利中心页面接口数据请求异常处理;
邀请好友页面接口数据请求异常处理;
充值页面接口数据请求异常处理;
首页刷新状态异常处理;
助农页面ui异常处理;
兑换列表ui异常处理;
tabui异常部分更改;
dart3
wurong 6 months ago
parent
commit
02126387f4
  1. BIN
      assets/image/2x/disenable_seletor.png
  2. BIN
      assets/image/3x/disenable_seletor.png
  3. BIN
      assets/image/disenable_seletor.png
  4. 470
      lib/address/address_map_page.dart
  5. 2
      lib/community/community_list.dart
  6. 3
      lib/community/community_page.dart
  7. 4
      lib/community/community_view/home_class.dart
  8. 6
      lib/community/headlines/activity_top_list.dart
  9. 4
      lib/community/headlines/headlines_collection.dart
  10. 4
      lib/home/help_farmers/help_farmers_page.dart
  11. 13
      lib/home/home_page.dart
  12. 8
      lib/home/home_view/discount_zone.dart
  13. 109
      lib/home/home_view/quick_order.dart
  14. 3
      lib/home/points_mall_view/points_goods_title.dart
  15. 4
      lib/home/welfare_exchange.dart
  16. 131
      lib/home/welfare_page.dart
  17. 4
      lib/main.dart
  18. 28
      lib/main_page.dart
  19. 12
      lib/mine/mine_shop_details.dart
  20. 11
      lib/mine/recharge_page.dart
  21. 13
      lib/mine/vip_detail_page.dart
  22. 2
      lib/order/exchange_history_page.dart
  23. 2
      lib/order/exchange_order_page.dart
  24. 447
      lib/qr/invite_friends.dart
  25. 4
      lib/retrofit/min_api.g.dart
  26. 10
      lib/retrofit/retrofit_api.dart
  27. 31
      lib/retrofit/retrofit_api.g.dart
  28. 595
      lib/settlement/settlement.dart
  29. 85
      lib/settlement/settlement_view/distribution.dart
  30. 13
      lib/store/shopping/shopping_cart/shopping_cart_page.dart
  31. 19
      lib/store/store_order.dart
  32. 7
      lib/store/store_view/shop_car.dart
  33. 97
      lib/store/store_view/store_info.dart
  34. 2336
      lib/union/location_map_page.dart
  35. 6
      lib/union/union_list.dart
  36. 345
      lib/union/union_page.dart
  37. 178
      lib/union/union_view/store_info.dart
  38. 37
      lib/utils/flutter_utils.dart
  39. 141
      lib/utils/gps_utils.dart
  40. 206
      lib/utils/location.dart
  41. 13
      lib/utils/upload_async.dart
  42. 1
      lib/vip/vip_page.dart
  43. 17
      lib/web/web_page.dart
  44. 16
      lib/web/web_view/comment_list.dart
  45. 4
      lib/web/web_view/web_header.dart
  46. 96
      pubspec.lock
  47. 7
      pubspec.yaml

BIN
assets/image/2x/disenable_seletor.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

BIN
assets/image/3x/disenable_seletor.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

BIN
assets/image/disenable_seletor.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

470
lib/address/address_map_page.dart

@ -1,23 +1,23 @@
import 'dart:io';
import 'dart:ui';
import 'package:android_intent_plus/android_intent.dart';
import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart';
import 'package:flutter_baidu_mapapi_map/flutter_baidu_mapapi_map.dart';
import 'package:flutter_baidu_mapapi_utils/flutter_baidu_mapapi_utils.dart';
import 'package:flutter_bmflocation/flutter_bmflocation.dart';
import 'package:flutter/services.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:geolocator/geolocator.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/data/address.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/location.dart';
import 'package:huixiang/view_widget/request_permission.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:permission_handler/permission_handler.dart' as PH;
import 'package:shared_preferences/shared_preferences.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../data/address.dart';
class AddressMapPage extends StatefulWidget {
@override
State<StatefulWidget> createState() {
@ -26,22 +26,22 @@ class AddressMapPage extends StatefulWidget {
}
class _AddressMapPage extends State<AddressMapPage> {
//
void _loadCustomData() async {
setState(() {
_mapController?.setCustomMapStyle('assets/map_style/chatian.sty', 0);
});
}
LocationFlutterPlugin? aMapFlutterLocation;
// //
// void _loadCustomData() async {
// setState(() {
// _mapController?.setCustomMapStyle('assets/map_style/chatian.sty', 0);
// });
// }
// LocationFlutterPlugin? aMapFlutterLocation;
String city = "武汉市";
String keyWord = "";
@override
void dispose() {
super.dispose();
aMapFlutterLocation?.stopLocation();
}
// @override
// void dispose() {
// super.dispose();
// aMapFlutterLocation?.stopLocation();
// }
ApiService? apiService;
@ -53,84 +53,83 @@ class _AddressMapPage extends State<AddressMapPage> {
apiService = ApiService(Dio(),
context: context, token: value.getString('token')),
});
aMapFlutterLocation?.singleLocationCallback(callback: (BaiduLocation result){
LocationInstance.getInstance().startLocation(context, (Position? result) {
print("event: $result");
if (result.latitude != null &&
result.longitude != null) {
city = "${result.city}";
BMFCoordinate latLng = BMFCoordinate(result.latitude!, result.longitude!);
BMFCalculateUtils.coordConvert(
coordinate: latLng,
fromType: BMF_COORD_TYPE.COMMON,
toType: BMF_COORD_TYPE.BD09LL)
.then((value) {
saveLatLng(value);
this.latLng = Platform.isIOS ? value : latLng;
addMarker();
_mapController?.updateMapOptions(
BMFMapOptions(
center: latLng,
zoomLevel: 15,
showZoomControl: false,
showMapScaleBar: false,
rotateEnabled: false,
),
);
searchPoi(latLng);
if (result?.latitude != null && result?.longitude != null) {
latLng = Position(
latitude: result!.latitude,
longitude: result.longitude,
timestamp: DateTime.now(),
accuracy: 0,
altitude: 0,
heading: 0,
speed: 0,
speedAccuracy: 0);
LocationInstance.getInstance()
.getAddress(result.latitude, result.longitude)
?.then((value) {
if (value != null) {
city = value.city ?? "";
}
});
saveLatLng(result);
searchPoi(latLng);
}
});
_setLocOption();
getLatLng();
// _setLocOption();
//
// getLatLng();
startLocation();
}
/// android端和ios端定位参数
void _setLocOption() {
/// android
BaiduLocationAndroidOption androidOption = BaiduLocationAndroidOption(coordType: BMFLocationCoordType.gcj02);
androidOption.setCoorType("GCJ02"); //
androidOption.setIsNeedAltitude(true); //
androidOption.setIsNeedAddress(true); //
androidOption.setIsNeedLocationPoiList(true); // poi信息
androidOption.setIsNeedNewVersionRgc(true); // rgc信息
androidOption.setIsNeedLocationDescribe(true); //
androidOption.setOpenGps(true); // 使gps
androidOption.setLocationMode(BMFLocationMode.hightAccuracy); //
androidOption.setScanspan(0); //
androidOption.setCoordType(BMFLocationCoordType.gcj02);
Map androidMap = androidOption.getMap();
/// ios
BaiduLocationIOSOption iosOption = BaiduLocationIOSOption(coordType: BMFLocationCoordType.gcj02);
iosOption.setIsNeedNewVersionRgc(true); // rgc信息
iosOption.setBMKLocationCoordinateType(
"BMKLocationCoordinateTypeGCJ02"); //
iosOption.setActivityType(BMFActivityType.automotiveNavigation); //
iosOption.setLocationTimeout(10); //
iosOption.setDesiredAccuracy(BMFDesiredAccuracy.best); //
iosOption.setReGeocodeTimeout(10); //
iosOption.setDistanceFilter(1000); //
iosOption.setAllowsBackgroundLocationUpdates(true); //
iosOption.setPauseLocUpdateAutomatically(true); //
iosOption.coordType = BMFLocationCoordType.gcj02;
Map iosMap = iosOption.getMap();
aMapFlutterLocation?.prepareLoc(androidMap, iosMap);
}
// /// android端和ios端定位参数
// void _setLocOption() {
// /// android
// BaiduLocationAndroidOption androidOption =
// BaiduLocationAndroidOption(coordType: BMFLocationCoordType.gcj02);
// androidOption.setCoorType("GCJ02"); //
// androidOption.setIsNeedAltitude(true); //
// androidOption.setIsNeedAddress(true); //
// androidOption.setIsNeedLocationPoiList(true); // poi信息
// androidOption.setIsNeedNewVersionRgc(true); // rgc信息
// androidOption.setIsNeedLocationDescribe(true); //
// androidOption.setOpenGps(true); // 使gps
// androidOption.setLocationMode(BMFLocationMode.hightAccuracy); //
// androidOption.setScanspan(0); //
// androidOption.setCoordType(BMFLocationCoordType.gcj02);
//
// Map androidMap = androidOption.getMap();
//
// /// ios
// BaiduLocationIOSOption iosOption =
// BaiduLocationIOSOption(coordType: BMFLocationCoordType.gcj02);
// iosOption.setIsNeedNewVersionRgc(true); // rgc信息
// iosOption.setBMKLocationCoordinateType(
// "BMKLocationCoordinateTypeGCJ02"); //
// iosOption.setActivityType(BMFActivityType.automotiveNavigation); //
// iosOption.setLocationTimeout(10); //
// iosOption.setDesiredAccuracy(BMFDesiredAccuracy.best); //
// iosOption.setReGeocodeTimeout(10); //
// iosOption.setDistanceFilter(1000); //
// iosOption.setAllowsBackgroundLocationUpdates(true); //
// iosOption.setPauseLocUpdateAutomatically(true); //
// iosOption.coordType = BMFLocationCoordType.gcj02;
//
// Map iosMap = iosOption.getMap();
//
// aMapFlutterLocation?.prepareLoc(androidMap, iosMap);
// }
Position? center;
List<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);
//,;:['pois'],['entrances']
List<dynamic> poi = addressPoi['pois']??addressPoi['entrances'];
List<dynamic> poi = addressPoi['pois'] ?? addressPoi['entrances'];
poiList = poi
.map((e) => Address.fromJson({
"address": e["address"] is List ? "" : e["address"],
@ -176,25 +175,28 @@ class _AddressMapPage extends State<AddressMapPage> {
int time = 0;
startLocation() async {
if (!(await Permission.locationWhenInUse.serviceStatus.isEnabled)) {
if (!(await PH.Permission.locationWhenInUse.serviceStatus.isEnabled)) {
enableLocation();
return;
}
if (await Permission.location.isPermanentlyDenied) {
if (await PH.Permission.location.isPermanentlyDenied) {
requestDialog();
} else if (await Permission.location.isGranted) {
} else if (await PH.Permission.location.isGranted) {
// EasyLoading.show(status: S.of(context).zhengzaijiazai);
aMapFlutterLocation?.startLocation();
center = await Geolocator.getCurrentPosition();
Future.delayed(Duration(seconds: 6), () {
EasyLoading.dismiss();
});
} else {
}
// else if (await PH.Permission.location.) {
// await PH.Permission.location.request();
// }
else {
if (Platform.isIOS) {
//
requestDialog();
} else {
await Permission.location.request();
await PH.Permission.location.request();
}
}
}
@ -210,11 +212,12 @@ class _AddressMapPage extends State<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,
@ -234,8 +237,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();
}
}
@ -245,77 +248,78 @@ 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?.longitude == status.targetGeoPt?.longitude &&
bmfCoordinate?.latitude == status.targetGeoPt?.latitude) {
if ((DateTime.now().millisecondsSinceEpoch - time) > 1000) {
center = status.targetGeoPt;
searchPoi(center);
time = DateTime.now().millisecondsSinceEpoch;
}
} else {
bmfCoordinate = status.targetGeoPt;
}
});
setState(() {
_mapController = controller;
_mapController?.showUserLocation(true);
_loadCustomData();
addMarker();
});
}
BMFCoordinate? latLng;
BMFMarker? bmfMarker;
addMarker() {
bmfMarker?.updateIsLockedToScreen(
true,
BMFPoint(
(Platform.isIOS
? MediaQuery.of(context).size.width
: window.physicalSize.width) /
2,
(Platform.isIOS
? MediaQuery.of(context).size.height
: window.physicalSize.height) /
4));
}
saveLatLng(BMFCoordinate? latLng) async {
// BMFMapController? _mapController;
// BMFCoordinate? bmfCoordinate;
// void onMapCreated(BMFMapController controller) {
// controller.setMapRegionDidChangeCallback(callback: (status) {
// BMFMapStatus bmfMapStatus = status;
// print("status: ${bmfMapStatus.toMap()}");
// if (bmfCoordinate?.longitude == status.targetGeoPt?.longitude &&
// bmfCoordinate?.latitude == status.targetGeoPt?.latitude) {
// if ((DateTime.now().millisecondsSinceEpoch - time) > 1000) {
// center = status.targetGeoPt;
// searchPoi(center);
// time = DateTime.now().millisecondsSinceEpoch;
// }
// } else {
// bmfCoordinate = status.targetGeoPt;
// }
// });
//
// setState(() {
// _mapController = controller;
// _mapController?.showUserLocation(true);
// _loadCustomData();
// addMarker();
// });
// }
Position? latLng;
// BMFMarker? bmfMarker;
// addMarker() {
// bmfMarker?.updateIsLockedToScreen(
// true,
// BMFPoint(
// (Platform.isIOS
// ? MediaQuery.of(context).size.width
// : window.physicalSize.width) /
// 2,
// (Platform.isIOS
// ? MediaQuery.of(context).size.height
// : window.physicalSize.height) /
// 4));
// }
saveLatLng(Position? latLng) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
await prefs.setString("latitude", "${latLng?.latitude}");
await prefs.setString("longitude", "${latLng?.longitude}");
}
getLatLng() async {
SharedPreferences.getInstance().then((value) => {
setState(() {
_mapController?.updateMapOptions(
BMFMapOptions(
center: BMFCoordinate(
double.tryParse("${value.getString("latitude")}") ?? 0,
double.tryParse("${value.getString("longitude")}") ?? 0,
),
zoomLevel: 15,
showZoomControl: false,
showMapScaleBar: false,
rotateEnabled: false,
),
);
})
});
}
BMFMapWidget? map;
BMFCoordinate? center = BMFCoordinate(30.553111, 114.342366);
// getLatLng() async {
// SharedPreferences.getInstance().then((value) => {
// setState(() {
// _mapController?.updateMapOptions(
// BMFMapOptions(
// center: BMFCoordinate(
// double.tryParse("${value.getString("latitude")}") ?? 0,
// double.tryParse("${value.getString("longitude")}") ?? 0,
// ),
// zoomLevel: 15,
// showZoomControl: false,
// showMapScaleBar: false,
// rotateEnabled: false,
// ),
// );
// })
// });
// }
//
// BMFMapWidget? map;
// BMFCoordinate? center = BMFCoordinate(30.553111, 114.342366);
@override
Widget build(BuildContext context) {
@ -323,76 +327,76 @@ class _AddressMapPage extends State<AddressMapPage> {
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: 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: Container(
child: ListView.separated(

2
lib/community/community_list.dart

@ -38,8 +38,8 @@ class _CommunityList extends State<CommunityList> {
@override
void initState() {
super.initState();
SharedPreferences.getInstance().then((value) => {
if(apiService != null)
apiService = ApiService(Dio(),
context: context, token: value.getString("token")),
});

3
lib/community/community_page.dart

@ -1,10 +1,7 @@
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:get/get.dart';
import 'package:huixiang/community/community_child_page.dart';
import 'package:huixiang/view_widget/my_appbar.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:huixiang/view_widget/my_tab.dart';

4
lib/community/community_view/home_class.dart

@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart';
import 'package:geolocator/geolocator.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/data/collect_class.dart';
import 'package:huixiang/data/course.dart';
@ -22,7 +22,7 @@ class HomeClass extends StatefulWidget {
class _HomeClass extends State<HomeClass> {
ApiService? apiService;
BMFCoordinate? latLng;
Position? latLng;
final TextEditingController editingController = TextEditingController();

6
lib/community/headlines/activity_top_list.dart

@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart';
import 'package:geolocator/geolocator.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/data/article.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
@ -20,7 +20,7 @@ class ActivityTopList extends StatefulWidget {
class _ActivityTopList extends State<ActivityTopList> {
ApiService? apiService;
BMFCoordinate? latLng;
Position? latLng;
final TextEditingController editingController = TextEditingController();
@ -38,7 +38,7 @@ class _ActivityTopList extends State<ActivityTopList> {
scrollDirection: Axis.horizontal,
physics: BouncingScrollPhysics(),
padding: EdgeInsets.symmetric(horizontal: 10),
itemCount: widget.articleTop?.length ?? 0,
itemCount: widget.articleTop.length ?? 0,
itemBuilder: (context, position) {
return GestureDetector(
onTap: () {

4
lib/community/headlines/headlines_collection.dart

@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart';
import 'package:geolocator/geolocator.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/data/article.dart';
import 'package:huixiang/data/headlines.dart';
@ -22,7 +22,7 @@ class HeadlinesCollection extends StatefulWidget {
class _HeadlinesCollection extends State<HeadlinesCollection> {
ApiService? apiService;
BMFCoordinate? latLng;
Position? latLng;
final TextEditingController editingController = TextEditingController();

4
lib/home/help_farmers/help_farmers_page.dart

@ -126,6 +126,10 @@ class _HelpFarmersPage extends State<HelpFarmersPage> {
isScrollable: true,
//
indicatorColor: Colors.white,
//tab排放方向
tabAlignment:TabAlignment.start,
//线
dividerHeight: 0,
labelColor: Colors.white,
labelStyle: TextStyle(
fontSize: 16.sp,

13
lib/home/home_page.dart

@ -175,6 +175,8 @@ class HomePageState extends State<HomePage> with AutomaticKeepAliveClientMixin {
"model": {"type": "HOME_PAGE"},
}).catchError((onError) {
dioErrorType = onError.type;
refreshController.loadFailed();
refreshController.refreshFailed();
});
if (baseData?.isSuccess ?? false) {
bannerData = baseData?.data?.records ?? [];
@ -209,7 +211,7 @@ class HomePageState extends State<HomePage> with AutomaticKeepAliveClientMixin {
SmartDialog.showToast(toastText,
alignment: Alignment.center);
}
refreshController.refreshFailed();
if (refreshController.isRefresh) refreshController.refreshCompleted();
if (mounted) setState(() {});
}
}
@ -322,6 +324,15 @@ class HomePageState extends State<HomePage> with AutomaticKeepAliveClientMixin {
///
queryWiped(memberCouponId) async {
if (apiService == null) {
SharedPreferences.getInstance().then((value) {
apiService = ApiService(
Dio(),
context: context,
token: value.getString("token"),
);
});
}
BaseData? baseData = await apiService?.wiped(memberCouponId).catchError((onError) {});
if (baseData?.isSuccess ?? false) {
SmartDialog.showToast("核销成功", alignment: Alignment.center);

8
lib/home/home_view/discount_zone.dart

@ -62,7 +62,7 @@ class _DiscountZone extends State<DiscountZone> {
),),
if(widget.coupon.length != 0)
Container(
height: 108.h,
height: 109.h,
margin: EdgeInsets.only(top: 16.h),
child: ListView.builder(
scrollDirection: Axis.horizontal,
@ -178,17 +178,17 @@ class _DiscountZone extends State<DiscountZone> {
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
Expanded(child: Container(
padding: EdgeInsets.only(bottom:10.h,top: 7.h,left: 12.w),
child: Text(
S.of(context).duihuanquan,
style: TextStyle(
fontSize: 26.sp,
fontSize: 24.sp,
fontWeight: MyFontWeight.semi_bold,
color: coupon.status == 3 ? Color(0xFFB3B3B3):Color(0xFF32A060),
),
),
),
)),
Text(
S.of(context).xianshangshiyong,
style: TextStyle(

109
lib/home/home_view/quick_order.dart

@ -1,11 +1,8 @@
import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart';
import 'package:flutter_baidu_mapapi_map/flutter_baidu_mapapi_map.dart';
import 'package:flutter_baidu_mapapi_utils/flutter_baidu_mapapi_utils.dart';
import 'package:flutter_bmflocation/flutter_bmflocation.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:geolocator/geolocator.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/utils/location.dart';
import 'package:huixiang/data/base_data.dart';
@ -18,7 +15,7 @@ import 'package:huixiang/view_widget/item_title.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:huixiang/view_widget/request_permission.dart';
import 'package:huixiang/view_widget/round_button.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:permission_handler/permission_handler.dart' as PH;
import 'package:shared_preferences/shared_preferences.dart';
class QuickOrder extends StatefulWidget {
@ -31,9 +28,9 @@ class QuickOrder extends StatefulWidget {
class _QuickOrder extends State<QuickOrder> {
ApiService? apiService;
List<Store>? storeList;
BMFCoordinate? latLng;
Position? latLng;
BMFMapController? _mapController;
// BMFMapController? _mapController;
final TextEditingController editingController = TextEditingController();
@override
@ -44,7 +41,7 @@ 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,
@ -52,7 +49,9 @@ class _QuickOrder extends State<QuickOrder> {
"latitude": latitude,
"longitude": longitude,
"searchKey": searchKey
}).catchError((error) {});
}).catchError((error) {
});
if (baseData?.isSuccess ?? false) {
storeList = baseData!.data;
}
@ -67,70 +66,76 @@ class _QuickOrder extends State<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")}") ?? 0,
double.tryParse("${value.getString("longitude")}") ?? 0),
latLng = Position(
latitude: double.tryParse(value.getString("latitude") ??"")!,
longitude: double.tryParse(value.getString("longitude") ?? "")!,
timestamp: DateTime.now(),
accuracy: 0,
altitude: 0,
heading: 0,
speed: 0,
speedAccuracy: 0
),
queryStore(
value.getString("latitude"),
value.getString("longitude"),
value.getString("province"),
value.getString("city"),
value.getString("district"),
editingController.text,
),
setState(() {
_mapController?.updateMapOptions(
BMFMapOptions(
center: latLng,
zoomLevel: 15,
));
// _mapController?.updateMapOptions(
// BMFMapOptions(
// center: latLng,
// zoomLevel: 15,
// ));
})
}
else
{
queryStore("", "", "", "", "", editingController.text),
queryStore("", "", editingController.text),
}
},
);
}
startLocation() async {
Location.instance.startLocation(context, (BaiduLocation result){
if (result.latitude != null &&
result.longitude != null) {
LocationInstance.getInstance().startLocation(context, (Position? result){
if (result?.latitude != null &&
result?.longitude != null) {
print("location: $result");
latLng = BMFCoordinate(result.latitude!, result.longitude!);
BMFCalculateUtils.coordConvert(
coordinate: latLng!,
fromType: BMF_COORD_TYPE.BD09LL,
toType: BMF_COORD_TYPE.COMMON)
.then((value) {
this.latLng = value!;
saveLatLng(value!, result.province, result.city, result.district);
print("union: Location result ${value.latitude} "
"${value.longitude}");
Location.instance.stopLocation();
latLng = Position(
latitude: result?.latitude??0,
longitude: result?.longitude ?? 0,
timestamp: DateTime.now(),
accuracy: 0,
altitude: 0,
heading: 0,
speed: 0,
speedAccuracy: 0
);
LocationInstance.getInstance().getAddress(latLng!.latitude, latLng!.longitude)?.then((r) {
if (r != null) {
saveLatLng(latLng!, r.province, r.city, r.area);
}
LocationInstance.getInstance().stopLocation();
queryStore(
"${value.latitude}",
"${value.longitude}",
result.province,
result.city,
result.district,
"${latLng?.latitude}",
"${latLng?.longitude}",
editingController.text);
_mapController?.updateMapOptions(BMFMapOptions(
center: value,
zoomLevel: 15,
));
// _mapController?.updateMapOptions(BMFMapOptions(
// center: value,
// zoomLevel: 15,
// )
// );
return r;
});
}
}).then((value) {});
}
saveLatLng(BMFCoordinate latLng, province, city, district) async {
saveLatLng(Position latLng, province, city, district) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
await prefs.setString("latitude", "${latLng.latitude}");
await prefs.setString("longitude", "${latLng.longitude}");
@ -358,7 +363,7 @@ class _QuickOrder extends State<QuickOrder> {
///
toScan() async {
if (await Permission.camera.isPermanentlyDenied) {
if (await PH.Permission.camera.isPermanentlyDenied) {
showCupertinoDialog(
context: context,
builder: (context) {
@ -369,13 +374,13 @@ class _QuickOrder extends State<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
@ -402,7 +407,7 @@ class _QuickOrder extends State<QuickOrder> {
);
}
} else {
await Permission.camera.request();
await PH.Permission.camera.request();
}
}
}

3
lib/home/points_mall_view/points_goods_title.dart

@ -86,6 +86,9 @@ class _PointsGoodsTitle extends State<PointsGoodsTitle>
isScrollable: true,
//
indicatorColor: Color(0xff39B54A),
tabAlignment:TabAlignment.start,
dividerHeight: 0,
dividerColor: Colors.transparent,
labelColor: Color(0xff32A060),
labelStyle: TextStyle(
fontSize: 14.sp,

4
lib/home/welfare_exchange.dart

@ -230,6 +230,8 @@ class _WelfareExchange extends State<WelfareExchange>
//
indicatorColor: Color(0xff39B54A),
labelColor: Color(0xff32A060),
dividerHeight: 0,
tabAlignment:TabAlignment.start,
labelStyle: TextStyle(
fontSize: 14.sp,
fontWeight: FontWeight.bold,
@ -366,7 +368,7 @@ class _WelfareExchange extends State<WelfareExchange>
)
: Container(
margin: EdgeInsets.only(left: 15.w),
height: 50.h,
height: 62.h,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,

131
lib/home/welfare_page.dart

@ -1,4 +1,4 @@
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
@ -21,6 +21,7 @@ import 'package:huixiang/view_widget/no_data_view.dart';
import 'package:huixiang/view_widget/receive_success.dart';
import 'package:huixiang/view_widget/selector_store_dialog.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../view_widget/settlement_tips_dialog.dart';
@ -49,7 +50,16 @@ class _WelfarePage extends State<WelfarePage> {
@override
void initState() {
super.initState();
_onRefresh();
if (apiService == null) {
SharedPreferences.getInstance().then((value) {
apiService = ApiService(
Dio(),
context: context,
token: value.getString("token"),
);
_onRefresh();
});
}
}
queryGoods() async {
@ -336,7 +346,7 @@ class _WelfarePage extends State<WelfarePage> {
///
Widget weekCoupon(Coupon cop) {
return Container(
height: 95.h,
height: 101.h,
width: double.infinity,
margin: EdgeInsets.only(bottom: 10),
padding: EdgeInsets.symmetric(horizontal: 12),
@ -351,54 +361,54 @@ class _WelfarePage extends State<WelfarePage> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Container(
margin: EdgeInsets.only(top: 12, bottom: 12),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
cop.couponName ?? "",
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 14.sp,
fontWeight: MyFontWeight.semi_bold,
color: Color(0xFF0D0D0D),
child: Container(
margin: EdgeInsets.only(top: 12, bottom: 12),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
cop.couponName ?? "",
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 14.sp,
fontWeight: MyFontWeight.semi_bold,
color: Color(0xFF0D0D0D),
),
),
),
SizedBox(
height: 12,
),
(cop.status == 0)
? Text(
"发放时间: ${cop.publishStartTime ?? ""}",
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
color: cop.status == 3
? Color(0xFFB3B3B3)
: Color(0xFF4D4D4D),
),
)
: Text(
"有效期至 ${cop.useEndTime ?? ""}",
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
color: cop.status == 3
? Color(0xFFB3B3B3)
: Color(0xFF4D4D4D),
),
)
],
SizedBox(
height: 12,
),
(cop.status == 0)
? Text(
"发放时间: ${cop.publishStartTime ?? ""}",
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
color: cop.status == 3
? Color(0xFFB3B3B3)
: Color(0xFF4D4D4D),
),
)
: Text(
"有效期至 ${cop.useEndTime ?? ""}",
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
color: cop.status == 3
? Color(0xFFB3B3B3)
: Color(0xFF4D4D4D),
),
)
],
),
),
),
),
Column(
// mainAxisAlignment: MainAxisAlignment.start,
// crossAxisAlignment: CrossAxisAlignment.end,
@ -475,7 +485,8 @@ class _WelfarePage extends State<WelfarePage> {
style: TextStyle(
fontSize: 22.sp,
fontWeight: MyFontWeight.semi_bold,
color: cop.status == 3 ? Color(0xFFB3B3B3) : Color(0xff32A060),
color:
cop.status == 3 ? Color(0xFFB3B3B3) : Color(0xff32A060),
),
),
],
@ -506,7 +517,8 @@ class _WelfarePage extends State<WelfarePage> {
style: TextStyle(
fontSize: 26.sp,
fontWeight: MyFontWeight.semi_bold,
color: cop.status == 3 ? Color(0xFFB3B3B3) : Color(0xff32A060),
color:
cop.status == 3 ? Color(0xFFB3B3B3) : Color(0xff32A060),
),
),
],
@ -537,7 +549,8 @@ class _WelfarePage extends State<WelfarePage> {
style: TextStyle(
fontSize: 16.sp,
fontWeight: MyFontWeight.medium,
color: cop.status == 3 ? Color(0xFFB3B3B3) : Color(0xff32A060),
color:
cop.status == 3 ? Color(0xFFB3B3B3) : Color(0xff32A060),
),
),
SizedBox(
@ -550,7 +563,8 @@ class _WelfarePage extends State<WelfarePage> {
style: TextStyle(
fontSize: 24.sp,
fontWeight: FontWeight.bold,
color: cop.status == 3 ? Color(0xFFB3B3B3) : Color(0xff32A060),
color:
cop.status == 3 ? Color(0xFFB3B3B3) : Color(0xff32A060),
),
),
],
@ -574,7 +588,8 @@ class _WelfarePage extends State<WelfarePage> {
style: TextStyle(
fontSize: 30.sp,
fontWeight: MyFontWeight.semi_bold,
color: cop.status == 3 ? Color(0xFFB3B3B3) : Color(0xff32A060),
color:
cop.status == 3 ? Color(0xFFB3B3B3) : Color(0xff32A060),
),
),
SizedBox(
@ -585,7 +600,8 @@ class _WelfarePage extends State<WelfarePage> {
style: TextStyle(
fontSize: 16.sp,
fontWeight: MyFontWeight.semi_bold,
color: cop.status == 3 ? Color(0xFFB3B3B3) : Color(0xff32A060),
color:
cop.status == 3 ? Color(0xFFB3B3B3) : Color(0xff32A060),
),
),
],
@ -672,9 +688,9 @@ class _WelfarePage extends State<WelfarePage> {
showAlertDialog();
} else {
SmartDialog.show(
clickBgDismissTemp: false,
clickBgDismissTemp: false,
widget: SettlementTips(
() {},
() {},
text: "${baseData?.msg}",
));
}
@ -915,8 +931,7 @@ class _WelfarePage extends State<WelfarePage> {
} else if (goodsPrice.onePrice != "0") {
return S.of(context).jifen_("${goodsPrice.onePrice}");
} else if ((goodsPrice.onePrice == "0") &&
((goodsPrice.price != "0") ||
(goodsPrice.money != "0.00"))) {
((goodsPrice.price != "0") || (goodsPrice.money != "0.00"))) {
return (goodsPrice.price == "0"
? ""
: S.of(context).jifen_("${goodsPrice.price}")) +

4
lib/main.dart

@ -395,8 +395,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}) =>

28
lib/main_page.dart

@ -3,8 +3,6 @@ import 'dart:io';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart';
import 'package:flutter_bmflocation/flutter_bmflocation.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:flutter_svg/flutter_svg.dart';
@ -245,19 +243,19 @@ class _MainPage extends State<MainPage> with WidgetsBindingObserver {
);
SharesdkPlugin.regist(shareSDKRegister);
LocationFlutterPlugin myLocPlugin = LocationFlutterPlugin();
// //
myLocPlugin.setAgreePrivacy(true);
BMFMapSDK.setAgreePrivacy(true);
if (Platform.isIOS) {
myLocPlugin.authAK("ylW2QPlsbERkho7jOgU4GQSeawmdUIoR");
BMFMapSDK.setApiKeyAndCoordType(
'ylW2QPlsbERkho7jOgU4GQSeawmdUIoR',
BMF_COORD_TYPE.BD09LL,
);
} else if (Platform.isAndroid) {
BMFMapSDK.setCoordType(BMF_COORD_TYPE.BD09LL);
}
// LocationFlutterPlugin myLocPlugin = LocationFlutterPlugin();
// // //
// myLocPlugin.setAgreePrivacy(true);
// BMFMapSDK.setAgreePrivacy(true);
// if (Platform.isIOS) {
// myLocPlugin.authAK("ylW2QPlsbERkho7jOgU4GQSeawmdUIoR");
// BMFMapSDK.setApiKeyAndCoordType(
// 'ylW2QPlsbERkho7jOgU4GQSeawmdUIoR',
// BMF_COORD_TYPE.BD09LL,
// );
// } else if (Platform.isAndroid) {
// BMFMapSDK.setCoordType(BMF_COORD_TYPE.BD09LL);
// }
// if (Platform.isAndroid) {
// xgFlutterPlugin.getXgAndroidApi().addNativeEventHandler(

12
lib/mine/mine_shop_details.dart

@ -1,8 +1,8 @@
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bmflocation/flutter_bmflocation.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:geolocator/geolocator.dart';
import 'package:huixiang/data/store.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/data/base_data.dart';
@ -44,7 +44,7 @@ class _MineShopDetails extends State<MineShopDetails> {
super.dispose();
refreshController.dispose();
consumeRefreshController.dispose();
Location.instance.stopLocation();
LocationInstance.getInstance().stopLocation();
}
@override
@ -85,10 +85,10 @@ class _MineShopDetails extends State<MineShopDetails> {
startLocation() async {
// EasyLoading.show(status: S.current.zhengzaijiazai);
Location.instance.startLocation(context, (BaiduLocation result){
if (result.latitude != null &&
result.longitude != null) {
vipDetail(result.latitude, result.longitude);
LocationInstance.getInstance().startLocation(context, (Position? result){
if (result?.latitude != null &&
result?.longitude != null) {
vipDetail(result?.latitude, result?.longitude);
} else {
EasyLoading.dismiss();
}

11
lib/mine/recharge_page.dart

@ -1,5 +1,6 @@
import 'dart:io';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
@ -57,7 +58,13 @@ class _RechargePage extends State<RechargePage> {
@override
void initState() {
super.initState();
_onRefresh();
SharedPreferences.getInstance().then((value) => {
apiService = ApiService(Dio(),
context: context,
token: value.getString("token"),
showLoading: false),
_onRefresh()
});
fluwx.addSubscriber((event) async {
print("payCallback: ${event.errCode}");
if (event.errCode == 0) {
@ -133,7 +140,7 @@ class _RechargePage extends State<RechargePage> {
_onRefresh() async {
EasyLoading.show(status: S.current.zhengzaijiazai, maskType: EasyLoadingMaskType.black);
SharedPreferences value = await SharedPreferences.getInstance();
// SharedPreferences value = await SharedPreferences.getInstance();
queryBenefitList();
queryRuleDetails();
queryRechargeActList();

13
lib/mine/vip_detail_page.dart

@ -1,12 +1,11 @@
import 'package:barcode_widget/barcode_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bmflocation/flutter_bmflocation.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:geolocator/geolocator.dart';
import 'package:huixiang/data/store.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/data/base_data.dart';
import 'package:huixiang/data/product.dart';
import 'package:huixiang/data/vip_card.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/store/scan.dart';
@ -38,7 +37,7 @@ class _VipDetailPage extends State<VipDetailPage> {
void dispose() {
super.dispose();
refreshController.dispose();
Location.instance.stopLocation();
LocationInstance.getInstance().stopLocation();
}
@override
@ -52,10 +51,10 @@ class _VipDetailPage extends State<VipDetailPage> {
startLocation() async {
// EasyLoading.show(status: S.current.zhengzaijiazai);
Location.instance.startLocation(context, (BaiduLocation result) {
if (result.latitude != null &&
result.longitude != null) {
vipDetail(result.latitude, result.longitude);
LocationInstance.getInstance().startLocation(context, (Position? result) {
if (result?.latitude != null &&
result?.longitude != null) {
vipDetail(result?.latitude, result?.longitude);
} else {
EasyLoading.dismiss();
}

2
lib/order/exchange_history_page.dart

@ -445,7 +445,7 @@ class _ExchangeHistoryList extends State<ExchangeHistoryList>
),
Expanded(
child: SizedBox(
height: 66.h,
// height: 66.h,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,

2
lib/order/exchange_order_page.dart

@ -984,7 +984,7 @@ class _ExchangeOrderPage extends State<ExchangeOrderPage> {
Align(
alignment: Alignment.bottomCenter,
child: Container(
height: 54.h,
height: 60.h,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(45),

447
lib/qr/invite_friends.dart

@ -1,5 +1,6 @@
import 'dart:convert';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:huixiang/generated/l10n.dart';
@ -45,6 +46,11 @@ class _InviteFriends extends State<InviteFriends> {
phone = UserInfo.fromJson(jsonDecode(user!)).inviteCode;
setState(() {});
}
if(apiService != null)
apiService = ApiService(Dio(),
context: context,
token: value.getString('token'),
showLoading: false);
queryUserInfo();
queryInviteMember();
});
@ -52,7 +58,8 @@ class _InviteFriends extends State<InviteFriends> {
///
queryInviteMember() async {
BaseData<PageInfo<Invitation>>? baseData = await apiService?.inviteMemberList({
BaseData<PageInfo<Invitation>>? baseData =
await apiService?.inviteMemberList({
"searchKey": "",
"pageNum": 1,
"pageSize": 100,
@ -60,7 +67,8 @@ class _InviteFriends extends State<InviteFriends> {
refreshController.refreshFailed();
});
if (baseData?.isSuccess ?? false) {
if (baseData!.data != null && (baseData.data!.list?.isNotEmpty ?? false)) {
if (baseData!.data != null &&
(baseData.data!.list?.isNotEmpty ?? false)) {
if (pageNum == 1) {
invitationList.clear();
}
@ -76,7 +84,8 @@ class _InviteFriends extends State<InviteFriends> {
///
queryUserInfo() async {
BaseData<UserInfo>? baseDate = await apiService?.queryInfo().catchError((onError) {
BaseData<UserInfo>? baseDate =
await apiService?.queryInfo().catchError((onError) {
refreshController.refreshFailed();
});
if (baseDate?.isSuccess ?? false) {
@ -84,7 +93,7 @@ class _InviteFriends extends State<InviteFriends> {
userInfo = baseDate!.data;
});
SharedPreferences.getInstance().then(
(value) => {
(value) => {
value.setString('user', jsonEncode(baseDate!.data)),
},
);
@ -95,109 +104,107 @@ class _InviteFriends extends State<InviteFriends> {
EasyLoading.dismiss();
}
_onRefresh(){
_onRefresh() {
queryUserInfo();
queryInviteMember();
}
@override
Widget build(BuildContext context) {
return Stack(
children: [
Scaffold(
backgroundColor: Color(0xFFF9FAF7),
appBar: AppBar(
backgroundColor: Colors.white,
leading: GestureDetector(
child: Icon(
Icons.clear,
color: Colors.black,
),
onTap: () {
Navigator.of(context).pop();
}),
title: Text(
S.of(context).yaoqinghaoyou,
style: TextStyle(
fontWeight: MyFontWeight.semi_bold,
fontSize: 17.sp,
color: Color(0xFF000000),
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
shadowColor: Colors.white,
backgroundColor: Colors.white,
leading: GestureDetector(
child: Icon(
Icons.clear,
color: Colors.black,
),
onTap: () {
Navigator.of(context).pop();
}),
title: Text(
S.of(context).yaoqinghaoyou,
style: TextStyle(
fontWeight: MyFontWeight.semi_bold,
fontSize: 17.sp,
color: Color(0xFF000000),
),
centerTitle: true,
elevation: 0.0,
// actions: [
// GestureDetector(
// child: Container(
// margin: EdgeInsets.only(right: 14),
// padding:EdgeInsets.only(left:70,right: 20),
// child: Icon(
// Icons.more_horiz,
// color: Colors.black,
// ),
// ),
// onTap: () {
// // Navigator.of(context).pop();
// // share();
// })
// ],
),
body: SmartRefresher(
controller: refreshController,
enablePullDown: true,
enablePullUp: false,
header: MyHeader(),
footer: CustomFooter(
builder: (context, mode) {
return MyFooter(mode);
},
),
onRefresh: () {
setState(() {
_onRefresh();
});
},
centerTitle: true,
elevation: 0.0,
//
scrolledUnderElevation: 0.0
// actions: [
// GestureDetector(
// child: Container(
// margin: EdgeInsets.only(right: 14),
// padding:EdgeInsets.only(left:70,right: 20),
// child: Icon(
// Icons.more_horiz,
// color: Colors.black,
// ),
// ),
// onTap: () {
// // Navigator.of(context).pop();
// // share();
// })
// ],
),
body: SmartRefresher(
controller: refreshController,
enablePullDown: true,
enablePullUp: false,
header: MyHeader(),
footer: CustomFooter(
builder: (context, mode) {
return MyFooter(mode);
},
),
onRefresh: () {
setState(() {
_onRefresh();
});
},
physics: BouncingScrollPhysics(),
scrollController: scrollController,
child: Container(
child: SingleChildScrollView(
physics: BouncingScrollPhysics(),
scrollController: scrollController,
child: Container(
child: SingleChildScrollView(
physics: BouncingScrollPhysics(),
child: Column(
children: [
invite(),
activityRule(),
achievement(),
mineInvite(),
],
),
),
child: Column(
children: [
invite(),
activityRule(),
achievement(),
mineInvite(),
],
),
),
),
],
),
);
}
///
Widget invite(){
Widget invite() {
return Container(
width:double.infinity,
width: double.infinity,
height: 370.h,
margin: EdgeInsets.only(bottom:20.h),
child:Column(
margin: EdgeInsets.only(bottom: 20.h),
child: Column(
children: [
Image.asset(
"assets/image/invite_friends.webp",
height: 300.h,
width:double.infinity,
width: double.infinity,
fit: BoxFit.fill,
),
SizedBox(height: 12.h,),
SizedBox(
height: 12.h,
),
GestureDetector(
onTap: (){
onTap: () {
widgetToUrl();
},
child: Container(
@ -207,7 +214,7 @@ class _InviteFriends extends State<InviteFriends> {
borderRadius: BorderRadius.circular(26),
color: Color(0xFF32A060),
),
margin: EdgeInsets.symmetric(horizontal:14.w),
margin: EdgeInsets.symmetric(horizontal: 14.w),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
@ -215,10 +222,12 @@ class _InviteFriends extends State<InviteFriends> {
Image.asset(
"assets/image/wx.webp",
height: 20,
width:20,
width: 20,
fit: BoxFit.fill,
),
SizedBox(width:4.w,),
SizedBox(
width: 4.w,
),
Text(
"邀请微信好友",
style: TextStyle(
@ -237,45 +246,47 @@ class _InviteFriends extends State<InviteFriends> {
}
///
Widget activityRule(){
Widget activityRule() {
return Container(
width:double.infinity,
width: double.infinity,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(6),
color: Color(0xFFFFFFFF),
),
margin: EdgeInsets.only(bottom:12.h,left:14.h,right: 14.h),
borderRadius: BorderRadius.circular(6),
color: Color(0xFFFFFFFF),
),
margin: EdgeInsets.only(bottom: 12.h, left: 14.h, right: 14.h),
padding: EdgeInsets.all(6),
child:Column(
child: Column(
// mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
decoration: BoxDecoration(
image: DecorationImage(
fit: BoxFit.cover,
image: AssetImage("assets/image/invite_bj.webp"),
),
),
height: 54.h,
width:double.infinity,
alignment: Alignment.center,
child: Text(
S.of(context).huodongguize,
style: TextStyle(
fontWeight: MyFontWeight.semi_bold,
fontSize: 16.sp,
color: Color(0xFF32A060),
decoration: BoxDecoration(
image: DecorationImage(
fit: BoxFit.cover,
image: AssetImage("assets/image/invite_bj.webp"),
),
),
)
height: 54.h,
width: double.infinity,
alignment: Alignment.center,
child: Text(
S.of(context).huodongguize,
style: TextStyle(
fontWeight: MyFontWeight.semi_bold,
fontSize: 16.sp,
color: Color(0xFF32A060),
),
)),
SizedBox(
height: 17.h,
),
SizedBox(height: 17.h,),
IntrinsicHeight(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(child: Column(
Expanded(
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
@ -288,7 +299,7 @@ class _InviteFriends extends State<InviteFriends> {
fit: BoxFit.cover,
),
Container(
width:50.w,
width: 50.w,
child: Flex(
children: List.generate(8, (_) {
return SizedBox(
@ -296,7 +307,7 @@ class _InviteFriends extends State<InviteFriends> {
height: 1,
child: DecoratedBox(
decoration:
BoxDecoration(color: Color(0xFF32A060)),
BoxDecoration(color: Color(0xFF32A060)),
),
);
}),
@ -324,7 +335,8 @@ class _InviteFriends extends State<InviteFriends> {
width: 3.w,
height: 1.h,
child: DecoratedBox(
decoration: BoxDecoration(color: Colors.white),
decoration:
BoxDecoration(color: Colors.white),
),
);
}),
@ -340,9 +352,8 @@ class _InviteFriends extends State<InviteFriends> {
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
width:50.w,
child:
Text(
width: 50.w,
child: Text(
"分享链接给好友",
style: TextStyle(
fontSize: 12.sp,
@ -360,7 +371,8 @@ class _InviteFriends extends State<InviteFriends> {
width: 3.w,
height: 1.h,
child: DecoratedBox(
decoration: BoxDecoration(color: Colors.white),
decoration:
BoxDecoration(color: Colors.white),
),
);
}),
@ -372,7 +384,8 @@ class _InviteFriends extends State<InviteFriends> {
),
],
)),
Expanded(child: Column(
Expanded(
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
@ -393,7 +406,7 @@ class _InviteFriends extends State<InviteFriends> {
height: 1.w,
child: DecoratedBox(
decoration:
BoxDecoration(color: Color(0xFF32A060)),
BoxDecoration(color: Color(0xFF32A060)),
),
);
}),
@ -421,7 +434,8 @@ class _InviteFriends extends State<InviteFriends> {
width: 3.w,
height: 1.h,
child: DecoratedBox(
decoration: BoxDecoration(color: Colors.white),
decoration:
BoxDecoration(color: Colors.white),
),
);
}),
@ -437,9 +451,8 @@ class _InviteFriends extends State<InviteFriends> {
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
width:50.w,
child:
Text(
width: 50.w,
child: Text(
"好友注册并获得10元优惠券",
style: TextStyle(
fontSize: 12.sp,
@ -457,7 +470,8 @@ class _InviteFriends extends State<InviteFriends> {
width: 3.w,
height: 1.h,
child: DecoratedBox(
decoration: BoxDecoration(color: Colors.white),
decoration:
BoxDecoration(color: Colors.white),
),
);
}),
@ -469,7 +483,8 @@ class _InviteFriends extends State<InviteFriends> {
),
],
)),
Expanded(child: Column(
Expanded(
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
@ -490,7 +505,7 @@ class _InviteFriends extends State<InviteFriends> {
height: 1.h,
child: DecoratedBox(
decoration:
BoxDecoration(color: Color(0xFF32A060)),
BoxDecoration(color: Color(0xFF32A060)),
),
);
}),
@ -518,7 +533,8 @@ class _InviteFriends extends State<InviteFriends> {
width: 3.w,
height: 1.h,
child: DecoratedBox(
decoration: BoxDecoration(color: Colors.white),
decoration:
BoxDecoration(color: Colors.white),
),
);
}),
@ -535,8 +551,7 @@ class _InviteFriends extends State<InviteFriends> {
children: [
Container(
width: 50.w,
child:
Text(
child: Text(
"好友完成首单",
style: TextStyle(
fontSize: 12.sp,
@ -554,7 +569,8 @@ class _InviteFriends extends State<InviteFriends> {
width: 3.w,
height: 1.h,
child: DecoratedBox(
decoration: BoxDecoration(color: Colors.white),
decoration:
BoxDecoration(color: Colors.white),
),
);
}),
@ -583,8 +599,7 @@ class _InviteFriends extends State<InviteFriends> {
SizedBox(height: 8.h),
Container(
width: 50.w,
child:
Text(
child: Text(
"邀请达成获得奖励",
style: TextStyle(
fontSize: 12.sp,
@ -595,8 +610,7 @@ class _InviteFriends extends State<InviteFriends> {
),
)
],
)
,
),
],
),
),
@ -606,17 +620,17 @@ class _InviteFriends extends State<InviteFriends> {
}
///
Widget achievement(){
Widget achievement() {
return Container(
width:double.infinity,
width: double.infinity,
height: 150.h,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(6),
color: Color(0xFFFFFFFF),
),
margin: EdgeInsets.only(bottom:12.h,left:14.h,right: 14.h),
padding: EdgeInsets.only(top: 6.h,left: 6,right: 6,bottom: 16.h),
child:Column(
borderRadius: BorderRadius.circular(6),
color: Color(0xFFFFFFFF),
),
margin: EdgeInsets.only(bottom: 12.h, left: 14.h, right: 14.h),
padding: EdgeInsets.only(top: 6.h, left: 6, right: 6, bottom: 16.h),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@ -628,7 +642,7 @@ class _InviteFriends extends State<InviteFriends> {
),
),
height: 54.h,
width:double.infinity,
width: double.infinity,
alignment: Alignment.center,
child: Text(
S.of(context).wodechengjiu,
@ -637,11 +651,11 @@ class _InviteFriends extends State<InviteFriends> {
fontSize: 16.sp,
color: Color(0xFF32A060),
),
)
),
)),
Row(
children: [
Expanded(child:Column(
Expanded(
child: Column(
children: [
Text(
"${userInfo?.todayInviteNumber ?? 0}",
@ -651,7 +665,9 @@ class _InviteFriends extends State<InviteFriends> {
color: Color(0xFF000000),
),
),
SizedBox(height: 5.h,),
SizedBox(
height: 5.h,
),
Text(
"今日邀请",
style: TextStyle(
@ -662,7 +678,8 @@ class _InviteFriends extends State<InviteFriends> {
)
],
)),
Expanded(child:Column(
Expanded(
child: Column(
children: [
Text(
"${userInfo?.inviteNumber ?? 0}",
@ -672,7 +689,9 @@ class _InviteFriends extends State<InviteFriends> {
color: Color(0xFF000000),
),
),
SizedBox(height: 5.h,),
SizedBox(
height: 5.h,
),
Text(
"累积邀请",
style: TextStyle(
@ -691,16 +710,16 @@ class _InviteFriends extends State<InviteFriends> {
}
///
Widget mineInvite(){
Widget mineInvite() {
return Container(
width:double.infinity,
width: double.infinity,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(6),
color: Color(0xFFFFFFFF),
),
margin: EdgeInsets.only(bottom:12.h,left:14.h,right: 14.h),
padding: EdgeInsets.only(top: 6.h,left: 6,right: 6),
child:Column(
borderRadius: BorderRadius.circular(6),
color: Color(0xFFFFFFFF),
),
margin: EdgeInsets.only(bottom: 12.h, left: 14.h, right: 14.h),
padding: EdgeInsets.only(top: 6.h, left: 6, right: 6),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@ -712,7 +731,7 @@ class _InviteFriends extends State<InviteFriends> {
),
),
height: 54.h,
width:double.infinity,
width: double.infinity,
alignment: Alignment.center,
child: Text(
S.of(context).wodeyaoqing,
@ -721,75 +740,80 @@ class _InviteFriends extends State<InviteFriends> {
fontSize: 16.sp,
color: Color(0xFF32A060),
),
)
)),
SizedBox(
height: 12.h,
),
SizedBox(height:12.h,),
Padding(padding:EdgeInsets.symmetric(horizontal: 6.w),
child:
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
S.of(context).shoujihao,
style: TextStyle(
fontWeight: MyFontWeight.semi_bold,
fontSize:14.sp,
color: Color(0xFF000000),
Padding(
padding: EdgeInsets.symmetric(horizontal: 6.w),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
S.of(context).shoujihao,
style: TextStyle(
fontWeight: MyFontWeight.semi_bold,
fontSize: 14.sp,
color: Color(0xFF000000),
),
),
),
Text(
"注册时间",
style: TextStyle(
fontWeight: MyFontWeight.semi_bold,
fontSize:14.sp,
color: Color(0xFF000000),
Text(
"注册时间",
style: TextStyle(
fontWeight: MyFontWeight.semi_bold,
fontSize: 14.sp,
color: Color(0xFF000000),
),
),
),
],),),
SizedBox(height:12.h,),
],
),
),
SizedBox(
height: 12.h,
),
(invitationList.length == 0)
? NoDataView(
src: "assets/image/ding_dan.webp",
isShowBtn: false,
text:"还没有邀请记录哦~",
fontSize: 16.sp,
margin: EdgeInsets.only(top: 120.h),
):ListView.builder(
padding: EdgeInsets.zero,
itemCount:invitationList.length,
scrollDirection: Axis.vertical,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemBuilder: (context, position) {
return GestureDetector(
onTap: () {
},
child: mineInviteItem(invitationList[position]),
);
},
),
src: "assets/image/ding_dan.webp",
isShowBtn: false,
text: "还没有邀请记录哦~",
fontSize: 16.sp,
margin: EdgeInsets.only(top: 120.h),
)
: ListView.builder(
padding: EdgeInsets.zero,
itemCount: invitationList.length,
scrollDirection: Axis.vertical,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemBuilder: (context, position) {
return GestureDetector(
onTap: () {},
child: mineInviteItem(invitationList[position]),
);
},
),
],
),
);
}
Widget mineInviteItem(Invitation invitationList){
Widget mineInviteItem(Invitation invitationList) {
return Container(
child:Column(
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
AppUtils.phoneEncode(invitationList.phone ?? ""),
style: TextStyle(
color: Color(0xFF000000),
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
AppUtils.phoneEncode(invitationList.phone ?? ""),
style: TextStyle(
color: Color(0xFF000000),
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
),
),
),
Text(
invitationList.createTime ?? "",
style: TextStyle(
@ -831,13 +855,12 @@ class _InviteFriends extends State<InviteFriends> {
SSDKContentTypes.webpage,
);
SharesdkPlugin.share(ShareSDKPlatforms.wechatSession, params,
(state, userData, contentEntity, error) {
print("share!$state");
});
(state, userData, contentEntity, error) {
print("share!$state");
});
}
String buildShareUrl() {
return "https://hx.lotus-wallet.com/invite.html?invite=${phone}";
}
}

4
lib/retrofit/min_api.g.dart

@ -13,7 +13,9 @@ class _MinApiService implements MinApiService {
this._dio, {
this.baseUrl,
}) {
baseUrl ??= 'http://192.168.10.54:8765/app/';
// baseUrl ??= 'http://192.168.10.54:8765/app/';
baseUrl ??= kReleaseMode?serviceBaseUrl:localBaseUrl;
}
final Dio _dio;

10
lib/retrofit/retrofit_api.dart

@ -76,7 +76,7 @@ abstract class ApiService {
factory ApiService(
Dio dio, {
String? baseUrl,
required BuildContext context,
BuildContext? context,
String? token,
bool showLoading = false,
bool isIp = false,
@ -103,7 +103,7 @@ abstract class ApiService {
debugPrint("method = ${options.method.toString()}");
debugPrint("url = ${options.uri.toString()}");
debugPrint("headers = ${options.headers}");
if (showLoading && !EasyLoading.isShow) {
if (context != null && showLoading && !EasyLoading.isShow) {
//loading
EasyLoading.show(
status: S.of(context).zhengzaijiazai,
@ -129,7 +129,7 @@ abstract class ApiService {
if (response.data is Map) {
Map map = response.data;
if (map["code"] == 40005 || map["code"] == 40001) {
if (!LoginTipsDialog().isShow) {
if (context != null && !LoginTipsDialog().isShow) {
print("show: ${LoginTipsDialog().isShow}");
LoginTipsDialog().show(context);
}
@ -182,6 +182,10 @@ abstract class ApiService {
@GET("https://restapi.amap.com/v3/place/around?key=542b46afa8e4b88fe1eb3c4d0ba0872f&location={lat},{lng}&keywords={keywords}&offset={size}&page={page}&extensions=all")
Future<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<LoginInfo>?> memberLogin(@Body() Map<String, dynamic> param);

31
lib/retrofit/retrofit_api.g.dart

@ -13,7 +13,7 @@ class _ApiService implements ApiService {
this._dio, {
this.baseUrl,
}) {
baseUrl ??= 'http://192.168.10.54:8766/app/';
baseUrl ??= kReleaseMode ? serviceBaseUrl : localBaseUrl;
}
final Dio _dio;
@ -95,6 +95,35 @@ class _ApiService implements ApiService {
return value;
}
@override
Future<dynamic> geocodeRegeo(
String lat,
String lng,
) async {
final _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null;
final _result = await _dio.fetch(_setStreamType<dynamic>(Options(
method: 'GET',
headers: _headers,
extra: _extra,
)
.compose(
_dio.options,
'https://restapi.amap.com/v3/geocode/regeo?key=542b46afa8e4b88fe1eb3c4d0ba0872f&location=${lng},${lat}&extensions=base',
queryParameters: queryParameters,
data: _data,
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
))));
final value = _result.data;
return value;
}
@override
Future<BaseData<LoginInfo>?> memberLogin(Map<String, dynamic> param) async {
final _extra = <String, dynamic>{};

595
lib/settlement/settlement.dart

@ -4,11 +4,13 @@ import 'dart:io';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_datetime_picker_plus/src/datetime_picker_theme.dart' as picker_theme;
import 'package:flutter_datetime_picker_plus/src/datetime_picker_theme.dart'
as picker_theme;
import 'package:flutter_datetime_picker_plus/flutter_datetime_picker_plus.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:fluwx/fluwx.dart';
import 'package:geolocator/geolocator.dart';
import 'package:huixiang/data/settle_order_info.dart';
import 'package:huixiang/data/shopping_cart.dart';
import 'package:huixiang/data/subscribe_param.dart';
@ -72,13 +74,13 @@ class _Settlement extends State<Settlement> {
String? actProductId;
String? actProductSkuId;
ActivityDetails? activityDetails;
BargainType bargainType = BargainType.BargainZBug;
BargainType? bargainType = BargainType.BargainZBug;
LaunchJoinAct? launchJoinAct;
String? skuPrice1;
JoinActivity joinA = JoinActivity.GoJoin;
JoinActivity? joinA = JoinActivity.GoJoin;
String? bargainOrderId;
String? productSkuId;
int count1 = 0;
int? count1 = 0;
String? productId;
bool orderButton = false;
bool useVipPriceSelect = true;
@ -140,7 +142,9 @@ class _Settlement extends State<Settlement> {
storeId: storeId,
showLoading: false);
queryMemberInfo();
if (widget.arguments["pid"] != null && widget.arguments["pid"] != "" && tableId <= 0) {
if (widget.arguments["pid"] != null &&
widget.arguments["pid"] != "" &&
tableId <= 0) {
queryOrderInfo(
address != null ? address!.id : null,
((storeInfo?.pickupType?.dineInTakeStatus ?? false) == true &&
@ -161,7 +165,9 @@ class _Settlement extends State<Settlement> {
count1,
payChannel,
tableId);
} else if ( widget.arguments["cid"] != null && widget.arguments["cid"] != "" && tableId <= 0) {
} else if (widget.arguments["cid"] != null &&
widget.arguments["cid"] != "" &&
tableId <= 0) {
queryOrderInfo(
address != null ? address!.id : null,
((storeInfo?.pickupType?.dineInTakeStatus ?? false) == true &&
@ -170,7 +176,7 @@ class _Settlement extends State<Settlement> {
selectedBtn != 2)
? diningStatus
: selectedBtn,
widget.arguments["cid"]??0,
widget.arguments["cid"] ?? 0,
0,
productId ?? 0,
productSkuId ?? "",
@ -228,7 +234,9 @@ class _Settlement extends State<Settlement> {
payChannel,
tableId) async {
try {
EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black);
EasyLoading.show(
status: S.current.zhengzaijiazai,
maskType: EasyLoadingMaskType.black);
BaseData<SettleOrderInfo>? baseData = await minService?.getOrderInfo({
"addressId": addressId,
@ -328,7 +336,8 @@ class _Settlement extends State<Settlement> {
///
queryOrderDetails(id) async {
EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black);
EasyLoading.show(
status: S.current.zhengzaijiazai, maskType: EasyLoadingMaskType.black);
BaseData<MinOrderInfo>? baseData = await minService?.getOrderDetails({
"id": pageType != null ? widget.arguments["orderId"] : id ?? parentId,
}).catchError((error) {});
@ -347,7 +356,7 @@ class _Settlement extends State<Settlement> {
///
queryCancelMemberCoupon(orderId) async {
BaseData? baseData =
await minService?.cancelMemberCoupon(orderId).catchError((error) {});
await minService?.cancelMemberCoupon(orderId).catchError((error) {});
if (baseData?.isSuccess ?? false) {
queryOrderDetails(parentId);
// SmartDialog.showToast(baseData.data, alignment: Alignment.center);
@ -374,90 +383,112 @@ class _Settlement extends State<Settlement> {
setState(() {
this.selectedBtn = selectedBtn;
});
queryOrderInfo(
address?.id,
((storeInfo?.pickupType?.dineInTakeStatus ?? false) == true &&
(subscribeParam?.isEnableSubscribe ?? false) == false &&
selectedBtn != 1 &&
selectedBtn != 2)
? diningStatus
: selectedBtn,
null,
0,
productId ?? null,
productSkuId ?? "",
actProductId ?? "",
actProductSkuId ?? "",
"AUTO",
// useVipPriceSelect,
// useBenefitSelect,
count1,
payChannel,
tableId);
return;
// BaseData<List<Address>> baseDate =
// await minService?.queryAddress().catchError((error) {});
//
// BMFCoordinate bmfCoordinate = BMFCoordinate(
// double.tryParse(storeInfo.latitude),
// double.tryParse(storeInfo.longitude),
// );
// if (baseDate.isSuccess) {
// setState(() {
// address = baseDate.data[0];
// });
// for (int i = 1; i < baseDate.data.length; i++) {
// Address address1 = baseDate.data[i];
//
// BMFCoordinate coordinate = await BMFCalculateUtils.coordConvert(
// coordinate: BMFCoordinate(
// double.tryParse(address.longitude),
// double.tryParse(address.latitude),
// ),
// fromType: BMF_COORD_TYPE.COMMON,
// toType: BMF_COORD_TYPE.BD09LL);
// BMFCoordinate coordinate1 = await BMFCalculateUtils.coordConvert(
// coordinate: BMFCoordinate(
// double.tryParse(address1.longitude),
// double.tryParse(address1.latitude),
// ),
// fromType: BMF_COORD_TYPE.COMMON,
// toType: BMF_COORD_TYPE.BD09LL);
//
// double mi = await BMFCalculateUtils.getLocationDistance(
// bmfCoordinate, coordinate);
// double mi1 = await BMFCalculateUtils.getLocationDistance(
// bmfCoordinate, coordinate1);
// if (mi1 < mi) {
// address = address1;
// }
// }
// await queryOrderInfo(
// address.id,
// ((storeInfo.pickupType.dineInTakeStatus ?? false) == true &&
// (subscribeParam.isEnableSubscribe ?? false) == false &&
// selectedBtn != 1 &&
// selectedBtn != 2)
// ? diningStatus
// : selectedBtn,
// null,
// 0,
// productId ?? null,
// productSkuId ?? "",
// actProductId ?? "",
// actProductSkuId ?? "",
// "AUTO",
// // useVipPriceSelect,
// // useBenefitSelect,
// count1,
// payChannel,
// tableId);
// }
if (address != null) {
queryOrderInfo(
address?.id,
((storeInfo?.pickupType?.dineInTakeStatus ?? false) == true &&
(subscribeParam?.isEnableSubscribe ?? false) == false &&
selectedBtn != 1 &&
selectedBtn != 2)
? diningStatus
: selectedBtn,
null,
0,
productId ?? null,
productSkuId ?? "",
actProductId ?? "",
actProductSkuId ?? "",
"AUTO",
// useVipPriceSelect,
// useBenefitSelect,
count1,
payChannel,
tableId);
return;
}
BaseData<List<Address>>? baseDate =
await minService?.queryAddress().catchError((error) {});
Position? bmfCoordinate = Position(
latitude: double.tryParse(storeInfo?.latitude ?? "")!,
longitude: double.tryParse(storeInfo?.longitude ?? "")!,
timestamp: DateTime.now(),
accuracy: 0,
altitude: 0,
heading: 0,
speed: 0,
speedAccuracy: 0);
if (baseDate != null &&
(baseDate.isSuccess ?? false) &&
(baseDate.data ?? []).isNotEmpty) {
setState(() {
address = baseDate.data![0];
});
for (int i = 1; i < baseDate.data!.length; i++) {
Address? address1 = baseDate.data![i];
Position? coordinate = Position(
// COMMON->BD09LL
longitude: double.tryParse(address?.longitude ?? "")!,
latitude: double.tryParse(address?.latitude ?? "")!,
timestamp: DateTime.now(),
accuracy: 0,
altitude: 0,
heading: 0,
speed: 0,
speedAccuracy: 0);
Position? coordinate1 = Position(
// COMMON->BD09LL
longitude: double.tryParse(address1.longitude ?? "")!,
latitude: double.tryParse(address1.latitude ?? "")!,
timestamp: DateTime.now(),
accuracy: 0,
altitude: 0,
heading: 0,
speed: 0,
speedAccuracy: 0);
double mi = Geolocator.distanceBetween(
bmfCoordinate.latitude,
bmfCoordinate.longitude,
coordinate.latitude,
coordinate.longitude,
);
double mi1 = Geolocator.distanceBetween(
bmfCoordinate.latitude,
bmfCoordinate.longitude,
coordinate1.latitude,
coordinate1.longitude,
);
if (mi1 < mi) {
address = address1;
}
}
await queryOrderInfo(
address?.id,
((storeInfo?.pickupType?.dineInTakeStatus ?? false) == true &&
(subscribeParam?.isEnableSubscribe ?? false) == false &&
selectedBtn != 1 &&
selectedBtn != 2)
? diningStatus
: selectedBtn,
null,
0,
productId ?? null,
productSkuId ?? "",
actProductId ?? "",
actProductSkuId ?? "",
"AUTO",
// useVipPriceSelect,
// useBenefitSelect,
count1,
payChannel,
tableId);
}
}
///
selectedAddress(String addId) async {
BaseData<List<Address>>? baseDate = await minService?.queryAddress().catchError((error) {});
BaseData<List<Address>>? baseDate =
await minService?.queryAddress().catchError((error) {});
if (baseDate?.isSuccess ?? false) {
setState(() {
baseDate!.data?.forEach((element) {
@ -553,7 +584,8 @@ class _Settlement extends State<Settlement> {
///
queryPlaceOrderFirst() async {
try {
EasyLoading.show(status: S.current.zhengzaijiazai,
EasyLoading.show(
status: S.current.zhengzaijiazai,
maskType: EasyLoadingMaskType.black);
// for (int i = 0; i < settleOrderInfo.orderProductList.length; i++) {
// settleOrderInfo.orderProductList.forEach((element1) {
@ -573,21 +605,20 @@ class _Settlement extends State<Settlement> {
placeOrderFirst?.cartSum = settleOrderInfo?.price;
placeOrderFirst?.addressId = address == null ? null : address!.id;
placeOrderFirst?.isSubscribe =
((subscribeParam?.isEnableSubscribe ?? false) == true)
? true
: false; //
placeOrderFirst?.isTakeOut = ((storeInfo?.pickupType?.dineInTakeStatus ?? false) &&
!(subscribeParam?.isEnableSubscribe ?? false) &&
selectedBtn != 1 &&
selectedBtn != 2)
? diningStatus
: selectedBtn;
((subscribeParam?.isEnableSubscribe ?? false) == true)
? true
: false; //
placeOrderFirst?.isTakeOut =
((storeInfo?.pickupType?.dineInTakeStatus ?? false) &&
!(subscribeParam?.isEnableSubscribe ?? false) &&
selectedBtn != 1 &&
selectedBtn != 2)
? diningStatus
: selectedBtn;
placeOrderFirst?.notes = remakers +
(reservationTime ?? "") +
((subscribeParam?.isEnableSubscribe ?? false) == true
? "预约门店:${((subscribeParam?.stores?.length ?? 0) == 1
? (subscribeParam?.stores?[0])
: (subscribeStoresName ?? ""))}"
? "预约门店:${((subscribeParam?.stores?.length ?? 0) == 1 ? (subscribeParam?.stores?[0]) : (subscribeStoresName ?? ""))}"
: "");
placeOrderFirst?.numberOfPeople = "$numberOfPeople";
placeOrderFirst?.orderSource = 2;
@ -598,32 +629,41 @@ class _Settlement extends State<Settlement> {
placeOrderFirst?.payChannel = ((placeOrderFirst?.cartSum == "0.00")
? payChannel = 0
: ((tableId > 0
? (minOrderInfo?.isRaise ?? false)
: (settleOrderInfo?.isRaise ?? false))
? 7
: payChannel));
? (minOrderInfo?.isRaise ?? false)
: (settleOrderInfo?.isRaise ?? false))
? 7
: payChannel));
placeOrderFirst?.promotionInfoDTO = PromotionInfoDTOBean();
placeOrderFirst?.promotionInfoDTO?.promotionId = (tableId <= 0) ? (promotion?.id ?? "") : "";
placeOrderFirst?.promotionInfoDTO?.promotionId =
(tableId <= 0) ? (promotion?.id ?? "") : "";
// : widget.arguments["pid"] ?? "";
placeOrderFirst?.promotionInfoDTO?.couponId = (tableId <= 0) ? (couponListBean?.id ?? "") : "";
placeOrderFirst?.promotionInfoDTO?.couponId =
(tableId <= 0) ? (couponListBean?.id ?? "") : "";
// : widget.arguments["cid"] ?? "";
// placeOrderFirst.promotionInfoDTO.useVipPrice = (settleOrderInfo.isRaise || payChannel == 5 || ((payChannel == 4 && (settleOrderInfo.usePlateMoney == false))) ) ? false : useVipPriceSelect;
// placeOrderFirst.promotionInfoDTO.useBenefit = (settleOrderInfo.isRaise || payChannel == 5 || ((payChannel == 4 && settleOrderInfo.usePlateMoney == false))) ? false : useBenefitSelect;
placeOrderFirst?.promotionInfoDTO?.discountType = (!placeOrder) ? "AUTO" : settleOrderInfo?.discountType ?? "";
placeOrderFirst?.recMobile = (mobile?.isNotEmpty ?? false) ? mobile! : storeInfo!.headMobile;
placeOrderFirst?.shoppingCartSkuItemList = settleOrderInfo!.orderProductList;
placeOrderFirst?.promotionInfoDTO?.discountType =
(!placeOrder) ? "AUTO" : settleOrderInfo?.discountType ?? "";
placeOrderFirst?.recMobile =
(mobile?.isNotEmpty ?? false) ? mobile! : storeInfo!.headMobile;
placeOrderFirst?.shoppingCartSkuItemList =
settleOrderInfo!.orderProductList;
placeOrderFirst?.skuItemDTOList = [];
placeOrderFirst?.source = 1;
placeOrderFirst?.storeId = storeInfo!.id;
placeOrderFirst?.subcribeTime = subTime ?? ""; //
placeOrderFirst?.tableId = "$tableId";
for (int i = 0; i < (shopCarGoods?.shoppingCartSkuItemList?.length ?? 0); i++) {
placeOrderFirst?.shoppingCartSkuItemList?[i].setMealDataList = shopCarGoods!.shoppingCartSkuItemList?[i].setMealDataList;
for (int i = 0;
i < (shopCarGoods?.shoppingCartSkuItemList?.length ?? 0);
i++) {
placeOrderFirst?.shoppingCartSkuItemList?[i].setMealDataList =
shopCarGoods!.shoppingCartSkuItemList?[i].setMealDataList;
}
if (tableId == 0) {
///
BaseData<dynamic>? baseData = await minService?.placeOrderFirst(placeOrderFirst!.toJson())
BaseData<dynamic>? baseData = await minService
?.placeOrderFirst(placeOrderFirst!.toJson())
.catchError((error) {
print("error: $error");
});
@ -633,7 +673,8 @@ class _Settlement extends State<Settlement> {
await querySettlement();
} else {
// orderButton = false;
SmartDialog.showToast(baseData?.msg ?? "", alignment: Alignment.center);
SmartDialog.showToast(baseData?.msg ?? "",
alignment: Alignment.center);
}
} else {
///
@ -645,13 +686,15 @@ class _Settlement extends State<Settlement> {
} else {
if (parentId == "") {
//
baseData = await minService?.placeOrderFirst(placeOrderFirst!.toJson())
baseData = await minService
?.placeOrderFirst(placeOrderFirst!.toJson())
.catchError((error) {
print("error: $error");
});
} else {
//
baseData = await minService?.addOrder(placeOrderFirst!.toJson())
baseData = await minService
?.addOrder(placeOrderFirst!.toJson())
.catchError((error) {
print("error: $error");
});
@ -668,22 +711,25 @@ class _Settlement extends State<Settlement> {
}
} else {
// orderButton = false;
SmartDialog.showToast(baseData?.msg ?? "", alignment: Alignment.center);
SmartDialog.showToast(baseData?.msg ?? "",
alignment: Alignment.center);
}
}
}finally{
} finally {
EasyLoading.dismiss();
}
}
///
querySettlement() async {
if (placeOrderFirst == null || minOrderInfo == null || downOrder == null) {
return;
}
placeOrderFirst?.id = ((parentId?.isNotEmpty ?? false) ? parentId : downOrder?.id);
placeOrderFirst?.orderProductVOList = ((downOrder == null) ? minOrderInfo!.orderProductVOList : downOrder!.orderProductVOList);
placeOrderFirst?.id =
((parentId?.isNotEmpty ?? false) ? parentId : downOrder?.id);
placeOrderFirst?.orderProductVOList = ((downOrder == null)
? minOrderInfo!.orderProductVOList
: downOrder!.orderProductVOList);
if (placeOrderFirst?.payChannel == 1) {
if (Platform.isAndroid) {
@ -694,7 +740,8 @@ class _Settlement extends State<Settlement> {
await Min.initialize();
}
}
BaseData<WxPay>? baseData = await minService?.settlementWx(placeOrderFirst!.toJson())
BaseData<WxPay>? baseData = await minService
?.settlementWx(placeOrderFirst!.toJson())
.catchError((error) {
print(error);
});
@ -710,25 +757,25 @@ class _Settlement extends State<Settlement> {
universalLink: "https://hx.lotus-wallet.com/app/",
);
fluwx.pay(
which: Payment(
appId: wxPay.appId!,
partnerId: wxPay.partnerId!,
prepayId: wxPay.prepayId!,
packageValue: wxPay.packageValue!,
nonceStr: wxPay.nonceStr!,
timestamp: int.tryParse(wxPay.timeStamp!) ?? 0,
sign: wxPay.sign!,
)
);
}else{
which: Payment(
appId: wxPay.appId!,
partnerId: wxPay.partnerId!,
prepayId: wxPay.prepayId!,
packageValue: wxPay.packageValue!,
nonceStr: wxPay.nonceStr!,
timestamp: int.tryParse(wxPay.timeStamp!) ?? 0,
sign: wxPay.sign!,
));
} else {
EasyLoading.dismiss();
SmartDialog.showToast("${baseData?.msg}", alignment: Alignment.center);
Future.delayed(Duration(seconds:2), () {
Future.delayed(Duration(seconds: 2), () {
toOrderDetails(placeOrderFirst!.id);
});
}
} else {
BaseData? baseData = await minService?.settlementApi(placeOrderFirst!.toJson())
BaseData? baseData = await minService
?.settlementApi(placeOrderFirst!.toJson())
.catchError((error) {
print(error);
});
@ -761,7 +808,8 @@ class _Settlement extends State<Settlement> {
}
}
BaseData<WxPay>? baseData = await minService?.actPay({
"orderId": bargainOrderId != null ? bargainOrderId! : launchJoinAct?.orderId,
"orderId":
bargainOrderId != null ? bargainOrderId! : launchJoinAct?.orderId,
"payChannel": placeOrderFirst!.payChannel
}).catchError((error) {
print(error);
@ -777,31 +825,34 @@ class _Settlement extends State<Settlement> {
universalLink: "https://hx.lotus-wallet.com/app/",
);
fluwx.pay(
which: Payment(
appId: wxPay.appId!,
partnerId: wxPay.partnerId!,
prepayId: wxPay.prepayId!,
packageValue: wxPay.packageValue!,
nonceStr: wxPay.nonceStr!,
timestamp: int.tryParse(wxPay.timeStamp!) ?? 0,
sign: wxPay.sign!,
)
);
which: Payment(
appId: wxPay.appId!,
partnerId: wxPay.partnerId!,
prepayId: wxPay.prepayId!,
packageValue: wxPay.packageValue!,
nonceStr: wxPay.nonceStr!,
timestamp: int.tryParse(wxPay.timeStamp!) ?? 0,
sign: wxPay.sign!,
));
}
} else {
BaseData? baseData = await minService?.actPay({
"orderId": bargainOrderId != null ? bargainOrderId : launchJoinAct?.orderId,
"orderId":
bargainOrderId != null ? bargainOrderId : launchJoinAct?.orderId,
"payChannel": payChannel
}).catchError((error) {
print(error);
});
if (baseData?.isSuccess ?? false) {
toOrderDetails(bargainOrderId != null ? bargainOrderId! : launchJoinAct?.orderId);
toOrderDetails(
bargainOrderId != null ? bargainOrderId! : launchJoinAct?.orderId);
} else {
SmartDialog.show(
widget: SettlementTips(
() {
toOrderDetails(bargainOrderId != null ? bargainOrderId! : launchJoinAct?.orderId);
toOrderDetails(bargainOrderId != null
? bargainOrderId!
: launchJoinAct?.orderId);
},
text: "${baseData?.msg}",
));
@ -875,14 +926,19 @@ class _Settlement extends State<Settlement> {
child: Column(
children: [
DistributionMode(
(addressId, isTake, memberCouponId, orderId, String? promotionId) {
(addressId, isTake, memberCouponId, orderId,
String? promotionId) {
setState(() {
this.selectedBtn = 0;
});
queryOrderInfo(
addressId,
((storeInfo?.pickupType?.dineInTakeStatus ?? false) &&
(subscribeParam?.isEnableSubscribe ?? false) &&
((storeInfo?.pickupType
?.dineInTakeStatus ??
false) &&
(subscribeParam
?.isEnableSubscribe ??
false) &&
selectedBtn != 1 &&
selectedBtn != 2)
? diningStatus
@ -913,8 +969,10 @@ class _Settlement extends State<Settlement> {
),
////
if ((storeInfo?.pickupType?.dineInTakeStatus ?? false) &&
!(subscribeParam?.isEnableSubscribe ?? false) &&
if ((storeInfo?.pickupType?.dineInTakeStatus ??
false) &&
!(subscribeParam?.isEnableSubscribe ??
false) &&
selectedBtn != 1 &&
selectedBtn != 2)
takeStatus(),
@ -944,8 +1002,10 @@ class _Settlement extends State<Settlement> {
///
if ((settleOrderInfo != null ||
minOrderInfo != null) && (placeOrder && tableId <= 0 &&
!(settleOrderInfo?.isRaise ?? false)))
minOrderInfo != null) &&
(placeOrder &&
tableId <= 0 &&
!(settleOrderInfo?.isRaise ?? false)))
VipDiscountsSelect(
vipSelectCheck,
settleOrderInfo,
@ -973,7 +1033,8 @@ class _Settlement extends State<Settlement> {
"remake": remakers
}).then((value) => {
setState(() {
if (value != null) remakers = value as String;
if (value != null)
remakers = value as String;
})
});
},
@ -1074,11 +1135,12 @@ class _Settlement extends State<Settlement> {
// return;
// } else
// orderButton = true;
if (((subscribeParam?.isEnableSubscribe ?? false)) &&
if (((subscribeParam?.isEnableSubscribe ??
false)) &&
(((subscribeParam?.stores?.length == 1
? subscribeParam?.stores![0]
: subscribeStoresName) ==
null))) {
? subscribeParam?.stores![0]
: subscribeStoresName) ==
null))) {
SmartDialog.showToast(
(reservationTime == null)
? S.of(context).qingxuanzeyuyeushijian
@ -1271,10 +1333,12 @@ class _Settlement extends State<Settlement> {
borderRadius: BorderRadius.all(Radius.circular(6)),
border: Border.all(
width: diningStatus == 3 ? 2.w : 1.w,
color: diningStatus == 3 ? Color(0xFF32A060) : Color(0xFFDEDEDE),
color:
diningStatus == 3 ? Color(0xFF32A060) : Color(0xFFDEDEDE),
style: BorderStyle.solid,
),
color: diningStatus == 3 ? Color(0xFFEEFFF5) : Color(0xFFFFFFFF),
color:
diningStatus == 3 ? Color(0xFFEEFFF5) : Color(0xFFFFFFFF),
),
padding: EdgeInsets.only(top: 11.h, bottom: 14.h),
child: Row(
@ -1489,8 +1553,7 @@ class _Settlement extends State<Settlement> {
}
int couponCount() {
if (settleOrderInfo?.couponList?.isEmpty ?? true)
return 0;
if (settleOrderInfo?.couponList?.isEmpty ?? true) return 0;
int count = 0;
settleOrderInfo!.couponList?.forEach((element) {
if (element.tenantCode == "") {
@ -1530,13 +1593,19 @@ class _Settlement extends State<Settlement> {
selectedBtn != 2)
? diningStatus
: selectedBtn,
((couponBean.id??0) == 0 && (promotion?.id ?? productId ?? 0) !=0) ? 0: couponBean.id,
((couponBean.id ?? 0) == 0 && (promotion?.id ?? productId ?? 0) != 0)
? 0
: couponBean.id,
0,
((couponBean.id??0) == 0 && (promotion?.id ?? productId ?? 0) !=0) ? promotion?.id ?? productId :0,
((couponBean.id ?? 0) == 0 && (promotion?.id ?? productId ?? 0) != 0)
? promotion?.id ?? productId
: 0,
productSkuId ?? "",
actProductId ?? "",
actProductSkuId ?? "",
(couponBean.id ?? 0) == 0 ? ((promotion?.id ?? productId ?? 0) !=0 ? "ACTIVITY":"AUTO") : "COUPON",
(couponBean.id ?? 0) == 0
? ((promotion?.id ?? productId ?? 0) != 0 ? "ACTIVITY" : "AUTO")
: "COUPON",
// useVipPriceSelect,
// useBenefitSelect,
count1,
@ -1570,13 +1639,21 @@ class _Settlement extends State<Settlement> {
selectedBtn != 2)
? diningStatus
: selectedBtn,
(((pro.id ?? 0) ?? (productId ?? 0)) == 0 && (couponListBean?.id ??0) != 0)?couponListBean?.id:0,
(((pro.id ?? 0) ?? (productId ?? 0)) == 0 &&
(couponListBean?.id ?? 0) != 0)
? couponListBean?.id
: 0,
0,
(((pro.id ?? 0) ?? (productId ?? 0)) == 0 && (couponListBean?.id ??0) != 0) ? 0 :((pro.id ?? 0) ?? productId),
(((pro.id ?? 0) ?? (productId ?? 0)) == 0 &&
(couponListBean?.id ?? 0) != 0)
? 0
: ((pro.id ?? 0) ?? productId),
productSkuId ?? "",
actProductId ?? "",
actProductSkuId ?? "",
(((pro.id ?? 0) ?? (productId ?? 0)) == 0 ? ((couponListBean?.id ??0) != 0 ? "COUPON":"AUTO") : "ACTIVITY"),
(((pro.id ?? 0) ?? (productId ?? 0)) == 0
? ((couponListBean?.id ?? 0) != 0 ? "COUPON" : "AUTO")
: "ACTIVITY"),
// useVipPriceSelect,
// useBenefitSelect,
count1,
@ -1586,7 +1663,9 @@ class _Settlement extends State<Settlement> {
///
showDateSelector() {
var minTime = DateTime.now().isAfter(DateTime.tryParse(subscribeParam?.subscribeStartTime ?? "") ?? DateTime.now())
var minTime = DateTime.now().isAfter(
DateTime.tryParse(subscribeParam?.subscribeStartTime ?? "") ??
DateTime.now())
? DateTime.now()
: DateTime.tryParse(subscribeParam?.subscribeStartTime ?? "");
DatePicker.showDateTimePicker(context,
@ -1614,32 +1693,32 @@ class _Settlement extends State<Settlement> {
///
showAlertDialog() {
showModalBottomSheet(
builder: (BuildContext context) {
return StatefulBuilder(builder: (context, state) {
return Container(
width: double.infinity,
height: 300.h,
padding: EdgeInsets.symmetric(
horizontal: 14.w,
vertical: 16.h,
),
decoration: new BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8),
topRight: Radius.circular(8),
),
builder: (BuildContext context) {
return StatefulBuilder(builder: (context, state) {
return Container(
width: double.infinity,
height: 300.h,
padding: EdgeInsets.symmetric(
horizontal: 14.w,
vertical: 16.h,
),
decoration: new BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8),
topRight: Radius.circular(8),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: Container(
),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: Container(
alignment: Alignment.center,
margin: EdgeInsets.symmetric(vertical: 5.h),
child: Text(
@ -1650,72 +1729,74 @@ class _Settlement extends State<Settlement> {
color: Color(0xFF353535),
),
),
),),
GestureDetector(
),
),
GestureDetector(
onTap: () {
setState(() {
Navigator.of(context).pop();
});
},
child: Icon(
Icons.clear,
color: Colors.black,
size: 18,
),
),
// SizedBox(width:4.w),
],
),
Expanded(
child: ListView.builder(
itemCount: subscribeParam?.stores?.length ?? 0,
itemBuilder: (context, position) {
return GestureDetector(
onTap: () {
setState(() {
Navigator.of(context).pop();
state(() {
storesIndex = position;
});
},
child: Icon(
Icons.clear,
color: Colors.black,
size: 18,
),
),
// SizedBox(width:4.w),
],
child: storesNameItem(position),
);
},
),
Expanded(
child: ListView.builder(
itemCount: subscribeParam?.stores?.length ?? 0,
itemBuilder: (context, position) {
return GestureDetector(
onTap: () {
state(() {
storesIndex = position;
});
},
child: storesNameItem(position),
);
},
),
GestureDetector(
onTap: () {
setState(() {
subscribeStoresName =
subscribeParam?.stores?[storesIndex];
});
Navigator.of(context).pop();
},
child: Container(
width: double.infinity,
height: 40.h,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(100),
color: Color(0xFF32A060),
),
),
GestureDetector(
onTap: () {
setState(() {
subscribeStoresName = subscribeParam?.stores?[storesIndex];
});
Navigator.of(context).pop();
},
child: Container(
width: double.infinity,
height: 40.h,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(100),
color: Color(0xFF32A060),
),
alignment: Alignment.center,
margin: EdgeInsets.only(
bottom: 10.h,
),
child: Text(
S.of(context).queding,
style: TextStyle(
fontWeight: MyFontWeight.bold,
fontSize: 16.sp,
color: Color(0xFFFFFFFF),
),
alignment: Alignment.center,
margin: EdgeInsets.only(
bottom: 10.h,
),
child: Text(
S.of(context).queding,
style: TextStyle(
fontWeight: MyFontWeight.bold,
fontSize: 16.sp,
color: Color(0xFFFFFFFF),
),
),
),
],
),
);
});
},
backgroundColor: Colors.transparent,
context: context,
),
],
),
);
});
},
backgroundColor: Colors.transparent,
context: context,
);
}

85
lib/settlement/settlement_view/distribution.dart

@ -1,7 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart';
import 'package:flutter_bmflocation/flutter_bmflocation.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:geolocator/geolocator.dart';
import 'package:huixiang/data/address.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/data/store_info.dart';
@ -42,7 +41,7 @@ class _DistributionMode extends State<DistributionMode> {
"assets/svg/dingdan_wuliu.svg",
];
BMFCoordinate? myLatLng;
Position? myLatLng;
String distance = "0";
int selectedBtn = 0;
@ -55,28 +54,41 @@ class _DistributionMode extends State<DistributionMode> {
///
void startLocation() async {
Location.instance.startLocation(context, (BaiduLocation result) {
if (result.latitude != null &&
result.longitude != null) {
LocationInstance.getInstance().startLocation(context, (Position? result) {
if (result?.latitude != null && result?.longitude != null) {
print("location: $result");
myLatLng = BMFCoordinate(result.latitude!, result.longitude!);
myLatLng = Position(
latitude: result?.latitude ?? 0,
longitude: result?.longitude ?? 0,
timestamp: DateTime.now(),
accuracy: 0,
altitude: 0,
heading: 0,
speed: 0,
speedAccuracy: 0);
calculate();
Location.instance.stopLocation();
LocationInstance.getInstance().stopLocation();
}
});
}
calculate() async {
if (widget.storeInfo == null) {
return;
}
BMFCoordinate bmfCoordinate = BMFCoordinate(
double.tryParse("${widget.storeInfo!.latitude}") ?? 0,
double.tryParse("${widget.storeInfo!.longitude}") ?? 0,
Position? bmfCoordinate = Position(
latitude: double.tryParse(widget.storeInfo?.latitude ?? "")!,
longitude: double.tryParse(widget.storeInfo?.longitude ?? "")!,
timestamp: DateTime.now(),
accuracy: 0,
altitude: 0,
heading: 0,
speed: 0,
speedAccuracy: 0
);
if (myLatLng != null) {
distance = await AppUtils.calculateDistance(bmfCoordinate, myLatLng!);
}
distance = "${Geolocator.distanceBetween(
bmfCoordinate.latitude,
bmfCoordinate.longitude,
myLatLng!.latitude,
myLatLng!.longitude,
)}";
setState(() {});
}
@ -126,7 +138,8 @@ class _DistributionMode extends State<DistributionMode> {
onTap: () {
setState(() {
selectedBtn = 0;
widget.queryOrderInfo(null, selectedBtn, null, 0, null);
widget.queryOrderInfo(
null, selectedBtn, null, 0, null);
});
},
child: Container(
@ -161,7 +174,10 @@ class _DistributionMode extends State<DistributionMode> {
height: 50.h,
alignment: Alignment.center,
child: Text(
(widget.storeInfo?.pickupType?.takeawayStatus ?? false) ? "" :S.of(context).waimaipeisong,
(widget.storeInfo?.pickupType?.takeawayStatus ??
false)
? ""
: S.of(context).waimaipeisong,
style: TextStyle(
fontSize: 14.sp,
fontWeight: MyFontWeight.regular,
@ -189,7 +205,11 @@ class _DistributionMode extends State<DistributionMode> {
height: 50.h,
alignment: Alignment.center,
child: Text(
(widget.storeInfo?.pickupType?.expressDeliveryStatus ?? false) ? "" :S.of(context).kuaidiwuliu,
(widget.storeInfo?.pickupType
?.expressDeliveryStatus ??
false)
? ""
: S.of(context).kuaidiwuliu,
style: TextStyle(
fontSize: 14.sp,
fontWeight: MyFontWeight.regular,
@ -205,14 +225,16 @@ class _DistributionMode extends State<DistributionMode> {
selectedBtn == 0
? Container(
width: double.infinity,
padding: EdgeInsets.only(left: 16.w, right: 16.w, top: 15.h),
padding:
EdgeInsets.only(left: 16.w, right: 16.w, top: 15.h),
child: Column(
children: [
Row(
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
children: [
@ -270,9 +292,7 @@ class _DistributionMode extends State<DistributionMode> {
100)
.toInt() /
100.0))
: "距离您${(widget.distance ?? 0) > 1000 ?
"${((widget.distance ?? 0) / 1000 * 100).toInt() / 100.0}km"
: S.of(context).mi(((widget.distance ?? 0) * 100).toInt() / 100.0)}",
: "距离您${(widget.distance ?? 0) > 1000 ? "${((widget.distance ?? 0) / 1000 * 100).toInt() / 100.0}km" : S.of(context).mi(((widget.distance ?? 0) * 100).toInt() / 100.0)}",
// distance.length > 3
// ? "${distance}km"
// : "距离您${distance}km",
@ -311,7 +331,8 @@ class _DistributionMode extends State<DistributionMode> {
},
child: Container(
width: double.infinity,
padding: EdgeInsets.only(left: 16.w, right: 16.w, top: 15.h),
padding:
EdgeInsets.only(left: 16.w, right: 16.w, top: 15.h),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
@ -321,10 +342,14 @@ class _DistributionMode extends State<DistributionMode> {
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Image.asset(
(widget.storeInfo?.pickupType?.expressDeliveryStatus ?? false) ? "assets/image/order_wl.webp":"assets/image/icon_permission_location.webp",
height: 24.h,
width: 24.w,
),
(widget.storeInfo?.pickupType
?.expressDeliveryStatus ??
false)
? "assets/image/order_wl.webp"
: "assets/image/icon_permission_location.webp",
height: 24.h,
width: 24.w,
),
SizedBox(width: 5),
Text(
widget.address?.username ?? "",

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

@ -101,13 +101,16 @@ 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 ?? false) {
setState(() {
queryShopCar();
});
// setState(() {
queryShopCar();
// });
refreshController.refreshCompleted();
} else {
queryShopCar();
refreshController.refreshFailed();
}
refreshController.refreshFailed();
}
final SwiperController controller = SwiperController();

19
lib/store/store_order.dart

@ -910,9 +910,24 @@ class _StoreOrderPage extends State<StoreOrderPage>
await minService?.shoppingCartSingle(shopCarTemp);
if (baseDate?.isSuccess ?? false) {
this.shopCarGoods = await queryShopCar();
shopCartKey.currentState?.setState(() {});
setState(() {});
if (shopCartKey != null) {
shopCartKey.currentState?.setState(() {});
}
}else {
this.shopCarGoods = await queryShopCar();
if (shopCartKey != null) {
shopCartKey.currentState?.setState(() {});
}
if (baseDate != null
&& baseDate.msg != null
&& baseDate.msg != "") {
SmartDialog.showToast(
"${baseDate.msg}",
alignment: Alignment.center,
);
}
}
setState(() {});
return this.shopCarGoods;
}

7
lib/store/store_view/shop_car.dart

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

97
lib/store/store_view/store_info.dart

@ -1,5 +1,8 @@
import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:huixiang/data/store_info.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/utils/flutter_utils.dart';
@ -9,6 +12,8 @@ import 'package:huixiang/view_widget/custom_image.dart';
import 'package:huixiang/view_widget/round_button.dart';
import 'package:url_launcher/url_launcher.dart';
import '../../utils/location.dart';
class StoreInfoView extends StatefulWidget {
final StoreInfo? storeInfo;
final double? distance;
@ -161,15 +166,16 @@ class _StoreInfoView extends State<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
},
);
// Navigator.of(context).pushNamed(
// '/router/location_map',
// arguments: {
// "lat": widget.storeInfo?.latitude,
// "lng": widget.storeInfo?.longitude,
// "storeInfo":widget.storeInfo,
// "distance":widget.distance
// },
// );
showMapSelect();
},
child: Container(
color: Colors.transparent,
@ -185,15 +191,16 @@ class _StoreInfoView extends State<StoreInfoView> {
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
Navigator.of(context).pushNamed(
'/router/location_map',
arguments: {
"lat": widget.storeInfo?.latitude,
"lng": widget.storeInfo?.longitude,
"storeInfo":widget.storeInfo,
"distance":widget.distance
},
);
// Navigator.of(context).pushNamed(
// '/router/location_map',
// arguments: {
// "lat": widget.storeInfo?.latitude,
// "lng": widget.storeInfo?.longitude,
// "storeInfo":widget.storeInfo,
// "distance":widget.distance
// },
// );
showMapSelect();
},
child:Padding(
padding: EdgeInsets.only(bottom: 8.h,),
@ -295,4 +302,58 @@ class _StoreInfoView extends State<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,
);
}
});
});
}
}

2336
lib/union/location_map_page.dart

File diff suppressed because it is too large Load Diff

6
lib/union/union_list.dart

@ -1,8 +1,8 @@
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:geolocator/geolocator.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/data/store.dart';
import 'package:huixiang/utils/font_weight.dart';
@ -22,7 +22,7 @@ import '../view_widget/round_button.dart';
class UnionList extends StatefulWidget {
final String serviceType;
final BMFCoordinate? latLng;
final Position latLng;
final String? searchKey;
final String? city;
@ -38,7 +38,7 @@ class UnionList extends StatefulWidget {
class _UnionList extends State<UnionList> with AutomaticKeepAliveClientMixin {
ApiService? apiService;
List<Store>? storeList;
BMFCoordinate? latLng;
Position? latLng;
final RefreshController _refreshController = RefreshController();
int networkStatus = 0;

345
lib/union/union_page.dart

@ -1,9 +1,8 @@
import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_baidu_mapapi_utils/flutter_baidu_mapapi_utils.dart';
import 'package:flutter_bmflocation/flutter_bmflocation.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:geolocator/geolocator.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/main.dart';
import 'package:huixiang/data/ip_data.dart';
@ -15,9 +14,9 @@ import 'package:huixiang/view_widget/my_tab.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart';
import 'package:visibility_detector/visibility_detector.dart';
import '../data/address.dart';
import '../view_widget/location_tips.dart';
import '../view_widget/no_data_view.dart';
@ -40,7 +39,7 @@ class UnionPageState extends State<UnionPage>
final TextEditingController editingController = TextEditingController();
bool isKeyBoardShow = false;
TabController? tabController;
BMFCoordinate? latLng;
Position? latLng;
String? areaName;
List<GlobalKey> _allKey = [];
bool _isShowLocalTips = false;
@ -54,7 +53,7 @@ class UnionPageState extends State<UnionPage>
void dispose() {
super.dispose();
WidgetsBinding.instance.removeObserver(this);
Location.instance.aMapFlutterLocation.stopLocation();
// Location.instance.aMapFlutterLocation.stopLocation();
}
@override
@ -110,29 +109,33 @@ class UnionPageState extends State<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.instance.stopLocation();
});
powerFlag = await Location.instance.startLocation(context,
(BaiduLocation result) async {
if (result.latitude != null && result.longitude != null) {
powerFlag = await LocationInstance.getInstance().startLocation(context,
(Position? result) async {
if (result?.latitude != null && result?.longitude != null) {
print("location: $result");
latLng = BMFCoordinate(result.latitude!, result.longitude!);
latLng = await BMFCalculateUtils.coordConvert(
coordinate: latLng!,
fromType: BMF_COORD_TYPE.BD09LL,
toType: BMF_COORD_TYPE.COMMON);
await saveLatLng(latLng!, result.province, result.city, result.district);
print("union: Location result ${latLng!.latitude} "
"${latLng!.longitude}");
Location.instance.stopLocation();
latLng = Position(
latitude: result!.latitude,
longitude: result.longitude,
timestamp: DateTime.now(),
accuracy: 0,
altitude: 0,
heading: 0,
speed: 0,
speedAccuracy: 0
);
Address? address = await LocationInstance.getInstance()
.getAddress(result.latitude, result.longitude);
if (address != null) {
await saveLatLng(
latLng!, address.province, address.city, address.area);
}
LocationInstance.getInstance().stopLocation();
} else {
await getLatLng();
}
@ -151,7 +154,7 @@ class UnionPageState extends State<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}");
@ -167,9 +170,16 @@ class UnionPageState extends State<UnionPage>
tempLatLng.containsKey("province") &&
tempLatLng.containsKey("city") &&
tempLatLng.containsKey("district")) {
latLng = BMFCoordinate(
double.tryParse(tempLatLng.getString("latitude") ?? "0") ?? 0,
double.tryParse(tempLatLng.getString("longitude") ?? "0") ?? 0);
latLng = Position(
latitude: double.tryParse(tempLatLng.getString("latitude") ??"")!,
longitude: double.tryParse(tempLatLng.getString("longitude")??"")!,
timestamp: DateTime.now(),
accuracy: 0,
altitude: 0,
heading: 0,
speed: 0,
speedAccuracy: 0
);
}
}
@ -205,158 +215,155 @@ class UnionPageState extends State<UnionPage>
Widget build(BuildContext context) {
super.build(context);
return VisibilityDetector(
key: Key('my-widget-key'),
onVisibilityChanged: (visibilityInfo) {
visiblePercentage = visibilityInfo.visibleFraction;
if (visiblePercentage == 1) permissionSettings();
key: Key('my-widget-key'),
onVisibilityChanged: (visibilityInfo) {
visiblePercentage = visibilityInfo.visibleFraction;
if (visiblePercentage == 1) permissionSettings();
},
child: GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () {
FocusScope.of(context).requestFocus(FocusNode());
},
child: GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () {
FocusScope.of(context).requestFocus(FocusNode());
},
child: Stack(
alignment: Alignment.bottomCenter,
children: [
Container(
child: Column(
children: [
Row(
children: [
Padding(
padding: EdgeInsets.only(left: 18.w, right: 10.w),
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
Navigator.of(context).pushNamed(
'/router/union_select_city',
arguments: {
"cityName": areaName
}).then((value) {
if (value != null) {
areaName = "$value";
loadFinish();
}
});
},
child: Row(
children: [
Text(
areaName ?? "",
overflow: TextOverflow.ellipsis,
maxLines: 1,
style: TextStyle(
fontSize: 14.sp,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
Icon(
Icons.keyboard_arrow_down,
child: Stack(
alignment: Alignment.bottomCenter,
children: [
Container(
child: Column(
children: [
Row(
children: [
Padding(
padding: EdgeInsets.only(left: 18.w, right: 10.w),
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
Navigator.of(context).pushNamed(
'/router/union_select_city',
arguments: {
"cityName": areaName
}).then((value) {
if (value != null) {
areaName = "$value";
loadFinish();
}
});
},
child: Row(
children: [
Text(
areaName ?? "",
overflow: TextOverflow.ellipsis,
maxLines: 1,
style: TextStyle(
fontSize: 14.sp,
fontWeight: FontWeight.bold,
color: Colors.white,
size: 24,
)
],
),
),
),
Icon(
Icons.keyboard_arrow_down,
color: Colors.white,
size: 24,
)
],
),
),
Expanded(child: buildSearchItem())
],
),
Align(
alignment: Alignment.centerLeft,
child: TabBar(
controller: tabController,
isScrollable: true,
//
dividerHeight: 0,
dividerColor: Colors.transparent,
indicatorColor: Colors.white,
labelColor: Colors.white,
labelStyle: TextStyle(
fontSize: 18.sp,
fontWeight: FontWeight.bold,
),
unselectedLabelStyle: TextStyle(
fontSize: 15.sp,
fontWeight: FontWeight.normal,
),
//
unselectedLabelColor: Colors.white,
indicatorSize: TabBarIndicatorSize.label,
//
tabs: <Widget>[
MyTab(text: S.of(context).quanbu),
MyTab(text: S.of(context).chi),
MyTab(text: S.of(context).he),
MyTab(text: S.of(context).wan),
],
),
),
_allKey.isEmpty
? NoDataView(
src: "assets/image/di_zhi.webp",
isShowBtn: false,
text: "暂无店铺列表~",
fontSize: 16.sp,
margin: EdgeInsets.only(top: 120.h),
)
: Expanded(
child: TabBarView(
controller: tabController,
children: [
UnionList(
_allKey[0],
"",
latLng,
editingController.text,
areaName,
),
UnionList(_allKey[1], "EATSTORE", latLng,
editingController.text, areaName),
UnionList(_allKey[2], "DRINKSTORE", latLng,
editingController.text, areaName),
UnionList(_allKey[3], "HAPPYSTORE", latLng,
editingController.text, areaName),
],
),
)
],
),
padding: EdgeInsets.only(
top: MediaQuery.of(context).padding.top + 17.h,
),
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Color(0xFF32A060),
Color(0xFF32A060),
Colors.white,
Colors.white,
],
stops: [
0,
0.2,
0.4,
1
Expanded(child: buildSearchItem())
],
),
Align(
alignment: Alignment.centerLeft,
child: TabBar(
controller: tabController,
//tab排放方向
tabAlignment:TabAlignment.start,
isScrollable: true,
//
dividerHeight: 0,
dividerColor: Colors.transparent,
indicatorColor: Colors.white,
labelColor: Colors.white,
labelStyle: TextStyle(
fontSize: 18.sp,
fontWeight: FontWeight.bold,
),
unselectedLabelStyle: TextStyle(
fontSize: 15.sp,
fontWeight: FontWeight.normal,
),
//
unselectedLabelColor: Colors.white,
indicatorSize: TabBarIndicatorSize.label,
//
tabs: <Widget>[
MyTab(text: S.of(context).quanbu),
MyTab(text: S.of(context).chi),
MyTab(text: S.of(context).he),
MyTab(text: S.of(context).wan),
],
),
),
_allKey.isEmpty
? NoDataView(
src: "assets/image/di_zhi.webp",
isShowBtn: false,
text: "暂无店铺列表~",
fontSize: 16.sp,
margin: EdgeInsets.only(top: 120.h),
)
: Expanded(
child: TabBarView(
controller: tabController,
children: [
UnionList(
_allKey[0],
"",
latLng!,
editingController.text,
areaName,
),
UnionList(_allKey[1], "EATSTORE", latLng!,
editingController.text, areaName),
UnionList(_allKey[2], "DRINKSTORE", latLng!,
editingController.text, areaName),
UnionList(_allKey[3], "HAPPYSTORE", latLng!,
editingController.text, areaName),
],
),
)
],
),
padding: EdgeInsets.only(
top: MediaQuery.of(context).padding.top + 17.h,
),
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Color(0xFF32A060),
Color(0xFF32A060),
Colors.white,
Colors.white,
],
stops: [0, 0.2, 0.4, 1],
),
),
if (_isShowLocalTips)
Padding(
padding: EdgeInsets.only(bottom: 70.h),
child: LocationTips(() {
setState(() {
_isShowLocalTips = false;
});
}),
)
],
),
),
if (_isShowLocalTips)
Padding(
padding: EdgeInsets.only(bottom: 70.h),
child: LocationTips(() {
setState(() {
_isShowLocalTips = false;
});
}),
)
],
),
),
);
}

178
lib/union/union_view/store_info.dart

@ -1,5 +1,8 @@
import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:flutter_swiper_view/flutter_swiper_view.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/data/store_info.dart';
@ -10,6 +13,8 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:huixiang/view_widget/round_button.dart';
import 'package:url_launcher/url_launcher.dart';
import '../../utils/location.dart';
class StoreInfos extends StatefulWidget {
final StoreInfo? storeInfo;
@ -64,7 +69,9 @@ class _StoreInfos extends State<StoreInfos> {
Row(
children: [
Text(
S.of(context).ren(widget.storeInfo!.perCapitaConsumption ?? ""),
S
.of(context)
.ren(widget.storeInfo!.perCapitaConsumption ?? ""),
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 14.sp,
@ -76,7 +83,8 @@ class _StoreInfos extends State<StoreInfos> {
width: 22.w,
),
Row(
children: itemServer(widget.storeInfo?.businessService ?? ""),
children:
itemServer(widget.storeInfo?.businessService ?? ""),
),
],
),
@ -99,10 +107,11 @@ class _StoreInfos extends State<StoreInfos> {
Text(
S.of(context).yingyeshijian(widget.storeInfo == null
? ""
: ((widget.storeInfo!.openStartTime?.isEmpty ?? true) && (widget.storeInfo!.openEndTime?.isEmpty ?? true))
? S.of(context).quantian
: "${widget.storeInfo!.openStartTime!.substring(0, widget.storeInfo!.openStartTime!.lastIndexOf(":"))} "
"- ${widget.storeInfo!.openEndTime!.substring(0, widget.storeInfo!.openEndTime!.lastIndexOf(":"))}"),
: ((widget.storeInfo!.openStartTime?.isEmpty ?? true) &&
widget.storeInfo?.openEndTime == null)
? S.of(context).quantian
: "${widget.storeInfo?.openStartTime?.substring(0, widget.storeInfo?.openStartTime?.lastIndexOf(":"))} "
"- ${widget.storeInfo?.openEndTime?.substring(0, widget.storeInfo?.openEndTime?.lastIndexOf(":"))}"),
style: TextStyle(
color: Color(0xFF353535),
fontWeight: MyFontWeight.regular,
@ -130,14 +139,12 @@ class _StoreInfos extends State<StoreInfos> {
children: [
InkWell(
onTap: () {
if ((widget.storeInfo?.latitude?.isEmpty ?? true)||
(widget.storeInfo?.longitude?.isEmpty ?? true)) return;
Navigator.of(context)
.pushNamed('/router/location_map', arguments: {
"lat": widget.storeInfo!.latitude,
"lng": widget.storeInfo!.longitude,
"storeName": widget.storeInfo!.storeName,
});
if (widget.storeInfo == null ||
widget.storeInfo?.latitude == null ||
widget.storeInfo?.longitude == null ||
widget.storeInfo?.latitude == "" ||
widget.storeInfo?.longitude == "") return;
showMapSelect();
},
child: Image.asset(
"assets/image/icon_union_location.webp",
@ -338,32 +345,32 @@ class _StoreInfos extends State<StoreInfos> {
Widget buildSwiper() {
return Container(
child: Swiper(
pagination: SwiperPagination(
alignment: Alignment.bottomCenter,
builder: DotSwiperPaginationBuilder(
size: 8.w,
activeSize: 8.w,
space: 5.w,
activeColor: Colors.white,
color: Colors.white.withAlpha(76),
),
child: Swiper(
pagination: SwiperPagination(
alignment: Alignment.bottomCenter,
builder: DotSwiperPaginationBuilder(
size: 8.w,
activeSize: 8.w,
space: 5.w,
activeColor: Colors.white,
color: Colors.white.withAlpha(76),
),
),
itemBuilder: (context, position) {
return Container(
margin: EdgeInsets.only(left: 10.w, right: 10.w),
child: MImage(
(position < (widget.storeInfo!.bannerList?.length ?? 0))
? (widget.storeInfo!.bannerList![position].imgUrl ?? "")
: "",
fit: BoxFit.cover,
radius: BorderRadius.circular(4),
errorSrc: "assets/image/default_2_1.webp",
fadeSrc: "assets/image/default_2_1.webp",
),
itemBuilder: (context, position) {
return Container(
margin: EdgeInsets.only(left: 10.w, right: 10.w),
child: MImage(
(position < (widget.storeInfo!.bannerList?.length ?? 0))
? (widget.storeInfo!.bannerList![position].imgUrl ?? "")
: "",
fit: BoxFit.cover,
radius: BorderRadius.circular(4),
errorSrc: "assets/image/default_2_1.webp",
fadeSrc: "assets/image/default_2_1.webp",
),
);
},
itemCount: widget.storeInfo?.bannerList?.length ?? 1,
);
},
itemCount: widget.storeInfo?.bannerList?.length ?? 1,
));
}
@ -389,41 +396,94 @@ class _StoreInfos extends State<StoreInfos> {
}
showCallMobile() {
showCupertinoModalPopup(
context: context,
builder: (context) {
return CupertinoActionSheet(
title: Text(S.of(context).bodadianhua),
actions: [
if (widget.storeInfo?.tel?.isNotEmpty ?? false)
CupertinoActionSheetAction(
child: Text(widget.storeInfo!.tel ?? ""),
onPressed: () {
callMobile(widget.storeInfo!.tel);
Navigator.of(context).pop();
},
isDefaultAction: true,
isDestructiveAction: false,
),
],
cancelButton: CupertinoActionSheetAction(
onPressed: () {
Navigator.of(context).pop();
},
child: Text(S.of(context).quxiao),
isDestructiveAction: true,
),
);
},
);
}
callMobile(mobile) async {
String url = "tel:$mobile";
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}
showMapSelect() {
showCupertinoModalPopup(
context: context,
builder: (context) {
return CupertinoActionSheet(
title: Text(S.of(context).bodadianhua),
actions: [
if (widget.storeInfo?.tel?.isNotEmpty ?? false)
CupertinoActionSheetAction(
child: Text(widget.storeInfo!.tel ?? ""),
onPressed: () {
callMobile(widget.storeInfo!.tel);
Navigator.of(context).pop();
},
isDefaultAction: true,
isDestructiveAction: false,
CupertinoActionSheetAction(
child: Text(
"使用高德地图导航",
style: TextStyle(
fontWeight: MyFontWeight.regular,
),
),
onPressed: () {
onOpenBaiduMap();
Navigator.of(context).pop();
},
isDefaultAction: true,
isDestructiveAction: false,
),
],
cancelButton: CupertinoActionSheetAction(
onPressed: () {
Navigator.of(context).pop();
},
child: Text(S.of(context).quxiao),
child: Text(
S.of(context).quxiao,
style: TextStyle(
color: Colors.blue,
),
),
isDestructiveAction: true,
),
);
},
);
});
}
callMobile(mobile) async {
String url = "tel:$mobile";
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
void onOpenBaiduMap() async {
LocationInstance.getInstance().startLocation(context, (locationData) {
String url =
"${Platform.isIOS ? 'ios' : 'android'}amap://path?sourceApplication=haixia&sid="
"&slat=${locationData?.latitude.toStringAsFixed(8)}&slon=${locationData?.longitude.toStringAsFixed(8)}&sname=&did=&dlat=${widget.storeInfo?.latitude}&dlon=${widget.storeInfo?.longitude}&dname=&dev=0&t=0";
launch(url).then((value) {
if (!value) {
SmartDialog.showToast(
"未检测到安装高德地图",
alignment: Alignment.center,
);
}
});
});
}
}

37
lib/utils/flutter_utils.dart

@ -2,23 +2,20 @@ import 'dart:io';
import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart';
import 'package:flutter_baidu_mapapi_utils/flutter_baidu_mapapi_utils.dart';
import 'package:intl/intl.dart';
import 'package:path_provider/path_provider.dart';
class AppUtils {
///线
static Future<String> calculateDistance(
BMFCoordinate bmfCoordinate, BMFCoordinate myLatLng, {bool isMi = false}) async {
double? mi = await BMFCalculateUtils.getLocationDistance(bmfCoordinate, myLatLng);
if (mi == null) {
return "0";
}
NumberFormat numberFormat = NumberFormat("#.#");
return "${numberFormat.format(mi! / (isMi ? 1 :1000))}";
}
// ///线
// static Future<String> calculateDistance(
// BMFCoordinate bmfCoordinate, BMFCoordinate myLatLng, {bool isMi = false}) async {
// double? mi = await BMFCalculateUtils.getLocationDistance(bmfCoordinate, myLatLng);
// if (mi == null) {
// return "0";
// }
// NumberFormat numberFormat = NumberFormat("#.#");
// return "${numberFormat.format(mi! / (isMi ? 1 :1000))}";
// }
///
static double stringAsFixedDouble2(double value) {
@ -82,13 +79,13 @@ class AppUtils {
return resString;
}
///()
static Future<BMFCoordinate?> coordConvert(BMFCoordinate latLng) async {
// return BMFCalculateUtils.coordConvert(
// coordinate: latLng,
// fromType: BMF_COORD_TYPE.COMMON,
// toType: BMF_COORD_TYPE.BD09LL);
}
// ///()
// 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));
}
}

206
lib/utils/location.dart

@ -1,113 +1,60 @@
import 'dart:io';
import 'package:android_intent_plus/android_intent.dart';
import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bmflocation/flutter_bmflocation.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:geolocator/geolocator.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/view_widget/request_permission.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:intl/intl.dart';
import 'package:permission_handler/permission_handler.dart' as PH;
import '../data/address.dart';
import 'font_weight.dart';
BaiduLocationAndroidOption initAndroidOptions() {
BaiduLocationAndroidOption options = BaiduLocationAndroidOption(
//
locationMode: BMFLocationMode.hightAccuracy,
//
isNeedAddress: true,
//
isNeedAltitude: false,
// poi信息
isNeedLocationPoiList: false,
// rgc信息
isNeedNewVersionRgc: false,
//
isNeedLocationDescribe: true,
// 使gps
openGps: true,
//
locationPurpose: BMFLocationPurpose.signIn,
//
coordType: BMFLocationCoordType.bd09ll,
// int类型ms
// 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;
Location._internal() {
aMapFlutterLocation = LocationFlutterPlugin();
}
static Location get instance => _getInstance();
class LocationInstance {
static LocationInstance? _instance;
factory Location() => _getInstance();
LocationInstance._internal() {}
static Location _getInstance() {
_instance ??= Location._internal();
static LocationInstance getInstance() {
if (_instance == null) {
_instance = LocationInstance._internal();
}
return _instance!;
}
late LocationFlutterPlugin aMapFlutterLocation;
Future<bool> startLocation(
context, Function(BaiduLocation result) locationCallback) async {
aMapFlutterLocation.prepareLoc(
initAndroidOptions().getMap(), initIOSOptions().getMap());
var permissionStatus = await Permission.location.status;
if (!permissionStatus.isGranted) {
showTipsAlertDialog(context);
context, Function(Position? locationData) locationCallback) async {
LocationPermission permissionStatus = await Geolocator.checkPermission();
if (permissionStatus == LocationPermission.denied) {
permissionStatus = await Geolocator.requestPermission();
}
if (permissionStatus == LocationPermission.denied) {
showTipsAlertDialog(context);
return false;
}
if (permissionStatus == LocationPermission.deniedForever) {
showTipsAlertDialog(context);
return false;
} else {
aMapFlutterLocation.singleLocationCallback(
callback: (BaiduLocation result) {
locationCallback.call(result);
}
if (permissionStatus == LocationPermission.whileInUse ||
permissionStatus == LocationPermission.always) {
bool isNext = true;
Future.delayed(Duration(seconds: 5), () {
if (isNext) {
EasyLoading.dismiss();
}
});
if (Platform.isIOS) {
await aMapFlutterLocation.singleLocation({
'isReGeocode': true,
'isNetworkState': true,
});
} else if (Platform.isAndroid) {
await aMapFlutterLocation.startLocation();
}
return true;
Position locationData = await Geolocator.getCurrentPosition();
isNext = false;
locationCallback.call(locationData);
}
return true;
}
void stopLocation() {
aMapFlutterLocation.stopLocation();
}
void stopLocation() {}
enableLocation(context) {
showCupertinoDialog(
@ -118,12 +65,14 @@ class Location {
S.of(context).nindingweigongnengweikaiqi,
S.of(context).weilexiangnintuijianfujindemendianxinxi,
S.of(context).dakaidingwei,
(result) async {
(result) async {
if (result) {
final AndroidIntent intent = AndroidIntent(
action: 'action_location_source_settings',
package: "com.zsw.huixiang");
await intent.launch();
// final AndroidIntent intent = AndroidIntent(
// action: 'action_location_source_settings',
// package: "com.zsw.huixiang",
// );
// await intent.launch();
Geolocator.openLocationSettings();
// startLocation();
}
},
@ -133,7 +82,7 @@ class Location {
);
}
requestDialog(context, Function(BaiduLocation result) locationCallback) {
requestDialog(context, Function(Position? result) locationCallback) {
showCupertinoDialog(
context: context,
builder: (context) {
@ -142,10 +91,13 @@ class Location {
S.of(context).nindingweiquanxianweiyunxu,
S.of(context).weilexiangnintuijianfujindemendianxinxi,
S.of(context).kaiqiquanxian,
(result) async {
(result) async {
if (result) {
await openAppSettings();
if (await Permission.location.isGranted) {
await PH.openAppSettings();
if ((await Geolocator.checkPermission()) ==
LocationPermission.whileInUse ||
(await Geolocator.checkPermission()) ==
LocationPermission.always) {
startLocation(context, locationCallback);
}
}
@ -219,7 +171,7 @@ class Location {
);
},
);
await Permission.location.request();
Geolocator.requestPermission();
Navigator.of(context).pop();
}
@ -286,15 +238,18 @@ class Location {
margin: EdgeInsets.symmetric(
horizontal: 15.w, vertical: 25.h),
padding:
EdgeInsets.symmetric(vertical: 2.h, horizontal: 10.w),
EdgeInsets.symmetric(vertical: 2.h, horizontal: 10.w),
decoration: BoxDecoration(
color: Colors.green,
borderRadius: BorderRadius.circular(100),
),
),
onTap: () async {
await openAppSettings();
if (await Permission.location.isGranted)
await PH.openAppSettings();
if ((await Geolocator.checkPermission()) ==
LocationPermission.whileInUse ||
(await Geolocator.checkPermission()) ==
LocationPermission.always)
Navigator.of(context).pop();
},
behavior: HitTestBehavior.opaque,
@ -326,4 +281,45 @@ class Location {
},
);
}
}
///线
static Future<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;
}
}

13
lib/utils/upload_async.dart

@ -152,10 +152,19 @@ class UploadAsync {
thumbnail = element.thumbPath!;
} else {
var result = await ImageGallerySaver.saveFile(
element.path!,
file.path,
isReturnPathOfIOS: true,
);
thumbnail = element.path!;
if (result["isSuccess"] == true) {
thumbnail = element.thumbPath!;
} else {
thumbnail = element.thumbPath!;
}
// var result = await ImageGallerySaver.saveFile(
// element.path!,
// isReturnPathOfIOS: true,
// );
// thumbnail = element.path!;
// thumbnail = await Thumbnails.getThumbnail(
// videoFile: file.path,
// imageType: ThumbFormat.JPEG,

1
lib/vip/vip_page.dart

@ -54,6 +54,7 @@ class _VipPageState extends State<VipPage> with AutomaticKeepAliveClientMixin {
_refreshController.refreshCompleted();
_refreshController.loadComplete();
} else {
if(baseData?.msg != null)
SmartDialog.showToast(baseData?.msg ?? "", alignment: Alignment.center);
_refreshController.refreshFailed();
_refreshController.loadFailed();

17
lib/web/web_page.dart

@ -21,6 +21,7 @@ import 'package:shared_preferences/shared_preferences.dart';
import 'package:sharesdk_plugin/sharesdk_defines.dart';
import 'package:sharesdk_plugin/sharesdk_interface.dart';
import 'package:sharesdk_plugin/sharesdk_map.dart';
import 'package:dio/dio.dart';
class WebPage extends StatefulWidget {
final Map<String, dynamic>? arguments;
@ -57,7 +58,15 @@ class _WebPage extends State<WebPage> with WidgetsBindingObserver {
super.initState();
WidgetsBinding.instance.addObserver(this);
commentFocus.addListener(_focusNodeListener);
queryHtml();
SharedPreferences.getInstance().then((value) => {
apiService = ApiService(
Dio(),
context: context,
token: value.getString('token'),
showLoading: true
),
queryHtml()
});
}
bool isKeyBoardShow = false;
@ -129,13 +138,13 @@ class _WebPage extends State<WebPage> with WidgetsBindingObserver {
}
queryHtml() async {
SharedPreferences value = await SharedPreferences.getInstance();
// SharedPreferences value = await SharedPreferences.getInstance();
if (widget.arguments?["activityId"] != null) {
BaseData<Activity>? baseData = await apiService?.activityInfo(widget.arguments!["activityId"])
.catchError((onError) {});
if (baseData?.isSuccess ?? false) {
activity = baseData!.data;
activity = baseData?.data;
setState(() {});
}
}
@ -143,7 +152,7 @@ class _WebPage extends State<WebPage> with WidgetsBindingObserver {
BaseData<Article>? baseData = await apiService?.informationInfo(widget.arguments!["articleId"])
.catchError((onError) {});
if (baseData?.isSuccess ?? false) {
article = baseData!.data;
article = baseData?.data;
setState(() {});
}
}

16
lib/web/web_view/comment_list.dart

@ -1,3 +1,4 @@
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:huixiang/generated/l10n.dart';
@ -66,7 +67,15 @@ class CommentListState extends State<CommentList> {
@override
void initState() {
super.initState();
queryMemberCommentList();
SharedPreferences.getInstance().then((value) => {
apiService = ApiService(
Dio(),
context: context,
token: value.getString('token'),
showLoading: true
),
queryMemberCommentList()
});
}
@override
@ -111,7 +120,7 @@ class CommentListState extends State<CommentList> {
ListView.builder(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemCount: memberList?.length ?? 0,
itemCount: memberList.length ?? 0,
scrollDirection: Axis.vertical,
itemBuilder: (context, position) {
return Material(
@ -188,7 +197,6 @@ class CommentListState extends State<CommentList> {
//
queryMemberCommentList() async {
if (widget.relationalId?.isEmpty ?? true) return;
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
BaseData<PageInfo<MemberComment>>? baseData = await apiService?.memberCommentList({
"pageNum": 1,
"pageSize": 100,
@ -403,7 +411,7 @@ class CommentListState extends State<CommentList> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"${member.parentUserName}:" ?? "",
"${member.parentUserName ?? ""}:",
style: TextStyle(
fontSize: widget.fontSize,
color: Color(0xff808080),

4
lib/web/web_view/web_header.dart

@ -27,7 +27,7 @@ class _WebHeader extends State<WebHeader> {
padding: EdgeInsets.all(12),
alignment: Alignment.centerLeft,
child: Text(
widget.activity!.mainTitle ?? widget.article!.mainTitle ?? "",
widget.activity?.mainTitle ?? widget.article?.mainTitle ?? "",
style: TextStyle(
fontSize: widget.fontSize,
fontWeight: FontWeight.bold,
@ -84,7 +84,7 @@ class _WebHeader extends State<WebHeader> {
width: 10.w,
),
Text(
widget.activity!.createTime ?? widget.article!.createTime ?? "",
widget.activity?.createTime ?? widget.article?.createTime ?? "",
style: TextStyle(
fontWeight: FontWeight.normal,
fontSize: widget.fontSize - 4,

96
pubspec.lock

@ -257,22 +257,6 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.7.10"
device_info_plus:
dependency: transitive
description:
name: device_info_plus
sha256: "77f757b789ff68e4eaf9c56d1752309bd9f7ad557cb105b938a7f8eb89e59110"
url: "https://pub.flutter-io.cn"
source: hosted
version: "9.1.2"
device_info_plus_platform_interface:
dependency: transitive
description:
name: device_info_plus_platform_interface
sha256: d3b01d5868b50ae571cd1dc6e502fc94d956b665756180f7b16ead09e836fd64
url: "https://pub.flutter-io.cn"
source: hosted
version: "7.0.0"
dio:
dependency: "direct main"
description:
@ -374,46 +358,6 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_baidu_mapapi_base:
dependency: "direct main"
description:
name: flutter_baidu_mapapi_base
sha256: "24926c52eb057f25a7cdacb781e5387558773aa65ee351708efd3c83468e94cf"
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.7.2"
flutter_baidu_mapapi_map:
dependency: "direct main"
description:
name: flutter_baidu_mapapi_map
sha256: "28f5226538432e8e0aacd7e8828943272e0dbdc3c3a5e32fc31859a4f2dd52dc"
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.7.2"
flutter_baidu_mapapi_search:
dependency: "direct main"
description:
name: flutter_baidu_mapapi_search
sha256: "82007d3afd0a0bc8469ccb2e3c85b0f3881253eb144ec5a09ed5f48ca596cce3"
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.7.2"
flutter_baidu_mapapi_utils:
dependency: "direct main"
description:
name: flutter_baidu_mapapi_utils
sha256: "24486e8c10fb74b45162b5bc6315bc6fe5ea65e2b0d8be8f215ecf2a6e93e1b5"
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.7.2"
flutter_bmflocation:
dependency: "direct main"
description:
name: flutter_bmflocation
sha256: "74a9d96c4e95cbcd1c8dadc0d05004c48032bda1eee6fa2dbddf9ff0cfbd94f7"
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.6.0"
flutter_datetime_picker_plus:
dependency: "direct main"
description:
@ -483,14 +427,6 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_plugin_android_lifecycle:
dependency: transitive
description:
name: flutter_plugin_android_lifecycle
sha256: "8cf40eebf5dec866a6d1956ad7b4f7016e6c0cc69847ab946833b7d43743809f"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.19"
flutter_screenutil:
dependency: "direct main"
description:
@ -581,6 +517,30 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "4.0.0"
geolocator:
dependency: "direct main"
description:
name: geolocator
sha256: f659200283c62dffa4b7ea107bfe22eaa19c4490f94dc623986aad39caa1dd0d
url: "https://pub.flutter-io.cn"
source: hosted
version: "7.0.0"
geolocator_platform_interface:
dependency: transitive
description:
name: geolocator_platform_interface
sha256: "9d6f34a8a4b704d504f34acc5e52d880a7d2caedd99739902d6319179b0336d4"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.3.6"
geolocator_web:
dependency: transitive
description:
name: geolocator_web
sha256: "0b9e0ec13ce2211085cae0055b3516c975bd6cfe2878a20c8f13611f1a259855"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.6"
get:
dependency: "direct main"
description:
@ -1627,14 +1587,6 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "5.5.0"
win32_registry:
dependency: transitive
description:
name: win32_registry
sha256: "10589e0d7f4e053f2c61023a31c9ce01146656a70b7b7f0828c0b46d7da2a9bb"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.3"
xdg_directories:
dependency: transitive
description:

7
pubspec.yaml

@ -57,11 +57,8 @@ dependencies:
permission_handler: ^11.3.0
flutter_bmflocation: ^3.6.0
flutter_baidu_mapapi_base: ^3.6.0
flutter_baidu_mapapi_map: ^3.6.0
flutter_baidu_mapapi_search: ^3.6.0
flutter_baidu_mapapi_utils: ^3.6.0
geolocator: ^7.0.0
# location: ^3.2.4
dio: ^5.4.1
rxdart: ^0.27.07

Loading…
Cancel
Save