From 667f31c7e80fec3c440a043a0e0878553c2a78a9 Mon Sep 17 00:00:00 2001 From: wurong <953969641@qq.com> Date: Fri, 6 Sep 2024 13:56:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=9A=E5=91=98=E7=A0=81=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=9B=20=E9=80=89=E5=A5=97=E9=A4=90?= =?UTF-8?q?=E5=BE=85=E8=A7=A3=E5=86=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/mine/vip_pay_code.dart | 48 +- lib/retrofit/data/miNiDetail.dart | 9 + lib/store/shop_details_page.dart | 11 +- lib/store/store_view/product_meals_sku.dart | 1130 +++++++++++++------ lib/store/store_view/shop_goods.dart | 34 +- lib/store/store_view/store_order_list.dart | 1 - 6 files changed, 835 insertions(+), 398 deletions(-) diff --git a/lib/mine/vip_pay_code.dart b/lib/mine/vip_pay_code.dart index 9ee51a99..d47db687 100644 --- a/lib/mine/vip_pay_code.dart +++ b/lib/mine/vip_pay_code.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'dart:convert'; import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/utils/font_weight.dart'; @@ -27,7 +28,9 @@ class _VipPayCode extends State { @override void dispose() { super.dispose(); - refreshController.dispose(); + refreshController?.dispose(); + _timer?.cancel(); + isDispose = true; } @override @@ -44,40 +47,47 @@ class _VipPayCode extends State { ///查询用户信息 queryUser() async { - try{ - SharedPreferences value = await SharedPreferences.getInstance(); + SharedPreferences prefs; + try { + prefs = await SharedPreferences.getInstance(); + if (prefs.getString("bannerData") != null) { + userInfo = UserInfo.fromJson(jsonDecode(prefs.getString('userInfo'))); + setState(() {}); + } if (apiService == null) apiService = ApiService( - Dio(), - context: context, - token: value.getString("token"), + Dio(), + context: context, + token: prefs.getString("token"), + showLoading: true ); - BaseData baseData = - await apiService.queryInfo().catchError((onError) { - refreshController.refreshFailed();}); + BaseData baseData = await apiService.queryInfo().catchError((onError) { + refreshController.refreshFailed(); + }); if (baseData != null && baseData.isSuccess) { userInfo = baseData.data; - SharedPreferences.getInstance().then((value) => { - value.setString('user', jsonEncode(baseData.data)), - }); + prefs.setString('userInfo', jsonEncode(baseData.data)); setState(() {}); refreshController.refreshCompleted(); - }else{ + } else { refreshController.refreshFailed(); } - }finally{ + } finally { refreshCode(); + EasyLoading.dismiss(); } } refreshCode(){ if (_timer != null) return; const oneSec = const Duration(minutes: 2); - var callback = ((timer) { - if (isDispose) return; + _timer = Timer.periodic(oneSec, (timer) { + if (isDispose) { + timer.cancel(); + return; + } queryUser(); }); - _timer = Timer.periodic(oneSec, callback); } @override @@ -132,9 +142,7 @@ class _VipPayCode extends State { ), SizedBox(height: 30.h,), QrImage( - data: userInfo != null - ? (userInfo?.vipScanNo ?? "") - : "", + data:userInfo?.vipScanNo ?? "622868c3c2c5a02508ed7064c7c27387a1c2c0cb2052ba344d82266a64feb1cfc75014532616b2fb179024c83a6066757cf2639efca8f2731c54a24859e200ca", version: QrVersions.auto, size: 200.w, gapless: true, diff --git a/lib/retrofit/data/miNiDetail.dart b/lib/retrofit/data/miNiDetail.dart index afd55ae0..0361a056 100644 --- a/lib/retrofit/data/miNiDetail.dart +++ b/lib/retrofit/data/miNiDetail.dart @@ -416,6 +416,7 @@ class ProductSetMeals { int _totalNumber; int _optionalNumber; List _productInfoList; + int checkIndex = 0; ProductSetMeals copyWith({ String groupName, @@ -686,16 +687,19 @@ class SkuInfoList { SkuInfoList({ String id, String skuName, + String skuPrice, List productSkuAttrList, }) { _id = id; _skuName = skuName; + _skuPrice = skuPrice; _productSkuAttrList = productSkuAttrList; } SkuInfoList.fromJson(dynamic json) { _id = json['id']; _skuName = json['skuName']; + _skuPrice = json['skuPrice']; if (json['productSkuAttrList'] != null) { _productSkuAttrList = []; json['productSkuAttrList'].forEach((v) { @@ -706,17 +710,20 @@ class SkuInfoList { String _id; String _skuName; + String _skuPrice; bool _isSelected = false; List _productSkuAttrList; SkuInfoList copyWith({ String id, String skuName, + String skuPrice, List productSkuAttrList, }) => SkuInfoList( id: id ?? _id, skuName: skuName ?? _skuName, + skuPrice: skuPrice ?? _skuPrice, productSkuAttrList: productSkuAttrList ?? _productSkuAttrList, ); @@ -724,6 +731,8 @@ class SkuInfoList { String get skuName => _skuName; + String get skuPrice => _skuPrice; + List get productSkuAttrList => _productSkuAttrList; bool get isSelected => _isSelected; diff --git a/lib/store/shop_details_page.dart b/lib/store/shop_details_page.dart index 3b331db7..6800e955 100644 --- a/lib/store/shop_details_page.dart +++ b/lib/store/shop_details_page.dart @@ -77,13 +77,13 @@ class _ShopDetailsPage extends State { 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(() { @@ -206,6 +206,11 @@ class _ShopDetailsPage extends State { 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( @@ -944,7 +949,7 @@ class _ShopDetailsPage extends State { if (storeInfo.posType.code == "NORMALSTORE" && tableId == 0) { showDeleteDialog(); - } else if (isSetMeal == true) { + } else if (_jumpType == 1) { await Navigator.of(context).pushNamed( '/router/product_meals_sku', arguments: { @@ -1111,7 +1116,7 @@ class _ShopDetailsPage extends State { if (storeInfo.posType.code == "NORMALSTORE" && tableId == 0) { showDeleteDialog(); - } else if (isSetMeal == true) { + } else if (_jumpType == 1) { await Navigator.of(context).pushNamed( '/router/product_meals_sku', arguments: { diff --git a/lib/store/store_view/product_meals_sku.dart b/lib/store/store_view/product_meals_sku.dart index 78841b1f..851ae6a6 100644 --- a/lib/store/store_view/product_meals_sku.dart +++ b/lib/store/store_view/product_meals_sku.dart @@ -3,9 +3,10 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.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/miNiDetail.dart'; +import 'package:huixiang/retrofit/data/miNiDetail.dart' as MiNi; import 'package:huixiang/retrofit/data/shoppingCart.dart'; import 'package:huixiang/retrofit/min_api.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; @@ -16,6 +17,9 @@ import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import '../../view_widget/classic_header.dart'; +import '../../view_widget/my_footer.dart'; + class ProductMealsSku extends StatefulWidget { final arguments; @@ -31,15 +35,18 @@ class _ProductMealsSku extends State { ApiService apiService; MinApiService minService; final RefreshController refreshController = RefreshController(); + final ScrollController scrollController = ScrollController(); String id; - MiNiDetail miNiDetail; + MiNi.MiNiDetail miNiDetail; String parentCode = ""; int tableId = 0; String storeId; String parentId; int numberOfPeople = 0; - List productSetMeals; + List productSetMeals; List setMealData; + // int mealsIndex = 0; + int setMealsIndex = 0; @override void initState() { @@ -63,7 +70,7 @@ class _ProductMealsSku extends State { ///商品详情 queryMiNiDetail(id) async { - BaseData baseData = + BaseData baseData = await minService.miNiDetail(id).catchError((error) { refreshController.refreshFailed(); }); @@ -78,6 +85,10 @@ class _ProductMealsSku extends State { } } + _onRefresh() { + queryMiNiDetail(id); + } + ///添加购物车 addShopCar() async { List setMealDataList = []; @@ -129,7 +140,135 @@ class _ProductMealsSku extends State { @override Widget build(BuildContext context) { - return Container( + return Scaffold( + backgroundColor: Colors.white, + body: Column( + children: [ + Expanded(child: SmartRefresher( + controller: refreshController, + enablePullDown: true, + enablePullUp: false, + header: MyHeader(), + footer: CustomFooter( + builder: (context, mode) { + return MyFooter(mode); + }, + ), + onRefresh: () { + setState(() { + _onRefresh(); + }); + }, + physics: BouncingScrollPhysics(), + scrollController: scrollController, + child: SingleChildScrollView( + physics: BouncingScrollPhysics(), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + swiper(), + Padding(padding:EdgeInsets.only(left:14.w,top:10.h,bottom:18.h), + child:Text( + miNiDetail?.productName ?? "", + style: TextStyle( + fontSize: 16.sp, + fontFamily: 'JDZhengHT', + fontWeight: FontWeight.w600, + color: Color(0xFF000000), + ), + )), + ListView.builder( + itemCount: productSetMeals?.length ?? 0, + scrollDirection: Axis.vertical, + physics: BouncingScrollPhysics(), + shrinkWrap: true, + padding: EdgeInsets.zero, + itemBuilder: (context, position) { + return GestureDetector( + onTap:(){ + setMealsIndex = position; + }, + child: productMealsList(productSetMeals[position]), + ); + }, + ), + ], + ), + ), + )), + Container( + margin: EdgeInsets.only( + left: 14.w, + right: 14.w, + bottom: 30.h, + ), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(100), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding(padding:EdgeInsets.symmetric(vertical:10.h), + child:Text.rich( + TextSpan( + children: [ + TextSpan( + text: "¥", + style: TextStyle( + fontWeight: FontWeight.w500, + fontSize:12.sp, + color: Color(0xFF191919), + ), + ), + TextSpan( + text:miNiDetail?.price ?? "", + style: TextStyle( + fontWeight: FontWeight.w500, + fontSize: 18.sp, + color: Color(0xFF191919), + ), + ), + ], + ), + textDirection: TextDirection.ltr, + ),), + RoundButton( + width: double.infinity, + height: 54.h, + text: "加入购物车", + textColor: Colors.white, + fontWeight: MyFontWeight.medium, + radius: 27, + backgroup: Color(0xFF32A060), + fontSize: 16.sp, + callback: () { + bool flag = true; + productSetMeals.forEach((element) { + int pInfoTotal = 0; + element.productInfoList.forEach((ele) { + pInfoTotal += ele.count; + }); + if (pInfoTotal != element.optionalNumber) { + flag = false; + return; + } + }); + if (!flag) { + SmartDialog.showToast("抱歉,还有商品未加购", + alignment: Alignment.center); + return; + } else { + addShopCar(); + } + }, + ) + ], + )) + ], + ), + ); + Container( color: Colors.white, child: Stack( children: [ @@ -209,7 +348,7 @@ class _ProductMealsSku extends State { shrinkWrap: true, padding: EdgeInsets.zero, itemBuilder: (context, position) { - return productMealsList(position); + // return productMealsList(position); }, ), ], @@ -277,17 +416,65 @@ class _ProductMealsSku extends State { ); } - Widget productMealsList(int position) { + Widget swiper() { + return Container( + child: AspectRatio( + aspectRatio: 375 / 375, + child: Stack( + children: [ + Swiper( + pagination: SwiperPagination( + alignment: Alignment.bottomCenter, + builder: DotSwiperPaginationBuilder( + size: 8, + activeSize: 8, + space: 5, + activeColor: Colors.black, + color: Colors.black.withAlpha(76), + ), + ), + itemBuilder: (context, position) { + return MImage( + miNiDetail?.imgs != null ? miNiDetail.imgs[position] : "", + fit: BoxFit.cover, + radius: BorderRadius.zero, + height: 375, + width: 375, + errorSrc: "assets/image/default_2_1.webp", + fadeSrc: "assets/image/default_2_1.webp", + ); + }, + itemCount: miNiDetail?.imgs?.length ?? 1, + ), + GestureDetector( + onTap: () { + Navigator.of(context).pop(); + }, + child: Container( + margin: EdgeInsets.only(left: 16, top: 52), + padding: EdgeInsets.all(5), + child: Image.asset( + "assets/image/integral_return.webp", + ), + ), + ), + ], + ), + ), + ); + } + + Widget productMealsList(MiNi.ProductSetMeals productSetMeals) { return Container( - margin: EdgeInsets.symmetric(vertical: 16.h), + padding:EdgeInsets.symmetric(horizontal:14.w), child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - "${productSetMeals[position].groupName}(${productSetMeals[position].totalNumber}选${productSetMeals[position].optionalNumber})", + "${productSetMeals.groupName}(${productSetMeals.totalNumber}选${productSetMeals.optionalNumber})", style: TextStyle( - fontSize: 15.sp, + fontSize: 14.sp, color: Colors.black, fontWeight: FontWeight.w600, ), @@ -295,263 +482,143 @@ class _ProductMealsSku extends State { SizedBox( height: 8.h, ), + Container( + height: 205.h, + margin:EdgeInsets.only(bottom:18.h), + child: ListView.builder( + itemCount: productSetMeals?.productInfoList?.length??0, + scrollDirection: Axis.horizontal, + physics: BouncingScrollPhysics(), + shrinkWrap: true, + padding: EdgeInsets.zero, + itemBuilder: (context, index) { + return GestureDetector( + onTap:(){ + setState(() { + productSetMeals.checkIndex = index; + }); + }, + child: productMealsItem(productSetMeals.productInfoList[index], productSetMeals.checkIndex == index), + ); + }, + ), + ), + // if (productSetMeals + // .productInfoList[productSetMeals.checkIndex] + // .productAttrInfoList[0] + // .attrName != + // "") ListView.builder( - itemCount: productSetMeals[position].productInfoList.length, + itemCount: productSetMeals + .productInfoList[productSetMeals.checkIndex] + .productAttrInfoList + .length, scrollDirection: Axis.vertical, physics: BouncingScrollPhysics(), - shrinkWrap: true, padding: EdgeInsets.zero, - itemBuilder: (context, index) { - return productMealsItem(position, index); + itemBuilder: (context, pos) { + return porAttrItem(productSetMeals + .productInfoList[productSetMeals.checkIndex] + .productAttrInfoList[pos]); }, ), ], )); } - Widget productMealsItem(int position, int index) { + Widget productMealsItem(MiNi.ProductInfoList productInfoList, bool check) { return Container( - margin: EdgeInsets.symmetric(vertical: 16.h), - child: Row( + width: 140.h, + margin: EdgeInsets.only(right:15.w), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(4), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(10), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, + ) + ], + border: Border.all( + color: check ? Color(0xFF32A060): Colors.transparent, + width: 1, + ), + color: Color(0xFFF7F7F7), + ), + child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ MImage( - productSetMeals[position].productInfoList[index].productImg ?? "", - width: 70.h, - height: 70.h, + productInfoList.productImg ?? "", + width: 140.h, + height: 140.h, radius: BorderRadius.circular(4), fit: BoxFit.cover, errorSrc: "assets/image/default_1.webp", fadeSrc: "assets/image/default_1.webp", ), - SizedBox(width: 12.h), - Expanded( - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.symmetric(vertical: 8.h), - child: Row( - children: [ - Expanded( - child: Text( - productSetMeals[position] - .productInfoList[index] - .productName ?? - "", - overflow: TextOverflow.ellipsis, - maxLines: 1, - style: TextStyle( - color: Colors.black, - fontSize: 13.sp, - fontWeight: MyFontWeight.semi_bold, - ), - ), - ), - if (productSetMeals[position] - .productInfoList[index] - .productAttrInfoList[0] - .attrName != - "") - GestureDetector( - child: Text( - S.of(context).xuanguige, - style: TextStyle( - color: Colors.black, - fontSize: 13.sp, - fontWeight: MyFontWeight.regular, - ), - ), - onTap: () { - showSkuDialog(position, index); - }, - ), - if (productSetMeals[position] - .productInfoList[index] - .productAttrInfoList[0] - .attrName != - "") - GestureDetector( - onTap: () { - showSkuDialog(position, index); - }, - child: Icon( - Icons.chevron_right, - color: Colors.black, - size: 18, - ), - ) - ], + SizedBox(height:6.h), + Padding(padding:EdgeInsets.only(left:8.w,right:8.w,top:8.h,bottom: 6.h), + child:Text( + productInfoList.productName ?? "", + style: TextStyle( + fontSize: 14.sp, + color: Colors.black, + fontWeight: FontWeight.w600, + ), + ),), + Padding(padding:EdgeInsets.only(left:8.w,right:8.w), + child:Text.rich( + TextSpan( + children: [ + TextSpan( + text: "¥", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize:12.sp, + color: Color(0xFFF65720), + ), ), - ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - if (productSetMeals[position] - .productInfoList[index] - .skuInfoList - .where((element) => element.isSelected) - .isNotEmpty && - productSetMeals[position].productInfoList[index].count > - 0) - Text( - productSetMeals[position] - .productInfoList[index] - .skuInfoList - .firstWhere((element) => element.isSelected) - .skuName ?? - "", - overflow: TextOverflow.ellipsis, - maxLines: 1, - style: TextStyle( - color: Color(0xFFA29E9E), - fontSize: 13.sp, - fontWeight: MyFontWeight.regular, - ), - ), - Spacer(), - if (productSetMeals[position] - .productInfoList[index] - .skuInfoList - .where((element) => element.isSelected) - .isNotEmpty && - productSetMeals[position].productInfoList[index].count > - 0) - Padding( - padding: EdgeInsets.only(right: 4.w), - child: Text( - "x${productSetMeals[position].productInfoList[index].count}", - overflow: TextOverflow.ellipsis, - maxLines: 1, - style: TextStyle( - color: Color(0xffFF7A1A), - fontSize: 13.sp, - fontWeight: MyFontWeight.regular, - ), - ), - ), - if (productSetMeals[position] - .productInfoList[index] - .productAttrInfoList[0] - .attrName == - "") - InkWell( - onTap: () { - setState(() { - if (productSetMeals[position] - .productInfoList[index] - .count >= - 1) - productSetMeals[position] - .productInfoList[index] - .count -= 1; - }); - }, - child: Image.asset( - "assets/image/reduce.webp", - width: 22, - height: 22.h, - ), - ), - if (productSetMeals[position] - .productInfoList[index] - .productAttrInfoList[0] - .attrName == - "") - Container( - width: 30, - alignment: Alignment.center, - child: Text( - (productSetMeals[position].totalNumber > 1 && - productSetMeals[position].totalNumber != - productSetMeals[position].optionalNumber) - ? productSetMeals[position] - .productInfoList[index] - .count - .toString() - : (productSetMeals[position] - .productInfoList[index] - .count = 1) - .toString(), - style: TextStyle( - color: Colors.black, - fontSize: 14.sp, - fontWeight: MyFontWeight.medium, - ), - ), + TextSpan( + text:(productInfoList.skuInfoList[0].skuPrice ?? "").split(".")[0], + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18.sp, + color: Color(0xFFF65720), + ), + ), + if(productInfoList.skuInfoList[0].skuPrice.contains(".")) + TextSpan( + text:".", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18.sp, + color: Color(0xFFF65720), ), - if (productSetMeals[position] - .productInfoList[index] - .productAttrInfoList[0] - .attrName == - "") - GestureDetector( - onTap: () { - setState(() { - if (productSetMeals[position] - .productInfoList[index] - .productAttrInfoList[0] - .attrName != - "") { - showSkuDialog(position, index); - return; - } - int total = 0; - productSetMeals[position] - .productInfoList - .forEach((element) { - total += element.count; - }); - if (total >= - productSetMeals[position].optionalNumber || - productSetMeals[position] - .productInfoList[index] - .count >= - 1) { - SmartDialog.showToast("抱歉,无法加购更多", - alignment: Alignment.center); - return; - } - if (productSetMeals[position] - .productInfoList[index] - .count == - 0) - productSetMeals[position] - .productInfoList[index] - .count += 1; - }); - }, - child: Image.asset( - "assets/image/add.webp", - width: 22, - height: 22.h, - ), + ), + if(productInfoList.skuInfoList[0].skuPrice.contains(".")) + TextSpan( + text:(productInfoList.skuInfoList[0].skuPrice ?? "").split(".")[1], + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize:12.sp, + color: Color(0xFFF65720), ), - ], - ), - SizedBox( - height: 4.h, - ), - ], - ), - ), + ), + ], + ), + textDirection: TextDirection.ltr, + ),) ], ), ); } - Widget porAttrItem(int position, int index, int pos, state) { - if (productSetMeals[position] - .productInfoList[index] - .productAttrInfoList[pos] - .attrValueList != - null && - productSetMeals[position] - .productInfoList[index] - .productAttrInfoList[pos] - .attrValueList - .length > + Widget porAttrItem(MiNi.ProductAttrInfoList productAttrInfoList) { + if (productAttrInfoList.attrValueList != + null && productAttrInfoList.attrValueList + .length > 0) return Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -559,10 +626,7 @@ class _ProductMealsSku extends State { Padding( padding: EdgeInsets.only(top: 16, bottom: 16), child: Text( - productSetMeals[position] - .productInfoList[index] - .productAttrInfoList[pos] - .attrName, + productAttrInfoList.attrName, style: TextStyle( color: Color(0xFFB3B3B3), fontSize: 14.sp, @@ -570,7 +634,29 @@ class _ProductMealsSku extends State { ), ), ), - sweetnessStore(position, index, pos, state), + Wrap( + runSpacing: 10.0, + spacing: 10.0, + children: productAttrInfoList + .attrValueList + .take(productAttrInfoList + .attrValueList + .length) + .map((MiNi.AttrValueList tag) { + return GestureDetector( + onTap: () { + setState(() { + productAttrInfoList + .selectSku = tag.attrName; + }); + }, + child: sweetnessItem( + tag.attrName, + (productAttrInfoList + .selectSku == + tag.attrName), + )); + }).toList()), ], ); else { @@ -587,11 +673,11 @@ class _ProductMealsSku extends State { .productAttrInfoList[pos] .attrValueList .take(productSetMeals[position] - .productInfoList[index] - .productAttrInfoList[pos] - .attrValueList - .length) - .map((AttrValueList tag) { + .productInfoList[index] + .productAttrInfoList[pos] + .attrValueList + .length) + .map((MiNi.AttrValueList tag) { return GestureDetector( onTap: () { state(() { @@ -604,9 +690,9 @@ class _ProductMealsSku extends State { child: sweetnessItem( tag.attrName, (productSetMeals[position] - .productInfoList[index] - .productAttrInfoList[pos] - .selectSku == + .productInfoList[index] + .productAttrInfoList[pos] + .selectSku == tag.attrName), )); }).toList()); @@ -636,111 +722,439 @@ class _ProductMealsSku extends State { ), )); } + // + // Widget productMealsItems(int position, int index) { + // return Container( + // margin: EdgeInsets.symmetric(vertical: 16.h), + // child: Row( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // MImage( + // productSetMeals[position].productInfoList[index].productImg ?? "", + // width: 70.h, + // height: 70.h, + // radius: BorderRadius.circular(4), + // fit: BoxFit.cover, + // errorSrc: "assets/image/default_1.webp", + // fadeSrc: "assets/image/default_1.webp", + // ), + // SizedBox(width: 12.h), + // Expanded( + // child: Column( + // mainAxisAlignment: MainAxisAlignment.start, + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Padding( + // padding: EdgeInsets.symmetric(vertical: 8.h), + // child: Row( + // children: [ + // Expanded( + // child: Text( + // productSetMeals[position] + // .productInfoList[index] + // .productName ?? + // "", + // overflow: TextOverflow.ellipsis, + // maxLines: 1, + // style: TextStyle( + // color: Colors.black, + // fontSize: 13.sp, + // fontWeight: MyFontWeight.semi_bold, + // ), + // ), + // ), + // if (productSetMeals[position] + // .productInfoList[index] + // .productAttrInfoList[0] + // .attrName != + // "") + // GestureDetector( + // child: Text( + // S.of(context).xuanguige, + // style: TextStyle( + // color: Colors.black, + // fontSize: 13.sp, + // fontWeight: MyFontWeight.regular, + // ), + // ), + // onTap: () { + // showSkuDialog(position, index); + // }, + // ), + // if (productSetMeals[position] + // .productInfoList[index] + // .productAttrInfoList[0] + // .attrName != + // "") + // GestureDetector( + // onTap: () { + // showSkuDialog(position, index); + // }, + // child: Icon( + // Icons.chevron_right, + // color: Colors.black, + // size: 18, + // ), + // ) + // ], + // ), + // ), + // Row( + // mainAxisAlignment: MainAxisAlignment.center, + // children: [ + // if (productSetMeals[position] + // .productInfoList[index] + // .skuInfoList + // .where((element) => element.isSelected) + // .isNotEmpty && + // productSetMeals[position].productInfoList[index].count > + // 0) + // Text( + // productSetMeals[position] + // .productInfoList[index] + // .skuInfoList + // .firstWhere((element) => element.isSelected) + // .skuName ?? + // "", + // overflow: TextOverflow.ellipsis, + // maxLines: 1, + // style: TextStyle( + // color: Color(0xFFA29E9E), + // fontSize: 13.sp, + // fontWeight: MyFontWeight.regular, + // ), + // ), + // Spacer(), + // if (productSetMeals[position] + // .productInfoList[index] + // .skuInfoList + // .where((element) => element.isSelected) + // .isNotEmpty && + // productSetMeals[position].productInfoList[index].count > + // 0) + // Padding( + // padding: EdgeInsets.only(right: 4.w), + // child: Text( + // "x${productSetMeals[position].productInfoList[index].count}", + // overflow: TextOverflow.ellipsis, + // maxLines: 1, + // style: TextStyle( + // color: Color(0xffFF7A1A), + // fontSize: 13.sp, + // fontWeight: MyFontWeight.regular, + // ), + // ), + // ), + // if (productSetMeals[position] + // .productInfoList[index] + // .productAttrInfoList[0] + // .attrName == + // "") + // InkWell( + // onTap: () { + // setState(() { + // if (productSetMeals[position] + // .productInfoList[index] + // .count >= + // 1) + // productSetMeals[position] + // .productInfoList[index] + // .count -= 1; + // }); + // }, + // child: Image.asset( + // "assets/image/reduce.webp", + // width: 22, + // height: 22.h, + // ), + // ), + // if (productSetMeals[position] + // .productInfoList[index] + // .productAttrInfoList[0] + // .attrName == + // "") + // Container( + // width: 30, + // alignment: Alignment.center, + // child: Text( + // (productSetMeals[position].totalNumber > 1 && + // productSetMeals[position].totalNumber != + // productSetMeals[position].optionalNumber) + // ? productSetMeals[position] + // .productInfoList[index] + // .count + // .toString() + // : (productSetMeals[position] + // .productInfoList[index] + // .count = 1) + // .toString(), + // style: TextStyle( + // color: Colors.black, + // fontSize: 14.sp, + // fontWeight: MyFontWeight.medium, + // ), + // ), + // ), + // if (productSetMeals[position] + // .productInfoList[index] + // .productAttrInfoList[0] + // .attrName == + // "") + // GestureDetector( + // onTap: () { + // setState(() { + // if (productSetMeals[position] + // .productInfoList[index] + // .productAttrInfoList[0] + // .attrName != + // "") { + // showSkuDialog(position, index); + // return; + // } + // int total = 0; + // productSetMeals[position] + // .productInfoList + // .forEach((element) { + // total += element.count; + // }); + // if (total >= + // productSetMeals[position].optionalNumber || + // productSetMeals[position] + // .productInfoList[index] + // .count >= + // 1) { + // SmartDialog.showToast("抱歉,无法加购更多", + // alignment: Alignment.center); + // return; + // } + // if (productSetMeals[position] + // .productInfoList[index] + // .count == + // 0) + // productSetMeals[position] + // .productInfoList[index] + // .count += 1; + // }); + // }, + // child: Image.asset( + // "assets/image/add.webp", + // width: 22, + // height: 22.h, + // ), + // ), + // ], + // ), + // SizedBox( + // height: 4.h, + // ), + // ], + // ), + // ), + // ], + // ), + // ); + // } + // + // Widget porAttrItems(int position, int index, int pos, state) { + // if (productSetMeals[position] + // .productInfoList[index] + // .productAttrInfoList[pos] + // .attrValueList != + // null && + // productSetMeals[position] + // .productInfoList[index] + // .productAttrInfoList[pos] + // .attrValueList + // .length > + // 0) + // return Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Padding( + // padding: EdgeInsets.only(top: 16, bottom: 16), + // child: Text( + // productSetMeals[position] + // .productInfoList[index] + // .productAttrInfoList[pos] + // .attrName, + // style: TextStyle( + // color: Color(0xFFB3B3B3), + // fontSize: 14.sp, + // fontWeight: MyFontWeight.regular, + // ), + // ), + // ), + // sweetnessStore(position, index, pos, state), + // ], + // ); + // else { + // return Container(); + // } + // } + // + // Widget sweetnessStores(int position, int index, int pos, state) { + // return Wrap( + // runSpacing: 10.0, + // spacing: 10.0, + // children: productSetMeals[position] + // .productInfoList[index] + // .productAttrInfoList[pos] + // .attrValueList + // .take(productSetMeals[position] + // .productInfoList[index] + // .productAttrInfoList[pos] + // .attrValueList + // .length) + // .map((MiNi.AttrValueList tag) { + // return GestureDetector( + // onTap: () { + // state(() { + // productSetMeals[position] + // .productInfoList[index] + // .productAttrInfoList[pos] + // .selectSku = tag.attrName; + // }); + // }, + // child: sweetnessItem( + // tag.attrName, + // (productSetMeals[position] + // .productInfoList[index] + // .productAttrInfoList[pos] + // .selectSku == + // tag.attrName), + // )); + // }).toList()); + // } + // + // Widget sweetnessItems(String name, bool isCheck) { + // return Container( + // padding: const EdgeInsets.symmetric(vertical: 5.0, horizontal: 12.0), + // decoration: BoxDecoration( + // color: !isCheck ? Color(0xFFF2F2F2) : Color(0xFFF0FAF4), + // border: Border.all( + // width: !isCheck ? 0 : 1, + // color: !isCheck ? Color(0xFFF2F2F2) : Color(0xFF32A060), + // style: BorderStyle.solid, + // ), + // borderRadius: const BorderRadius.all( + // Radius.circular(4.0), + // ), + // ), + // child: Text( + // name, + // overflow: TextOverflow.ellipsis, + // style: TextStyle( + // color: !isCheck ? Color(0xFF4D4D4D) : Color(0xFF32A060), + // fontSize: 14.sp, + // fontWeight: MyFontWeight.regular, + // ), + // )); + // } ///选择規格弹窗 - showSkuDialog(int position, int index) async { - showDialog( - context: context, - builder: (context) { - return StatefulBuilder(builder: ( - context, - state, - ) { - return AlertDialog( - content: Container( - width: MediaQuery.of(context).size.width - 84, - height: 350.h, - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - child: ListView.builder( - itemCount: productSetMeals[position] - .productInfoList[index] - .productAttrInfoList - .length, - scrollDirection: Axis.vertical, - physics: BouncingScrollPhysics(), - padding: EdgeInsets.zero, - itemBuilder: (context, pos) { - return porAttrItem(position, index, pos, state); - }, - ), - ), - SizedBox( - height: 24, - ), - GestureDetector( - onTap: () { - setState(() { - int total = 0; - productSetMeals[position] - .productInfoList - .forEach((element) { - total += element.count; - }); - if (productSetMeals[position] - .productInfoList[index] - .productAttrInfoList - .where((element) => element.selectSku == null) - .isNotEmpty) { - SmartDialog.showToast(S.of(context).qingxianxuanguige, - alignment: Alignment.center); - return; - } - if (total >= productSetMeals[position].optionalNumber && - productSetMeals[position] - .productInfoList[index] - .count != - 1) { - SmartDialog.showToast("抱歉,无法加购更多", - alignment: Alignment.center); - return; - } - productSetMeals[position].productInfoList[index].count = - 1; - productSetMeals[position] - .productInfoList[index] - .skuInfoList - .forEach((element) { - bool flag = true; - productSetMeals[position] - .productInfoList[index] - .productAttrInfoList - .forEach((e1) { - if (!element.skuName.contains(e1.selectSku)) - flag = false; - }); - element.isSelected = flag; - }); - Navigator.of(context).pop(); - }); - }, - child: Container( - width: double.infinity, - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(20), - color: Color(0xFF32A060), - ), - padding: EdgeInsets.symmetric(vertical: 6), - child: Text( - S.of(context).xuanhaola, - style: TextStyle( - fontSize: 15.sp, - fontWeight: MyFontWeight.bold, - color: Color(0xFFFFFFFF), - ), - ), - ), - ) - ], - ), - ), - ); - }); - }, - ); - } + // showSkuDialog(int position, int index) async { + // showDialog( + // context: context, + // builder: (context) { + // return StatefulBuilder(builder: ( + // context, + // state, + // ) { + // return AlertDialog( + // content: Container( + // width: MediaQuery.of(context).size.width - 84, + // height: 350.h, + // child: Column( + // mainAxisAlignment: MainAxisAlignment.start, + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Expanded( + // child: ListView.builder( + // itemCount: productSetMeals[position] + // .productInfoList[index] + // .productAttrInfoList + // .length, + // scrollDirection: Axis.vertical, + // physics: BouncingScrollPhysics(), + // padding: EdgeInsets.zero, + // itemBuilder: (context, pos) { + // return porAttrItems(position, index, pos, state); + // }, + // ), + // ), + // SizedBox( + // height: 24, + // ), + // GestureDetector( + // onTap: () { + // setState(() { + // int total = 0; + // productSetMeals[position] + // .productInfoList + // .forEach((element) { + // total += element.count; + // }); + // if (productSetMeals[position] + // .productInfoList[index] + // .productAttrInfoList + // .where((element) => element.selectSku == null) + // .isNotEmpty) { + // SmartDialog.showToast(S.of(context).qingxianxuanguige, + // alignment: Alignment.center); + // return; + // } + // if (total >= productSetMeals[position].optionalNumber && + // productSetMeals[position] + // .productInfoList[index] + // .count != + // 1) { + // SmartDialog.showToast("抱歉,无法加购更多", + // alignment: Alignment.center); + // return; + // } + // productSetMeals[position].productInfoList[index].count = + // 1; + // productSetMeals[position] + // .productInfoList[index] + // .skuInfoList + // .forEach((element) { + // bool flag = true; + // productSetMeals[position] + // .productInfoList[index] + // .productAttrInfoList + // .forEach((e1) { + // if (!element.skuName.contains(e1.selectSku)) + // flag = false; + // }); + // element.isSelected = flag; + // }); + // Navigator.of(context).pop(); + // }); + // }, + // child: Container( + // width: double.infinity, + // alignment: Alignment.center, + // decoration: BoxDecoration( + // borderRadius: BorderRadius.circular(20), + // color: Color(0xFF32A060), + // ), + // padding: EdgeInsets.symmetric(vertical: 6), + // child: Text( + // S.of(context).xuanhaola, + // style: TextStyle( + // fontSize: 15.sp, + // fontWeight: MyFontWeight.bold, + // color: Color(0xFFFFFFFF), + // ), + // ), + // ), + // ) + // ], + // ), + // ), + // ); + // }); + // }, + // ); + // } } diff --git a/lib/store/store_view/shop_goods.dart b/lib/store/store_view/shop_goods.dart index 4e8588c4..480f6cb9 100644 --- a/lib/store/store_view/shop_goods.dart +++ b/lib/store/store_view/shop_goods.dart @@ -430,22 +430,24 @@ class _ShopGoods extends State { // SmartDialog.showToast("库存不足", // alignment: Alignment.center); // } else - /// 点击的时候获取当前 widget 的位置,传入 overlayEntry - var _overlayEntry = OverlayEntry(builder: (_) { - RenderBox box = context.findRenderObject(); - var offset = box.localToGlobal(Offset.zero); - return RedDotPage( - startPosition: offset, - endPosition: widget.endOffset, - ); - }); - // 显示Overlay - Overlay.of(context).insert(_overlayEntry); - // 等待动画结束 - Future.delayed(Duration(milliseconds: 800), () { - _overlayEntry.remove(); - _overlayEntry = null; - }); + if(_jumpType != 1){ + /// 点击的时候获取当前 widget 的位置,传入 overlayEntry + var _overlayEntry = OverlayEntry(builder: (_) { + RenderBox box = context.findRenderObject(); + var offset = box.localToGlobal(Offset.zero); + return RedDotPage( + startPosition: offset, + endPosition: widget.endOffset, + ); + }); + // 显示Overlay + Overlay.of(context).insert(_overlayEntry); + // 等待动画结束 + Future.delayed(Duration(milliseconds: 800), () { + _overlayEntry.remove(); + _overlayEntry = null; + }); + } if (_jumpType == -1) queryMiNiDetail(widget.productListBean.id); else if (_jumpType == 0) diff --git a/lib/store/store_view/store_order_list.dart b/lib/store/store_view/store_order_list.dart index 5f9fec2c..eba0c2f7 100644 --- a/lib/store/store_view/store_order_list.dart +++ b/lib/store/store_view/store_order_list.dart @@ -213,7 +213,6 @@ class _StoreOrderListPage extends State { .pushNamed('/router/shop_details_page', arguments: { "id": e.id, "storeId": e.storeId, - "isSetMeal":e.isSetMeal, "minQty":e.minQty, }); widget.queryShoppingCart();