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. 15
      lib/store/store_order.dart
  4. 52
      lib/store/store_view/shop_car.dart

12
lib/retrofit/data/shoppingCart.dart

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

33
lib/retrofit/min_api.g.dart

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

15
lib/store/store_order.dart

@ -80,7 +80,7 @@ class _StoreOrderPage extends State<StoreOrderPage>
activitys, activitys,
), ),
]; ];
minLogin();
queryStoreInfo(); queryStoreInfo();
} }
@ -123,7 +123,6 @@ class _StoreOrderPage extends State<StoreOrderPage>
}); });
} }
/// ///
queryStoreInfo() async { queryStoreInfo() async {
final SharedPreferences value = await SharedPreferences.getInstance(); final SharedPreferences value = await SharedPreferences.getInstance();
@ -452,14 +451,18 @@ class _StoreOrderPage extends State<StoreOrderPage>
context: context, context: context,
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
builder: (context) { builder: (context) {
return ShopCar(productLists, _queryMiNiDetail, (ac, ap) { return ShopCar(
productLists,
_queryMiNiDetail,
(allCount, allPrice) {
setState(() { setState(() {
allCount = ac; this.allCount = allCount;
allPrice = ap; this.allPrice = allPrice;
});
}); });
}, },
); );
},
);
} }
/// ///

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