|
|
|
@ -1,12 +1,20 @@
|
|
|
|
|
import 'package:dio/dio.dart'; |
|
|
|
|
import 'package:flutter/cupertino.dart'; |
|
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
|
import 'package:huixiang/generated/l10n.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/data/coupon.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/retrofit_api.dart'; |
|
|
|
|
import 'package:huixiang/utils/font_weight.dart'; |
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
|
import 'package:huixiang/view_widget/classic_header.dart'; |
|
|
|
|
import 'package:huixiang/view_widget/item_title.dart'; |
|
|
|
|
import 'package:huixiang/view_widget/my_footer.dart'; |
|
|
|
|
import 'package:pull_to_refresh/pull_to_refresh.dart'; |
|
|
|
|
|
|
|
|
|
class DiscountZone extends StatefulWidget { |
|
|
|
|
final List<Coupon> coupon; |
|
|
|
|
|
|
|
|
|
DiscountZone(this.coupon); |
|
|
|
|
@override |
|
|
|
|
State<StatefulWidget> createState() { |
|
|
|
|
return _DiscountZone(); |
|
|
|
@ -19,6 +27,7 @@ class _DiscountZone extends State<DiscountZone> {
|
|
|
|
|
@override |
|
|
|
|
void initState() { |
|
|
|
|
super.initState(); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@ -30,22 +39,44 @@ class _DiscountZone extends State<DiscountZone> {
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start, |
|
|
|
|
children: [ |
|
|
|
|
ItemTitle( |
|
|
|
|
text: "特惠专区", |
|
|
|
|
), |
|
|
|
|
Padding(padding:EdgeInsets.symmetric(horizontal: 14.w), |
|
|
|
|
child: Row( |
|
|
|
|
children: [ |
|
|
|
|
Expanded(child: |
|
|
|
|
Text( |
|
|
|
|
"特惠专区", |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Color(0xFF0D0D0D), |
|
|
|
|
fontSize: 15.sp, |
|
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
|
), |
|
|
|
|
)), |
|
|
|
|
GestureDetector( |
|
|
|
|
onTap: (){ |
|
|
|
|
Navigator.of(context).pushNamed('/router/welfare_page'); |
|
|
|
|
}, |
|
|
|
|
child: Text( |
|
|
|
|
"更多好券", |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Color(0xFF4D4D4D), |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
) |
|
|
|
|
], |
|
|
|
|
),), |
|
|
|
|
Container( |
|
|
|
|
height: 91.h, |
|
|
|
|
margin: EdgeInsets.only(top: 14,left: 14.w), |
|
|
|
|
height: 91, |
|
|
|
|
margin: EdgeInsets.only(top: 10), |
|
|
|
|
child: ListView.builder( |
|
|
|
|
scrollDirection: Axis.horizontal, |
|
|
|
|
physics: BouncingScrollPhysics(), |
|
|
|
|
itemCount: 6, |
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 10), |
|
|
|
|
itemBuilder: (context, position) { |
|
|
|
|
return GestureDetector( |
|
|
|
|
onTap: () {}, |
|
|
|
|
child: discountItem(), |
|
|
|
|
); |
|
|
|
|
return discountItem(widget.coupon[position]); |
|
|
|
|
}, |
|
|
|
|
itemCount:widget.coupon.length, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
@ -53,9 +84,9 @@ class _DiscountZone extends State<DiscountZone> {
|
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Widget discountItem() { |
|
|
|
|
Widget discountItem(Coupon coupon) { |
|
|
|
|
return Container( |
|
|
|
|
width: 246.w, |
|
|
|
|
width: 300.w, |
|
|
|
|
height: 91.h, |
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
image: DecorationImage( |
|
|
|
@ -63,79 +94,232 @@ class _DiscountZone extends State<DiscountZone> {
|
|
|
|
|
image: AssetImage("assets/image/discount.webp"), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 15.h), |
|
|
|
|
margin: EdgeInsets.only(right: 6.w), |
|
|
|
|
child: Row( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start, |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
|
children: [ |
|
|
|
|
Column( |
|
|
|
|
children: [ |
|
|
|
|
Text.rich( |
|
|
|
|
TextSpan( |
|
|
|
|
Expanded( |
|
|
|
|
flex: 1, |
|
|
|
|
child:Container( |
|
|
|
|
margin: EdgeInsets.only(top: 12,bottom: 12), |
|
|
|
|
child: Column( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start, |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
|
children: [ |
|
|
|
|
TextSpan( |
|
|
|
|
text: "¥", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
fontWeight: MyFontWeight.semi_bold, |
|
|
|
|
color: Color(0xFF32A060), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
TextSpan( |
|
|
|
|
text: "30", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 30.sp, |
|
|
|
|
fontWeight: MyFontWeight.semi_bold, |
|
|
|
|
color: Color(0xFF32A060), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
Expanded(child: Container( |
|
|
|
|
child:discountWidget(coupon), |
|
|
|
|
)), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
)), |
|
|
|
|
Expanded( |
|
|
|
|
flex: 2, |
|
|
|
|
child: Container( |
|
|
|
|
margin: EdgeInsets.only(top: 12,left:35,bottom: 12), |
|
|
|
|
child: Column( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
|
|
|
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(0xFF0D0D0D), |
|
|
|
|
), |
|
|
|
|
),), |
|
|
|
|
Spacer(), |
|
|
|
|
SizedBox(height:5), |
|
|
|
|
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: Color(0xFF4D4D4D), |
|
|
|
|
), |
|
|
|
|
):Text( |
|
|
|
|
"有效期至 ${coupon.useEndTime.substring(0, coupon.useEndTime.indexOf(" "))}", |
|
|
|
|
maxLines:1, |
|
|
|
|
overflow: TextOverflow.ellipsis, |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
|
color: Color(0xFF4D4D4D), |
|
|
|
|
), |
|
|
|
|
)), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
)), |
|
|
|
|
], |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Widget discountWidget(Coupon coupon) { |
|
|
|
|
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( |
|
|
|
|
"满30.1可用", |
|
|
|
|
"¥", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
|
color: Color(0xFF32A060), |
|
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
|
color: coupon.status == 3 ? Color(0xFFB3B3B3):Color(0xff32A060), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
Spacer(), |
|
|
|
|
Column( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start, |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
|
children: [ |
|
|
|
|
SizedBox( |
|
|
|
|
height: 4.h, |
|
|
|
|
), |
|
|
|
|
Text( |
|
|
|
|
"百年川椒(哈乐城店)", |
|
|
|
|
coupon != null |
|
|
|
|
? double.tryParse("${coupon.discountAmount}" ?? "0") |
|
|
|
|
.toInt() |
|
|
|
|
.toString() |
|
|
|
|
: "", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 14.sp, |
|
|
|
|
fontWeight: MyFontWeight.bold, |
|
|
|
|
color: Color(0xFF0D0D0D), |
|
|
|
|
fontSize: 30.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: 30.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( |
|
|
|
|
"新人满减30元", |
|
|
|
|
coupon != null |
|
|
|
|
? "${(coupon.discountPercent / 10.0 >= 10) ? 10 : coupon.discountPercent / 10.0}" ?? |
|
|
|
|
"0" |
|
|
|
|
: "", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 10.sp, |
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
|
color: Color(0xFF4D4D4D), |
|
|
|
|
fontSize: 30.sp, |
|
|
|
|
fontWeight: MyFontWeight.semi_bold, |
|
|
|
|
color: coupon.status == 3 ? Color(0xFFB3B3B3):Color(0xff32A060), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
|
height: 4.h, |
|
|
|
|
), |
|
|
|
|
Text( |
|
|
|
|
"有效期至2022-09-10", |
|
|
|
|
"折", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
|
color: Color(0xFF4D4D4D), |
|
|
|
|
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), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|