Browse Source

UI

null_safety
fmk 3 years ago
parent
commit
cad2155388
  1. 5
      lib/mine/vip_card_page.dart
  2. 60
      lib/mine/vip_detail_page.dart
  3. 3
      lib/retrofit/data/vip_card.dart
  4. 16
      lib/retrofit/retrofit_api.dart
  5. 2
      lib/union/location_map_page.dart
  6. 7
      lib/utils/location.dart
  7. 12
      lib/view_widget/icon_text.dart

5
lib/mine/vip_card_page.dart

@ -31,8 +31,7 @@ class _VipCardPage extends State<VipCardPage> {
_refreshController = RefreshController(); _refreshController = RefreshController();
SharedPreferences.getInstance().then((value) { SharedPreferences.getInstance().then((value) {
apiService = apiService = ApiService(Dio(), context: context, token: value.getString("token"));
ApiService(Dio(), context: context, token: value.getString("token"));
queryVipCard(); queryVipCard();
}); });
} }
@ -40,7 +39,7 @@ class _VipCardPage extends State<VipCardPage> {
List<VipCard> coupons = []; List<VipCard> coupons = [];
queryVipCard() async { queryVipCard() async {
BaseData baseData = await apiService.vipList().catchError((error) { BaseData baseData = await apiService.vipList({}).catchError((error) {
_refreshController.refreshFailed(); _refreshController.refreshFailed();
}); });
if (baseData != null && baseData.isSuccess) { if (baseData != null && baseData.isSuccess) {

60
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/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,

3
lib/retrofit/data/vip_card.dart

@ -196,6 +196,7 @@ class StoreListBean {
String businessType; String businessType;
dynamic deliveryInfo; dynamic deliveryInfo;
dynamic miniParam; dynamic miniParam;
dynamic distance;
int isDelete; int isDelete;
PosTypeBean posType; PosTypeBean posType;
@ -233,6 +234,7 @@ class StoreListBean {
storeListBean.businessType = map['businessType']; storeListBean.businessType = map['businessType'];
storeListBean.deliveryInfo = map['deliveryInfo']; storeListBean.deliveryInfo = map['deliveryInfo'];
storeListBean.miniParam = map['miniParam']; storeListBean.miniParam = map['miniParam'];
storeListBean.distance = map['distance'];
storeListBean.isDelete = map['is_delete']; storeListBean.isDelete = map['is_delete'];
storeListBean.posType = PosTypeBean.fromMap(map['posType']); storeListBean.posType = PosTypeBean.fromMap(map['posType']);
return storeListBean; return storeListBean;
@ -270,6 +272,7 @@ class StoreListBean {
"businessType": businessType, "businessType": businessType,
"deliveryInfo": deliveryInfo, "deliveryInfo": deliveryInfo,
"miniParam": miniParam, "miniParam": miniParam,
"distance": distance,
"is_delete": isDelete, "is_delete": isDelete,
"posType": posType, "posType": posType,
}; };

16
lib/retrofit/retrofit_api.dart

@ -14,11 +14,11 @@ import 'package:shared_preferences/shared_preferences.dart';
part 'retrofit_api.g.dart'; part 'retrofit_api.g.dart';
const base_url = "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 baseUrl = "https://pos.platform.lotus-wallet.com/app/"; ///
// const base_url = "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/"; const baseUrl = "http://192.168.10.236:8766/app/";
/// ///
@ -285,12 +285,12 @@ abstract class ApiService {
Future<BaseData> receiveToCard(@Path("id") String id); Future<BaseData> receiveToCard(@Path("id") String id);
/// ///
@GET("/member/vipList") @POST("/member/vipList")
Future<BaseData> vipList(); Future<BaseData> vipList(@Body() Map<String, dynamic> param);
/// ///
@GET("/member/vipDetail/{id}") @POST("/member/vipDetail")
Future<BaseData> vipDetail(@Path("id") String id); Future<BaseData> vipDetail(@Body() Map<String, dynamic> param);
///App消息列表 ///App消息列表
@POST("/app-msg/list") @POST("/app-msg/list")

2
lib/union/location_map_page.dart

@ -72,7 +72,7 @@ class _LocationMap extends State<LocationMap> {
@override @override
void dispose() { void dispose() {
super.dispose(); super.dispose();
Location.getInstance().sotpLocation(); Location.getInstance().stopLocation();
} }
@override @override

7
lib/utils/location.dart

@ -51,20 +51,15 @@ class Location {
Future<void> startLocation(context) async { Future<void> startLocation(context) async {
if (!(await Permission.locationWhenInUse.serviceStatus.isEnabled)) { if (!(await Permission.locationWhenInUse.serviceStatus.isEnabled)) {
enableLocation(context); enableLocation(context);
print("object1111");
return; return;
} }
if (await Permission.location.isPermanentlyDenied) { if (await Permission.location.isPermanentlyDenied) {
requestDialog(context); requestDialog(context);
print("object2222");
} else if (await Permission.location.isGranted) { } else if (await Permission.location.isGranted) {
aMapFlutterLocation.startLocation(); aMapFlutterLocation.startLocation();
print("object3333");
} else if (await Permission.location.isUndetermined) { } else if (await Permission.location.isUndetermined) {
await Permission.location.request(); await Permission.location.request();
print("object44444");
} else { } else {
print("object5555");
if (Platform.isIOS) { if (Platform.isIOS) {
// //
requestDialog(context); requestDialog(context);
@ -74,7 +69,7 @@ class Location {
} }
} }
void sotpLocation() { void stopLocation() {
aMapFlutterLocation.stopLocation(); aMapFlutterLocation.stopLocation();
} }

12
lib/view_widget/icon_text.dart

@ -46,7 +46,11 @@ class IconText extends StatelessWidget {
} else if (leftImage != null && leftImage != "") { } else if (leftImage != null && leftImage != "") {
widgets.add(Padding( widgets.add(Padding(
padding: EdgeInsets.only(left: 2), padding: EdgeInsets.only(left: 2),
child: Image.asset( child: leftImage.startsWith("http") ? Image.network(
leftImage,
width: iconSize,
height: iconSize,
) : Image.asset(
leftImage, leftImage,
width: iconSize, width: iconSize,
height: iconSize, height: iconSize,
@ -91,7 +95,11 @@ class IconText extends StatelessWidget {
widgets.add( widgets.add(
Padding( Padding(
padding: EdgeInsets.only(left: 2), padding: EdgeInsets.only(left: 2),
child: Image.asset( child: rightImage.startsWith("http") ? Image.network(
rightImage,
width: iconSize,
height: iconSize,
) : Image.asset(
rightImage, rightImage,
width: iconSize, width: iconSize,
height: iconSize, height: iconSize,

Loading…
Cancel
Save