|
|
|
@ -16,6 +16,7 @@ import 'package:huixiang/retrofit/data/store_info.dart';
|
|
|
|
|
import 'package:huixiang/retrofit/min_api.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/retrofit_api.dart'; |
|
|
|
|
import 'package:huixiang/store/store_view/people_num.dart'; |
|
|
|
|
import 'package:huixiang/store/store_view/red_dot_page.dart'; |
|
|
|
|
import 'package:huixiang/store/store_view/shop_car.dart'; |
|
|
|
|
import 'package:huixiang/utils/font_weight.dart'; |
|
|
|
|
import 'package:huixiang/view_widget/classic_header.dart'; |
|
|
|
@ -28,6 +29,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,13 +70,20 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
|
|
|
|
|
int index; |
|
|
|
|
bool isSetMeal; |
|
|
|
|
int scIndex = 0; |
|
|
|
|
int skuMinQty = 0; |
|
|
|
|
int singleNum = 0; |
|
|
|
|
String goodsSkuId; |
|
|
|
|
bool isCounts = false; |
|
|
|
|
GlobalKey _key = GlobalKey(); |
|
|
|
|
Offset _endOffset; |
|
|
|
|
double rightOffset = 23.0; |
|
|
|
|
int _jumpType = -1; |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
void initState() { |
|
|
|
|
super.initState(); |
|
|
|
|
id = widget.arguments["id"]; |
|
|
|
|
storeId = widget.arguments["storeId"]; |
|
|
|
|
isSetMeal = widget.arguments["isSetMeal"] ?? false; |
|
|
|
|
scrollController.addListener(() { |
|
|
|
|
if(scIndex == 0 && scrollController.offset > (MediaQuery.of(context).size.height >= 750 ? 392.h : 400.h)){ |
|
|
|
|
setState(() { |
|
|
|
@ -86,6 +95,12 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
|
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((c) { |
|
|
|
|
// 获取「购物车」的位置 |
|
|
|
|
_endOffset = (_key.currentContext.findRenderObject() as RenderBox) |
|
|
|
|
.localToGlobal(Offset.zero)+ |
|
|
|
|
Offset(rightOffset, 0.0); |
|
|
|
|
}); |
|
|
|
|
// SharedPreferences.getInstance().then((value) { |
|
|
|
|
// String minToken = value.getString("minToken"); |
|
|
|
|
// String tenant = value.getString("tenant"); |
|
|
|
@ -191,6 +206,11 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
|
|
|
|
|
miNiDetail = baseData.data; |
|
|
|
|
miNiDetail.attrList.forEach((element) { |
|
|
|
|
selectSkus.add(element.attrValueList[0].attrValue); |
|
|
|
|
if (baseData.data.productSkuVOList[0].productSetMeals.length == 0) { |
|
|
|
|
_jumpType = 0; |
|
|
|
|
} else { |
|
|
|
|
_jumpType = 1; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
SharedPreferences.getInstance().then( |
|
|
|
@ -325,20 +345,36 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
|
|
|
|
|
queryShopCar().then((value) { |
|
|
|
|
this.shopCarGoods = value; |
|
|
|
|
dialogShowing = true; |
|
|
|
|
SmartDialog.show( |
|
|
|
|
widget: ShopCar( |
|
|
|
|
shopCartKey, |
|
|
|
|
this.shopCarGoods, |
|
|
|
|
clearShopCar, |
|
|
|
|
toDownOrder, |
|
|
|
|
shopCartAdd, |
|
|
|
|
shopCartReduce, |
|
|
|
|
), |
|
|
|
|
onDismiss: () { |
|
|
|
|
dialogShowing = false; |
|
|
|
|
}, |
|
|
|
|
alignmentTemp: Alignment.bottomCenter, |
|
|
|
|
); |
|
|
|
|
//使用showModalBottomSheet加载弹窗才有效 |
|
|
|
|
showModalBottomSheet( |
|
|
|
|
backgroundColor: Colors.transparent, |
|
|
|
|
context: context, |
|
|
|
|
//点击背景弹窗是否关闭 |
|
|
|
|
// isDismissible: true, |
|
|
|
|
builder: (_) { |
|
|
|
|
return ShopCar( |
|
|
|
|
shopCartKey, |
|
|
|
|
this.shopCarGoods, |
|
|
|
|
clearShopCar, |
|
|
|
|
toDownOrder, |
|
|
|
|
shopCartAdd, |
|
|
|
|
shopCartReduce, |
|
|
|
|
); |
|
|
|
|
}); |
|
|
|
|
// SmartDialog.show( |
|
|
|
|
// widget: ShopCar( |
|
|
|
|
// shopCartKey, |
|
|
|
|
// this.shopCarGoods, |
|
|
|
|
// clearShopCar, |
|
|
|
|
// toDownOrder, |
|
|
|
|
// shopCartAdd, |
|
|
|
|
// shopCartReduce, |
|
|
|
|
// ), |
|
|
|
|
// onDismiss: () { |
|
|
|
|
// dialogShowing = false; |
|
|
|
|
// }, |
|
|
|
|
// alignmentTemp: Alignment.bottomCenter, |
|
|
|
|
// ); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -347,14 +383,15 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
|
|
|
|
|
BaseData<bool> baseData = await minService.clearShoppingCart(storeId); |
|
|
|
|
if (baseData.isSuccess) { |
|
|
|
|
shopCarGoods = null; |
|
|
|
|
singleNum = 0; |
|
|
|
|
setState(() {}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
///选规格 |
|
|
|
|
_queryMiNiDetail(String id, int count) async { |
|
|
|
|
EasyLoading.show( |
|
|
|
|
status: S.current.zhengzaijiazai, maskType: EasyLoadingMaskType.black); |
|
|
|
|
//加红点抛物线动画,故单规格加购时不显示加载中 |
|
|
|
|
// EasyLoading.show( status: S.current.zhengzaijiazai, maskType: EasyLoadingMaskType.black); |
|
|
|
|
if (count < 0) { |
|
|
|
|
shopCarGoods.shoppingCartSkuItemList.forEach((element) { |
|
|
|
|
if (element.productId == id) { |
|
|
|
@ -367,8 +404,10 @@ 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(); |
|
|
|
|
// EasyLoading.dismiss(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
///选规格弹窗 |
|
|
|
@ -376,9 +415,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,8 +484,13 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
|
|
|
|
|
setState(() {}); |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
SmartDialog.showToast(baseDate?.msg, alignment: Alignment.center); |
|
|
|
|
} |
|
|
|
|
SmartDialog.show( |
|
|
|
|
widget: SettlementTips( |
|
|
|
|
() {}, |
|
|
|
|
text: "${baseDate.msg.replaceAll("~", ",") + "请重新加购商品"}", |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -475,6 +521,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 +558,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 +635,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 +683,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 |
|
|
|
@ -795,9 +853,10 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
|
|
|
|
|
}, |
|
|
|
|
child: Image.asset( |
|
|
|
|
"assets/image/shopping_bag.webp", |
|
|
|
|
width: 66, |
|
|
|
|
height: 66, |
|
|
|
|
width: 57.w, |
|
|
|
|
height: 57.w, |
|
|
|
|
fit: BoxFit.fitWidth, |
|
|
|
|
key: _key, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
if (count() != 0) |
|
|
|
@ -848,8 +907,7 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
|
|
|
|
|
SizedBox( |
|
|
|
|
width: 2.w, |
|
|
|
|
), |
|
|
|
|
Expanded( |
|
|
|
|
child: Text( |
|
|
|
|
Text( |
|
|
|
|
miNiDetail?.applyPrice ?? "", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 16.sp, |
|
|
|
@ -858,66 +916,115 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
|
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
|
color: Color(0xFFA29E9E), |
|
|
|
|
), |
|
|
|
|
)), |
|
|
|
|
GestureDetector( |
|
|
|
|
onTap: () async { |
|
|
|
|
if (storeInfo.posType.code == "NORMALSTORE" && |
|
|
|
|
tableId == 0) { |
|
|
|
|
showDeleteDialog(); |
|
|
|
|
} else if (isSetMeal == true) { |
|
|
|
|
await Navigator.of(context) |
|
|
|
|
.pushNamed('/router/product_meals_sku', arguments: { |
|
|
|
|
"id": id, |
|
|
|
|
"storeId": storeId, |
|
|
|
|
"tableId": tableId |
|
|
|
|
}); |
|
|
|
|
queryShopCar().then((value) { |
|
|
|
|
this.shopCarGoods = value; |
|
|
|
|
setState(() {}); |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
_queryMiNiDetail(id, counts); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
child: Container( |
|
|
|
|
width: 92.w, |
|
|
|
|
height: 32.h, |
|
|
|
|
), |
|
|
|
|
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(4), |
|
|
|
|
color: Color(0xFF32A060), |
|
|
|
|
borderRadius: |
|
|
|
|
BorderRadius.circular(2), |
|
|
|
|
border: Border.all( |
|
|
|
|
width: 1, |
|
|
|
|
color: Color(0xFFF65720), |
|
|
|
|
style: BorderStyle.solid, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
margin: EdgeInsets.only(bottom: 8), |
|
|
|
|
child: Row( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
|
|
|
children: [ |
|
|
|
|
Image.asset( |
|
|
|
|
"assets/image/goods_shopp.webp", |
|
|
|
|
fit: BoxFit.fill, |
|
|
|
|
width: 18, |
|
|
|
|
height: 18, |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
|
width: 2, |
|
|
|
|
), |
|
|
|
|
Text( |
|
|
|
|
((miNiDetail?.subscribeParam?.isEnableSubscribe ?? |
|
|
|
|
false) == |
|
|
|
|
true) |
|
|
|
|
? S.of(context).lijiyuyue |
|
|
|
|
: (isSetMeal ?? false) == true |
|
|
|
|
? "选套餐" |
|
|
|
|
: "加入购物车", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
|
color: Color(0xFFFFFFFF), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
alignment: Alignment.center, |
|
|
|
|
child: Text( |
|
|
|
|
"${widget?.arguments["minQty"] ?? 0 ?? "0"}份起购", |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Color(0xFFF65720), |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
) |
|
|
|
|
Spacer(), |
|
|
|
|
Builder( |
|
|
|
|
builder: (context) { |
|
|
|
|
return GestureDetector( |
|
|
|
|
onTap: () async { |
|
|
|
|
if (storeInfo.posType.code == "NORMALSTORE" && |
|
|
|
|
tableId == 0) { |
|
|
|
|
showDeleteDialog(); |
|
|
|
|
} else if (_jumpType == 1) { |
|
|
|
|
await Navigator.of(context).pushNamed( |
|
|
|
|
'/router/product_meals_sku', |
|
|
|
|
arguments: { |
|
|
|
|
"id": id, |
|
|
|
|
"storeId": storeId, |
|
|
|
|
"tableId": tableId |
|
|
|
|
}); |
|
|
|
|
queryShopCar().then((value) { |
|
|
|
|
this.shopCarGoods = value; |
|
|
|
|
setState(() {}); |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
if (miNiDetail.attrList != null && |
|
|
|
|
miNiDetail.attrList.length == 1 && |
|
|
|
|
miNiDetail.attrList[0].attrValueList.length == 1){ |
|
|
|
|
/// 点击的时候获取当前 widget 的位置,传入 overlayEntry |
|
|
|
|
var _overlayEntry = OverlayEntry(builder: (_) { |
|
|
|
|
RenderBox box = context.findRenderObject(); |
|
|
|
|
var offset = box.localToGlobal(Offset.zero); |
|
|
|
|
return RedDotPage( |
|
|
|
|
startPosition: offset, |
|
|
|
|
endPosition: _endOffset, |
|
|
|
|
); |
|
|
|
|
}); |
|
|
|
|
// 显示Overlay |
|
|
|
|
Overlay.of(context).insert(_overlayEntry); |
|
|
|
|
// 等待动画结束 |
|
|
|
|
Future.delayed(Duration(milliseconds: 800), () { |
|
|
|
|
_overlayEntry.remove(); |
|
|
|
|
_overlayEntry = null; |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
_queryMiNiDetail(id,(skuMinQty > 1 ? counts : ((widget.arguments["minQty"]??0) > 1 && singleNum==0) |
|
|
|
|
? (widget.arguments["minQty"]??0):counts)); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
child: Container( |
|
|
|
|
width: 92.w, |
|
|
|
|
height: 32.h, |
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
borderRadius: BorderRadius.circular(4), |
|
|
|
|
color: Color(0xFF32A060), |
|
|
|
|
), |
|
|
|
|
margin: EdgeInsets.only(bottom: 8), |
|
|
|
|
child: Row( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
|
|
|
children: [ |
|
|
|
|
Image.asset( |
|
|
|
|
"assets/image/goods_shopp.webp", |
|
|
|
|
fit: BoxFit.fill, |
|
|
|
|
width: 18, |
|
|
|
|
height: 18, |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
|
width: 2, |
|
|
|
|
), |
|
|
|
|
Text( |
|
|
|
|
((miNiDetail?.subscribeParam?.isEnableSubscribe ?? |
|
|
|
|
false) == |
|
|
|
|
true) |
|
|
|
|
? S.of(context).lijiyuyue |
|
|
|
|
: (isSetMeal ?? false) == true |
|
|
|
|
? "选套餐" |
|
|
|
|
: "加入购物车", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
|
color: Color(0xFFFFFFFF), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
);},) |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
) |
|
|
|
@ -968,8 +1075,7 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
|
|
|
|
|
SizedBox( |
|
|
|
|
width: 2.w, |
|
|
|
|
), |
|
|
|
|
Expanded( |
|
|
|
|
child: Text( |
|
|
|
|
Text( |
|
|
|
|
miNiDetail?.applyPrice ?? "", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 16.sp, |
|
|
|
@ -978,67 +1084,114 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
|
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
|
color: Color(0xFFA29E9E), |
|
|
|
|
), |
|
|
|
|
)), |
|
|
|
|
GestureDetector( |
|
|
|
|
onTap: () async { |
|
|
|
|
if (storeInfo.posType.code == "NORMALSTORE" && |
|
|
|
|
tableId == 0) { |
|
|
|
|
showDeleteDialog(); |
|
|
|
|
} else if (isSetMeal == true) { |
|
|
|
|
await Navigator.of(context).pushNamed( |
|
|
|
|
'/router/product_meals_sku', |
|
|
|
|
arguments: { |
|
|
|
|
"id": id, |
|
|
|
|
"storeId": storeId, |
|
|
|
|
"tableId": tableId |
|
|
|
|
}); |
|
|
|
|
queryShopCar().then((value) { |
|
|
|
|
this.shopCarGoods = value; |
|
|
|
|
setState(() {}); |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
_queryMiNiDetail(id, counts); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
child: Container( |
|
|
|
|
width: 92.w, |
|
|
|
|
height: 32.h, |
|
|
|
|
), |
|
|
|
|
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(4), |
|
|
|
|
color: Color(0xFF32A060), |
|
|
|
|
borderRadius: |
|
|
|
|
BorderRadius.circular(2), |
|
|
|
|
border: Border.all( |
|
|
|
|
width: 1, |
|
|
|
|
color: Color(0xFFF65720), |
|
|
|
|
style: BorderStyle.solid, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
margin: EdgeInsets.only(bottom: 8), |
|
|
|
|
child: Row( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
|
|
|
children: [ |
|
|
|
|
Image.asset( |
|
|
|
|
"assets/image/goods_shopp.webp", |
|
|
|
|
fit: BoxFit.fill, |
|
|
|
|
width: 18, |
|
|
|
|
height: 18, |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
|
width: 2, |
|
|
|
|
alignment: Alignment.center, |
|
|
|
|
child: Text( |
|
|
|
|
"${widget?.arguments["minQty"] ?? 0}份起购", |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Color(0xFFF65720), |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
Spacer(), |
|
|
|
|
Builder( |
|
|
|
|
builder: (context) { |
|
|
|
|
return GestureDetector( |
|
|
|
|
onTap: () async { |
|
|
|
|
if (storeInfo.posType.code == "NORMALSTORE" && |
|
|
|
|
tableId == 0) { |
|
|
|
|
showDeleteDialog(); |
|
|
|
|
} else if (_jumpType == 1) { |
|
|
|
|
await Navigator.of(context).pushNamed( |
|
|
|
|
'/router/product_meals_sku', |
|
|
|
|
arguments: { |
|
|
|
|
"id": id, |
|
|
|
|
"storeId": storeId, |
|
|
|
|
"tableId": tableId |
|
|
|
|
}); |
|
|
|
|
queryShopCar().then((value) { |
|
|
|
|
this.shopCarGoods = value; |
|
|
|
|
setState(() {}); |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
if (miNiDetail.attrList != null && |
|
|
|
|
miNiDetail.attrList.length == 1 && |
|
|
|
|
miNiDetail.attrList[0].attrValueList.length == 1){ |
|
|
|
|
/// 点击的时候获取当前 widget 的位置,传入 overlayEntry |
|
|
|
|
var _overlayEntry = OverlayEntry(builder: (_) { |
|
|
|
|
RenderBox box = context.findRenderObject(); |
|
|
|
|
var offset = box.localToGlobal(Offset.zero); |
|
|
|
|
return RedDotPage( |
|
|
|
|
startPosition: offset, |
|
|
|
|
endPosition: _endOffset, |
|
|
|
|
); |
|
|
|
|
}); |
|
|
|
|
// 显示Overlay |
|
|
|
|
Overlay.of(context).insert(_overlayEntry); |
|
|
|
|
// 等待动画结束 |
|
|
|
|
Future.delayed(Duration(milliseconds: 800), () { |
|
|
|
|
_overlayEntry.remove(); |
|
|
|
|
_overlayEntry = null; |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
_queryMiNiDetail(id,(skuMinQty > 1 ? counts : ((widget.arguments["minQty"]??0) > 1 && singleNum==0) |
|
|
|
|
? (widget.arguments["minQty"]??0):counts)); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
child: Container( |
|
|
|
|
width: 92.w, |
|
|
|
|
height: 32.h, |
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
borderRadius: BorderRadius.circular(4), |
|
|
|
|
color: Color(0xFF32A060), |
|
|
|
|
), |
|
|
|
|
Text( |
|
|
|
|
((miNiDetail?.subscribeParam?.isEnableSubscribe ?? |
|
|
|
|
false) == |
|
|
|
|
margin: EdgeInsets.only(bottom: 8), |
|
|
|
|
child: Row( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
|
|
|
children: [ |
|
|
|
|
Image.asset( |
|
|
|
|
"assets/image/goods_shopp.webp", |
|
|
|
|
fit: BoxFit.fill, |
|
|
|
|
width: 18, |
|
|
|
|
height: 18, |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
|
width: 2, |
|
|
|
|
), |
|
|
|
|
Text( |
|
|
|
|
((miNiDetail?.subscribeParam?.isEnableSubscribe ?? |
|
|
|
|
false) == |
|
|
|
|
true) |
|
|
|
|
? S.of(context).lijiyuyue |
|
|
|
|
: (isSetMeal ?? false) == true |
|
|
|
|
? S.of(context).lijiyuyue |
|
|
|
|
: (isSetMeal ?? false) == true |
|
|
|
|
? "选套餐" |
|
|
|
|
: "加入购物车", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
|
color: Color(0xFFFFFFFF), |
|
|
|
|
), |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
|
color: Color(0xFFFFFFFF), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
) |
|
|
|
|
), |
|
|
|
|
);},), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
Text( |
|
|
|
@ -1191,6 +1344,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 +1415,7 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
|
|
|
|
|
), |
|
|
|
|
Column( |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start, |
|
|
|
|
// mainAxisAlignment: MainAxisAlignment.start, |
|
|
|
|
children: [ |
|
|
|
|
Text( |
|
|
|
|
S.of(context).shuliang, |
|
|
|
@ -1247,28 +1425,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: Icon( |
|
|
|
|
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 +1487,27 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
|
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
InkWell( |
|
|
|
|
GestureDetector( |
|
|
|
|
behavior: HitTestBehavior.opaque, |
|
|
|
|
onTap: () { |
|
|
|
|
state(() { |
|
|
|
|
counts += 1; |
|
|
|
|
// add(miNiDetail, selectSkus); |
|
|
|
|
isCounts = true; |
|
|
|
|
add(miNiDetail, selectSkus); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
child: Icon( |
|
|
|
|
Icons.add, |
|
|
|
|
color: Color(0xFF32A060), |
|
|
|
|
size: 24, |
|
|
|
|
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 +1519,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); |
|
|
|
|
counts = 1; |
|
|
|
|
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(); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|