diff --git a/assets/image/2x/week_coupons.png b/assets/image/2x/week_coupons.png deleted file mode 100644 index b72f25bd..00000000 Binary files a/assets/image/2x/week_coupons.png and /dev/null differ diff --git a/assets/image/2x/week_coupons.webp b/assets/image/2x/week_coupons.webp new file mode 100644 index 00000000..83eddd92 Binary files /dev/null and b/assets/image/2x/week_coupons.webp differ diff --git a/assets/image/3x/week_coupons.png b/assets/image/3x/week_coupons.png deleted file mode 100644 index 34250fe2..00000000 Binary files a/assets/image/3x/week_coupons.png and /dev/null differ diff --git a/assets/image/3x/week_coupons.webp b/assets/image/3x/week_coupons.webp new file mode 100644 index 00000000..17851b1e Binary files /dev/null and b/assets/image/3x/week_coupons.webp differ diff --git a/assets/image/week_coupons.png b/assets/image/week_coupons.png deleted file mode 100644 index fc926870..00000000 Binary files a/assets/image/week_coupons.png and /dev/null differ diff --git a/assets/image/week_coupons.webp b/assets/image/week_coupons.webp new file mode 100644 index 00000000..29f70261 Binary files /dev/null and b/assets/image/week_coupons.webp differ diff --git a/lib/home/welfare_page.dart b/lib/home/welfare_page.dart index c52b512a..8ad83b7b 100644 --- a/lib/home/welfare_page.dart +++ b/lib/home/welfare_page.dart @@ -252,46 +252,14 @@ class _WelfarePage extends State { decoration: BoxDecoration( image: DecorationImage( fit: BoxFit.fill, - image: AssetImage("assets/image/week_coupons.png"), + image: AssetImage("assets/image/week_coupons.webp"), ), ), - padding: EdgeInsets.symmetric(horizontal: 10.w,vertical: 10.h), + padding: EdgeInsets.symmetric(horizontal: 12.w,vertical: 12.h), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.end, children: [ - Expanded(child: - Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded(child: Text( - "百年川椒(哈乐城店)", - style: TextStyle( - fontSize: 14.sp, - fontWeight: MyFontWeight.bold, - color: Color(0xFF0D0D0D), - ), - )), - Text( - "新人满减30元", - style: TextStyle( - fontSize: 11.sp, - fontWeight: MyFontWeight.regular, - color: Color(0xFF4D4D4D), - ), - ), - SizedBox(height:4.h,), - Text( - "有效期至2022-09-10 12:00:00", - style: TextStyle( - fontSize: 11.sp, - fontWeight: MyFontWeight.regular, - color: Color(0xFF4D4D4D), - ), - ), - ], - )), Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, @@ -302,57 +270,93 @@ class _WelfarePage extends State { TextSpan( text: "¥", style: TextStyle( - fontSize: 12.sp, + fontSize: 16.sp, fontWeight: MyFontWeight.semi_bold, - color: Color(0xFFFF4500), + color: Color(0xFF32A060), ), ), TextSpan( text: "30", style: TextStyle( - fontSize: 24.sp, + fontSize: 26.sp, fontWeight: MyFontWeight.semi_bold, - color: Color(0xFFFF4500), + color: Color(0xFF32A060), ), ), ], ), ), - Expanded(child: Text( + Text( "满30.1可用", style: TextStyle( fontSize: 12.sp, fontWeight: MyFontWeight.regular, - color: Color(0xFFFF4500), + color: Color(0xFF32A060), + ), + ), + ], + ), + SizedBox(width: 30,), + Expanded(child: + Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded(child: Text( + "新人满减30元", + style: TextStyle( + fontSize: 14.sp, + fontWeight: MyFontWeight.semi_bold, + color: Color(0xFF353535), ), )), - Container( - width: 55.w, - height: 19.h, - decoration: BoxDecoration( - gradient: new LinearGradient( - begin: Alignment.bottomCenter, - end: Alignment.topCenter, - colors: [ - Color(0xFFFF4F00), - Color(0xFFFF2700), - ]), - // border: Border.all(color: Colors.white,width: 0.5), - shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(3), + SizedBox(height:4.h,), + Text( + "有效期至2022-09-10 12:00:00", + style: TextStyle( + fontSize: 11.sp, + fontWeight: MyFontWeight.regular, + color: Color(0xFF4D4D4D), ), - alignment: Alignment.center, - child:Text( - "领取", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: Color(0xFFFFFFFF), + ), + SizedBox(height:5.h,), + Row( + children: [ + Text( + "使用详情", + style: TextStyle( + fontSize: 11.sp, + fontWeight: MyFontWeight.regular, + color: Color(0xFF4D4D4D), + ), ), - ), - ) + Icon( + Icons.keyboard_arrow_right, + color: Color(0xFF4D4D4D), + size: 20, + ) + ], + ), ], - ), + )), + 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), + ), + ), + ) ], ), ); diff --git a/lib/view_widget/new_coupon_widget.dart b/lib/view_widget/new_coupon_widget.dart index 4df2b639..25fe5328 100644 --- a/lib/view_widget/new_coupon_widget.dart +++ b/lib/view_widget/new_coupon_widget.dart @@ -16,9 +16,10 @@ class NewCouponWidget extends StatelessWidget { @override Widget build(BuildContext context) { - return buildCoupon(context); + return homeCoupon(context); } + ///优惠券ui Widget buildCoupon(BuildContext context) { // if(coupon != null) { // coupon.isEx = fa; @@ -368,6 +369,414 @@ class NewCouponWidget extends StatelessWidget { ); } + ///首页优惠券ui + Widget homeCoupon(BuildContext context) { + return Container( + height: 100.h, + width: double.infinity, + margin: EdgeInsets.fromLTRB(14.w, 6.h, 14.w, 6.h), + decoration: BoxDecoration( + image: DecorationImage( + fit: BoxFit.fill, + image: AssetImage("assets/image/week_coupons.webp"), + ), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 1, + child:Container( + margin: EdgeInsets.only(top: 12,bottom: 12), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded(child: Container( + child:homeWidget(context), + )), + ], + ), + )), + Expanded( + flex: 2, + child:Container( + margin: EdgeInsets.only(top: 12,left: 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.end, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Container( + margin: EdgeInsets.only(right:12.w,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.start, + 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.start, + 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.start, + 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: 40.sp, + fontWeight: MyFontWeight.semi_bold, + color: coupon.status == 3 ? Color(0xFFB3B3B3):Color(0xff32A060), + ), + ), + SizedBox( + height: 4.h, + ), + Text( + "折", + style: TextStyle( + fontSize: 20.sp, + fontWeight: MyFontWeight.semi_bold, + color: coupon.status == 3 ? Color(0xFFB3B3B3):Color(0xff32A060), + ), + ), + ], + ), + Text( + S.of(context).quanchangtongyong, + style: TextStyle( + fontSize: 12.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: 14,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, + decoration: BoxDecoration( + color: Color(0xFF32A060), + borderRadius: BorderRadius.circular(3), + ), + alignment: Alignment.center, + child:Text( + "立即使用", + 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(