|
|
|
@ -24,7 +24,6 @@ class StoreOrderListPage extends StatefulWidget {
|
|
|
|
|
final Function(String id, int count) queryMiNiDetail; |
|
|
|
|
final Function queryShoppingCart; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ShoppingCart shopCarGoods; |
|
|
|
|
|
|
|
|
|
StoreOrderListPage( |
|
|
|
@ -47,32 +46,43 @@ class StoreOrderListPage extends StatefulWidget {
|
|
|
|
|
|
|
|
|
|
class _StoreOrderListPage extends State<StoreOrderListPage> { |
|
|
|
|
int isSelected = 0; |
|
|
|
|
int tempClickIndex = 0; |
|
|
|
|
|
|
|
|
|
// int tempClickIndex = 0; |
|
|
|
|
ApiService apiService; |
|
|
|
|
MinApiService minService; |
|
|
|
|
List<FindMiNiGroupList> appletProducts; |
|
|
|
|
List<ProductListBean> productListBeans = []; |
|
|
|
|
|
|
|
|
|
ScrollController controller = ScrollController(); |
|
|
|
|
int currentIndex = 0; |
|
|
|
|
final ScrollController controller = ScrollController(); |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
void initState() { |
|
|
|
|
super.initState(); |
|
|
|
|
|
|
|
|
|
controller.addListener(() { |
|
|
|
|
for (int i = 0; i < appletProducts.length; i++) { |
|
|
|
|
if (currentIndex != i && |
|
|
|
|
controller.offset >= appletProducts[i].goodsIndex && |
|
|
|
|
(i == appletProducts.length - 1 || |
|
|
|
|
controller.offset < appletProducts[i + 1].goodsIndex)) { |
|
|
|
|
setState(() { |
|
|
|
|
currentIndex = i; |
|
|
|
|
}); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
appletGoods(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
///小程序查询分组及商品列表 |
|
|
|
|
appletGoods() async { |
|
|
|
|
SharedPreferences value = await SharedPreferences.getInstance(); |
|
|
|
|
minService = MinApiService( |
|
|
|
|
Dio(), |
|
|
|
|
minService = MinApiService(Dio(), |
|
|
|
|
context: context, |
|
|
|
|
token: widget.minToken, |
|
|
|
|
tenant: widget.tenant, |
|
|
|
|
storeId: widget.arguments["id"], |
|
|
|
|
showLoading: true |
|
|
|
|
); |
|
|
|
|
showLoading: true); |
|
|
|
|
|
|
|
|
|
BaseData<List<FindMiNiGroupList>> baseData = |
|
|
|
|
await minService.findMiNiGroupList({ |
|
|
|
@ -83,10 +93,16 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
|
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
// refreshController.refreshCompleted(); |
|
|
|
|
setState(() { |
|
|
|
|
appletProducts = baseData.data; |
|
|
|
|
productListBeans.clear(); |
|
|
|
|
if (appletProducts.length > 0) |
|
|
|
|
productListBeans.addAll(appletProducts[isSelected].productList); |
|
|
|
|
appletProducts = baseData.data ?? []; |
|
|
|
|
// productListBeans.clear(); |
|
|
|
|
// if (appletProducts.length > 0) |
|
|
|
|
// productListBeans.addAll(appletProducts[isSelected].productList); |
|
|
|
|
double goodsIndex = 0; |
|
|
|
|
appletProducts.forEach((element) { |
|
|
|
|
element.goodsIndex = goodsIndex; |
|
|
|
|
element.height = ((element.productList.length ?? 0) * 90.h + 76.h); |
|
|
|
|
goodsIndex += element.height; |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
// refreshController.refreshFailed(); |
|
|
|
@ -110,74 +126,95 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
|
|
|
|
|
width: 100.w, |
|
|
|
|
child: ListView.builder( |
|
|
|
|
itemCount: appletProducts == null ? 0 : appletProducts.length, |
|
|
|
|
controller: controller, |
|
|
|
|
// controller: controller, |
|
|
|
|
physics: BouncingScrollPhysics(), |
|
|
|
|
shrinkWrap: true, |
|
|
|
|
padding: EdgeInsets.only(top: 0, bottom: 25), |
|
|
|
|
itemBuilder: (context, position) { |
|
|
|
|
return orderItem(appletProducts[position], position); |
|
|
|
|
return GestureDetector( |
|
|
|
|
onTap: () { |
|
|
|
|
}, |
|
|
|
|
child: orderItem(position), |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
Container( |
|
|
|
|
width: MediaQuery.of(context).size.width - 100.w, |
|
|
|
|
child: ListView.builder( |
|
|
|
|
itemCount: productListBeans == null ? 0 : productListBeans.length, |
|
|
|
|
itemCount: appletProducts == null ? 0 : appletProducts.length, |
|
|
|
|
controller: controller, |
|
|
|
|
physics: BouncingScrollPhysics(), |
|
|
|
|
shrinkWrap: true, |
|
|
|
|
padding: EdgeInsets.zero, |
|
|
|
|
padding: EdgeInsets.only(top: 0, bottom: 25), |
|
|
|
|
itemBuilder: (context, position) { |
|
|
|
|
return GestureDetector( |
|
|
|
|
onTap: () { |
|
|
|
|
if (widget.storeInfo.posType.code == |
|
|
|
|
"NORMALSTORE" && |
|
|
|
|
widget.storeInfo.storeName == "百年川椒(光谷店)"||widget.storeInfo.storeName == "百年川椒(汉街店)"||widget.storeInfo.storeName == "回乡农场火锅") |
|
|
|
|
return; |
|
|
|
|
else |
|
|
|
|
goShopDetailsPage(position); |
|
|
|
|
}, |
|
|
|
|
child: goodsItem(position), |
|
|
|
|
); |
|
|
|
|
return rightOrderItem(position); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
// Container( |
|
|
|
|
// width: MediaQuery.of(context).size.width - 100.w, |
|
|
|
|
// child: ListView.builder( |
|
|
|
|
// itemCount: productListBeans == null ? 0 : productListBeans.length, |
|
|
|
|
// physics: BouncingScrollPhysics(), |
|
|
|
|
// shrinkWrap: true, |
|
|
|
|
// padding: EdgeInsets.zero, |
|
|
|
|
// itemBuilder: (context, position) { |
|
|
|
|
// return GestureDetector( |
|
|
|
|
// onTap: () { |
|
|
|
|
// if (widget.storeInfo.posType.code == |
|
|
|
|
// "NORMALSTORE" && |
|
|
|
|
// widget.storeInfo.storeName == "百年川椒(光谷店)"||widget.storeInfo.storeName == "百年川椒(汉街店)"||widget.storeInfo.storeName == "回乡农场火锅") |
|
|
|
|
// return; |
|
|
|
|
// else |
|
|
|
|
// goShopDetailsPage(position); |
|
|
|
|
// }, |
|
|
|
|
// child: goodsItem(position), |
|
|
|
|
// ); |
|
|
|
|
// }, |
|
|
|
|
// ), |
|
|
|
|
// ), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
goShopDetailsPage(position) async{ |
|
|
|
|
await Navigator.of(context).pushNamed('/router/shop_details_page',arguments: { |
|
|
|
|
"id":productListBeans[position].id, |
|
|
|
|
"storeId":productListBeans[position].storeId, |
|
|
|
|
goShopDetailsPage(ProductListBean e) async { |
|
|
|
|
await Navigator.of(context) |
|
|
|
|
.pushNamed('/router/shop_details_page', arguments: { |
|
|
|
|
"id": e.id, |
|
|
|
|
"storeId": e.storeId, |
|
|
|
|
}); |
|
|
|
|
widget. queryShoppingCart(); |
|
|
|
|
widget.queryShoppingCart(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Widget orderItem(FindMiNiGroupList findMiNiGroupList, int index) { |
|
|
|
|
int count = calculateItemCount(findMiNiGroupList); |
|
|
|
|
Widget orderItem(int index) { |
|
|
|
|
int count = calculateItemCount(appletProducts[index]); |
|
|
|
|
return Container( |
|
|
|
|
width: 100, |
|
|
|
|
child: GestureDetector( |
|
|
|
|
onTap: () { |
|
|
|
|
setState(() { |
|
|
|
|
isSelected = index; |
|
|
|
|
productListBeans.clear(); |
|
|
|
|
productListBeans.addAll(findMiNiGroupList.productList); |
|
|
|
|
// isSelected = index; |
|
|
|
|
// productListBeans.clear(); |
|
|
|
|
// productListBeans.addAll(appletProducts[index].productList); |
|
|
|
|
controller.animateTo(appletProducts[index].goodsIndex, |
|
|
|
|
duration: Duration(milliseconds: 300), |
|
|
|
|
curve: Curves.ease); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
child: Stack( |
|
|
|
|
alignment: Alignment.center, |
|
|
|
|
children: [ |
|
|
|
|
Container( |
|
|
|
|
color: isSelected != index ? Color(0xFFFAFAFA) : Colors.white, |
|
|
|
|
color: currentIndex != index ? Color(0xFFFAFAFA) : Colors.white, |
|
|
|
|
alignment: Alignment.center, |
|
|
|
|
padding: EdgeInsets.all(15), |
|
|
|
|
child: Row( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
|
|
|
children: [ |
|
|
|
|
if (isSelected == index) |
|
|
|
|
if (currentIndex == index) |
|
|
|
|
Container( |
|
|
|
|
width: 2, |
|
|
|
|
height: 17, |
|
|
|
@ -186,14 +223,15 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
|
|
|
|
|
), |
|
|
|
|
Expanded( |
|
|
|
|
child: Text( |
|
|
|
|
findMiNiGroupList.groupName, |
|
|
|
|
appletProducts[index].groupName, |
|
|
|
|
textAlign: TextAlign.center, |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: isSelected != index |
|
|
|
|
? Color(0xFF202020) |
|
|
|
|
color: currentIndex != index |
|
|
|
|
? Color(0xFF4D4D4D) |
|
|
|
|
: Color(0xFF000000), |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
|
fontWeight: currentIndex != index |
|
|
|
|
? MyFontWeight.medium : MyFontWeight.semi_bold , |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
flex: 1, |
|
|
|
@ -223,6 +261,51 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
|
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Widget rightOrderItem(int rightIndex) { |
|
|
|
|
return Container( |
|
|
|
|
color: Colors.white, |
|
|
|
|
padding: EdgeInsets.only( |
|
|
|
|
right: 16.w, |
|
|
|
|
bottom: 30.h, |
|
|
|
|
top: 10.h, |
|
|
|
|
), |
|
|
|
|
child: Column( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start, |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
|
children: [ |
|
|
|
|
Padding( |
|
|
|
|
padding: EdgeInsets.only(left: 16.w, bottom: 24.h), |
|
|
|
|
child: Text( |
|
|
|
|
appletProducts[rightIndex].groupName, |
|
|
|
|
textAlign: TextAlign.center, |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Color(0xFF000000), |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
fontWeight: MyFontWeight.semi_bold, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
Column( |
|
|
|
|
children: appletProducts[rightIndex].productList.map((e) { |
|
|
|
|
return GestureDetector( |
|
|
|
|
onTap: (){ |
|
|
|
|
if (widget.storeInfo.posType.code == |
|
|
|
|
"NORMALSTORE" && |
|
|
|
|
widget.storeInfo.storeName == "百年川椒(光谷店)"||widget.storeInfo.storeName == "百年川椒(汉街店)"||widget.storeInfo.storeName == "回乡农场火锅") |
|
|
|
|
return; |
|
|
|
|
else |
|
|
|
|
goShopDetailsPage(e); |
|
|
|
|
}, |
|
|
|
|
child:goodsItem(e), |
|
|
|
|
); |
|
|
|
|
}).toList() ?? |
|
|
|
|
[], |
|
|
|
|
) |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int calculateItemCount(FindMiNiGroupList findMiNiGroupList) { |
|
|
|
|
if (widget.shopCarGoods == null) return 0; |
|
|
|
|
int count = 0; |
|
|
|
@ -236,12 +319,12 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
|
|
|
|
|
return count; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Widget goodsItem(position) { |
|
|
|
|
Widget goodsItem(ProductListBean e) { |
|
|
|
|
ShoppingCartSkuItemListBean shoppingCartSkuItemListBean; |
|
|
|
|
int count = 0; |
|
|
|
|
if (widget.shopCarGoods != null) { |
|
|
|
|
widget.shopCarGoods.shoppingCartSkuItemList.forEach((element) { |
|
|
|
|
if (productListBeans[position].id == element.productId) { |
|
|
|
|
if (e.id == element.productId) { |
|
|
|
|
if (shoppingCartSkuItemListBean == null) { |
|
|
|
|
shoppingCartSkuItemListBean = element; |
|
|
|
|
count = shoppingCartSkuItemListBean.buyNum; |
|
|
|
@ -253,13 +336,12 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
|
|
|
|
|
} |
|
|
|
|
return ShopGoods( |
|
|
|
|
(ShoppingCartSkuItemListBean shoppingCartSkuItemListBean) { |
|
|
|
|
widget.queryMiNiDetail(productListBeans[position].id, 1); |
|
|
|
|
widget.queryMiNiDetail(e.id, 1); |
|
|
|
|
}, |
|
|
|
|
(ShoppingCartSkuItemListBean shoppingCartSkuItemListBean) { |
|
|
|
|
if (count > 0) |
|
|
|
|
widget.queryMiNiDetail(productListBeans[position].id, -1); |
|
|
|
|
if (count > 0) widget.queryMiNiDetail(e.id, -1); |
|
|
|
|
}, |
|
|
|
|
productListBean: productListBeans[position], |
|
|
|
|
productListBean: e, |
|
|
|
|
count: count, |
|
|
|
|
isShopCart: false, |
|
|
|
|
queryMiNiDetail: widget.queryMiNiDetail, |
|
|
|
|