diff --git a/lib/retrofit/min_api.dart b/lib/retrofit/min_api.dart index 75ecd31d..eaceffa8 100644 --- a/lib/retrofit/min_api.dart +++ b/lib/retrofit/min_api.dart @@ -31,11 +31,6 @@ part 'min_api.g.dart'; // const base_url = "http://192.168.10.236:8765/app/";///费韬 // const baseUrl = "http://192.168.10.236:8765/app/";///费韬 - -const base_url = "http://192.168.10.142:8765/app/";///詹云久 -const baseUrl = "http://192.168.10.142:8765/app/";///詹云久 - - // const base_url = "http://192.168.10.37:8766/app/"; // const baseUrl = "http://192.168.10.37:8766/app/"; diff --git a/lib/settlement/settlement_view/settlement_order_commodity.dart b/lib/settlement/settlement_view/settlement_order_commodity.dart index 4b7e12c1..67529d5b 100644 --- a/lib/settlement/settlement_view/settlement_order_commodity.dart +++ b/lib/settlement/settlement_view/settlement_order_commodity.dart @@ -134,7 +134,7 @@ class _SettlementOrderCommodity extends State { margin: EdgeInsets.only( left: 16.w, ), - height: 44.h, + // height: 44.h, child: Column( mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.start, diff --git a/lib/store/shopping/activity_prefecture_details.dart b/lib/store/shopping/activity_prefecture_details.dart index 0f57f20c..cab7d39f 100644 --- a/lib/store/shopping/activity_prefecture_details.dart +++ b/lib/store/shopping/activity_prefecture_details.dart @@ -65,6 +65,7 @@ class _ActivityPrefectureDetails extends State { Dio(), context: context, token: value.getString("token"), + ); } BaseData baseData = diff --git a/lib/store/shopping/shopping_cart/shopping_cart_page.dart b/lib/store/shopping/shopping_cart/shopping_cart_page.dart index 035ed866..abd87a31 100644 --- a/lib/store/shopping/shopping_cart/shopping_cart_page.dart +++ b/lib/store/shopping/shopping_cart/shopping_cart_page.dart @@ -2,6 +2,9 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_swiper/flutter_swiper.dart'; import 'package:huixiang/generated/l10n.dart'; +import 'package:huixiang/retrofit/data/base_data.dart'; +import 'package:huixiang/retrofit/data/shoppingCart.dart'; +import 'package:huixiang/retrofit/min_api.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/store/shopping/shopping_home/recommend_goods_list_view.dart'; import 'package:huixiang/utils/font_weight.dart'; @@ -23,12 +26,101 @@ class ShoppingCartPage extends StatefulWidget { class _ShoppingCartPage extends State with AutomaticKeepAliveClientMixin { ApiService apiService; + MinApiService minService; + ShoppingCart shopCarGoods; + String pName; + String pid; + String cName; + String cid; + int tableId = 0; + @override void initState() { super.initState(); } + ///清空购物车 + clearShopCar() async { + BaseData baseData = await minService.clearShoppingCart(); + if (baseData.isSuccess) { + shopCarGoods = null; + setState(() {}); + } + } + + ///查询购物车 + Future queryShopCar() async { + pName="";//活动 + pid="";//活动 + cName="";//优惠券 + cid="";//优惠券 + BaseData> baseDate = + await minService.getShoppingCart(tableId); + if (baseDate != null && + baseDate.isSuccess && + baseDate.data != null && + baseDate.data.length > 0) { + if( baseDate.data[0].selectDiscount ==1){ + baseDate.data[0].couponList.forEach((element) { + if(element.isMaxCoupon){ + cName = element.promotionName; + cid = element.id; + } + }); + }else if(baseDate.data[0].selectDiscount==2){ + baseDate.data[0].promotionInfoList.forEach((element) { + if(element.isMaxPromotion){ + pName=element.name; + pid=element.id; + } + }); + } + return baseDate.data[0]; + } else { + return null; + } + } + + /// 购物车的key,用于刷新UI + GlobalKey shopCartKey = GlobalKey(); + + ///购物车➕1 + Future shopCartAdd( + ShoppingCartSkuItemListBean cartSkuItem) async { + Map shopCarTemp = shopCarGoods.toJson(); + cartSkuItem.buyNum += 1; + shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()]; + BaseData> baseDate = + await minService.shoppingCartSingle(shopCarTemp); + if (baseDate.isSuccess) { + this.shopCarGoods = await queryShopCar(); + if (shopCartKey != null) { + shopCartKey.currentState.setState(() {}); + } + setState(() {}); + } + return this.shopCarGoods; + } + + ///购物车➖1 + Future shopCartReduce( + ShoppingCartSkuItemListBean cartSkuItem) async { + Map shopCarTemp = shopCarGoods.toJson(); + cartSkuItem.buyNum -= 1; + shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()]; + BaseData> baseDate = + await minService.shoppingCartSingle(shopCarTemp); + if (baseDate.isSuccess) { + this.shopCarGoods = await queryShopCar(); + if (shopCartKey != null) { + shopCartKey.currentState.setState(() {}); + } + setState(() {}); + } + return this.shopCarGoods; + } + final SwiperController controller = SwiperController(); @override diff --git a/lib/store/shopping/shopping_mall_home.dart b/lib/store/shopping/shopping_mall_home.dart index 72becd83..38c4128e 100644 --- a/lib/store/shopping/shopping_mall_home.dart +++ b/lib/store/shopping/shopping_mall_home.dart @@ -54,10 +54,12 @@ class _ShoppingMallHome extends State void initState() { super.initState(); if (widget.arguments != null) choiceIndex = widget.arguments["type"]; - tenant = widget.arguments["tenant"]; storeId = widget.arguments["id"]; + debugPrint( + "store_param tenant:$tenant storeId:$storeId"); + SharedPreferences.getInstance().then((value) { minLogin(value); queryStoreInfo(); @@ -159,7 +161,8 @@ class _ShoppingMallHome extends State ShoppingHomePage( storeInfo, ), - if (choiceIndex == 1) ShoppingCartPage(), + if (choiceIndex == 1) ShoppingCartPage( + ), Align( alignment: Alignment.bottomCenter, child: Container( diff --git a/lib/store/store_view/store_info.dart b/lib/store/store_view/store_info.dart index e7cd4870..b11d70c5 100644 --- a/lib/store/store_view/store_info.dart +++ b/lib/store/store_view/store_info.dart @@ -30,7 +30,7 @@ class _StoreInfoView extends State { top: 5.h, bottom: 6.h, ), - height: 138.h, + height: 160.h, padding: EdgeInsets.all(12.w), decoration: BoxDecoration( color: Colors.white,