From cd5903ae8ec1b2c781a6e1fcc0005d4436dba8d5 Mon Sep 17 00:00:00 2001 From: w-R <953969641@qq.com> Date: Mon, 23 May 2022 18:38:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E7=89=88=E7=A6=8F=E5=88=A9=E4=B8=AD?= =?UTF-8?q?=E5=BF=83=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/home/welfare_page.dart | 723 +++++--------- lib/mine/mine_vip/mine_attainment_page.dart | 2 - lib/store/shop__details_page.dart | 985 +++++++++++++------- lib/view_widget/new_coupon_widget.dart | 391 +------- lib/view_widget/receive_success.dart | 32 +- 5 files changed, 910 insertions(+), 1223 deletions(-) diff --git a/lib/home/welfare_page.dart b/lib/home/welfare_page.dart index 90eeba29..057cc4ce 100644 --- a/lib/home/welfare_page.dart +++ b/lib/home/welfare_page.dart @@ -33,15 +33,13 @@ class WelfarePage extends StatefulWidget { class _WelfarePage extends State { ApiService apiService; final RefreshController refreshController = RefreshController(); - final ScrollController scrollController = ScrollController(); List goods = []; List coupons = []; - // List coupon; List> coupon=[]; String categoryId; bool orderDesc = true; int orderType = 1; - int pageNum = 1; + int type = 1; @override void initState() { @@ -52,20 +50,23 @@ class _WelfarePage extends State { queryCoupon(), }); - for(var i = 0;i < coupons.length~/3+1;i++){ - List con = []; - con = coupons.skip(i*3).take((i*3> pageGoods = @@ -76,18 +77,11 @@ class _WelfarePage extends State { EasyLoading.dismiss(); if (pageGoods != null && pageGoods.isSuccess) { setState(() { - if (pageNum == 1) { - goods.clear(); - } + goods.clear(); goods.addAll(pageGoods.data.list); }); refreshController.refreshCompleted(); refreshController.loadComplete(); - if (pageGoods.data.pageNum == pageGoods.data.pages) { - refreshController.loadNoData(); - } else { - pageNum += 1; - } } else { refreshController.loadFailed(); refreshController.refreshFailed(); @@ -95,26 +89,35 @@ class _WelfarePage extends State { } queryCoupon() async { + if (apiService == null) { + SharedPreferences value = await SharedPreferences.getInstance(); + apiService = ApiService( + Dio(), + context: context, + token: value.getString("token"), + ); + } BaseData> baseData = await apiService.queryCoupon({ "centre": true, - "pageNum": pageNum, - "pageSize": 10, + "pageNum": 1, + "pageSize": 100, "searchKey": "", "state": 0 }).catchError((onError) { refreshController.refreshFailed(); refreshController.loadFailed(); }); - if (pageNum == 1) coupons.clear(); + coupons.clear(); + coupon.clear(); if (baseData != null && baseData.isSuccess) { coupons.addAll(baseData.data.list); + for(var i = 0;i < coupons.length~/3+1;i++){ + List con = []; + con = coupons.skip(i*3).take((i*3 { } + _onRefresh(){ + queryGoods(); + // queryCoupon(); + } + + @override Widget build(BuildContext context) { return Stack( @@ -159,33 +168,29 @@ class _WelfarePage extends State { ), onRefresh:(){ setState(() { + _onRefresh(); }); }, physics: BouncingScrollPhysics(), - scrollController: scrollController, + scrollController: ScrollController(), child: Container( margin: EdgeInsets.only(top: 45.h,left: 14,right: 14), child: SingleChildScrollView( physics: BouncingScrollPhysics(), - child: FutureBuilder( - // future: querySignInfo(), - builder: (context, snap) { - return Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ - weekCoupons(), + weekCoupons(), - inviteFriends(), + inviteFriends(), - benefitExchange(), + benefitExchange(), - // activityTask(), - ], - ); - }, + // activityTask(), + ], ), ), ), @@ -246,10 +251,11 @@ class _WelfarePage extends State { ], )), AspectRatio( - aspectRatio: 1.22, + aspectRatio: 1.10, child: Swiper( viewportFraction: 0.9, scale: 0.7, + key: UniqueKey(), pagination: SwiperPagination( alignment: Alignment.bottomCenter, builder: DotSwiperPaginationBuilder( @@ -265,14 +271,13 @@ class _WelfarePage extends State { return Column( children: [ Container( - child: weekList1(), + child: weekList(coupon[position]), // weekList(testList2[position]), ), ], ); }, itemCount:coupon.length, - // testList2.length, ), ) ], @@ -318,14 +323,10 @@ class _WelfarePage extends State { ); } - List testList = ["1","2","3","4","5","6","7","8","9","10","11"]; - - List> testList2 = []; - - Widget weekList(List list){ + Widget weekList(List cops){ return Expanded(child: ListView.builder( padding: EdgeInsets.zero, - itemCount: list.length, + itemCount: cops.length, scrollDirection: Axis.vertical, shrinkWrap: true, physics: BouncingScrollPhysics(), @@ -333,294 +334,113 @@ class _WelfarePage extends State { return GestureDetector( onTap: () { }, - child: weekItem(list[position]), + child: weekCoupon(cops[position]), ); }, )); } - Widget weekItem(String cnt) { + Widget weekCoupon(Coupon cop) { return Container( - width:double.infinity, - height:110.h, + height: 95.h, + width: double.infinity, + margin: EdgeInsets.only(bottom:10), + padding:EdgeInsets.symmetric(horizontal: 12), decoration: BoxDecoration( image: DecorationImage( fit: BoxFit.fill, image: AssetImage("assets/image/week_coupons.webp"), ), ), - padding: EdgeInsets.symmetric(horizontal: 12.w,vertical: 12.h), - margin: EdgeInsets.only(bottom:10), child: Row( mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Expanded(child: - Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - cnt, - // "新人满减30元", - style: TextStyle( - fontSize: 14.sp, - fontWeight: MyFontWeight.semi_bold, - color: Color(0xFF353535), - ), - ), - SizedBox(height:4.h,), - Text( - "有效期至2022-09-10 12:00:00", - style: TextStyle( - fontSize: 11.sp, - fontWeight: MyFontWeight.regular, - color: Color(0xFF4D4D4D), - ), - ), - SizedBox(height:5.h,), - Row( - children: [ - Text( - "使用详情", - style: TextStyle( - fontSize: 11.sp, - fontWeight: MyFontWeight.regular, - color: Color(0xFF4D4D4D), - ), + Expanded(child: Container( + margin: EdgeInsets.only(top: 12,bottom: 12), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded(child: + Text( + cop != null ? cop.couponName ?? "" : "", + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 14.sp, + fontWeight: MyFontWeight.semi_bold, + color: Color(0xFF353535), ), - Icon( - Icons.keyboard_arrow_right, - color: Color(0xFF4D4D4D), - size: 20, - ) - ], - ), - ], - )), - Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Text.rich( - TextSpan( - children: [ - TextSpan( - text: "¥", - style: TextStyle( - fontSize: 16.sp, - fontWeight: MyFontWeight.semi_bold, - color: Color(0xFF32A060), - ), - ), - TextSpan( - text: "30", - style: TextStyle( - fontSize: 26.sp, - fontWeight: MyFontWeight.semi_bold, - color: Color(0xFF32A060), - ), - ), - ], - ), - ), - Text( - "满30.1可用", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: Color(0xFF32A060), - ), - ), - SizedBox(height: 8,), - Container( - width: 50.w, - height: 19.h, - decoration: BoxDecoration( - color: Color(0xFF32A060), - shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(3), - ), - alignment: Alignment.center, - child:Text( - "领取", + )), + Expanded(child: + (cop.useStartTime == null && + cop.useEndTime == null)? + Text( + S.of(context).quantian, + maxLines: 1, + overflow: TextOverflow.ellipsis, style: TextStyle( fontSize: 12.sp, fontWeight: MyFontWeight.regular, - color: Color(0xFFFFFFFF), + color: cop.status == 3 ? Color(0xFFB3B3B3) :Color(0xFF4D4D4D), ), - ), - ) - ], - ), - ], - ), - ); - } - - - Widget weekList1(){ - return Expanded(child: (coupons != null && coupons.length > 0) - ? ListView.builder( - itemBuilder: (context, position) { - return GestureDetector( - child: NewCouponWidget( - coupons[position], - (type) { - if (type == 1) { - receiveCoupon(coupons[position].id); - } else { - if (coupons[position].bizType == 5 || coupons[position].bizType == 3) { - Navigator.of(context).pushNamed( - '/router/write_off_page', - arguments: { - "couponId": coupons[position].id, - "coupon": coupons[position].toJson() - }); - } else { - showStoreSelector(coupons[position].storeList); - } - } - }, - () { - setState((){ - coupons[position].isEx = !coupons[position].isEx; - }); - }, - type: 1, - ), - ); - }, - itemCount: (coupons != null && coupons.length > 0) ? coupons.length : 0, - ) - : NoDataView( - src: "assets/image/ka.webp", - isShowBtn: false, - text: S.of(context).haimeiyouyouhuiquankeyilingqu, - fontSize: 16.sp, - )); - } + ):Text( + "有效期至 ${cop?.useEndTime ?? ""}", + maxLines:1, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: cop.status == 3 ? Color(0xFFB3B3B3) :Color(0xFF4D4D4D), + ), + )), + GestureDetector( + onTap: (){ + // showDeleteDialog(); - Widget weekItem1() { - return Container( - width:double.infinity, - height:110.h, - decoration: BoxDecoration( - image: DecorationImage( - fit: BoxFit.fill, - image: AssetImage("assets/image/week_coupons.webp"), - ), - ), - padding: EdgeInsets.symmetric(horizontal: 12.w,vertical: 12.h), - margin: EdgeInsets.only(bottom:10), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Expanded(child: - Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "新人满减30元", - style: TextStyle( - fontSize: 14.sp, - fontWeight: MyFontWeight.semi_bold, - color: Color(0xFF353535), - ), - ), - SizedBox(height:4.h,), - Text( - "有效期至2022-09-10 12:00:00", - style: TextStyle( - fontSize: 11.sp, - fontWeight: MyFontWeight.regular, - color: Color(0xFF4D4D4D), - ), - ), - SizedBox(height:5.h,), - Row( - children: [ - Text( - "使用详情", - style: TextStyle( - fontSize: 11.sp, - fontWeight: MyFontWeight.regular, - color: Color(0xFF4D4D4D), - ), + }, + child: Row( + children: [ + Text( + "使用详情", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: cop.status == 3 ? Color(0xFFB3B3B3):Color(0xFF4D4D4D), + ), + ), + Icon( + Icons.keyboard_arrow_right, + color: cop.status == 3 ? Color(0xFFB3B3B3) :Color(0xFF4D4D4D), + size: 20, + ) + ], ), - Icon( - Icons.keyboard_arrow_right, - color: Color(0xFF4D4D4D), - size: 20, - ) - ], - ), - ], + ) + ], + ), )), Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, + mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ - Text.rich( - TextSpan( - children: [ - TextSpan( - text: "¥", - style: TextStyle( - fontSize: 16.sp, - fontWeight: MyFontWeight.semi_bold, - color: Color(0xFF32A060), - ), - ), - TextSpan( - text: "30", - style: TextStyle( - fontSize: 26.sp, - fontWeight: MyFontWeight.semi_bold, - color: Color(0xFF32A060), - ), - ), - ], - ), - ), - Text( - "满30.1可用", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: Color(0xFF32A060), - ), - ), - SizedBox(height: 8,), + Expanded(child: Container( + child:weekWidget(cop), + )), Container( - width: 50.w, - height: 19.h, - decoration: BoxDecoration( - color: Color(0xFF32A060), - shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(3), - ), - alignment: Alignment.center, - child:Text( - "领取", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: Color(0xFFFFFFFF), - ), - ), + margin: EdgeInsets.only(bottom: 12), + child: weekBtn(cop), ) ], - ), + ) ], ), ); } - Widget weekWidget(Coupon coupon) { - if (coupon.bizType == 1) { + Widget weekWidget(Coupon cop) { + if (cop.bizType == 1) { return Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, @@ -635,7 +455,7 @@ class _WelfarePage extends State { style: TextStyle( fontSize: 16.sp, fontWeight: MyFontWeight.medium, - color: coupon.status == 3 ? Color(0xFFB3B3B3):Color(0xff32A060), + color: cop.status == 3 ? Color(0xFFB3B3B3):Color(0xff32A060), ), ), SizedBox( @@ -643,47 +463,47 @@ class _WelfarePage extends State { ), Text( coupon != null - ? double.tryParse("${coupon.discountAmount}" ?? "0") + ? double.tryParse("${cop.discountAmount}" ?? "0") .toInt() .toString() : "", style: TextStyle( - fontSize: 26.sp, + fontSize: 24.sp, fontWeight: MyFontWeight.semi_bold, - color: coupon.status == 3 ? Color(0xFFB3B3B3):Color(0xff32A060), + color: cop.status == 3 ? Color(0xFFB3B3B3):Color(0xff32A060), ), ), ], ), Text( S.of(context).manyuankeyong(coupon != null - ? ("${coupon.fullAmount}" ?? "0") + ? ("${cop.fullAmount}" ?? "0") .toString() : ""), style: TextStyle( fontSize: 12.sp, fontWeight: MyFontWeight.semi_bold, - color: coupon.status == 3 ? Color(0xFFB3B3B3):Color(0xff32A060), + color: cop.status == 3 ? Color(0xFFB3B3B3):Color(0xff32A060), ), ), ], ); - } else if (coupon.bizType == 3) { + } else if (cop.bizType == 3) { return Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Container( - padding: EdgeInsets.only(bottom:10,top: 7), + // padding: EdgeInsets.only(bottom:10,top: 7), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( S.of(context).duihuanquan, style: TextStyle( - fontSize: 26.sp, + fontSize: 22.sp, fontWeight: MyFontWeight.semi_bold, - color: coupon.status == 3 ? Color(0xFFB3B3B3):Color(0xff32A060), + color:cop.status == 3 ? Color(0xFFB3B3B3):Color(0xff32A060), ), ), ], @@ -694,12 +514,12 @@ class _WelfarePage extends State { style: TextStyle( fontSize: 12.sp, fontWeight: MyFontWeight.semi_bold, - color: coupon.status == 3 ? Color(0xFFB3B3B3):Color(0xff32A060), + color: cop.status == 3 ? Color(0xFFB3B3B3):Color(0xff32A060), ), ), ], ); - } else if (coupon.bizType == 5) { + } else if (cop.bizType == 5) { return Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, @@ -714,7 +534,7 @@ class _WelfarePage extends State { style: TextStyle( fontSize: 26.sp, fontWeight: MyFontWeight.semi_bold, - color: coupon.status == 3 ? Color(0xFFB3B3B3):Color(0xff32A060), + color: cop.status == 3 ? Color(0xFFB3B3B3):Color(0xff32A060), ), ), ], @@ -725,7 +545,7 @@ class _WelfarePage extends State { style: TextStyle( fontSize: 12.sp, fontWeight: MyFontWeight.semi_bold, - color: coupon.status == 3 ? Color(0xFFB3B3B3):Color(0xff32A060), + color: cop.status == 3 ? Color(0xFFB3B3B3):Color(0xff32A060), ), ), ], @@ -742,13 +562,13 @@ class _WelfarePage extends State { children: [ Text( coupon != null - ? "${(coupon.discountPercent / 10.0 >= 10) ? 10 : coupon.discountPercent / 10.0}" ?? + ? "${(cop.discountPercent / 10.0 >= 10) ? 10 : cop.discountPercent / 10.0}" ?? "0" : "", style: TextStyle( fontSize: 30.sp, fontWeight: MyFontWeight.semi_bold, - color: coupon.status == 3 ? Color(0xFFB3B3B3):Color(0xff32A060), + color: cop.status == 3 ? Color(0xFFB3B3B3):Color(0xff32A060), ), ), SizedBox( @@ -759,7 +579,7 @@ class _WelfarePage extends State { style: TextStyle( fontSize: 16.sp, fontWeight: MyFontWeight.semi_bold, - color: coupon.status == 3 ? Color(0xFFB3B3B3):Color(0xff32A060), + color: cop.status == 3 ? Color(0xFFB3B3B3):Color(0xff32A060), ), ), ], @@ -769,144 +589,101 @@ class _WelfarePage extends State { } } - // Widget weekBtn(Coupon coupon) { - // if (type == 1) { - // if (coupon != null && coupon.status == 0) { - // return Align( - // alignment: Alignment.centerRight, - // child: InkWell( - // onTap: () { - // callback(type); - // }, - // child: Container( - // padding: EdgeInsets.symmetric(horizontal: 14,vertical: 2), - // decoration: BoxDecoration( - // borderRadius: BorderRadius.circular(3), - // color: Color(0xFF32A060), - // ), - // child: Text( - // S.of(context).lingqu, - // style: TextStyle( - // fontSize: 12.sp, - // fontWeight: MyFontWeight.medium, - // color: Colors.white, - // ), - // ), - // ), - // ), - // ); - // } else { - // return Align( - // alignment: Alignment.centerRight, - // child: Container( - // padding: EdgeInsets.symmetric(horizontal:8,vertical: 2), - // decoration: BoxDecoration( - // borderRadius: BorderRadius.circular(3), - // color: Colors.grey, - // ), - // child: Text( - // S.of(context).yilingqu, - // style: TextStyle( - // fontSize: 12.sp, - // fontWeight: MyFontWeight.medium, - // color: Colors.white, - // ), - // ), - // ), - // ); - // } - // } else { - // if (coupon != null && coupon.status == 1) { - // return Align( - // alignment: Alignment.centerRight, - // child: InkWell( - // onTap: () { - // callback(type); - // }, - // child: Container( - // // width: 56.w, - // height: 19.h, - // // padding: EdgeInsets.symmetric(horizontal:8,vertical: 2), - // decoration: BoxDecoration( - // color: Color(0xFF32A060), - // borderRadius: BorderRadius.circular(3), - // ), - // alignment: Alignment.center, - // child:Text( - // S.of(context).qushiyong, - // maxLines: 1, - // overflow: TextOverflow.ellipsis, - // style: TextStyle( - // fontSize: 12.sp, - // fontWeight: MyFontWeight.regular, - // color: Color(0xFFFFFFFF), - // ), - // ), - // ), - // // Container( - // // padding: EdgeInsets.fromLTRB(16.w, 2.h, 16.w, 2.h), - // // decoration: BoxDecoration( - // // borderRadius: BorderRadius.circular(10.5), - // // color: Color(0xFF32A060), - // // ), - // // child: Text( - // // (coupon.bizType == 5 || coupon.bizType == 3) - // // ? S.of(context).quhexiao - // // : S.of(context).qushiyong, - // // style: TextStyle( - // // fontSize: 12.sp, - // // fontWeight: MyFontWeight.medium, - // // color: Colors.white, - // // ), - // // ), - // // ), - // ), - // ); - // } else if (coupon != null && coupon.status == 2) { - // return Align( - // alignment: Alignment.centerRight, - // child: Container( - // padding: EdgeInsets.symmetric(horizontal: 14,vertical: 2), - // decoration: BoxDecoration( - // borderRadius: BorderRadius.circular(3), - // // border: Border.all( - // // width: 1, color: Color(0xFFA0A0A0), style: BorderStyle.solid) - // color: Color(0xFFA0A0A0), - // ), - // child: Text( - // S.of(context).yishiyong, - // style: TextStyle( - // fontSize: 12.sp, - // fontWeight: MyFontWeight.medium, - // color: Colors.white, - // ), - // ), - // ), - // ); - // } else { - // return Align( - // alignment: Alignment.centerRight, - // child: Container( - // padding: EdgeInsets.symmetric(horizontal: 14,vertical: 2), - // // decoration: BoxDecoration( - // // borderRadius: BorderRadius.circular(10.5), - // // // border: Border.all( - // // // width: 1, color: Color(0xFFA0A0A0), style: BorderStyle.solid) - // // color: Color(0xFFA0A0A0), - // // ), - // child: Text( - // S.of(context).yishixiao, - // style: TextStyle( - // fontSize: 12.sp, - // fontWeight: MyFontWeight.semi_bold, - // color: Color(0xFFB3B3B3), - // ), - // ), - // ), - // ); - // } - // } - // } + Widget weekBtn(Coupon cop) { + if(cop.status == 0) + return Align( + alignment: Alignment.centerRight, + child: InkWell( + onTap: () { + setState(() { + receiveCoupon(cop.id); + }); + }, + child: Container( + padding: EdgeInsets.symmetric(horizontal: 14,vertical: 2), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(3), + color: Color(0xFF32A060), + ), + child: Text( + S.of(context).lingqu, + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + color: Colors.white, + ), + ), + ), + ), + ); + if(cop.status == 1) + return Align( + alignment: Alignment.centerRight, + child: InkWell( + onTap: () { + if (cop.bizType == 5 || cop.bizType == 3) { + Navigator.of(context).pushNamed( + '/router/write_off_page', + arguments: { + "couponId": cop.id, + "coupon": cop.toJson() + }); + } else { + showStoreSelector(cop.storeList); + } + }, + child: Container( + // height: 19.h, + padding: EdgeInsets.symmetric(horizontal:8,vertical: 2), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(3), + border: Border.all( + width: 1, color: Color(0xFF32A060), style: BorderStyle.solid), + color: Colors.transparent, + ), + alignment: Alignment.center, + child:Text( + S.of(context).qushiyong, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: Color(0xFF32A060), + ), + ), + ), + ), + ); + } + + receiveCoupon(couponId) async { + BaseData baseData = await apiService.receiveCoupon(couponId); + if (baseData != null && baseData.isSuccess) { + queryCoupon(); + showAlertDialog(); + } + } + + showStoreSelector(storeList) { + showModalBottomSheet( + context: context, + backgroundColor: Colors.transparent, + builder: (context) { + return SelectorStoreWidget(storeList); + }, + ); + } + + showAlertDialog() { + //显示对话框 + showDialog( + context: context, + builder: (BuildContext context) { + return ReceiveSuccess(); + }, + ); + } ///邀请好友 Widget inviteFriends() { @@ -1236,32 +1013,4 @@ class _WelfarePage extends State { ); } - receiveCoupon(couponId) async { - BaseData baseData = await apiService.receiveCoupon(couponId); - if (baseData != null && baseData.isSuccess) { - queryCoupon(); - showAlertDialog(); - } - } - - showStoreSelector(storeList) { - showModalBottomSheet( - context: context, - backgroundColor: Colors.transparent, - builder: (context) { - return SelectorStoreWidget(storeList); - }, - ); - } - - showAlertDialog() { - //显示对话框 - showDialog( - context: context, - builder: (BuildContext context) { - return ReceiveSuccess(); - }, - ); - } - } diff --git a/lib/mine/mine_vip/mine_attainment_page.dart b/lib/mine/mine_vip/mine_attainment_page.dart index 02359118..5710f5f5 100644 --- a/lib/mine/mine_vip/mine_attainment_page.dart +++ b/lib/mine/mine_vip/mine_attainment_page.dart @@ -39,7 +39,6 @@ class _MineAttainmentPage extends State { List achievementDetail = []; int checkPosition = 0; SocialInfo infoNumber; - final ScrollController scrollController = ScrollController(); final RefreshController refreshController = RefreshController(); @@ -165,7 +164,6 @@ class _MineAttainmentPage extends State { }); }, physics: BouncingScrollPhysics(), - scrollController: scrollController, child: Container( child: SingleChildScrollView( diff --git a/lib/store/shop__details_page.dart b/lib/store/shop__details_page.dart index ed0fa3fa..c8c404ef 100644 --- a/lib/store/shop__details_page.dart +++ b/lib/store/shop__details_page.dart @@ -17,6 +17,7 @@ import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/classic_header.dart'; import 'package:huixiang/view_widget/custom_image.dart'; import 'package:huixiang/view_widget/my_footer.dart'; +import 'package:huixiang/view_widget/round_button.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -43,6 +44,14 @@ class _ShopDetailsPage extends State { bool dialogShowing = false; StoreInfo storeInfo; String parentCode = ""; + int tableId = 0; + String pName; + String pid; + String cName; + String cid; + List selectSkus = []; + int counts = 1; + String selectedPrice = ""; @override void initState() { @@ -60,6 +69,7 @@ class _ShopDetailsPage extends State { showLoading: true); queryMiNiDetail(id); }); + } ///商品详情 @@ -82,336 +92,366 @@ class _ShopDetailsPage extends State { queryMiNiDetail(id); } - // ///选规格 - // _queryMiNiDetail(String id, int count) async { - // EasyLoading.show(status: S.current.zhengzaijiazai); - // if(count < 0){ - // shopCarGoods.shoppingCartSkuItemList.forEach((element) { - // if(element.productId == id){ - // shopCartReduce(element); - // setState(() { - // }); - // } - // }); - // return; - // } - // BaseData baseData = await minService.miNiDetail(id); - // if (baseData != null && baseData.isSuccess) { - // showStoreSelector(baseData.data, id, count); - // } - // } - // - // ///选规格弹窗 - // showStoreSelector(MiNiDetail miNiDetail, String id, int count) async { - // if (miNiDetail.attrList != null && - // miNiDetail.attrList.length == 1 && - // miNiDetail.attrList[0].attrValueList.length == 1) { - // _addShopCar(miNiDetail, [], count); - // } else { - // EasyLoading.dismiss(); - // dialogShowing = true; - // SmartDialog.show( - // widget: ProductSku( - // miNiDetail, - // shopCarGoods, - // id, - // _addShopCar, - // add, - // reduce, - // ), - // onDismiss: () { - // dialogShowing = false; - // }, - // alignmentTemp: Alignment.bottomCenter, - // ); - // } - // } - // - // ///添加购物车 - // Future _addShopCar(MiNiDetail miNiDetail, selectSkus, int count) async { - // ProductSkuVOListBean productSku; - // if (selectSkus != null && selectSkus.length == 0) { - // productSku = miNiDetail.productSkuVOList.first; - // } else { - // productSku = miNiDetail.productSkuVOList.firstWhere((element) { - // bool gg = true; - // selectSkus.forEach((element1) { - // if (element.skuNameStr.indexOf(element1) < 0) { - // gg = false; - // return gg; - // } - // }); - // return gg; - // }); - // } - // if (productSku == null) return; - // String skuId = productSku.id; - // String skuValue = selectSkus - // .toString() - // .replaceAll("[", "") - // .replaceAll("]", "") - // .replaceAll(",", ""); - // - // if (miNiDetail != null) { - // BaseData> baseDate = await minService.addShoppingCart({ - // "storeId": storeInfo.id, - // "storeName": storeInfo.storeName ?? "", - // "parentId": miNiDetail.id, - // "parentCode": parentCode, - // "shoppingCartSkuItemList": [ - // { - // "buyNum": count, - // "id": skuId, - // "productId": miNiDetail.id, - // "productName": miNiDetail.productName, - // "skuName": skuValue, - // "storeId": storeInfo.id, - // "skuPrice": productSku.skuPrice, - // "skuStock": productSku.skuStock, - // }, - // ], - // }); - // EasyLoading.dismiss(); - // if (baseDate != null && baseDate.isSuccess) { - // queryShopCar().then((value) { - // this.shopCarGoods = value; - // setState(() {}); - // }); - // } - // } - // } - // - // /// 购物车的key,用于刷新UI - // GlobalKey shopCartKey = GlobalKey(); - // - // ///购物车弹窗 - // showShoppingCart() { - // queryShopCar().then((value) { - // this.shopCarGoods = value; - // dialogShowing = true; - // SmartDialog.show( - // widget: ShopCar( - // shopCartKey, - // this.shopCarGoods, - // clearShopCar, - // toDownOrder, - // shopCartAdd, - // shopCartReduce, - // ), - // onDismiss: () { - // dialogShowing = false; - // }, - // alignmentTemp: Alignment.bottomCenter, - // ); - // }); - // } - // - // ///计算个数 - // int count() { - // if (shopCarGoods == null || - // shopCarGoods.shoppingCartSkuItemList == null || - // shopCarGoods.shoppingCartSkuItemList.length == 0) return 0; - // int count = 0; - // shopCarGoods.shoppingCartSkuItemList.forEach((element) { - // count += element.buyNum; - // }); - // return count; - // } - // - // ///去下单结算页面 - // toDownOrder() async { - // int num = count(); - // - // if (miNiDetail.id == null || miNiDetail.id == "") { - // if (num == 0) { - // SmartDialog.showToast("请先选择您要购买的商品!~"); - // return; - // } - // } - // - // await Navigator.of(context).pushNamed( - // '/router/settlement', - // arguments: { - // "storeInfo": storeInfo, - // "parentCode": parentCode, - // "parentId": miNiDetail.id, - // // "pName": pName, - // // "pid": pid, - // // "cName": cName, - // // "cid": cid, - // "shoppingCart": shopCarGoods, - // }, - // ); - // queryShopCar().then((value) { - // this.shopCarGoods = value; - // setState(() {}); - // }); - // } - // - // ///清空购物车 - // 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; - // } - // } - // - // ///购物车➕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) { - // EasyLoading.dismiss(); - // this.shopCarGoods = await queryShopCar(); - // if (shopCartKey?.currentState != null) { - // shopCartKey.currentState.setState(() {}); - // } - // setState(() { - // }); - // } - // return this.shopCarGoods; - // } - // - // ///商品➕1 - // add(MiNiDetail miNiDetail, selectSkus) async { - // ProductSkuVOListBean productSku = - // miNiDetail.productSkuVOList.firstWhere((element) { - // return skuY(element, selectSkus); - // }); - // - // if (productSku == null) return; - // String skuId = productSku.id; - // if (shopCarGoods == null) { - // await _addShopCar(miNiDetail, selectSkus, 2); - // return; - // } - // int shopSkuIndex = shopCarGoods.shoppingCartSkuItemList - // .indexWhere((element) => skuId == element.id); - // Map shopCarTemp = shopCarGoods.toJson(); - // shopCarGoods.tableId = "$tableId"; - // - // if (shopSkuIndex >= 0) { - // shopCarGoods.shoppingCartSkuItemList[shopSkuIndex].buyNum += 1; - // ShoppingCartSkuItemListBean cartSkuItem = shopCarGoods - // .shoppingCartSkuItemList - // .firstWhere((element) => skuId == element.id); - // shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()]; - // } else { - // await _addShopCar(miNiDetail, selectSkus, 2); - // return; - // } - // - // BaseData> baseDate = - // await minService.shoppingCartSingle(shopCarTemp); - // if (baseDate.isSuccess) { - // queryShopCar().then((value) { - // this.shopCarGoods = value; - // setState(() {}); - // }); - // } - // } - // - // ///商品➖1 - // reduce(MiNiDetail miNiDetail, selectSkus) async { - // ProductSkuVOListBean productSku = - // miNiDetail.productSkuVOList.firstWhere((element) { - // return skuY(element, selectSkus); - // }); - // - // if (productSku == null) return; - // String skuId = productSku.id; - // if (shopCarGoods == null) { - // await _addShopCar(miNiDetail, selectSkus, 2); - // return; - // } - // ShoppingCartSkuItemListBean shopSkuItem = shopCarGoods - // .shoppingCartSkuItemList - // .firstWhere((element) => skuId == element.id); - // int shopSkuIndex = shopCarGoods.shoppingCartSkuItemList - // .indexWhere((element) => skuId == element.id); - // - // if (shopSkuItem != null) { - // if (shopSkuItem.buyNum > 1) { - // shopCarGoods.shoppingCartSkuItemList[shopSkuIndex].buyNum -= 1; - // } - // } else { - // await _addShopCar(miNiDetail, selectSkus, 2); - // return; - // } - // shopCarGoods.tableId = "$tableId"; - // - // Map shopCarTemp = shopCarGoods.toJson(); - // ShoppingCartSkuItemListBean cartSkuItem = shopCarGoods - // .shoppingCartSkuItemList - // .firstWhere((element) => skuId == element.id); - // shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()]; - // - // BaseData> baseDate = - // await minService.shoppingCartSingle(shopCarTemp); - // if (baseDate.isSuccess) { - // queryShopCar().then((value) { - // this.shopCarGoods = value; - // setState(() {}); - // }); - // } - // } + ///选规格 + _queryMiNiDetail(String id, int count) async { + EasyLoading.show(status: S.current.zhengzaijiazai); + if(count < 0){ + shopCarGoods.shoppingCartSkuItemList.forEach((element) { + if(element.productId == id){ + shopCartReduce(element); + setState(() { + }); + } + }); + return; + } + BaseData baseData = await minService.miNiDetail(id); + if (baseData != null && baseData.isSuccess) { + showStoreSelector(baseData.data, id, count); + } + } + + ///选规格弹窗 + showStoreSelector(MiNiDetail miNiDetail, String id, int count) async { + if (miNiDetail.attrList != null && + miNiDetail.attrList.length == 1 && + miNiDetail.attrList[0].attrValueList.length == 1) { + _addShopCar(miNiDetail, [], count); + } else { + EasyLoading.dismiss(); + dialogShowing = true; + SmartDialog.show( + widget: ProductSku( + miNiDetail, + shopCarGoods, + id, + _addShopCar, + add, + reduce, + ), + onDismiss: () { + dialogShowing = false; + }, + alignmentTemp: Alignment.bottomCenter, + ); + } + } + + ///添加购物车 + Future _addShopCar(MiNiDetail miNiDetail, selectSkus, int count) async { + ProductSkuVOListBean productSku; + if (selectSkus != null && selectSkus.length == 0) { + productSku = miNiDetail.productSkuVOList.first; + } else { + productSku = miNiDetail.productSkuVOList.firstWhere((element) { + bool gg = true; + selectSkus.forEach((element1) { + if (element.skuNameStr.indexOf(element1) < 0) { + gg = false; + return gg; + } + }); + return gg; + }); + } + if (productSku == null) return; + String skuId = productSku.id; + String skuValue = selectSkus + .toString() + .replaceAll("[", "") + .replaceAll("]", "") + .replaceAll(",", ""); + + if (miNiDetail != null) { + BaseData> baseDate = await minService.addShoppingCart({ + "storeId": storeInfo.id, + "storeName": storeInfo.storeName ?? "", + "parentId": miNiDetail.id, + "parentCode": parentCode, + "shoppingCartSkuItemList": [ + { + "buyNum": count, + "id": skuId, + "productId": miNiDetail.id, + "productName": miNiDetail.productName, + "skuName": skuValue, + "storeId": storeInfo.id, + "skuPrice": productSku.skuPrice, + "skuStock": productSku.skuStock, + }, + ], + }); + EasyLoading.dismiss(); + if (baseDate != null && baseDate.isSuccess) { + queryShopCar().then((value) { + this.shopCarGoods = value; + setState(() {}); + }); + } + } + } + + /// 购物车的key,用于刷新UI + GlobalKey shopCartKey = GlobalKey(); + + ///购物车弹窗 + showShoppingCart() { + queryShopCar().then((value) { + this.shopCarGoods = value; + dialogShowing = true; + SmartDialog.show( + widget: ShopCar( + shopCartKey, + this.shopCarGoods, + clearShopCar, + toDownOrder, + shopCartAdd, + shopCartReduce, + ), + onDismiss: () { + dialogShowing = false; + }, + alignmentTemp: Alignment.bottomCenter, + ); + }); + } + + ///计算个数 + int count() { + if (shopCarGoods == null || + shopCarGoods.shoppingCartSkuItemList == null || + shopCarGoods.shoppingCartSkuItemList.length == 0) return 0; + int count = 0; + shopCarGoods.shoppingCartSkuItemList.forEach((element) { + count += element.buyNum; + }); + return count; + } + + ///去下单结算页面 + toDownOrder() async { + int num = count(); + + if (miNiDetail.id == null || miNiDetail.id == "") { + if (num == 0) { + SmartDialog.showToast("请先选择您要购买的商品!~"); + return; + } + } + + await Navigator.of(context).pushNamed( + '/router/settlement', + arguments: { + "storeInfo": storeInfo, + "parentCode": parentCode, + "parentId": miNiDetail.id, + // "pName": pName, + // "pid": pid, + // "cName": cName, + // "cid": cid, + "shoppingCart": shopCarGoods, + }, + ); + queryShopCar().then((value) { + this.shopCarGoods = value; + setState(() {}); + }); + } + + ///清空购物车 + 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; + } + } + + ///购物车➕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) { + EasyLoading.dismiss(); + this.shopCarGoods = await queryShopCar(); + if (shopCartKey?.currentState != null) { + shopCartKey.currentState.setState(() {}); + } + setState(() { + }); + } + return this.shopCarGoods; + } + + ///商品➕1 + add(MiNiDetail miNiDetail, selectSkus) async { + ProductSkuVOListBean productSku = + miNiDetail.productSkuVOList.firstWhere((element) { + return skuY(element, selectSkus); + }); + + if (productSku == null) return; + String skuId = productSku.id; + if (shopCarGoods == null) { + await _addShopCar(miNiDetail, selectSkus, 2); + return; + } + int shopSkuIndex = shopCarGoods.shoppingCartSkuItemList + .indexWhere((element) => skuId == element.id); + Map shopCarTemp = shopCarGoods.toJson(); + shopCarGoods.tableId = "$tableId"; + + if (shopSkuIndex >= 0) { + shopCarGoods.shoppingCartSkuItemList[shopSkuIndex].buyNum += 1; + ShoppingCartSkuItemListBean cartSkuItem = shopCarGoods + .shoppingCartSkuItemList + .firstWhere((element) => skuId == element.id); + shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()]; + } else { + await _addShopCar(miNiDetail, selectSkus, 2); + return; + } + + BaseData> baseDate = + await minService.shoppingCartSingle(shopCarTemp); + if (baseDate.isSuccess) { + queryShopCar().then((value) { + this.shopCarGoods = value; + setState(() {}); + }); + } + } + + ///商品➖1 + reduce(MiNiDetail miNiDetail, selectSkus) async { + ProductSkuVOListBean productSku = + miNiDetail.productSkuVOList.firstWhere((element) { + return skuY(element, selectSkus); + }); + + if (productSku == null) return; + String skuId = productSku.id; + if (shopCarGoods == null) { + await _addShopCar(miNiDetail, selectSkus, 2); + return; + } + ShoppingCartSkuItemListBean shopSkuItem = shopCarGoods + .shoppingCartSkuItemList + .firstWhere((element) => skuId == element.id); + int shopSkuIndex = shopCarGoods.shoppingCartSkuItemList + .indexWhere((element) => skuId == element.id); + + if (shopSkuItem != null) { + if (shopSkuItem.buyNum > 1) { + shopCarGoods.shoppingCartSkuItemList[shopSkuIndex].buyNum -= 1; + } + } else { + await _addShopCar(miNiDetail, selectSkus, 2); + return; + } + shopCarGoods.tableId = "$tableId"; + + Map shopCarTemp = shopCarGoods.toJson(); + ShoppingCartSkuItemListBean cartSkuItem = shopCarGoods + .shoppingCartSkuItemList + .firstWhere((element) => skuId == element.id); + shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()]; + + BaseData> baseDate = + await minService.shoppingCartSingle(shopCarTemp); + if (baseDate.isSuccess) { + queryShopCar().then((value) { + this.shopCarGoods = value; + setState(() {}); + }); + } + } + + bool skuY(ProductSkuVOListBean productSku, selectSkus) { + bool gg = true; + selectSkus.forEach((element1) { + if (productSku.skuNameStr.indexOf(element1) < 0) { + gg = false; + return gg; + } + }); + return gg; + } + buildCount() { + counts = 1; + ProductSkuVOListBean productSku; + try { + productSku = miNiDetail.productSkuVOList.firstWhere((element) { + return skuY(element, selectSkus); + }); + }catch(ex){ + return; + } + if (productSku == null) return; + selectedPrice = productSku.skuPrice; + String skuId = productSku.id; + if (shopCarGoods == null || shopCarGoods.shoppingCartSkuItemList == null) return; + int shopSkuIndex = shopCarGoods.shoppingCartSkuItemList.indexWhere((element) => skuId == element.id); + if (shopSkuIndex >= 0) { + counts = shopCarGoods.shoppingCartSkuItemList[shopSkuIndex].buyNum; + } + } @override Widget build(BuildContext context) { @@ -488,6 +528,100 @@ class _ShopDetailsPage extends State { ), flex: 1, ), + // if(count() != 0) + Positioned( + bottom: 0, + left: 0, + right: 0, + child: Stack( + alignment: Alignment.bottomLeft, + children: [ + Container( + margin: EdgeInsets.symmetric(horizontal: 14), + height: 45.h, + // color: Color(0xFFFAFAFA), + decoration: BoxDecoration( + color: Color(0xFF383A38), + borderRadius: BorderRadius.circular(100), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + SizedBox(width:45.w,), + Text.rich( + TextSpan(children: [ + TextSpan( + text: "¥ ", + style: TextStyle( + fontSize: 12.sp, + color: Color(0xFFFFFFFF), + fontWeight: MyFontWeight.bold), + ), + TextSpan( + text: + shopCarGoods != null ? shopCarGoods.cartSum : "0.0", + style: TextStyle( + fontSize: 20.sp, + color: Color(0xFFFFFFFF), + fontWeight: MyFontWeight.semi_bold), + ), + ]), + ), + Spacer(), + GestureDetector( + onTap: () { + toDownOrder(); + }, + child: RoundButton( + width: 103.w, + height: 54.h, + text: S.current.jiesuan, + textColor: Colors.white, + fontWeight: MyFontWeight.bold, + backgroup: Color(0xFF32A060), + radius: 100, + fontSize: 16.sp, + padding: EdgeInsets.symmetric(vertical: 5.h), + ), + ), + ], + ), + ), + Stack( + children: [ + InkWell( + onTap: () { + if(count() != 0) + showShoppingCart(); + }, + child: Image.asset( + "assets/image/shopping_bag.webp", + width: 66, + height: 66, + fit: BoxFit.fitWidth, + ), + ), + if(count() != 0) + Positioned( + right: 5, + // top: 14, + child: RoundButton( + width: 17.w, + height: 17.h, + text: "${count()}", + textColor: Colors.white, + fontWeight: MyFontWeight.regular, + backgroup: Color(0xFFF65720), + fontSize: 12.sp, + radius: 100, + ), + ), + ], + ), + ], + ), + ), ], ), ), @@ -711,11 +845,16 @@ class _ShopDetailsPage extends State { color: Color(0xFF000000), ), ), - Image.asset( - "assets/image/cancel.webp", - fit: BoxFit.cover, - height: 24, - width: 24, + GestureDetector( + onTap: (){ + Navigator.of(context).pop(); + }, + child: Image.asset( + "assets/image/cancel.webp", + fit: BoxFit.cover, + height: 24, + width: 24, + ), ), ], ), @@ -731,6 +870,117 @@ class _ShopDetailsPage extends State { ), )), ], + ), + // if (miNiDetail.attrList != null && miNiDetail.attrList.length > 0) + // SizedBox( + // height:10, + // ), + // if (miNiDetail.attrList != null && miNiDetail.attrList.length > 0) + // Expanded( + // child: ListView.builder( + // itemCount: miNiDetail.attrList.length, + // scrollDirection: Axis.vertical, + // physics: BouncingScrollPhysics(), + // padding: EdgeInsets.zero, + // itemBuilder: (context, position) { + // return attrItem( + // (attrValue) { + // setState(() { + // selectSkus[position] = attrValue; + // buildCount(); + // }); + // }, + // miNiDetail.attrList[position], + // position, + // ); + // }, + // ), + // ), + SizedBox( + height: 24, + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + "数量", + style: TextStyle( + color: Color(0xFFB3B3B3), + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + ), + ), + SizedBox(height: 10,), + Row( + children: [ + InkWell( + onTap: () { + if (counts > 1) + setState(() { + counts -= 1; + }); + reduce(miNiDetail, selectSkus); + }, + child: Icon( + Icons.remove, + color: Color(0xFF32A060), + size: 24, + ) + // Image.asset( + // "assets/image/reduce.webp", + // width: 22, + // height: 22, + // ), + ), + Padding( + padding: EdgeInsets.only(left: 8, right: 8), + child: Text( + // "$count", + "0", + style: TextStyle( + color: Colors.black, + fontSize: 14.sp, + fontWeight: MyFontWeight.medium, + ), + ), + ), + InkWell( + onTap: () { + setState(() { + counts += 1; + }); + add(miNiDetail, selectSkus); + }, + child:Icon( + Icons.add, + color: Color(0xFF32A060), + size: 24, + ) + ), + ], + ) + ], + ), + SizedBox( + height: 24, + ), + Container( + width: double.infinity, + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(20), + color: Color(0xFF32A060), + ), + padding: EdgeInsets.symmetric(vertical: 6), + child: Text( + "加入购物车", + style: TextStyle( + fontSize: 15.sp, + fontWeight: MyFontWeight.bold, + color: Color(0xFFFFFFFF), + ), + ), ) ], ), @@ -739,4 +989,71 @@ class _ShopDetailsPage extends State { }, ); } + + Widget attrItem(Function fc, AttrListBean attrListBean, position) { + if (attrListBean.attrValueList != null && attrListBean.attrValueList.length > 0) + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsets.only(top: 16, bottom: 16), + child: Text( + attrListBean.attrName, + style: TextStyle( + color: Color(0xFFB3B3B3), + fontSize: 14.sp, + fontWeight: MyFontWeight.regular, + ), + ), + ), + sweetnessStore(fc,attrListBean.attrValueList, position), + // sweetnessStore(fc, attrListBean.attrValueList, position), + ], + ); + else { + return Container(); + } + } + + Widget sweetnessStore(Function fc,List arrays, position){ + return Wrap( + runSpacing: 10.0, + spacing: 10.0, + children: arrays.take(arrays.length).map((AttrValueListBean tag) { + return GestureDetector( + onTap: () { + fc(tag.attrValue); + }, + child:sweetnessItem( + tag.attrValue, + (tag.attrValue == selectSkus[position]) ?? false, + )); + }).toList()); + } + + Widget sweetnessItem(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, + ), + )); + } + } diff --git a/lib/view_widget/new_coupon_widget.dart b/lib/view_widget/new_coupon_widget.dart index 939e6010..94c64733 100644 --- a/lib/view_widget/new_coupon_widget.dart +++ b/lib/view_widget/new_coupon_widget.dart @@ -16,7 +16,7 @@ class NewCouponWidget extends StatelessWidget { @override Widget build(BuildContext context) { - return homeCoupon(context); + return buildCoupon(context); } @@ -378,395 +378,6 @@ class NewCouponWidget extends StatelessWidget { ); } - ///首页优惠券ui - Widget homeCoupon(BuildContext context) { - return Container( - height: 110.h, - width: double.infinity, - margin: EdgeInsets.fromLTRB(14.w, 6.h, 14.w, 6.h), - padding:EdgeInsets.symmetric(horizontal: 12), - decoration: BoxDecoration( - image: DecorationImage( - fit: BoxFit.fill, - image: AssetImage("assets/image/week_coupons.webp"), - ), - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded(child: Container( - margin: EdgeInsets.only(top: 12,bottom: 12), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded(child: - Text( - coupon != null ? coupon.couponName ?? "" : "", - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 14.sp, - fontWeight: MyFontWeight.semi_bold, - color: Color(0xFF353535), - ), - )), - Expanded(child: - (coupon.useStartTime == null && - coupon.useEndTime == null)? - Text( - S.of(context).quantian, - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: coupon.status == 3 ? Color(0xFFB3B3B3) :Color(0xFF4D4D4D), - ), - ):Text( - "有效期至 ${coupon?.useEndTime ?? ""}", - maxLines:1, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: coupon.status == 3 ? Color(0xFFB3B3B3) :Color(0xFF4D4D4D), - ), - )), - GestureDetector( - onTap: (){ - // showDeleteDialog(); - - }, - child: Row( - children: [ - Text( - "使用详情", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: coupon.status == 3 ? Color(0xFFB3B3B3):Color(0xFF4D4D4D), - ), - ), - Icon( - Icons.keyboard_arrow_right, - color: coupon.status == 3 ? Color(0xFFB3B3B3) :Color(0xFF4D4D4D), - size: 20, - ) - ], - ), - ) - ], - ), - )), - Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Expanded(child: Container( - child:homeWidget(context), - )), - Container( - margin: EdgeInsets.only(bottom: 12), - child: homeBtn(context), - ) - ], - ) - ], - ), - ); - } - - Widget homeWidget(BuildContext context) { - if (coupon.bizType == 1) { - return Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.baseline, - textBaseline: TextBaseline.alphabetic, - children: [ - Text( - "¥", - style: TextStyle( - fontSize: 16.sp, - fontWeight: MyFontWeight.medium, - color: coupon.status == 3 ? Color(0xFFB3B3B3):Color(0xff32A060), - ), - ), - SizedBox( - height: 4.h, - ), - Text( - coupon != null - ? double.tryParse("${coupon.discountAmount}" ?? "0") - .toInt() - .toString() - : "", - style: TextStyle( - fontSize: 26.sp, - fontWeight: MyFontWeight.semi_bold, - color: coupon.status == 3 ? Color(0xFFB3B3B3):Color(0xff32A060), - ), - ), - ], - ), - Text( - S.of(context).manyuankeyong(coupon != null - ? ("${coupon.fullAmount}" ?? "0") - .toString() - : ""), - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.semi_bold, - color: coupon.status == 3 ? Color(0xFFB3B3B3):Color(0xff32A060), - ), - ), - ], - ); - } else if (coupon.bizType == 3) { - return Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Container( - padding: EdgeInsets.only(bottom:10,top: 7), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - S.of(context).duihuanquan, - style: TextStyle( - fontSize: 26.sp, - fontWeight: MyFontWeight.semi_bold, - color: coupon.status == 3 ? Color(0xFFB3B3B3):Color(0xff32A060), - ), - ), - ], - ), - ), - Text( - S.of(context).xianshangshiyong, - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.semi_bold, - color: coupon.status == 3 ? Color(0xFFB3B3B3):Color(0xff32A060), - ), - ), - ], - ); - } else if (coupon.bizType == 5) { - return Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Container( - padding: EdgeInsets.only(bottom:10,top: 7), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - S.of(context).duihuanquan, - style: TextStyle( - fontSize: 26.sp, - fontWeight: MyFontWeight.semi_bold, - color: coupon.status == 3 ? Color(0xFFB3B3B3):Color(0xff32A060), - ), - ), - ], - ), - ), - Text( - S.of(context).xianxiashiyong, - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.semi_bold, - color: coupon.status == 3 ? Color(0xFFB3B3B3):Color(0xff32A060), - ), - ), - ], - ); - } else { - return Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.baseline, - textBaseline: TextBaseline.alphabetic, - children: [ - Text( - coupon != null - ? "${(coupon.discountPercent / 10.0 >= 10) ? 10 : coupon.discountPercent / 10.0}" ?? - "0" - : "", - style: TextStyle( - fontSize: 30.sp, - fontWeight: MyFontWeight.semi_bold, - color: coupon.status == 3 ? Color(0xFFB3B3B3):Color(0xff32A060), - ), - ), - SizedBox( - height: 4.h, - ), - Text( - "折", - style: TextStyle( - fontSize: 16.sp, - fontWeight: MyFontWeight.semi_bold, - color: coupon.status == 3 ? Color(0xFFB3B3B3):Color(0xff32A060), - ), - ), - ], - ), - ], - ); - } - } - - Widget homeBtn(context) { - if (type == 1) { - if (coupon != null && coupon.status == 0) { - return Align( - alignment: Alignment.centerRight, - child: InkWell( - onTap: () { - callback(type); - }, - child: Container( - padding: EdgeInsets.symmetric(horizontal: 14,vertical: 2), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(3), - color: Color(0xFF32A060), - ), - child: Text( - S.of(context).lingqu, - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.medium, - color: Colors.white, - ), - ), - ), - ), - ); - } else { - return Align( - alignment: Alignment.centerRight, - child: Container( - padding: EdgeInsets.symmetric(horizontal:8,vertical: 2), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(3), - color: Colors.grey, - ), - child: Text( - S.of(context).yilingqu, - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.medium, - color: Colors.white, - ), - ), - ), - ); - } - } else { - if (coupon != null && coupon.status == 1) { - return Align( - alignment: Alignment.centerRight, - child: InkWell( - onTap: () { - callback(type); - }, - child: Container( - // width: 56.w, - height: 19.h, - // padding: EdgeInsets.symmetric(horizontal:8,vertical: 2), - decoration: BoxDecoration( - color: Color(0xFF32A060), - borderRadius: BorderRadius.circular(3), - ), - alignment: Alignment.center, - child:Text( - S.of(context).qushiyong, - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: Color(0xFFFFFFFF), - ), - ), - ), - // Container( - // padding: EdgeInsets.fromLTRB(16.w, 2.h, 16.w, 2.h), - // decoration: BoxDecoration( - // borderRadius: BorderRadius.circular(10.5), - // color: Color(0xFF32A060), - // ), - // child: Text( - // (coupon.bizType == 5 || coupon.bizType == 3) - // ? S.of(context).quhexiao - // : S.of(context).qushiyong, - // style: TextStyle( - // fontSize: 12.sp, - // fontWeight: MyFontWeight.medium, - // color: Colors.white, - // ), - // ), - // ), - ), - ); - } else if (coupon != null && coupon.status == 2) { - return Align( - alignment: Alignment.centerRight, - child: Container( - padding: EdgeInsets.symmetric(horizontal: 14,vertical: 2), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(3), - // border: Border.all( - // width: 1, color: Color(0xFFA0A0A0), style: BorderStyle.solid) - color: Color(0xFFA0A0A0), - ), - child: Text( - S.of(context).yishiyong, - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.medium, - color: Colors.white, - ), - ), - ), - ); - } else { - return Align( - alignment: Alignment.centerRight, - child: Container( - padding: EdgeInsets.symmetric(horizontal: 14,vertical: 2), - // decoration: BoxDecoration( - // borderRadius: BorderRadius.circular(10.5), - // // border: Border.all( - // // width: 1, color: Color(0xFFA0A0A0), style: BorderStyle.solid) - // color: Color(0xFFA0A0A0), - // ), - child: Text( - S.of(context).yishixiao, - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.semi_bold, - color: Color(0xFFB3B3B3), - ), - ), - ), - ); - } - } - } - Widget priceWidget(BuildContext context) { if (coupon.bizType == 1) { return Column( diff --git a/lib/view_widget/receive_success.dart b/lib/view_widget/receive_success.dart index 0cf7b0f9..e35269f2 100644 --- a/lib/view_widget/receive_success.dart +++ b/lib/view_widget/receive_success.dart @@ -1,4 +1,3 @@ - import 'package:flutter/material.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/view_widget/round_button.dart'; @@ -22,8 +21,8 @@ class ReceiveSuccess extends StatelessWidget { Container( margin: EdgeInsets.only(top: 40.h), decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(8),), + color: Colors.white, + borderRadius: BorderRadius.circular(8),), width: 218.w, height: 250.h, child: Column( @@ -31,7 +30,9 @@ class ReceiveSuccess extends StatelessWidget { Padding( padding: EdgeInsets.only(top: 50.h, bottom: 19.h), child: Text( - S.of(context).lingquchenggong, + S + .of(context) + .lingquchenggong, style: TextStyle( color: Color(0xff353535), fontSize: 16.sp, @@ -49,9 +50,18 @@ class ReceiveSuccess extends StatelessWidget { Row( mainAxisAlignment: MainAxisAlignment.center, children: [ + Text( + "${S.of(context).main_menu4}-", + style: TextStyle( + color: Color(0xff353535), + fontSize: 14.sp, + ), + ), GestureDetector( child: Text( - S.of(context).kaquan, + "${S + .of(context) + .youhuiquan}", style: TextStyle( color: Color(0xFFFF7A1A), fontSize: 14.sp, @@ -59,12 +69,13 @@ class ReceiveSuccess extends StatelessWidget { ), ), onTap: () { - Navigator.of(context) - .pushNamed('/router/mine_card'); + Navigator.of(context).pushNamed('/router/coupon_page'); }, ), Text( - S.of(context).zhongchakan, + S + .of(context) + .zhongchakan, style: TextStyle( color: Color(0xff353535), fontSize: 14.sp, @@ -77,7 +88,9 @@ class ReceiveSuccess extends StatelessWidget { child: RoundButton( width: 130.w, height: 34.h, - text: S.of(context).queren, + text: S + .of(context) + .queren, textColor: Colors.white, fontSize: 12.sp, callback: () { @@ -108,5 +121,4 @@ class ReceiveSuccess extends StatelessWidget { } - } \ No newline at end of file