|
|
@ -1,7 +1,6 @@ |
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
import 'package:huixiang/generated/l10n.dart'; |
|
|
|
import 'package:huixiang/generated/l10n.dart'; |
|
|
|
import 'package:huixiang/retrofit/data/findMiNiGroupList.dart'; |
|
|
|
import 'package:huixiang/retrofit/data/findMiNiGroupList.dart'; |
|
|
|
import 'package:huixiang/retrofit/data/order_info.dart'; |
|
|
|
|
|
|
|
import 'package:huixiang/store/store_view/shop_goods.dart'; |
|
|
|
import 'package:huixiang/store/store_view/shop_goods.dart'; |
|
|
|
import 'package:huixiang/utils/font_weight.dart'; |
|
|
|
import 'package:huixiang/utils/font_weight.dart'; |
|
|
|
import 'package:huixiang/view_widget/round_button.dart'; |
|
|
|
import 'package:huixiang/view_widget/round_button.dart'; |
|
|
@ -11,7 +10,7 @@ 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(ProductListBean plb) fc; |
|
|
|
|
|
|
|
|
|
|
|
ShopCar(this.productLists, this.queryMiNiDetail, this.fc); |
|
|
|
ShopCar(this.productLists, this.queryMiNiDetail, this.fc); |
|
|
|
|
|
|
|
|
|
|
@ -23,6 +22,41 @@ class ShopCar extends StatefulWidget { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class _ShopCar extends State<ShopCar> { |
|
|
|
class _ShopCar extends State<ShopCar> { |
|
|
|
|
|
|
|
int allCount = 0; |
|
|
|
|
|
|
|
double allPrice = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
|
|
|
void initState() { |
|
|
|
|
|
|
|
super.initState(); |
|
|
|
|
|
|
|
_fc(null); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_fc(ProductListBean plb) { |
|
|
|
|
|
|
|
setState(() { |
|
|
|
|
|
|
|
if(plb != null){ |
|
|
|
|
|
|
|
allCount = 0; |
|
|
|
|
|
|
|
allPrice = 0; |
|
|
|
|
|
|
|
bool flag = false; |
|
|
|
|
|
|
|
for(var i = 0;i < widget.productLists.length;i++){ |
|
|
|
|
|
|
|
if(widget.productLists[i].id == plb.id){ |
|
|
|
|
|
|
|
flag = true; |
|
|
|
|
|
|
|
if(plb.buyNum == 0) |
|
|
|
|
|
|
|
widget.productLists.removeAt(i); |
|
|
|
|
|
|
|
else widget.productLists[i] = plb; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(!flag) |
|
|
|
|
|
|
|
widget.productLists.add(plb); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
widget.productLists.forEach((element) { |
|
|
|
|
|
|
|
allCount += element.buyNum; |
|
|
|
|
|
|
|
allPrice += double.parse(element.price) * |
|
|
|
|
|
|
|
element.buyNum; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@override |
|
|
|
Widget build(BuildContext context) { |
|
|
|
Widget build(BuildContext context) { |
|
|
|
return StatefulBuilder(builder: (context1, state) { |
|
|
|
return StatefulBuilder(builder: (context1, state) { |
|
|
@ -61,7 +95,10 @@ class _ShopCar extends State<ShopCar> { |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
InkWell( |
|
|
|
InkWell( |
|
|
|
onTap: () {}, |
|
|
|
onTap: () { |
|
|
|
|
|
|
|
state(() { |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}, |
|
|
|
child: Image.asset( |
|
|
|
child: Image.asset( |
|
|
|
"assets/image/delete.png", |
|
|
|
"assets/image/delete.png", |
|
|
|
width: 22, |
|
|
|
width: 22, |
|
|
@ -84,7 +121,10 @@ class _ShopCar extends State<ShopCar> { |
|
|
|
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, (plb){setState(() { |
|
|
|
|
|
|
|
_fc(plb); |
|
|
|
|
|
|
|
widget.fc(plb); |
|
|
|
|
|
|
|
});}), |
|
|
|
); |
|
|
|
); |
|
|
|
}, |
|
|
|
}, |
|
|
|
), |
|
|
|
), |
|
|
@ -118,7 +158,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, |
|
|
@ -126,16 +166,23 @@ class _ShopCar extends State<ShopCar> { |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
Spacer(), |
|
|
|
Spacer(), |
|
|
|
RoundButton( |
|
|
|
GestureDetector( |
|
|
|
width: 103.w, |
|
|
|
onTap: () { |
|
|
|
height: 54.h, |
|
|
|
Navigator.of(context).pushNamed( |
|
|
|
text: S.current.jiesuan, |
|
|
|
'/router/settlement', |
|
|
|
textColor: Colors.white, |
|
|
|
); |
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
}, |
|
|
|
backgroup: Color(0xFF32A060), |
|
|
|
child: RoundButton( |
|
|
|
radius: 0, |
|
|
|
width: 103.w, |
|
|
|
fontSize: 16.sp, |
|
|
|
height: 54.h, |
|
|
|
padding: EdgeInsets.symmetric(vertical: 5.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), |
|
|
|
|
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
@ -158,7 +205,7 @@ 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), |
|
|
|