|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:huixiang/generated/l10n.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/store_info.dart';
|
|
|
|
import 'package:huixiang/utils/font_weight.dart';
|
|
|
|
import 'package:huixiang/view_widget/item_title.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import 'package:huixiang/view_widget/round_button.dart';
|
|
|
|
import 'package:huixiang/view_widget/separator.dart';
|
|
|
|
|
|
|
|
class UnionCoupon extends StatefulWidget {
|
|
|
|
final StoreInfo storeInfo;
|
|
|
|
final bool coupon;
|
|
|
|
final Function(String id) receiveCoupon;
|
|
|
|
|
|
|
|
UnionCoupon(this.storeInfo, this.receiveCoupon, {this.coupon = false});
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<StatefulWidget> createState() {
|
|
|
|
return _UnionCoupon();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class _UnionCoupon extends State<UnionCoupon> {
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return (widget.coupon != null &&
|
|
|
|
widget.coupon &&
|
|
|
|
(widget.storeInfo != null && widget.storeInfo.couponVOList != null))
|
|
|
|
? buildCoupon()
|
|
|
|
: Column(
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
margin: EdgeInsets.only(top: 10.h, bottom: 10.h),
|
|
|
|
child: ItemTitle(
|
|
|
|
text: S.of(context).youhuiquan,
|
|
|
|
imgPath: "assets/image/icon_union_coupons.webp",
|
|
|
|
),
|
|
|
|
),
|
|
|
|
(widget.storeInfo != null &&
|
|
|
|
widget.storeInfo.couponVOList != null)
|
|
|
|
? buildCoupon()
|
|
|
|
: Container(
|
|
|
|
width: double.infinity,
|
|
|
|
height: 50.h,
|
|
|
|
alignment: Alignment.center,
|
|
|
|
child: Text(
|
|
|
|
S.of(context).zanwuyouhuiquankelingqu,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 14.sp,
|
|
|
|
fontWeight: MyFontWeight.semi_bold,
|
|
|
|
color: Color(0xFFA0A0A0),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget buildCoupon() {
|
|
|
|
return Container(
|
|
|
|
height: 116.h,
|
|
|
|
child: ListView.builder(
|
|
|
|
itemCount: (widget.storeInfo != null && widget.storeInfo.couponVOList != null)
|
|
|
|
? widget.storeInfo.couponVOList.length
|
|
|
|
: 0,
|
|
|
|
physics: BouncingScrollPhysics(parent: PageScrollPhysics()),
|
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
itemBuilder: (context, position) {
|
|
|
|
return Container(
|
|
|
|
width: MediaQuery.of(context).size.width * 0.784,
|
|
|
|
margin: EdgeInsets.only(left: 6.w),
|
|
|
|
child: AspectRatio(
|
|
|
|
aspectRatio: 2.86,
|
|
|
|
child: Stack(
|
|
|
|
children: [
|
|
|
|
Image.asset(
|
|
|
|
"assets/image/icon_union_coupons_bg.webp",
|
|
|
|
fit: BoxFit.fill,
|
|
|
|
width: double.infinity,
|
|
|
|
height: double.infinity,
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
left: 24.w,
|
|
|
|
right: 24.w,
|
|
|
|
bottom: 17.h,
|
|
|
|
top: 11.h,
|
|
|
|
),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
margin: EdgeInsets.only(left: 5),
|
|
|
|
child: Text.rich(TextSpan(children: [
|
|
|
|
TextSpan(
|
|
|
|
text: (widget.storeInfo != null &&
|
|
|
|
widget.storeInfo.couponVOList != null &&
|
|
|
|
widget.storeInfo.couponVOList[position]
|
|
|
|
.bizType == 1)
|
|
|
|
? "¥"
|
|
|
|
: "",
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 22.sp,
|
|
|
|
color: Color(0xFFFF7A1A),
|
|
|
|
fontWeight: MyFontWeight.semi_bold,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
TextSpan(
|
|
|
|
text: (widget.storeInfo != null &&
|
|
|
|
widget.storeInfo.couponVOList != null &&
|
|
|
|
widget.storeInfo.couponVOList[position]
|
|
|
|
.bizType ==
|
|
|
|
1)
|
|
|
|
? "${double.tryParse(widget.storeInfo.couponVOList[position].discountAmount).toInt()}"
|
|
|
|
: (widget.storeInfo != null &&
|
|
|
|
widget.storeInfo.couponVOList !=
|
|
|
|
null &&
|
|
|
|
widget
|
|
|
|
.storeInfo
|
|
|
|
.couponVOList[position]
|
|
|
|
.bizType ==
|
|
|
|
5)
|
|
|
|
? S.of(context).duihuanquan
|
|
|
|
: "${widget.storeInfo.couponVOList[position].discountPercent ~/ 10}折",
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 36.sp,
|
|
|
|
color: Color(0xFFFF7A1A),
|
|
|
|
fontWeight: MyFontWeight.semi_bold,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
])),
|
|
|
|
alignment: Alignment.center,
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
margin: EdgeInsets.only(
|
|
|
|
top: 12.h,
|
|
|
|
bottom: 12.h,
|
|
|
|
left: 15.w,
|
|
|
|
right: 24.w,
|
|
|
|
),
|
|
|
|
child: MySeparator(
|
|
|
|
width: 1.w,
|
|
|
|
height: 5.h,
|
|
|
|
color: Color(0xFF979797),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: Container(
|
|
|
|
margin: EdgeInsets.only(
|
|
|
|
bottom: 12.h,
|
|
|
|
top: 12.h,
|
|
|
|
),
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
(widget.storeInfo != null &&
|
|
|
|
widget.storeInfo.couponVOList != null)
|
|
|
|
? widget.storeInfo.couponVOList[position]
|
|
|
|
.couponName
|
|
|
|
: "",
|
|
|
|
maxLines: 1,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 10.sp,
|
|
|
|
fontWeight: MyFontWeight.semi_bold,
|
|
|
|
color: Color(0xFF727272),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
(widget.storeInfo != null &&
|
|
|
|
widget.storeInfo.couponVOList != null)
|
|
|
|
? (widget.storeInfo.couponVOList[position]
|
|
|
|
.bizType ==
|
|
|
|
1
|
|
|
|
? S.of(context).manlijiandaijinquan(
|
|
|
|
double.tryParse(widget
|
|
|
|
.storeInfo
|
|
|
|
.couponVOList[position]
|
|
|
|
.fullAmount)
|
|
|
|
.toInt(),
|
|
|
|
double.tryParse(widget
|
|
|
|
.storeInfo
|
|
|
|
.couponVOList[position]
|
|
|
|
.discountAmount)
|
|
|
|
.toInt())
|
|
|
|
: S.of(context).quanchangzhe(widget
|
|
|
|
.storeInfo
|
|
|
|
.couponVOList[position]
|
|
|
|
.discountPercent /10.0))
|
|
|
|
: "",
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12.sp,
|
|
|
|
fontWeight: MyFontWeight.semi_bold,
|
|
|
|
color: Color(0xFFFF7A1A),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
S.of(context).youxiaoqizhi(
|
|
|
|
(widget.storeInfo != null &&
|
|
|
|
widget.storeInfo.couponVOList !=
|
|
|
|
null &&
|
|
|
|
// widget.storeInfo.couponVOList[position].useStartTime != null &&
|
|
|
|
widget
|
|
|
|
.storeInfo
|
|
|
|
.couponVOList[position]
|
|
|
|
.useEndTime !=
|
|
|
|
null)
|
|
|
|
// ? "${widget.storeInfo.couponVOList[position].useStartTime.replaceAll("-", ".").split(" ")[0]}-${widget.storeInfo.couponVOList[position].useEndTime.replaceAll("-", ".").split(" ")[0]}"
|
|
|
|
? "${widget.storeInfo.couponVOList[position].useEndTime.replaceAll("-", ".").split(" ")[0]}"
|
|
|
|
: "",
|
|
|
|
),
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
maxLines: 1,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 8.sp,
|
|
|
|
color: Color(0xFFA29E9E),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
InkWell(
|
|
|
|
onTap: () {
|
|
|
|
if (widget.storeInfo != null &&
|
|
|
|
widget.storeInfo.couponVOList != null &&
|
|
|
|
widget.storeInfo.couponVOList[position]
|
|
|
|
.status ==
|
|
|
|
0) {
|
|
|
|
widget.receiveCoupon(
|
|
|
|
widget.storeInfo.couponVOList[position].id);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
height: 25.h,
|
|
|
|
child: RoundButton(
|
|
|
|
text: (widget.storeInfo != null &&
|
|
|
|
widget.storeInfo.couponVOList != null &&
|
|
|
|
widget.storeInfo.couponVOList[position]
|
|
|
|
.status >
|
|
|
|
0)
|
|
|
|
? S.of(context).yilingqu
|
|
|
|
: S.of(context).lingqu,
|
|
|
|
textColor: Colors.white,
|
|
|
|
backgroup: (widget.storeInfo != null &&
|
|
|
|
widget.storeInfo.couponVOList != null &&
|
|
|
|
widget.storeInfo.couponVOList[position]
|
|
|
|
.status >
|
|
|
|
0)
|
|
|
|
? Colors.grey
|
|
|
|
: Color(0xFF32A060),
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
horizontal: 8.w, vertical:2.h),
|
|
|
|
fontSize: 12.sp,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|