|
|
@ -8,6 +8,7 @@ import 'package:huixiang/retrofit/data/order_info.dart'; |
|
|
|
import 'package:huixiang/retrofit/data/page.dart'; |
|
|
|
import 'package:huixiang/retrofit/data/page.dart'; |
|
|
|
import 'package:huixiang/retrofit/data/vip_card.dart'; |
|
|
|
import 'package:huixiang/retrofit/data/vip_card.dart'; |
|
|
|
import 'package:huixiang/retrofit/retrofit_api.dart'; |
|
|
|
import 'package:huixiang/retrofit/retrofit_api.dart'; |
|
|
|
|
|
|
|
import 'package:huixiang/utils/location.dart'; |
|
|
|
import 'package:huixiang/utils/painter_bg.dart'; |
|
|
|
import 'package:huixiang/utils/painter_bg.dart'; |
|
|
|
import 'package:huixiang/view_widget/custom_image.dart'; |
|
|
|
import 'package:huixiang/view_widget/custom_image.dart'; |
|
|
|
import 'package:huixiang/view_widget/my_appbar.dart'; |
|
|
|
import 'package:huixiang/view_widget/my_appbar.dart'; |
|
|
@ -34,52 +35,40 @@ class _VipDetailPage extends State<VipDetailPage> { |
|
|
|
void dispose() { |
|
|
|
void dispose() { |
|
|
|
super.dispose(); |
|
|
|
super.dispose(); |
|
|
|
refreshController.dispose(); |
|
|
|
refreshController.dispose(); |
|
|
|
|
|
|
|
Location.getInstance().stopLocation(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@override |
|
|
|
void initState() { |
|
|
|
void initState() { |
|
|
|
super.initState(); |
|
|
|
super.initState(); |
|
|
|
SharedPreferences.getInstance().then((value) { |
|
|
|
|
|
|
|
apiService = |
|
|
|
Location.getInstance().aMapFlutterLocation.onResultCallback().listen((event) { |
|
|
|
ApiService(Dio(), context: context, token: value.getString("token")); |
|
|
|
if (event != null && |
|
|
|
vipDetail(); |
|
|
|
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; |
|
|
|
VipCard vipCard; |
|
|
|
List<OrderInfo> orderInfos = []; |
|
|
|
|
|
|
|
final RefreshController refreshController = RefreshController(); |
|
|
|
final RefreshController refreshController = RefreshController(); |
|
|
|
int current = 1; |
|
|
|
int current = 1; |
|
|
|
|
|
|
|
|
|
|
|
vipDetail() async { |
|
|
|
vipDetail(latitude, longitude) async { |
|
|
|
BaseData baseData = await apiService |
|
|
|
BaseData baseData = await apiService.vipDetail({ |
|
|
|
.vipDetail(widget.arguments["id"]) |
|
|
|
"id": widget.arguments["id"], |
|
|
|
.catchError((onError) {}); |
|
|
|
"latitude": "$latitude", |
|
|
|
|
|
|
|
"longitude": "$longitude", |
|
|
|
|
|
|
|
}); |
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
vipCard = VipCard.fromMap(baseData.data); |
|
|
|
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(); |
|
|
|
refreshController.loadComplete(); |
|
|
|
if (current * 10 > int.tryParse(pageInfo.total)) { |
|
|
|
|
|
|
|
refreshController.loadNoData(); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
current += 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
setState(() {}); |
|
|
|
setState(() {}); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
refreshController.loadFailed(); |
|
|
|
refreshController.loadFailed(); |
|
|
@ -489,7 +478,14 @@ class _VipDetailPage extends State<VipDetailPage> { |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
Text(// "3.9km" |
|
|
|
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( |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 12.sp, |
|
|
|
fontSize: 12.sp, |
|
|
|
fontWeight: FontWeight.w400, |
|
|
|
fontWeight: FontWeight.w400, |
|
|
|