diff --git a/lib/mine/vip_card_page.dart b/lib/mine/vip_card_page.dart index 2202bced..4d4ed724 100644 --- a/lib/mine/vip_card_page.dart +++ b/lib/mine/vip_card_page.dart @@ -31,8 +31,7 @@ class _VipCardPage extends State { _refreshController = RefreshController(); SharedPreferences.getInstance().then((value) { - apiService = - ApiService(Dio(), context: context, token: value.getString("token")); + apiService = ApiService(Dio(), context: context, token: value.getString("token")); queryVipCard(); }); } @@ -40,7 +39,7 @@ class _VipCardPage extends State { List coupons = []; queryVipCard() async { - BaseData baseData = await apiService.vipList().catchError((error) { + BaseData baseData = await apiService.vipList({}).catchError((error) { _refreshController.refreshFailed(); }); if (baseData != null && baseData.isSuccess) { diff --git a/lib/mine/vip_detail_page.dart b/lib/mine/vip_detail_page.dart index e2d4c11e..099f2484 100644 --- a/lib/mine/vip_detail_page.dart +++ b/lib/mine/vip_detail_page.dart @@ -8,6 +8,7 @@ import 'package:huixiang/retrofit/data/order_info.dart'; import 'package:huixiang/retrofit/data/page.dart'; import 'package:huixiang/retrofit/data/vip_card.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; +import 'package:huixiang/utils/location.dart'; import 'package:huixiang/utils/painter_bg.dart'; import 'package:huixiang/view_widget/custom_image.dart'; import 'package:huixiang/view_widget/my_appbar.dart'; @@ -34,52 +35,40 @@ class _VipDetailPage extends State { void dispose() { super.dispose(); refreshController.dispose(); + Location.getInstance().stopLocation(); } @override void initState() { super.initState(); - SharedPreferences.getInstance().then((value) { - apiService = - ApiService(Dio(), context: context, token: value.getString("token")); - vipDetail(); + + Location.getInstance().aMapFlutterLocation.onResultCallback().listen((event) { + if (event != null && + event["latitude"] != null && + event["longitude"] != null) { + SharedPreferences.getInstance().then((value) { + apiService = ApiService(Dio(), context: context, token: value.getString("token")); + vipDetail(event["latitude"], event["longitude"]); + }); + } }); + Location.getInstance().prepareLoc(); + Location.getInstance().startLocation(context); } VipCard vipCard; - List orderInfos = []; final RefreshController refreshController = RefreshController(); int current = 1; - vipDetail() async { - BaseData baseData = await apiService - .vipDetail(widget.arguments["id"]) - .catchError((onError) {}); + vipDetail(latitude, longitude) async { + BaseData baseData = await apiService.vipDetail({ + "id": widget.arguments["id"], + "latitude": "$latitude", + "longitude": "$longitude", + }); if (baseData != null && baseData.isSuccess) { vipCard = VipCard.fromMap(baseData.data); - setState(() {}); - } - - BaseData order = await apiService.orderList({ - "current": current, - "model": {"status": 0, "storeId": vipCard.tenantCode}, - "order": "descending", - "size": 10, - "sort": "id" - }); - if (order != null && order.isSuccess) { - PageInfo pageInfo = PageInfo.fromJson(order.data); - if (current == 1) { - orderInfos.clear(); - } - orderInfos - .addAll(pageInfo.records.map((e) => OrderInfo.fromJson(e)).toList()); refreshController.loadComplete(); - if (current * 10 > int.tryParse(pageInfo.total)) { - refreshController.loadNoData(); - } else { - current += 1; - } setState(() {}); } else { refreshController.loadFailed(); @@ -489,7 +478,14 @@ class _VipDetailPage extends State { ), ), Text(// "3.9km" - "3.9km", + (store.distance ?? 0) > 1000 + ? S.of(context).gongli( + ((store.distance ?? 0) / 1000 * 100) + .toInt() / + 100.0) + : S.of(context).mi( + ((store.distance ?? 0) * 100).toInt() / + 100.0), style: TextStyle( fontSize: 12.sp, fontWeight: FontWeight.w400, diff --git a/lib/retrofit/data/vip_card.dart b/lib/retrofit/data/vip_card.dart index 9c2d2f31..850fea0e 100644 --- a/lib/retrofit/data/vip_card.dart +++ b/lib/retrofit/data/vip_card.dart @@ -196,6 +196,7 @@ class StoreListBean { String businessType; dynamic deliveryInfo; dynamic miniParam; + dynamic distance; int isDelete; PosTypeBean posType; @@ -233,6 +234,7 @@ class StoreListBean { storeListBean.businessType = map['businessType']; storeListBean.deliveryInfo = map['deliveryInfo']; storeListBean.miniParam = map['miniParam']; + storeListBean.distance = map['distance']; storeListBean.isDelete = map['is_delete']; storeListBean.posType = PosTypeBean.fromMap(map['posType']); return storeListBean; @@ -270,6 +272,7 @@ class StoreListBean { "businessType": businessType, "deliveryInfo": deliveryInfo, "miniParam": miniParam, + "distance": distance, "is_delete": isDelete, "posType": posType, }; diff --git a/lib/retrofit/retrofit_api.dart b/lib/retrofit/retrofit_api.dart index 48adb96b..c1006d55 100644 --- a/lib/retrofit/retrofit_api.dart +++ b/lib/retrofit/retrofit_api.dart @@ -14,11 +14,11 @@ import 'package:shared_preferences/shared_preferences.dart'; part 'retrofit_api.g.dart'; -const base_url = "https://pos.platform.lotus-wallet.com/app/"; ///正式 -const baseUrl = "https://pos.platform.lotus-wallet.com/app/"; ///正式 +// const base_url = "https://pos.platform.lotus-wallet.com/app/"; ///正式 +// const baseUrl = "https://pos.platform.lotus-wallet.com/app/"; ///正式 -// const base_url = "http://192.168.10.236:8766/app/"; -// const baseUrl = "http://192.168.10.236:8766/app/"; +const base_url = "http://192.168.10.236:8766/app/"; +const baseUrl = "http://192.168.10.236:8766/app/"; /// 本地 @@ -285,12 +285,12 @@ abstract class ApiService { Future receiveToCard(@Path("id") String id); ///会员卡列表 - @GET("/member/vipList") - Future vipList(); + @POST("/member/vipList") + Future vipList(@Body() Map param); ///会员卡详情 - @GET("/member/vipDetail/{id}") - Future vipDetail(@Path("id") String id); + @POST("/member/vipDetail") + Future vipDetail(@Body() Map param); ///分页查询App消息列表 @POST("/app-msg/list") diff --git a/lib/union/location_map_page.dart b/lib/union/location_map_page.dart index 33b219ea..82f09994 100644 --- a/lib/union/location_map_page.dart +++ b/lib/union/location_map_page.dart @@ -72,7 +72,7 @@ class _LocationMap extends State { @override void dispose() { super.dispose(); - Location.getInstance().sotpLocation(); + Location.getInstance().stopLocation(); } @override diff --git a/lib/utils/location.dart b/lib/utils/location.dart index 0468b758..3d237e58 100644 --- a/lib/utils/location.dart +++ b/lib/utils/location.dart @@ -51,20 +51,15 @@ class Location { Future startLocation(context) async { if (!(await Permission.locationWhenInUse.serviceStatus.isEnabled)) { enableLocation(context); - print("object1111"); return; } if (await Permission.location.isPermanentlyDenied) { requestDialog(context); - print("object2222"); } else if (await Permission.location.isGranted) { aMapFlutterLocation.startLocation(); - print("object3333"); } else if (await Permission.location.isUndetermined) { await Permission.location.request(); - print("object44444"); } else { - print("object5555"); if (Platform.isIOS) { //去设置中心 requestDialog(context); @@ -74,7 +69,7 @@ class Location { } } - void sotpLocation() { + void stopLocation() { aMapFlutterLocation.stopLocation(); } diff --git a/lib/view_widget/icon_text.dart b/lib/view_widget/icon_text.dart index b4480fa3..d7159535 100644 --- a/lib/view_widget/icon_text.dart +++ b/lib/view_widget/icon_text.dart @@ -46,7 +46,11 @@ class IconText extends StatelessWidget { } else if (leftImage != null && leftImage != "") { widgets.add(Padding( padding: EdgeInsets.only(left: 2), - child: Image.asset( + child: leftImage.startsWith("http") ? Image.network( + leftImage, + width: iconSize, + height: iconSize, + ) : Image.asset( leftImage, width: iconSize, height: iconSize, @@ -91,7 +95,11 @@ class IconText extends StatelessWidget { widgets.add( Padding( padding: EdgeInsets.only(left: 2), - child: Image.asset( + child: rightImage.startsWith("http") ? Image.network( + rightImage, + width: iconSize, + height: iconSize, + ) : Image.asset( rightImage, width: iconSize, height: iconSize,