|
|
|
@ -84,17 +84,18 @@ class _ProductMealsSku extends State<ProductMealsSku> {
|
|
|
|
|
|
|
|
|
|
///添加购物车 |
|
|
|
|
addShopCar() async { |
|
|
|
|
|
|
|
|
|
List<dynamic> setMealDataList = []; |
|
|
|
|
productSetMeals.forEach((element) { |
|
|
|
|
List<dynamic> productInfoListBean = []; |
|
|
|
|
element.productInfoList.forEach((ele) { |
|
|
|
|
if(ele.count > 0) |
|
|
|
|
if (ele.count > 0) { |
|
|
|
|
productInfoListBean.add({ |
|
|
|
|
"productId": ele.productId, |
|
|
|
|
"skuId":(ele.productAttrInfoList[0].attrName == "") ? (ele.skuInfoList[0].productSkuAttrList[0].skuId): |
|
|
|
|
(ele.skuInfoList.firstWhere((e1) => e1.skuName == ele.productAttrInfoList[0].selectSku).id) |
|
|
|
|
"skuId": ele.skuInfoList.length == 1 |
|
|
|
|
? ele.skuInfoList.first.id |
|
|
|
|
: ele.skuInfoList.firstWhere((e2) => e2.isSelected).id |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
setMealDataList.add({ |
|
|
|
|
"groupName": element.groupName, |
|
|
|
@ -119,7 +120,8 @@ class _ProductMealsSku extends State<ProductMealsSku> {
|
|
|
|
|
], |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
BaseData<List<ShoppingCart>> baseDate = await minService.addShoppingCart(requestData); |
|
|
|
|
BaseData<List<ShoppingCart>> baseDate = |
|
|
|
|
await minService.addShoppingCart(requestData); |
|
|
|
|
EasyLoading.dismiss(); |
|
|
|
|
if (baseDate != null && baseDate.isSuccess) { |
|
|
|
|
Navigator.of(context).pop(); |
|
|
|
@ -210,8 +212,7 @@ class _ProductMealsSku extends State<ProductMealsSku> {
|
|
|
|
|
shrinkWrap: true, |
|
|
|
|
padding: EdgeInsets.zero, |
|
|
|
|
itemBuilder: (context, position) { |
|
|
|
|
return productMealsList( |
|
|
|
|
position); |
|
|
|
|
return productMealsList(position); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
@ -335,7 +336,10 @@ class _ProductMealsSku extends State<ProductMealsSku> {
|
|
|
|
|
children: [ |
|
|
|
|
Expanded( |
|
|
|
|
child: Text( |
|
|
|
|
productSetMeals[position].productInfoList[index].productName ?? "", |
|
|
|
|
productSetMeals[position] |
|
|
|
|
.productInfoList[index] |
|
|
|
|
.productName ?? |
|
|
|
|
"", |
|
|
|
|
overflow: TextOverflow.ellipsis, |
|
|
|
|
maxLines: 1, |
|
|
|
|
style: TextStyle( |
|
|
|
@ -345,7 +349,11 @@ class _ProductMealsSku extends State<ProductMealsSku> {
|
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
if (productSetMeals[position].productInfoList[index].productAttrInfoList[0].attrName != "") |
|
|
|
|
if (productSetMeals[position] |
|
|
|
|
.productInfoList[index] |
|
|
|
|
.productAttrInfoList[0] |
|
|
|
|
.attrName != |
|
|
|
|
"") |
|
|
|
|
GestureDetector( |
|
|
|
|
child: Text( |
|
|
|
|
"选规格", |
|
|
|
@ -359,7 +367,11 @@ class _ProductMealsSku extends State<ProductMealsSku> {
|
|
|
|
|
showSkuDialog(position, index); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
if (productSetMeals[position].productInfoList[index].productAttrInfoList[0].attrName != "") |
|
|
|
|
if (productSetMeals[position] |
|
|
|
|
.productInfoList[index] |
|
|
|
|
.productAttrInfoList[0] |
|
|
|
|
.attrName != |
|
|
|
|
"") |
|
|
|
|
GestureDetector( |
|
|
|
|
onTap: () { |
|
|
|
|
showSkuDialog(position, index); |
|
|
|
@ -375,10 +387,20 @@ class _ProductMealsSku extends State<ProductMealsSku> {
|
|
|
|
|
SizedBox(height: 8.h), |
|
|
|
|
Row( |
|
|
|
|
children: [ |
|
|
|
|
if (productSetMeals[position].productInfoList[index].productAttrInfoList[0].attrName != "" |
|
|
|
|
&& productSetMeals[position].productInfoList[index].count > 0) |
|
|
|
|
if (productSetMeals[position] |
|
|
|
|
.productInfoList[index] |
|
|
|
|
.skuInfoList |
|
|
|
|
.where((element) => element.isSelected) |
|
|
|
|
.isNotEmpty && |
|
|
|
|
productSetMeals[position].productInfoList[index].count > |
|
|
|
|
0) |
|
|
|
|
Text( |
|
|
|
|
productSetMeals[position].productInfoList[index].productAttrInfoList[0].selectSku ?? "", |
|
|
|
|
productSetMeals[position] |
|
|
|
|
.productInfoList[index] |
|
|
|
|
.skuInfoList |
|
|
|
|
.firstWhere((element) => element.isSelected) |
|
|
|
|
.skuName ?? |
|
|
|
|
"", |
|
|
|
|
overflow: TextOverflow.ellipsis, |
|
|
|
|
maxLines: 1, |
|
|
|
|
style: TextStyle( |
|
|
|
@ -391,8 +413,13 @@ class _ProductMealsSku extends State<ProductMealsSku> {
|
|
|
|
|
InkWell( |
|
|
|
|
onTap: () { |
|
|
|
|
setState(() { |
|
|
|
|
if (productSetMeals[position].productInfoList[index].count >= 1) |
|
|
|
|
productSetMeals[position].productInfoList[index].count -= 1; |
|
|
|
|
if (productSetMeals[position] |
|
|
|
|
.productInfoList[index] |
|
|
|
|
.count >= |
|
|
|
|
1) |
|
|
|
|
productSetMeals[position] |
|
|
|
|
.productInfoList[index] |
|
|
|
|
.count -= 1; |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
child: Image.asset( |
|
|
|
@ -405,7 +432,10 @@ class _ProductMealsSku extends State<ProductMealsSku> {
|
|
|
|
|
width: 30, |
|
|
|
|
alignment: Alignment.center, |
|
|
|
|
child: Text( |
|
|
|
|
productSetMeals[position].productInfoList[index].count.toString(), |
|
|
|
|
productSetMeals[position] |
|
|
|
|
.productInfoList[index] |
|
|
|
|
.count |
|
|
|
|
.toString(), |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Colors.black, |
|
|
|
|
fontSize: 14.sp, |
|
|
|
@ -416,21 +446,33 @@ class _ProductMealsSku extends State<ProductMealsSku> {
|
|
|
|
|
GestureDetector( |
|
|
|
|
onTap: () { |
|
|
|
|
setState(() { |
|
|
|
|
if(productSetMeals[position].productInfoList[index].productAttrInfoList[0].attrName != ""){ |
|
|
|
|
if (productSetMeals[position] |
|
|
|
|
.productInfoList[index] |
|
|
|
|
.productAttrInfoList[0] |
|
|
|
|
.attrName != |
|
|
|
|
"") { |
|
|
|
|
showSkuDialog(position, index); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
int total = 0; |
|
|
|
|
productSetMeals[position].productInfoList.forEach((element) { |
|
|
|
|
productSetMeals[position] |
|
|
|
|
.productInfoList |
|
|
|
|
.forEach((element) { |
|
|
|
|
total += element.count; |
|
|
|
|
}); |
|
|
|
|
if (total >= productSetMeals[position].optionalNumber) { |
|
|
|
|
if (total >= |
|
|
|
|
productSetMeals[position].optionalNumber) { |
|
|
|
|
SmartDialog.showToast("抱歉,无法加购更多", |
|
|
|
|
alignment: Alignment.center); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (productSetMeals[position].productInfoList[index].count == 0) |
|
|
|
|
productSetMeals[position].productInfoList[index].count += 1; |
|
|
|
|
if (productSetMeals[position] |
|
|
|
|
.productInfoList[index] |
|
|
|
|
.count == |
|
|
|
|
0) |
|
|
|
|
productSetMeals[position] |
|
|
|
|
.productInfoList[index] |
|
|
|
|
.count += 1; |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
child: Image.asset( |
|
|
|
@ -453,15 +495,27 @@ class _ProductMealsSku extends State<ProductMealsSku> {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Widget porAttrItem(int position, int index, int pos, state) { |
|
|
|
|
if (productSetMeals[position].productInfoList[index].productAttrInfoList[pos].attrValueList != null && |
|
|
|
|
productSetMeals[position].productInfoList[index].productAttrInfoList[pos].attrValueList.length > 0) |
|
|
|
|
if (productSetMeals[position] |
|
|
|
|
.productInfoList[index] |
|
|
|
|
.productAttrInfoList[pos] |
|
|
|
|
.attrValueList != |
|
|
|
|
null && |
|
|
|
|
productSetMeals[position] |
|
|
|
|
.productInfoList[index] |
|
|
|
|
.productAttrInfoList[pos] |
|
|
|
|
.attrValueList |
|
|
|
|
.length > |
|
|
|
|
0) |
|
|
|
|
return Column( |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
|
children: [ |
|
|
|
|
Padding( |
|
|
|
|
padding: EdgeInsets.only(top: 16, bottom: 16), |
|
|
|
|
child: Text( |
|
|
|
|
productSetMeals[position].productInfoList[index].productAttrInfoList[pos].attrName, |
|
|
|
|
productSetMeals[position] |
|
|
|
|
.productInfoList[index] |
|
|
|
|
.productAttrInfoList[pos] |
|
|
|
|
.attrName, |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Color(0xFFB3B3B3), |
|
|
|
|
fontSize: 14.sp, |
|
|
|
@ -481,19 +535,32 @@ class _ProductMealsSku extends State<ProductMealsSku> {
|
|
|
|
|
return Wrap( |
|
|
|
|
runSpacing: 10.0, |
|
|
|
|
spacing: 10.0, |
|
|
|
|
children: productSetMeals[position].productInfoList[index].productAttrInfoList[pos].attrValueList |
|
|
|
|
.take(productSetMeals[position].productInfoList[index].productAttrInfoList[pos].attrValueList.length) |
|
|
|
|
children: productSetMeals[position] |
|
|
|
|
.productInfoList[index] |
|
|
|
|
.productAttrInfoList[pos] |
|
|
|
|
.attrValueList |
|
|
|
|
.take(productSetMeals[position] |
|
|
|
|
.productInfoList[index] |
|
|
|
|
.productAttrInfoList[pos] |
|
|
|
|
.attrValueList |
|
|
|
|
.length) |
|
|
|
|
.map<Widget>((AttrValueList tag) { |
|
|
|
|
return GestureDetector( |
|
|
|
|
onTap: () { |
|
|
|
|
state(() { |
|
|
|
|
productSetMeals[position].productInfoList[index].productAttrInfoList[pos].selectSku = |
|
|
|
|
tag.attrName; |
|
|
|
|
productSetMeals[position] |
|
|
|
|
.productInfoList[index] |
|
|
|
|
.productAttrInfoList[pos] |
|
|
|
|
.selectSku = tag.attrName; |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
child: sweetnessItem( |
|
|
|
|
tag.attrName, |
|
|
|
|
(productSetMeals[position].productInfoList[index].productAttrInfoList[pos].selectSku == tag.attrName), |
|
|
|
|
(productSetMeals[position] |
|
|
|
|
.productInfoList[index] |
|
|
|
|
.productAttrInfoList[pos] |
|
|
|
|
.selectSku == |
|
|
|
|
tag.attrName), |
|
|
|
|
)); |
|
|
|
|
}).toList()); |
|
|
|
|
} |
|
|
|
@ -542,18 +609,15 @@ class _ProductMealsSku extends State<ProductMealsSku> {
|
|
|
|
|
children: [ |
|
|
|
|
Expanded( |
|
|
|
|
child: ListView.builder( |
|
|
|
|
itemCount: productSetMeals[position].productInfoList[index] |
|
|
|
|
itemCount: productSetMeals[position] |
|
|
|
|
.productInfoList[index] |
|
|
|
|
.productAttrInfoList |
|
|
|
|
.length, |
|
|
|
|
scrollDirection: Axis.vertical, |
|
|
|
|
physics: BouncingScrollPhysics(), |
|
|
|
|
padding: EdgeInsets.zero, |
|
|
|
|
itemBuilder: (context, pos) { |
|
|
|
|
return porAttrItem( |
|
|
|
|
position,index, |
|
|
|
|
pos, |
|
|
|
|
state |
|
|
|
|
); |
|
|
|
|
return porAttrItem(position, index, pos, state); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
@ -564,20 +628,45 @@ class _ProductMealsSku extends State<ProductMealsSku> {
|
|
|
|
|
onTap: () { |
|
|
|
|
setState(() { |
|
|
|
|
int total = 0; |
|
|
|
|
productSetMeals[position].productInfoList.forEach((element) { |
|
|
|
|
productSetMeals[position] |
|
|
|
|
.productInfoList |
|
|
|
|
.forEach((element) { |
|
|
|
|
total += element.count; |
|
|
|
|
}); |
|
|
|
|
if(productSetMeals[position].productInfoList[index].productAttrInfoList[0].selectSku == null){ |
|
|
|
|
if (productSetMeals[position] |
|
|
|
|
.productInfoList[index] |
|
|
|
|
.productAttrInfoList |
|
|
|
|
.where((element) => element.selectSku == null) |
|
|
|
|
.isNotEmpty) { |
|
|
|
|
SmartDialog.showToast("请先选择规格", |
|
|
|
|
alignment: Alignment.center); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (total >= productSetMeals[position].optionalNumber && productSetMeals[position].productInfoList[index].count != 1) { |
|
|
|
|
if (total >= productSetMeals[position].optionalNumber && |
|
|
|
|
productSetMeals[position] |
|
|
|
|
.productInfoList[index] |
|
|
|
|
.count != |
|
|
|
|
1) { |
|
|
|
|
SmartDialog.showToast("抱歉,无法加购更多", |
|
|
|
|
alignment: Alignment.center); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
productSetMeals[position].productInfoList[index].count = 1; |
|
|
|
|
productSetMeals[position].productInfoList[index].count = |
|
|
|
|
1; |
|
|
|
|
productSetMeals[position] |
|
|
|
|
.productInfoList[index] |
|
|
|
|
.skuInfoList |
|
|
|
|
.forEach((element) { |
|
|
|
|
bool flag = true; |
|
|
|
|
productSetMeals[position] |
|
|
|
|
.productInfoList[index] |
|
|
|
|
.productAttrInfoList |
|
|
|
|
.forEach((e1) { |
|
|
|
|
if (!element.skuName.contains(e1.selectSku)) |
|
|
|
|
flag = false; |
|
|
|
|
}); |
|
|
|
|
element.isSelected = flag; |
|
|
|
|
}); |
|
|
|
|
Navigator.of(context).pop(); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|