|
|
|
@ -1,3 +1,4 @@
|
|
|
|
|
import 'package:ai_decimal_accuracy/ai_decimal_accuracy.dart'; |
|
|
|
|
import 'package:dio/dio.dart'; |
|
|
|
|
import 'package:flutter/cupertino.dart'; |
|
|
|
|
import 'package:flutter/gestures.dart'; |
|
|
|
@ -40,18 +41,21 @@ class StoreOrderPage extends StatefulWidget {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
class _StoreOrderPage extends State<StoreOrderPage> |
|
|
|
|
with TickerProviderStateMixin, AutomaticKeepAliveClientMixin { |
|
|
|
|
with TickerProviderStateMixin/*, AutomaticKeepAliveClientMixin*/ { |
|
|
|
|
TabController tabcontroller; |
|
|
|
|
ApiService apiService; |
|
|
|
|
MinApiService minService; |
|
|
|
|
StoreInfo storeInfo; |
|
|
|
|
List<Activity> activitys; |
|
|
|
|
RefreshController refreshController; |
|
|
|
|
List<Widget> _widgetOptions; |
|
|
|
|
|
|
|
|
|
int allCount = 0; |
|
|
|
|
double allPrice = 0; |
|
|
|
|
StoreOrderListPage storeOrderListPage; |
|
|
|
|
|
|
|
|
|
List<ProductListBean> productLists = []; |
|
|
|
|
List<Map<String, dynamic>> shopCarGoods = []; |
|
|
|
|
|
|
|
|
|
ScrollController controller = ScrollController(); |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@ -63,43 +67,20 @@ class _StoreOrderPage extends State<StoreOrderPage>
|
|
|
|
|
length: 2, |
|
|
|
|
vsync: this, |
|
|
|
|
); |
|
|
|
|
storeOrderListPage = StoreOrderListPage(widget.arguments, activitys, |
|
|
|
|
storeInfo, controller, _queryMiNiDetail, _fc); |
|
|
|
|
|
|
|
|
|
_widgetOptions = [ |
|
|
|
|
storeOrderListPage, |
|
|
|
|
|
|
|
|
|
///星店活动, |
|
|
|
|
StoreActivity( |
|
|
|
|
widget.arguments, |
|
|
|
|
activitys, |
|
|
|
|
), |
|
|
|
|
]; |
|
|
|
|
minLogin(); |
|
|
|
|
queryStoreInfo(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_fc(ProductListBean plb) { |
|
|
|
|
_fc(int count, String productId, int allCount, double allPrice) { |
|
|
|
|
if (count == 0) { |
|
|
|
|
int index = shopCarGoods.indexWhere((element) => element["id"] == productId); |
|
|
|
|
shopCarGoods.removeAt(index); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
setState(() { |
|
|
|
|
allCount = 0; |
|
|
|
|
allPrice = 0; |
|
|
|
|
bool flag = false; |
|
|
|
|
for (var i = 0; i < productLists.length; i++) { |
|
|
|
|
if (productLists[i].id == plb.id) { |
|
|
|
|
flag = true; |
|
|
|
|
if (plb.buyNum == 0) |
|
|
|
|
productLists.removeAt(i); |
|
|
|
|
else |
|
|
|
|
productLists[i] = plb; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
storeOrderListPage.notifyList(productLists); |
|
|
|
|
if (!flag && plb.buyNum != 0) productLists.add(plb); |
|
|
|
|
productLists.forEach((element) { |
|
|
|
|
allCount += element.buyNum; |
|
|
|
|
allPrice += double.parse(element.price) * element.buyNum; |
|
|
|
|
}); |
|
|
|
|
this.allCount = allCount; |
|
|
|
|
this.allPrice = allPrice; |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -321,7 +302,23 @@ class _StoreOrderPage extends State<StoreOrderPage>
|
|
|
|
|
}, |
|
|
|
|
body: TabBarView( |
|
|
|
|
physics: BouncingScrollPhysics(), |
|
|
|
|
children: _widgetOptions, |
|
|
|
|
children: [ |
|
|
|
|
StoreOrderListPage( |
|
|
|
|
widget.arguments, |
|
|
|
|
activitys, |
|
|
|
|
storeInfo, |
|
|
|
|
shopCarGoods, |
|
|
|
|
controller, |
|
|
|
|
_queryMiNiDetail, |
|
|
|
|
_fc, |
|
|
|
|
), |
|
|
|
|
|
|
|
|
|
///星店活动, |
|
|
|
|
StoreActivity( |
|
|
|
|
widget.arguments, |
|
|
|
|
activitys, |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
controller: tabcontroller, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
@ -350,7 +347,7 @@ class _StoreOrderPage extends State<StoreOrderPage>
|
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
Text( |
|
|
|
|
"¥" + allPrice.toString(), |
|
|
|
|
"¥$allPrice", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 20.sp, |
|
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
@ -384,9 +381,7 @@ class _StoreOrderPage extends State<StoreOrderPage>
|
|
|
|
|
children: [ |
|
|
|
|
InkWell( |
|
|
|
|
onTap: () { |
|
|
|
|
setState(() { |
|
|
|
|
showShoppingCart(); |
|
|
|
|
}); |
|
|
|
|
showShoppingCart(); |
|
|
|
|
}, |
|
|
|
|
child: Image.asset( |
|
|
|
|
"assets/image/shopp.png", |
|
|
|
@ -401,7 +396,7 @@ class _StoreOrderPage extends State<StoreOrderPage>
|
|
|
|
|
child: RoundButton( |
|
|
|
|
width: 17, |
|
|
|
|
height: 17, |
|
|
|
|
text: allCount.toString(), |
|
|
|
|
text: "$allCount", |
|
|
|
|
textColor: Colors.white, |
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
|
backgroup: Color(0xFF32A060), |
|
|
|
@ -455,21 +450,38 @@ class _StoreOrderPage extends State<StoreOrderPage>
|
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<ProductListBean> productLists = []; |
|
|
|
|
|
|
|
|
|
///购物车弹窗 |
|
|
|
|
showShoppingCart() { |
|
|
|
|
|
|
|
|
|
List<ProductListBean> shopCar = []; |
|
|
|
|
|
|
|
|
|
if (shopCarGoods != null && shopCarGoods.length > 0) { |
|
|
|
|
shopCarGoods.forEach((element) { |
|
|
|
|
ProductListBean productListBean = productLists.firstWhere((element1) { |
|
|
|
|
return element["id"] == element1.id; |
|
|
|
|
}); |
|
|
|
|
if (productListBean != null) { |
|
|
|
|
shopCar.add(productListBean); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
showModalBottomSheet( |
|
|
|
|
context: context, |
|
|
|
|
backgroundColor: Colors.transparent, |
|
|
|
|
builder: (context) { |
|
|
|
|
return ShopCar( |
|
|
|
|
productLists, |
|
|
|
|
_queryMiNiDetail, |
|
|
|
|
(ProductListBean productListBeans) { |
|
|
|
|
shopCar, |
|
|
|
|
shopCarGoods, |
|
|
|
|
(int count, String productId, allCount, allPrice) { |
|
|
|
|
if (count == 0) { |
|
|
|
|
int index = shopCarGoods.indexWhere((element) => element["id"] == productId); |
|
|
|
|
shopCarGoods.removeAt(index); |
|
|
|
|
} |
|
|
|
|
print("shopCarCount: $allCount allPrice: $allPrice "); |
|
|
|
|
setState(() { |
|
|
|
|
// this.allCount = allCount; |
|
|
|
|
// this.allPrice = allPrice; |
|
|
|
|
this.allCount = allCount; |
|
|
|
|
this.allPrice = allPrice; |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
); |
|
|
|
@ -481,9 +493,7 @@ class _StoreOrderPage extends State<StoreOrderPage>
|
|
|
|
|
_queryMiNiDetail(String id) async { |
|
|
|
|
BaseData<MiNiDetail> baseData = await minService.miNiDetail(id); |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
setState(() { |
|
|
|
|
showStoreSelector(baseData.data); |
|
|
|
|
}); |
|
|
|
|
showStoreSelector(baseData.data, id); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -500,18 +510,46 @@ class _StoreOrderPage extends State<StoreOrderPage>
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
///选规格弹窗 |
|
|
|
|
showStoreSelector(MiNiDetail miNiDetail) { |
|
|
|
|
showModalBottomSheet( |
|
|
|
|
showStoreSelector(MiNiDetail miNiDetail, String id) async { |
|
|
|
|
var result = await showModalBottomSheet( |
|
|
|
|
context: context, |
|
|
|
|
backgroundColor: Colors.transparent, |
|
|
|
|
builder: (context) { |
|
|
|
|
return ProductSku(miNiDetail); |
|
|
|
|
return ProductSku(miNiDetail, id); |
|
|
|
|
}, |
|
|
|
|
); |
|
|
|
|
if (result != null) { |
|
|
|
|
if (shopCarGoods == null || shopCarGoods.length == 0) { |
|
|
|
|
shopCarGoods = []; |
|
|
|
|
shopCarGoods.add(result); |
|
|
|
|
} else { |
|
|
|
|
Map<String, dynamic> map; |
|
|
|
|
shopCarGoods.forEach((element) { |
|
|
|
|
if (element["id"] == result["id"]) { |
|
|
|
|
map = element; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
print("result000: $map"); |
|
|
|
|
if (map != null) { |
|
|
|
|
int index = shopCarGoods.indexWhere((element) => element["id"] == result["id"]); |
|
|
|
|
shopCarGoods.removeAt(index); |
|
|
|
|
shopCarGoods.insert(index, result); |
|
|
|
|
} else { |
|
|
|
|
shopCarGoods.add(result); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
calculatePrice(); |
|
|
|
|
} |
|
|
|
|
print("result111: $shopCarGoods"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
bool get wantKeepAlive => true; |
|
|
|
|
calculatePrice() { |
|
|
|
|
|
|
|
|
|
setState(() {}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// @override |
|
|
|
|
// bool get wantKeepAlive => true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
class Title extends StatefulWidget { |
|
|
|
|