Browse Source

safety

master
fmk 3 years ago
parent
commit
f1fe091fad
  1. 12
      lib/retrofit/data/shoppingCart.dart
  2. 33
      lib/retrofit/min_api.g.dart
  3. 21
      lib/store/store_order.dart
  4. 72
      lib/store/store_view/shop_car.dart

12
lib/retrofit/data/shoppingCart.dart

@ -15,14 +15,14 @@ class ShoppingCart {
String storeName;
int tableId;
static ShoppingCart fromJon(Map<String, dynamic> map) {
static ShoppingCart fromJson(Map<String, dynamic> map) {
if (map == null) return null;
ShoppingCart shoppingCartBean = ShoppingCart();
shoppingCartBean.cartSum = map['cartSum'];
shoppingCartBean.numberOfPeople = map['numberOfPeople'];
shoppingCartBean.selected = map['selected'];
shoppingCartBean.shoppingCartSkuItemList = List()..addAll(
(map['shoppingCartSkuItemList'] as List ?? []).map((o) => ShoppingCartSkuItemListBean.fromJon(o))
shoppingCartBean.shoppingCartSkuItemList = []..addAll(
(map['shoppingCartSkuItemList'] as List ?? []).map((o) => ShoppingCartSkuItemListBean.fromJson(o))
);
shoppingCartBean.storeId = map['storeId'];
shoppingCartBean.storeName = map['storeName'];
@ -72,7 +72,7 @@ class ShoppingCartSkuItemListBean {
int storeId;
int tableId;
static ShoppingCartSkuItemListBean fromJon(Map<String, dynamic> map) {
static ShoppingCartSkuItemListBean fromJson(Map<String, dynamic> map) {
if (map == null) return null;
ShoppingCartSkuItemListBean shoppingCartSkuItemListBean = ShoppingCartSkuItemListBean();
shoppingCartSkuItemListBean.buyNum = map['buyNum'];
@ -80,7 +80,7 @@ class ShoppingCartSkuItemListBean {
shoppingCartSkuItemListBean.groupId = map['groupId'];
shoppingCartSkuItemListBean.id = map['id'];
shoppingCartSkuItemListBean.platterList = List()..addAll(
(map['platterList'] as List ?? []).map((o) => PlatterListBean.fromJon(o))
(map['platterList'] as List ?? []).map((o) => PlatterListBean.fromJson(o))
);
shoppingCartSkuItemListBean.productId = map['productId'];
shoppingCartSkuItemListBean.productName = map['productName'];
@ -125,7 +125,7 @@ class PlatterListBean {
bool required;
int skuId;
static PlatterListBean fromJon(Map<String, dynamic> map) {
static PlatterListBean fromJson(Map<String, dynamic> map) {
if (map == null) return null;
PlatterListBean platterListBean = PlatterListBean();
platterListBean.deleted = map['deleted'];

33
lib/retrofit/min_api.g.dart

@ -17,22 +17,18 @@ class _MinApiService implements MinApiService {
String baseUrl;
@override
Future<BaseData<List<FindMiNiGroupList>>> findMiNiGroupList(
param, header) async {
Future<BaseData<List<FindMiNiGroupList>>> findMiNiGroupList(param) async {
ArgumentError.checkNotNull(param, 'param');
ArgumentError.checkNotNull(header, 'header');
const _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _data = <String, dynamic>{};
_data.addAll(param ?? <String, dynamic>{});
final _header= <String, dynamic>{};
_header.addAll(header ?? <String,dynamic>{});
final _result = await _dio.request<Map<String, dynamic>>(
'product/findMiNiGroupList',
queryParameters: queryParameters,
options: RequestOptions(
method: 'POST',
headers: _header,
headers: <String, dynamic>{},
extra: _extra,
baseUrl: baseUrl),
data: _data);
@ -62,7 +58,30 @@ class _MinApiService implements MinApiService {
data: _data);
final value = BaseData<MiNiDetail>.fromJson(
_result.data,
(json) => MiNiDetail.fromMap(json),
(json) => MiNiDetail.fromJson(json),
);
return value;
}
@override
Future<BaseData<ShoppingCart>> shoppingCart(param, header) async {
ArgumentError.checkNotNull(param, 'param');
ArgumentError.checkNotNull(header, 'header');
const _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _data = <String, dynamic>{};
_data.addAll(param ?? <String, dynamic>{});
final _result = await _dio.request<Map<String, dynamic>>('shoppingcart',
queryParameters: queryParameters,
options: RequestOptions(
method: 'POST',
headers: <String, dynamic>{},
extra: _extra,
baseUrl: baseUrl),
data: _data);
final value = BaseData<ShoppingCart>.fromJson(
_result.data,
(json) => ShoppingCart.fromJson(json),
);
return value;
}

21
lib/store/store_order.dart

@ -80,7 +80,7 @@ class _StoreOrderPage extends State<StoreOrderPage>
activitys,
),
];
minLogin();
queryStoreInfo();
}
@ -108,7 +108,7 @@ class _StoreOrderPage extends State<StoreOrderPage>
String minToken = minStoreInfo["token"];
String tenant = widget.arguments["tenant"];
SharedPreferences.getInstance().then(
(value) => {
(value) => {
value.setString('minToken', minToken),
value.setString('tenant', tenant),
},
@ -123,7 +123,6 @@ class _StoreOrderPage extends State<StoreOrderPage>
});
}
///
queryStoreInfo() async {
final SharedPreferences value = await SharedPreferences.getInstance();
@ -452,12 +451,16 @@ class _StoreOrderPage extends State<StoreOrderPage>
context: context,
backgroundColor: Colors.transparent,
builder: (context) {
return ShopCar(productLists, _queryMiNiDetail, (ac, ap) {
setState(() {
allCount = ac;
allPrice = ap;
});
});
return ShopCar(
productLists,
_queryMiNiDetail,
(allCount, allPrice) {
setState(() {
this.allCount = allCount;
this.allPrice = allPrice;
});
},
);
},
);
}

72
lib/store/store_view/shop_car.dart

@ -8,21 +8,27 @@ import 'package:huixiang/view_widget/round_button.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class ShopCar extends StatefulWidget {
final List<ProductListBean> productLists;
final Function(String id) queryMiNiDetail;
final Function(int allCount, double allPrice) fc;
ShopCar(this.productLists, this.queryMiNiDetail, this.fc);
ShopCar(
this.productLists,
this.queryMiNiDetail,
this.fc,
);
@override
State<StatefulWidget> createState() {
return _ShopCar();
}
}
class _ShopCar extends State<ShopCar> {
int allCount;
double allPrice;
@override
Widget build(BuildContext context) {
return StatefulBuilder(builder: (context1, state) {
@ -32,8 +38,9 @@ class _ShopCar extends State<ShopCar> {
height: MediaQuery.of(context).size.height / 2,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.vertical(
top: Radius.circular(8),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8),
topRight: Radius.circular(8),
),
),
child: Column(
@ -78,12 +85,25 @@ class _ShopCar extends State<ShopCar> {
right: 16,
),
child: ListView.builder(
itemCount: widget.productLists == null ? 0 : widget.productLists.length,
itemCount: widget.productLists == null
? 0
: widget.productLists.length,
physics: BouncingScrollPhysics(),
itemBuilder: (context, position) {
return GestureDetector(
onTap: () {},
child: ShopGoods(widget.productLists, position, widget.queryMiNiDetail, widget.fc),
child: ShopGoods(
widget.productLists,
position,
widget.queryMiNiDetail,
(int allCount, double allPrice){
widget.fc(allCount, allPrice);
setState(() {
this.allCount = allCount;
this.allPrice = allPrice;
});
},
),
);
},
),
@ -117,7 +137,7 @@ class _ShopCar extends State<ShopCar> {
),
),
Text(
"19.00",
"" + allPrice.toString(),
style: TextStyle(
fontSize: 20.sp,
fontWeight: MyFontWeight.medium,
@ -125,16 +145,24 @@ class _ShopCar extends State<ShopCar> {
),
),
Spacer(),
RoundButton(
width: 103.w,
height: 54.h,
text: S.current.jiesuan,
textColor: Colors.white,
fontWeight: MyFontWeight.regular,
backgroup: Color(0xFF32A060),
radius: 0,
fontSize: 16.sp,
padding: EdgeInsets.symmetric(vertical: 5.h),
GestureDetector(
onTap: () {
Navigator.of(context).pushNamed(
'/router/settlement',
arguments: {},
);
},
child: RoundButton(
width: 103.w,
height: 54.h,
text: S.current.jiesuan,
textColor: Colors.white,
fontWeight: MyFontWeight.regular,
backgroup: Color(0xFF32A060),
radius: 0,
fontSize: 16.sp,
padding: EdgeInsets.symmetric(vertical: 5.h),
),
),
],
),
@ -157,15 +185,14 @@ class _ShopCar extends State<ShopCar> {
child: RoundButton(
width: 17,
height: 17,
text: "1",
text: allCount.toString(),
textColor: Colors.white,
fontWeight: MyFontWeight.regular,
backgroup: Color(0xFF32A060),
fontSize: 12.sp,
radius: 100,
callback: () {
Navigator.of(context)
.pushNamed('/router/test_page');
Navigator.of(context).pushNamed('/router/test_page');
},
),
),
@ -178,5 +205,4 @@ class _ShopCar extends State<ShopCar> {
);
});
}
}
}

Loading…
Cancel
Save