diff --git a/lib/retrofit/data/miNiDetail.dart b/lib/retrofit/data/miNiDetail.dart index adcf5c44..f7ee0fd5 100644 --- a/lib/retrofit/data/miNiDetail.dart +++ b/lib/retrofit/data/miNiDetail.dart @@ -83,7 +83,7 @@ class MiNiDetail { dynamic namePinyin; dynamic nameInitials; - static MiNiDetail fromMap(Map map) { + static MiNiDetail fromJson(Map map) { if (map == null) return null; MiNiDetail miNiDetailBean = MiNiDetail(); miNiDetailBean.id = map['id']; @@ -115,15 +115,15 @@ class MiNiDetail { miNiDetailBean.isDelete = map['isDelete']; miNiDetailBean.printerFlag = map['printerFlag']; miNiDetailBean.materialId = map['materialId']; - miNiDetailBean.imgs = List()..addAll( + miNiDetailBean.imgs = []..addAll( (map['imgs'] as List ?? []).map((o) => o.toString()) ); - miNiDetailBean.storeDTO = StoreDTOBean.fromMap(map['storeDTO']); - miNiDetailBean.attrList = List()..addAll( - (map['attrList'] as List ?? []).map((o) => AttrListBean.fromMap(o)) + miNiDetailBean.storeDTO = StoreDTOBean.fromJson(map['storeDTO']); + miNiDetailBean.attrList = []..addAll( + (map['attrList'] as List ?? []).map((o) => AttrListBean.fromJson(o)) ); - miNiDetailBean.productSkuVOList = List()..addAll( - (map['productSkuVOList'] as List ?? []).map((o) => ProductSkuVOListBean.fromMap(o)) + miNiDetailBean.productSkuVOList = []..addAll( + (map['productSkuVOList'] as List ?? []).map((o) => ProductSkuVOListBean.fromJson(o)) ); miNiDetailBean.shipAddress = map['shipAddress']; miNiDetailBean.buyCount = map['buyCount']; @@ -232,7 +232,7 @@ class ProductSkuVOListBean { List skuAttrList; dynamic setMealDTOList; - static ProductSkuVOListBean fromMap(Map map) { + static ProductSkuVOListBean fromJson(Map map) { if (map == null) return null; ProductSkuVOListBean productSkuVOListBean = ProductSkuVOListBean(); productSkuVOListBean.id = map['id']; @@ -257,8 +257,8 @@ class ProductSkuVOListBean { productSkuVOListBean.material = map['material']; productSkuVOListBean.version = map['version']; productSkuVOListBean.skuAttrCodeDTOList = map['skuAttrCodeDTOList']; - productSkuVOListBean.skuAttrList = List()..addAll( - (map['skuAttrList'] as List ?? []).map((o) => SkuAttrListBean.fromMap(o)) + productSkuVOListBean.skuAttrList = []..addAll( + (map['skuAttrList'] as List ?? []).map((o) => SkuAttrListBean.fromJson(o)) ); productSkuVOListBean.setMealDTOList = map['setMealDTOList']; return productSkuVOListBean; @@ -315,7 +315,7 @@ class SkuAttrListBean { dynamic sortOrder; int isDelete; - static SkuAttrListBean fromMap(Map map) { + static SkuAttrListBean fromJson(Map map) { if (map == null) return null; SkuAttrListBean skuAttrListBean = SkuAttrListBean(); skuAttrListBean.id = map['id']; @@ -364,7 +364,7 @@ class AttrListBean { String id; List attrValueList; - static AttrListBean fromMap(Map map) { + static AttrListBean fromJson(Map map) { if (map == null) return null; AttrListBean attrListBean = AttrListBean(); attrListBean.productId = map['productId']; @@ -374,8 +374,8 @@ class AttrListBean { attrListBean.isDelete = map['isDelete']; attrListBean.attrCode = map['attrCode']; attrListBean.id = map['id']; - attrListBean.attrValueList = List()..addAll( - (map['attrValueList'] as List ?? []).map((o) => AttrValueListBean.fromMap(o)) + attrListBean.attrValueList = []..addAll( + (map['attrValueList'] as List ?? []).map((o) => AttrValueListBean.fromJson(o)) ); return attrListBean; } @@ -410,7 +410,7 @@ class AttrValueListBean { dynamic attrValueCode; bool isSelected; - static AttrValueListBean fromMap(Map map) { + static AttrValueListBean fromJson(Map map) { if (map == null) return null; AttrValueListBean attrValueListBean = AttrValueListBean(); attrValueListBean.id = map['id']; @@ -449,7 +449,7 @@ class StoreDTOBean { int productCount; int soldNum; - static StoreDTOBean fromMap(Map map) { + static StoreDTOBean fromJson(Map map) { if (map == null) return null; StoreDTOBean storeDTOBean = StoreDTOBean(); storeDTOBean.id = map['id']; diff --git a/lib/retrofit/min_api.dart b/lib/retrofit/min_api.dart index 77fb98d2..92b33279 100644 --- a/lib/retrofit/min_api.dart +++ b/lib/retrofit/min_api.dart @@ -71,14 +71,17 @@ abstract class MinApiService { EasyLoading.dismiss(); } debugPrint("code = ${response.statusCode}"); - p(jsonEncode(response.data)); + // p(jsonEncode(response.data)); + + debugPrint(jsonEncode(response.data), wrapWidth: response.data.toString().length); + Map map = response.data; if (map["code"] != 0) { EasyLoading.dismiss(); } if (map["code"] == 40005 || map["code"] == 40001) { if (!LoginTipsDialog().isShow) { - print("show: ${LoginTipsDialog().isShow}"); + // print("show: ${LoginTipsDialog().isShow}"); LoginTipsDialog().show(context); } } else if (map["code"] != 0 && response.request.baseUrl == baseUrl) { diff --git a/lib/retrofit/min_api.g.dart b/lib/retrofit/min_api.g.dart index 2dcec64f..56e0cc46 100644 --- a/lib/retrofit/min_api.g.dart +++ b/lib/retrofit/min_api.g.dart @@ -17,22 +17,18 @@ class _MinApiService implements MinApiService { String baseUrl; @override - Future>> findMiNiGroupList( - param, header) async { + Future>> findMiNiGroupList(param) async { ArgumentError.checkNotNull(param, 'param'); - ArgumentError.checkNotNull(header, 'header'); const _extra = {}; final queryParameters = {}; final _data = {}; _data.addAll(param ?? {}); - final _header= {}; - _header.addAll(header ?? {}); final _result = await _dio.request>( 'product/findMiNiGroupList', queryParameters: queryParameters, options: RequestOptions( method: 'POST', - headers: _header, + headers: {}, extra: _extra, baseUrl: baseUrl), data: _data); @@ -62,7 +58,30 @@ class _MinApiService implements MinApiService { data: _data); final value = BaseData.fromJson( _result.data, - (json) => MiNiDetail.fromMap(json), + (json) => MiNiDetail.fromJson(json), + ); + return value; + } + + @override + Future> shoppingCart(param, header) async { + ArgumentError.checkNotNull(param, 'param'); + ArgumentError.checkNotNull(header, 'header'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>('shoppingcart', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => FindMiNiGroupList.fromJson(json), ); return value; } diff --git a/lib/store/store_order.dart b/lib/store/store_order.dart index 82f4e831..e5d6febb 100644 --- a/lib/store/store_order.dart +++ b/lib/store/store_order.dart @@ -176,12 +176,6 @@ class _StoreOrderPage extends State Positioned( child: Column( children: [ - // Image.asset( - // "assets/image/share_image_bg.png", - // fit: BoxFit.cover, - // width: MediaQuery.of(context).size.width, - // height: 180.h, - // ), buildSwiper(), Expanded( child: Container( @@ -203,77 +197,78 @@ class _StoreOrderPage extends State ///门店信息 StoreInfoView(storeInfo), - ///门店对应优惠券 - if (storeInfo != null && - storeInfo.couponVOList != null) - UnionCoupon( - storeInfo, - (a) {}, - coupon: true, - ), + ///门店对应优惠券 + if (storeInfo != null && + storeInfo.couponVOList != null) + UnionCoupon( + storeInfo, + (a) {}, + coupon: true, + ), - SizedBox( - height: 8, - ), + SizedBox( + height: 8, + ), - ///门店对应VIP信息 - Vip(storeInfo, () {}, false), - ], + ///门店对应VIP信息 + Vip(storeInfo, () {}, false), + ], + ), ), + top: 110.h, + bottom: 0, + left: 0, + right: 0, ), - top: 110.h, - bottom: 0, - left: 0, - right: 0, - ), - ], - ), - ), - backgroundColor: Color(0x33FAFAFA), - centerTitle: false, - elevation: 0, - bottom: PreferredSize( - preferredSize: Size( - MediaQuery.of(context).size.width, - 38, + ], + ), ), - child: Container( - padding: EdgeInsets.symmetric(horizontal: 10.w), - width: MediaQuery.of(context).size.width, - child: TabBar( - controller: tabcontroller, - automaticIndicatorColorAdjustment: true, - isScrollable: true, - indicatorWeight: 1, - indicatorColor: Color(0xFFFAFAFA), - labelPadding: - EdgeInsets.only(left: 8.w, right: 8.w), - indicatorSize: TabBarIndicatorSize.label, - unselectedLabelStyle: TextStyle( - fontSize: 15.sp, - fontWeight: FontWeight.w400, - ), - labelStyle: TextStyle( - color: Colors.black, - fontSize: 18.sp, - fontWeight: FontWeight.bold, + backgroundColor: Color(0x33FAFAFA), + centerTitle: false, + elevation: 0, + bottom: PreferredSize( + preferredSize: Size( + MediaQuery.of(context).size.width, + 38, + ), + child: Container( + padding: EdgeInsets.symmetric(horizontal: 10.w), + width: MediaQuery.of(context).size.width, + child: TabBar( + controller: tabcontroller, + automaticIndicatorColorAdjustment: true, + isScrollable: true, + indicatorWeight: 1, + indicatorColor: Color(0xFFFAFAFA), + labelPadding: + EdgeInsets.only(left: 8.w, right: 8.w), + indicatorSize: TabBarIndicatorSize.label, + unselectedLabelStyle: TextStyle( + fontSize: 15.sp, + fontWeight: FontWeight.w400, + ), + labelStyle: TextStyle( + color: Colors.black, + fontSize: 18.sp, + fontWeight: FontWeight.bold, + ), + labelColor: Colors.black, + tabs: [ + MyTab(text: S.current.diancan), + MyTab(text: S.current.xindianhuodong), + ], ), - labelColor: Colors.black, - tabs: [ - MyTab(text: S.current.diancan), - MyTab(text: S.current.xindianhuodong), - ], ), ), ), ), - ), - ]; - }, - body: TabBarView( - physics: BouncingScrollPhysics(), - children: _widgetOptions, - controller: tabcontroller, + ]; + }, + body: TabBarView( + physics: BouncingScrollPhysics(), + children: _widgetOptions, + controller: tabcontroller, + ), ), ), ), @@ -363,7 +358,7 @@ class _StoreOrderPage extends State ), ], ), - ) + ), ], ); } @@ -373,34 +368,35 @@ class _StoreOrderPage extends State width: double.infinity, height: 180.h, child: Swiper( - pagination: SwiperPagination( - alignment: Alignment.bottomCenter, - builder: DotSwiperPaginationBuilder( - size: 8.w, - activeSize: 8.w, - space: 5.w, - activeColor: Colors.white, - color: Colors.white.withAlpha(76), - ), + pagination: SwiperPagination( + alignment: Alignment.bottomCenter, + builder: DotSwiperPaginationBuilder( + size: 8.w, + activeSize: 8.w, + space: 5.w, + activeColor: Colors.white, + color: Colors.white.withAlpha(76), ), - itemBuilder: (context, position) { - return Container( - child: MImage( - (storeInfo != null && - storeInfo.bannerList != null && - position < storeInfo.bannerList.length) - ? storeInfo.bannerList[position].imgUrl - : "", - fit: BoxFit.cover, - radius: BorderRadius.zero, - errorSrc: "assets/image/default_2_1.png", - fadeSrc: "assets/image/default_2_1.png", - ), - ); - }, - itemCount: (storeInfo != null && storeInfo.bannerList != null) - ? storeInfo.bannerList.length - : 1), + ), + itemBuilder: (context, position) { + return Container( + child: MImage( + (storeInfo != null && + storeInfo.bannerList != null && + position < storeInfo.bannerList.length) + ? storeInfo.bannerList[position].imgUrl + : "", + fit: BoxFit.cover, + radius: BorderRadius.zero, + errorSrc: "assets/image/default_2_1.png", + fadeSrc: "assets/image/default_2_1.png", + ), + ); + }, + itemCount: (storeInfo != null && storeInfo.bannerList != null) + ? storeInfo.bannerList.length + : 1, + ), ); } @@ -412,9 +408,7 @@ class _StoreOrderPage extends State context: context, backgroundColor: Colors.transparent, builder: (context) { - return StatefulBuilder(builder: (context1, state) { - return ShopCar(productLists); - }); + return ShopCar(productLists); }, ); } @@ -454,7 +448,8 @@ class _Title extends State { if (alphaProgress <= 1) { alphatemp = 1; } else if (alphaProgress <= alphaHeight) { - alphatemp = (((alphaHeight - alphaProgress) / alphaHeight) > 0.5) ? 1 : 0; + alphatemp = + (((alphaHeight - alphaProgress) / alphaHeight) > 0.5) ? 1 : 0; } else { alphatemp = 0; } diff --git a/lib/store/store_view/product_sku.dart b/lib/store/store_view/product_sku.dart index 9608d09f..f32b4f5a 100644 --- a/lib/store/store_view/product_sku.dart +++ b/lib/store/store_view/product_sku.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:huixiang/retrofit/data/miNiDetail.dart'; @@ -23,190 +24,248 @@ class _ProductSku extends State<ProductSku> { @override Widget build(BuildContext context) { - return Container( - alignment: Alignment.topCenter, - padding: EdgeInsets.only(top: 16, left: 16, right: 16), - width: double.infinity, - decoration: BoxDecoration( - color: Color(0xFFFAFAFA), - borderRadius: BorderRadius.only( - topLeft: Radius.circular(8), - topRight: Radius.circular(8), + String selectSku = ""; + int selectCount = 1; + return StatefulBuilder(builder: (context1, state) { + return Container( + alignment: Alignment.topCenter, + padding: EdgeInsets.only( + top: 16, + left: 16, + right: 16, ), - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - MImage( - widget.miNiDetail.imgs[0], - width: 70, - height: 70, - fit: BoxFit.cover, - errorSrc: "assets/image/default_1.png", - fadeSrc: "assets/image/default_1.png", - ), - SizedBox( - width: 10, - ), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - widget.miNiDetail.productName, - style: TextStyle( - color: Colors.black, - fontSize: 16.sp, - fontWeight: MyFontWeight.medium, - ), - ), - Padding( - padding: EdgeInsets.only(top: 4, bottom: 7), - child: Text( - "已选:正常冰", + width: double.infinity, + decoration: BoxDecoration( + color: Color(0xFFFAFAFA), + borderRadius: BorderRadius.only( + topLeft: Radius.circular(8), + topRight: Radius.circular(8), + ), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + MImage( + widget.miNiDetail.imgs[0], + width: 70, + height: 70, + fit: BoxFit.cover, + errorSrc: "assets/image/default_1.png", + fadeSrc: "assets/image/default_1.png", + ), + SizedBox( + width: 10, + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + widget.miNiDetail.productName, style: TextStyle( - color: Color(0xFF727272), - fontSize: 11.sp, - fontWeight: MyFontWeight.regular, + color: Colors.black, + fontSize: 16.sp, + fontWeight: MyFontWeight.medium, ), ), - ), - Row( - children: [ - Text( - S.of(context).huiyuanjia, + Padding( + padding: EdgeInsets.only(top: 4, bottom: 7), + child: Text( + "已选:" + selectSku, style: TextStyle( - color: Color(0xFFFF7A1A), - fontSize: 13.sp, - fontWeight: MyFontWeight.medium, + color: Color(0xFF727272), + fontSize: 11.sp, + fontWeight: MyFontWeight.regular, ), ), - Text( - widget.miNiDetail.price, - style: TextStyle( - color: Color(0xFFFF7A1A), - fontSize: 14.sp, - fontWeight: MyFontWeight.medium, + ), + Row( + children: [ + Text( + S.of(context).huiyuanjia, + style: TextStyle( + color: Color(0xFFFF7A1A), + fontSize: 13.sp, + fontWeight: MyFontWeight.medium, + ), ), - ), - ], + Text( + widget.miNiDetail.price, + style: TextStyle( + color: Color(0xFFFF7A1A), + fontSize: 14.sp, + fontWeight: MyFontWeight.medium, + ), + ), + ], + ), + ], + ), + Spacer(), + InkWell( + onTap: () { + Navigator.of(context).pop(); + }, + child: Image.asset( + "assets/image/icon_order_cancel.png", + width: 22, + height: 22, ), - ], - ), - Spacer(), - InkWell( - onTap: () { - Navigator.of(context).pop(); - }, - child: Image.asset( - "assets/image/icon_order_cancel.png", - width: 22, - height: 22, ), + ], + ), + SizedBox( + height: 23, + ), + Expanded( + child: ListView.builder( + itemCount: widget.miNiDetail.attrList.length, + scrollDirection: Axis.vertical, + physics: BouncingScrollPhysics(), + itemBuilder: (context, position) { + return attrItem( + () { + state(() { + for (var i = 0; + i < + widget.miNiDetail.attrList[position] + .attrValueList.length; + i++) { + if (tempClickIndex == i) + widget.miNiDetail.attrList[position] + .attrValueList[i].isSelected = true; + else + widget.miNiDetail.attrList[position] + .attrValueList[i].isSelected = false; + } + selectSku = ""; + widget.miNiDetail.attrList.forEach((e0) { + e0.attrValueList.forEach((e1) { + if (e1.isSelected ?? false) + selectSku += e1.attrValue + " "; + }); + }); + }); + }, + widget.miNiDetail.attrList[position], + ); + }, ), - ], - ), - SizedBox( - height: 23, - ), - Expanded( - child: ListView.builder( - itemCount: widget.miNiDetail.attrList.length, - scrollDirection: Axis.vertical, - physics: BouncingScrollPhysics(), - itemBuilder: (context, position) { - return attrItem( - () { - setState(() { - for (var i = 0; - i < - widget.miNiDetail.attrList[position].attrValueList - .length; - i++) { - if (tempClickIndex == i) - widget.miNiDetail.attrList[position].attrValueList[i] - .isSelected = true; - else - widget.miNiDetail.attrList[position].attrValueList[i] - .isSelected = false; - } - }); - }, - widget.miNiDetail.attrList[position], - ); - }, ), - ), - SizedBox( - height: 24, - ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Expanded( - child: Text( - "数量", - style: TextStyle( - color: Colors.black, - fontSize: 14.sp, - fontWeight: MyFontWeight.regular, + SizedBox( + height: 24, + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Expanded( + child: Text( + "数量", + style: TextStyle( + color: Colors.black, + fontSize: 14.sp, + fontWeight: MyFontWeight.regular, + ), ), ), - ), - InkWell( - onTap: () {}, - child: Image.asset( - "assets/image/reduce.png", - width: 22, - height: 22, + InkWell( + onTap: () { + state(() { + if (selectCount > 1) selectCount--; + }); + }, + child: Image.asset( + "assets/image/reduce.png", + width: 22, + height: 22, + ), ), - ), - Padding( - padding: EdgeInsets.only(left: 8, right: 8), - child: Text( - "1", - style: TextStyle( - color: Colors.black, - fontSize: 14.sp, - fontWeight: MyFontWeight.medium, + Padding( + padding: EdgeInsets.only(left: 8, right: 8), + child: Text( + selectCount.toString(), + style: TextStyle( + color: Colors.black, + fontSize: 14.sp, + fontWeight: MyFontWeight.medium, + ), ), ), - ), - InkWell( - onTap: () {}, - child: Image.asset( - "assets/image/add.png", - width: 22, - height: 22, + InkWell( + onTap: () { + state(() { + selectCount++; + }); + }, + child: Image.asset( + "assets/image/add.png", + width: 22, + height: 22, + ), ), + ], + ), + SizedBox( + height: 24, + ), + GestureDetector( + onTap: () { + bool flag = false; + widget.miNiDetail.productSkuVOList.forEach((element) { + if (selectSku.trim() == element.skuNameStr) { + Navigator.of(context).pop(); + flag = true; + } + }); + if (!flag) + SmartDialog.showToast("请选择規格!", alignment: Alignment.center); + }, + child: RoundButton( + width: double.infinity, + height: 54.h, + text: "加入购物车", + textColor: Colors.white, + fontWeight: MyFontWeight.semi_bold, + radius: 27, + backgroup: Color(0xFF32A060), + fontSize: 16.sp, + // padding: EdgeInsets.symmetric(vertical: 5.h), ), - ], - ), - SizedBox( - height: 24, - ), - RoundButton( - width: double.infinity, - height: 54.h, - text: "加入购物车", - textColor: Colors.white, - fontWeight: MyFontWeight.semi_bold, - radius: 27, - backgroup: Color(0xFF32A060), - fontSize: 16.sp, - // padding: EdgeInsets.symmetric(vertical: 5.h), - callback: () { }, + ), + SizedBox( + height: 21.h, + ), + ], + ), + ); + }); + } + + Widget attrItem(Function fc, AttrListBean attrListBean) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsets.only(top: 24, bottom: 16), + child: Text( + attrListBean.attrName, + style: TextStyle( + color: Colors.black, + fontSize: 14.sp, + fontWeight: MyFontWeight.regular, + ), ), - ], - ), + ), + sweetnessStore(fc, attrListBean.attrValueList), + ], ); } - Widget sweetnessStore(Function fc, List<testModel> arrays) { + Widget sweetnessStore(Function fc, List<AttrValueListBean> arrays) { return GridView.builder( itemCount: arrays.length, shrinkWrap: true, @@ -227,7 +286,8 @@ class _ProductSku extends State<ProductSku> { tempClickIndex = index; fc(); }, - child: sweetnessItem(arrays[index].name, arrays[index].isSelected), + child: sweetnessItem( + arrays[index].attrValue, arrays[index].isSelected ?? false), ); }, ); diff --git a/lib/store/store_view/shop_car.dart b/lib/store/store_view/shop_car.dart index a33710d6..a41ea79a 100644 --- a/lib/store/store_view/shop_car.dart +++ b/lib/store/store_view/shop_car.dart @@ -22,158 +22,160 @@ class ShopCar extends StatefulWidget { class _ShopCar extends State<ShopCar> { @override Widget build(BuildContext context) { - return Container( - alignment: Alignment.topCenter, - width: double.infinity, - height: MediaQuery.of(context).size.height / 2, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.only( - topLeft: Radius.circular(8), - topRight: Radius.circular(8), - ), - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - padding: EdgeInsets.only( - top: 16, - left: 16, - right: 16, - bottom: 8, - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "已选商品", - style: TextStyle( - color: Colors.black, - fontSize: 14.sp, - fontWeight: MyFontWeight.medium, - ), - ), - InkWell( - onTap: () {}, - child: Image.asset( - "assets/image/delete.png", - width: 22, - height: 22, - ), - ), - ], - ), + return StatefulBuilder(builder: (context1, state) { + return Container( + alignment: Alignment.topCenter, + width: double.infinity, + height: MediaQuery.of(context).size.height / 2, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(8), + topRight: Radius.circular(8), ), - Expanded( - child: Container( + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( padding: EdgeInsets.only( - top: 8, + top: 16, left: 16, right: 16, + bottom: 8, ), - child: ListView.builder( - itemCount: widget.productLists == null ? 0 : widget.productLists.length, - physics: BouncingScrollPhysics(), - itemBuilder: (context, position) { - // return shoppGoodsItem(); - return GestureDetector( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "已选商品", + style: TextStyle( + color: Colors.black, + fontSize: 14.sp, + fontWeight: MyFontWeight.medium, + ), + ), + InkWell( onTap: () {}, - child: ShopGoods(widget.productLists[position], position), - ); - }, + child: Image.asset( + "assets/image/delete.png", + width: 22, + height: 22, + ), + ), + ], ), ), - ), - Stack( - alignment: Alignment.bottomLeft, - children: [ - Container( - height: 54.h, - decoration: BoxDecoration( - color: Color(0xFFFAFAFA), - boxShadow: [ - BoxShadow( - color: Colors.black.withAlpha(8), - offset: Offset(0, -1), - blurRadius: 3, - spreadRadius: 0, - ), - ], + Expanded( + child: Container( + padding: EdgeInsets.only( + top: 8, + left: 16, + right: 16, ), - child: Row( - children: [ - Spacer(), - Text( - S.of(context).heji, - style: TextStyle( - fontSize: 12.sp, + child: ListView.builder( + itemCount: widget.productLists == null ? 0 : widget.productLists.length, + physics: BouncingScrollPhysics(), + itemBuilder: (context, position) { + // return shoppGoodsItem(); + return GestureDetector( + onTap: () {}, + child: ShopGoods(widget.productLists[position], position), + ); + }, + ), + ), + ), + Stack( + alignment: Alignment.bottomLeft, + children: [ + Container( + height: 54.h, + decoration: BoxDecoration( + color: Color(0xFFFAFAFA), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(8), + offset: Offset(0, -1), + blurRadius: 3, + spreadRadius: 0, + ), + ], + ), + child: Row( + children: [ + Spacer(), + Text( + S.of(context).heji, + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: Colors.black, + ), + ), + Text( + "¥19.00", + style: TextStyle( + fontSize: 20.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF32A060), + ), + ), + Spacer(), + RoundButton( + width: 103.w, + height: 54.h, + text: S.current.jiesuan, + textColor: Colors.white, fontWeight: MyFontWeight.regular, - color: Colors.black, + backgroup: Color(0xFF32A060), + radius: 0, + fontSize: 16.sp, + padding: EdgeInsets.symmetric(vertical: 5.h), ), - ), - Text( - "¥19.00", - style: TextStyle( - fontSize: 20.sp, - fontWeight: MyFontWeight.medium, - color: Color(0xFF32A060), + ], + ), + ), + Stack( + children: [ + InkWell( + onTap: () { + Navigator.of(context).pop(); + }, + child: Image.asset( + "assets/image/shopp.png", + width: 88, + height: 88, ), ), - Spacer(), - RoundButton( - width: 103.w, - height: 54.h, - text: S.current.jiesuan, - textColor: Colors.white, - fontWeight: MyFontWeight.regular, - backgroup: Color(0xFF32A060), - radius: 0, - fontSize: 16.sp, - padding: EdgeInsets.symmetric(vertical: 5.h), + Positioned( + right: 15, + top: 14, + child: RoundButton( + width: 17, + height: 17, + text: "1", + textColor: Colors.white, + fontWeight: MyFontWeight.regular, + backgroup: Color(0xFF32A060), + fontSize: 12.sp, + radius: 100, + callback: () { + Navigator.of(context) + .pushNamed('/router/test_page'); + }, + ), ), ], ), - ), - Stack( - children: [ - InkWell( - onTap: () { - Navigator.of(context).pop(); - }, - child: Image.asset( - "assets/image/shopp.png", - width: 88, - height: 88, - ), - ), - Positioned( - right: 15, - top: 14, - child: RoundButton( - width: 17, - height: 17, - text: "1", - textColor: Colors.white, - fontWeight: MyFontWeight.regular, - backgroup: Color(0xFF32A060), - fontSize: 12.sp, - radius: 100, - callback: () { - Navigator.of(context) - .pushNamed('/router/test_page'); - }, - ), - ), - ], - ), - ], - ), - ], - ), - ); + ], + ), + ], + ), + ); + }); } } \ No newline at end of file diff --git a/lib/store/store_view/store_order_list.dart b/lib/store/store_view/store_order_list.dart index cb03f9bb..33e7f813 100644 --- a/lib/store/store_view/store_order_list.dart +++ b/lib/store/store_view/store_order_list.dart @@ -35,6 +35,7 @@ class StoreOrderListPage extends StatefulWidget { class _StoreOrderListPage extends State<StoreOrderListPage> { int isSelected = 0; + int tempClickIndex = 0; ApiService apiService; MinApiService minService; List<FindMiNiGroupList> appletProducts; @@ -403,288 +404,13 @@ class _StoreOrderListPage extends State<StoreOrderListPage> { ///选规格弹窗 showStoreSelector(MiNiDetail miNiDetail) { - String selectSku = ""; - int selectCount = 1; showModalBottomSheet( context: context, backgroundColor: Colors.transparent, builder: (context) { - return StatefulBuilder(builder: (context1, state) { - return Container( - alignment: Alignment.topCenter, - padding: EdgeInsets.only(top: 16, left: 16, right: 16), - width: double.infinity, - decoration: BoxDecoration( - color: Color(0xFFFAFAFA), - borderRadius: BorderRadius.only( - topLeft: Radius.circular(8), - topRight: Radius.circular(8), - ), - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - MImage( - miNiDetail.imgs[0], - width: 70, - height: 70, - fit: BoxFit.cover, - errorSrc: "assets/image/default_1.png", - fadeSrc: "assets/image/default_1.png", - ), - SizedBox(width: 10), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - miNiDetail.productName, - style: TextStyle( - color: Colors.black, - fontSize: 16.sp, - fontWeight: MyFontWeight.medium, - ), - ), - Padding( - padding: EdgeInsets.only(top: 4, bottom: 7), - child: Text( - "已选:" + selectSku, - style: TextStyle( - color: Color(0xFF727272), - fontSize: 11.sp, - fontWeight: MyFontWeight.regular, - ), - ), - ), - Row( - children: [ - Text( - S.of(context).huiyuanjia, - style: TextStyle( - color: Color(0xFFFF7A1A), - fontSize: 13.sp, - fontWeight: MyFontWeight.medium, - ), - ), - Text( - miNiDetail.price, - style: TextStyle( - color: Color(0xFFFF7A1A), - fontSize: 14.sp, - fontWeight: MyFontWeight.medium, - ), - ) - ], - ), - ], - ), - Spacer(), - InkWell( - onTap: () { - Navigator.of(context).pop(); - }, - child: Image.asset( - "assets/image/icon_order_cancel.png", - width: 22, - height: 22, - ), - ), - ], - ), - SizedBox( - height: 23, - ), - Expanded( - child: ListView.builder( - itemCount: miNiDetail.attrList.length, - scrollDirection: Axis.vertical, - physics: BouncingScrollPhysics(), - itemBuilder: (context, position) { - return attrItem(() { - state(() { - for (var i = 0; - i < - miNiDetail - .attrList[position].attrValueList.length; - i++) { - if (tempClickIndex == i) - miNiDetail.attrList[position].attrValueList[i] - .isSelected = true; - else - miNiDetail.attrList[position].attrValueList[i] - .isSelected = false; - } - selectSku = ""; - miNiDetail.attrList.forEach((e0) { - e0.attrValueList.forEach((e1) { - if (e1.isSelected ?? false) - selectSku += e1.attrValue + " "; - }); - }); - }); - }, miNiDetail.attrList[position]); - }, - )), - SizedBox( - height: 24, - ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Expanded( - child: Text( - "数量", - style: TextStyle( - color: Colors.black, - fontSize: 14.sp, - fontWeight: MyFontWeight.regular, - ), - )), - InkWell( - onTap: () { - state(() { - if (selectCount > 1) selectCount--; - }); - }, - child: Image.asset( - "assets/image/reduce.png", - width: 22, - height: 22, - ), - ), - Padding( - padding: EdgeInsets.only(left: 8, right: 8), - child: Text( - selectCount.toString(), - style: TextStyle( - color: Colors.black, - fontSize: 14.sp, - fontWeight: MyFontWeight.medium, - ), - ), - ), - InkWell( - onTap: () { - state(() { - selectCount++; - }); - }, - child: Image.asset( - "assets/image/add.png", - width: 22, - height: 22, - ), - ), - ], - ), - SizedBox( - height: 24, - ), - GestureDetector( - onTap: () { - bool flag = false; - miNiDetail.productSkuVOList.forEach((element) { - if (selectSku.trim() == element.skuNameStr) { - Navigator.of(context).pop(); - flag = true; - } - }); - if (!flag) - SmartDialog.showToast("请选择規格!", - alignment: Alignment.center); - }, - child: RoundButton( - width: double.infinity, - height: 54.h, - text: "加入购物车", - textColor: Colors.white, - fontWeight: MyFontWeight.semi_bold, - radius: 27, - backgroup: Color(0xFF32A060), - fontSize: 16.sp, - // padding: EdgeInsets.symmetric(vertical: 5.h), - ), - ), - SizedBox( - height: 21.h, - ), - ], - ), - ); - }); - }, - ); - } - - Widget attrItem(Function fc, AttrListBean attrListBean) { - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.only(top: 24, bottom: 16), - child: Text( - attrListBean.attrName, - style: TextStyle( - color: Colors.black, - fontSize: 14.sp, - fontWeight: MyFontWeight.regular, - ), - )), - sweetnessStore(fc, attrListBean.attrValueList), - ], - ); - } - - Widget sweetnessStore(Function fc, List<AttrValueListBean> arrays) { - return GridView.builder( - itemCount: arrays.length, - shrinkWrap: true, - physics: NeverScrollableScrollPhysics(), - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - //一行的Widget数量 - crossAxisCount: 4, - //水平子Widget之间间距 - crossAxisSpacing: 6.w, - //垂直子Widget之间间距 - mainAxisSpacing: 12.w, - //垂直单个子Widget之间间距 - childAspectRatio: 3 / 1), - itemBuilder: (contetx, index) { - return GestureDetector( - onTap: () { - tempClickIndex = index; - fc(); - }, - child: sweetnessItem( - arrays[index].attrValue, arrays[index].isSelected ?? false), - ); + return ProductSku(miNiDetail); }, ); } - Widget sweetnessItem(String name, bool isCheck) { - return Container( - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - RoundButton( - width: 68.w, - height: 29.h, - text: name, - textColor: !isCheck ? Color(0xFF727272) : Colors.white, - fontWeight: MyFontWeight.regular, - radius: 4, - backgroup: !isCheck ? Color(0xFFE5E5E5) : Color(0xFF32A060), - fontSize: 12.sp, - ), - ], - ), - ); - } - }