|
|
|
@ -28,6 +28,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart'; |
|
|
|
|
import '../view_widget/border_text.dart'; |
|
|
|
|
import '../view_widget/request_permission.dart'; |
|
|
|
|
import '../view_widget/settlement_tips_dialog.dart'; |
|
|
|
|
|
|
|
|
|
class ShopDetailsPage extends StatefulWidget { |
|
|
|
|
final Map<String, dynamic> arguments; |
|
|
|
@ -68,6 +69,10 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
|
|
|
|
|
int index; |
|
|
|
|
bool isSetMeal; |
|
|
|
|
int scIndex = 0; |
|
|
|
|
int skuMinQty = 0; |
|
|
|
|
int singleNum = 0; |
|
|
|
|
String goodsSkuId; |
|
|
|
|
bool isCounts = false; |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
void initState() { |
|
|
|
@ -347,6 +352,7 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
|
|
|
|
|
BaseData<bool> baseData = await minService.clearShoppingCart(storeId); |
|
|
|
|
if (baseData.isSuccess) { |
|
|
|
|
shopCarGoods = null; |
|
|
|
|
singleNum = 0; |
|
|
|
|
setState(() {}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -367,6 +373,8 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
|
|
|
|
|
BaseData<MiNiDetail> baseData = await minService.miNiDetail(id); |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
showStoreSelector(baseData.data, id, count); |
|
|
|
|
}else{ |
|
|
|
|
SmartDialog.showToast(baseData.msg); |
|
|
|
|
} |
|
|
|
|
EasyLoading.dismiss(); |
|
|
|
|
} |
|
|
|
@ -376,9 +384,11 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
|
|
|
|
|
if (miNiDetail.attrList != null && |
|
|
|
|
miNiDetail.attrList.length == 1 && |
|
|
|
|
miNiDetail.attrList[0].attrValueList.length == 1) { |
|
|
|
|
_addShopCar(miNiDetail, [], counts); |
|
|
|
|
_addShopCar(miNiDetail, [], count); |
|
|
|
|
} else { |
|
|
|
|
// showSpanDialog(); |
|
|
|
|
setState(() { |
|
|
|
|
buildCount(); |
|
|
|
|
}); |
|
|
|
|
selectSpecsShowBottomSheet(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -443,7 +453,12 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
|
|
|
|
|
setState(() {}); |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
SmartDialog.showToast(baseDate?.msg, alignment: Alignment.center); |
|
|
|
|
SmartDialog.show( |
|
|
|
|
widget: SettlementTips( |
|
|
|
|
() {}, |
|
|
|
|
text: "${baseDate.msg.replaceAll("~", ",") + "请重新加购商品"}", |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -475,6 +490,17 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
baseDate.data[0].shoppingCartSkuItemList.forEach((element) { |
|
|
|
|
if((goodsSkuId == element.id)){ |
|
|
|
|
singleNum = element.buyNum; |
|
|
|
|
}else{ |
|
|
|
|
if(id == element.productId){ |
|
|
|
|
singleNum = element.buyNum; |
|
|
|
|
}else{ |
|
|
|
|
singleNum = 0; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
return baseDate.data[0]; |
|
|
|
|
} else { |
|
|
|
|
return null; |
|
|
|
@ -501,9 +527,9 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
|
|
|
|
|
|
|
|
|
|
///购物车➖1 |
|
|
|
|
Future<ShoppingCart> shopCartReduce( |
|
|
|
|
ShoppingCartSkuItemListBean cartSkuItem) async { |
|
|
|
|
ShoppingCartSkuItemListBean cartSkuItem,{int count = 1}) async { |
|
|
|
|
Map<String, dynamic> shopCarTemp = shopCarGoods.toJson(); |
|
|
|
|
cartSkuItem.buyNum -= 1; |
|
|
|
|
cartSkuItem.buyNum -= (count>0) ? ((cartSkuItem.minQty>1 && cartSkuItem.buyNum == cartSkuItem.minQty) ? cartSkuItem.minQty: count) : -count; |
|
|
|
|
shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()]; |
|
|
|
|
BaseData<List<ShoppingCart>> baseDate = |
|
|
|
|
await minService.shoppingCartSingle(shopCarTemp); |
|
|
|
@ -578,7 +604,7 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
|
|
|
|
|
|
|
|
|
|
if (shopSkuItem != null) { |
|
|
|
|
if (shopSkuItem.buyNum > 1) { |
|
|
|
|
shopCarGoods.shoppingCartSkuItemList[shopSkuIndex].buyNum -= 1; |
|
|
|
|
shopCarGoods.shoppingCartSkuItemList[shopSkuIndex].buyNum -= (skuMinQty > 1 && skuMinQty ==shopSkuItem.buyNum) ? skuMinQty:1; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
await _addShopCar(miNiDetail, selectSkus, 2); |
|
|
|
@ -626,6 +652,7 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
|
|
|
|
|
if (productSku == null) return; |
|
|
|
|
selectedPrice = productSku.skuPrice; |
|
|
|
|
String skuId = productSku.id; |
|
|
|
|
skuMinQty = productSku.minQty; |
|
|
|
|
if (shopCarGoods == null || shopCarGoods.shoppingCartSkuItemList == null) |
|
|
|
|
return; |
|
|
|
|
int shopSkuIndex = shopCarGoods.shoppingCartSkuItemList |
|
|
|
@ -848,8 +875,7 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
|
|
|
|
|
SizedBox( |
|
|
|
|
width: 2.w, |
|
|
|
|
), |
|
|
|
|
Expanded( |
|
|
|
|
child: Text( |
|
|
|
|
Text( |
|
|
|
|
miNiDetail?.applyPrice ?? "", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 16.sp, |
|
|
|
@ -858,7 +884,32 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
|
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
|
color: Color(0xFFA29E9E), |
|
|
|
|
), |
|
|
|
|
)), |
|
|
|
|
), |
|
|
|
|
if((widget?.arguments["minQty"] ?? 0).toInt() > 1) |
|
|
|
|
Container( |
|
|
|
|
height: 20.h, |
|
|
|
|
padding: EdgeInsets.symmetric(horizontal:6.w), |
|
|
|
|
margin: EdgeInsets.only(left: 16.w), |
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
borderRadius: |
|
|
|
|
BorderRadius.circular(2), |
|
|
|
|
border: Border.all( |
|
|
|
|
width: 1, |
|
|
|
|
color: Color(0xFFF65720), |
|
|
|
|
style: BorderStyle.solid, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
alignment: Alignment.center, |
|
|
|
|
child: Text( |
|
|
|
|
"${widget?.arguments["minQty"] ?? 0 ?? "0"}份起购", |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Color(0xFFF65720), |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
Spacer(), |
|
|
|
|
GestureDetector( |
|
|
|
|
onTap: () async { |
|
|
|
|
if (storeInfo.posType.code == "NORMALSTORE" && |
|
|
|
@ -968,8 +1019,7 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
|
|
|
|
|
SizedBox( |
|
|
|
|
width: 2.w, |
|
|
|
|
), |
|
|
|
|
Expanded( |
|
|
|
|
child: Text( |
|
|
|
|
Text( |
|
|
|
|
miNiDetail?.applyPrice ?? "", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 16.sp, |
|
|
|
@ -978,7 +1028,31 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
|
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
|
color: Color(0xFFA29E9E), |
|
|
|
|
), |
|
|
|
|
)), |
|
|
|
|
), |
|
|
|
|
if((widget?.arguments["minQty"] ?? 0).toInt() > 1) |
|
|
|
|
Container( |
|
|
|
|
padding: EdgeInsets.symmetric(horizontal:6.w,vertical: 2.h), |
|
|
|
|
margin: EdgeInsets.only(left: 16.w), |
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
borderRadius: |
|
|
|
|
BorderRadius.circular(2), |
|
|
|
|
border: Border.all( |
|
|
|
|
width: 1, |
|
|
|
|
color: Color(0xFFF65720), |
|
|
|
|
style: BorderStyle.solid, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
alignment: Alignment.center, |
|
|
|
|
child: Text( |
|
|
|
|
"${widget?.arguments["minQty"] ?? 0}份起购", |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Color(0xFFF65720), |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
Spacer(), |
|
|
|
|
GestureDetector( |
|
|
|
|
onTap: () async { |
|
|
|
|
if (storeInfo.posType.code == "NORMALSTORE" && |
|
|
|
@ -997,7 +1071,8 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
|
|
|
|
|
setState(() {}); |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
_queryMiNiDetail(id, counts); |
|
|
|
|
_queryMiNiDetail(id,(skuMinQty > 1 ? counts : ((widget.arguments["minQty"]??0) > 1 && singleNum==0) |
|
|
|
|
? (widget.arguments["minQty"]??0):counts)); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
child: Container( |
|
|
|
@ -1191,6 +1266,31 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
|
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
if(skuMinQty > 1) |
|
|
|
|
Row(children: [ |
|
|
|
|
Container( |
|
|
|
|
padding: EdgeInsets.symmetric(horizontal:4.w), |
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
borderRadius: |
|
|
|
|
BorderRadius.circular(2), |
|
|
|
|
border: Border.all( |
|
|
|
|
width: 1, |
|
|
|
|
color: Color(0xFFF65720), |
|
|
|
|
style: BorderStyle.solid, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
alignment: Alignment.center, |
|
|
|
|
child: Text( |
|
|
|
|
"${skuMinQty}份起购", |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Color(0xFFF65720), |
|
|
|
|
fontSize: 10.sp, |
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
Spacer() |
|
|
|
|
]), |
|
|
|
|
Text( |
|
|
|
|
"¥${miNiDetail?.price ?? ""}", |
|
|
|
|
style: TextStyle( |
|
|
|
@ -1237,7 +1337,7 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
|
|
|
|
|
), |
|
|
|
|
Column( |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start, |
|
|
|
|
// mainAxisAlignment: MainAxisAlignment.start, |
|
|
|
|
children: [ |
|
|
|
|
Text( |
|
|
|
|
S.of(context).shuliang, |
|
|
|
@ -1247,28 +1347,59 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
|
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
|
height: 10, |
|
|
|
|
if(skuMinQty > 1 && (counts ==1 || counts ==0)) |
|
|
|
|
Row( |
|
|
|
|
children: [ |
|
|
|
|
GestureDetector( |
|
|
|
|
behavior: HitTestBehavior.opaque, |
|
|
|
|
onTap: () async { |
|
|
|
|
state(() { |
|
|
|
|
isCounts = true; |
|
|
|
|
counts += skuMinQty-1; |
|
|
|
|
_addShopCar(miNiDetail, selectSkus, counts); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
child:Container( |
|
|
|
|
margin: EdgeInsets.only(right: 8.w, top: 14.h,bottom: 24.h), |
|
|
|
|
child: RoundButton( |
|
|
|
|
text:"${skuMinQty}份起购", |
|
|
|
|
textColor: Colors.white, |
|
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
|
radius: 3, |
|
|
|
|
backgroup: Color(0xFF32A060), |
|
|
|
|
fontSize: 11.sp, |
|
|
|
|
padding: EdgeInsets.symmetric( |
|
|
|
|
vertical: 5.h, horizontal: 3.w), |
|
|
|
|
), |
|
|
|
|
)), |
|
|
|
|
Spacer() |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
if((skuMinQty > 1 && counts !=1) || skuMinQty == 0 || skuMinQty == 1) |
|
|
|
|
Row( |
|
|
|
|
children: [ |
|
|
|
|
InkWell( |
|
|
|
|
GestureDetector( |
|
|
|
|
behavior: HitTestBehavior.opaque, |
|
|
|
|
onTap: () { |
|
|
|
|
state(() { |
|
|
|
|
if (counts > 1) |
|
|
|
|
setState(() { |
|
|
|
|
counts -= 1; |
|
|
|
|
counts -= (skuMinQty > 1 && skuMinQty == counts) ? (skuMinQty - 1) : 1; |
|
|
|
|
}); |
|
|
|
|
// reduce(miNiDetail, selectSkus); |
|
|
|
|
|
|
|
|
|
isCounts = true; |
|
|
|
|
reduce(miNiDetail, selectSkus); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
child: Container( |
|
|
|
|
padding:EdgeInsets.only(right:8.w,top: 10.h,bottom: 24.h), |
|
|
|
|
child: Icon( |
|
|
|
|
Icons.remove, |
|
|
|
|
color: Color(0xFF32A060), |
|
|
|
|
size: 24, |
|
|
|
|
)), |
|
|
|
|
))), |
|
|
|
|
Padding( |
|
|
|
|
padding: EdgeInsets.only(left: 8, right: 8), |
|
|
|
|
padding: EdgeInsets.only(right: 8.w,bottom: 14.h), |
|
|
|
|
child: Text( |
|
|
|
|
"$counts", |
|
|
|
|
style: TextStyle( |
|
|
|
@ -1278,25 +1409,27 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
|
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
InkWell( |
|
|
|
|
GestureDetector( |
|
|
|
|
behavior: HitTestBehavior.opaque, |
|
|
|
|
onTap: () { |
|
|
|
|
state(() { |
|
|
|
|
counts += 1; |
|
|
|
|
// add(miNiDetail, selectSkus); |
|
|
|
|
isCounts = true; |
|
|
|
|
add(miNiDetail, selectSkus); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
child: Container( |
|
|
|
|
padding:EdgeInsets.only(right:20.w,top: 10.h,bottom: 24.h), |
|
|
|
|
child: Icon( |
|
|
|
|
Icons.add, |
|
|
|
|
color: Color(0xFF32A060), |
|
|
|
|
size: 24, |
|
|
|
|
), |
|
|
|
|
)), |
|
|
|
|
], |
|
|
|
|
) |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
|
height: 24, |
|
|
|
|
), |
|
|
|
|
RoundButton( |
|
|
|
|
width: double.infinity, |
|
|
|
|
height: 54.h, |
|
|
|
@ -1308,12 +1441,24 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
|
|
|
|
|
textColor: Colors.white, |
|
|
|
|
fontWeight: MyFontWeight.semi_bold, |
|
|
|
|
radius: 27, |
|
|
|
|
backgroup: Color(0xFF32A060), |
|
|
|
|
backgroup:Color(0xFF32A060), |
|
|
|
|
fontSize: 16.sp, |
|
|
|
|
callback: () { |
|
|
|
|
state(() { |
|
|
|
|
_addShopCar(miNiDetail, selectSkus, counts); |
|
|
|
|
if(skuMinQty > 1 && counts == 1){ |
|
|
|
|
SmartDialog.show( |
|
|
|
|
widget: SettlementTips( |
|
|
|
|
() {}, |
|
|
|
|
text: "请选择购买数量", |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if(!isCounts || counts == 1){ |
|
|
|
|
_addShopCar(miNiDetail, selectSkus,1); |
|
|
|
|
counts = 1; |
|
|
|
|
isCounts = false; |
|
|
|
|
} |
|
|
|
|
Navigator.of(context).pop(); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|