You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

566 lines
18 KiB

import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/data/activity.dart';
import 'package:huixiang/retrofit/data/base_data.dart';
import 'package:huixiang/retrofit/data/page.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/view_widget/classic_header.dart';
import 'package:huixiang/view_widget/item_title.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:huixiang/view_widget/my_appbar.dart';
import 'package:huixiang/view_widget/my_footer.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:shared_preferences/shared_preferences.dart';
class WelfarePage extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return _WelfarePage();
}
}
class _WelfarePage extends State<WelfarePage> {
ApiService apiService;
final RefreshController refreshController = RefreshController();
final ScrollController scrollController = ScrollController();
@override
void initState() {
super.initState();
}
@override
// Widget build(BuildContext context) {
// return Stack(
// children: [
// Positioned(
// child: Container(
// height: 155.h + kToolbarHeight + MediaQuery.of(context).padding.top,
// decoration: BoxDecoration(
// image: DecorationImage(
// fit: BoxFit.fill,
// image: AssetImage("assets/image/welfare_zx.webp"),
// ),
// ),
// ),
// top: 0,
// left: 0,
// right: 0,
// ),
// Scaffold(
// backgroundColor: Colors.transparent,
// appBar: MyAppBar(
// exit: (){},
// background: Colors.transparent,
// leadingColor: Colors.white,
// title: "福利中心",
// titleColor: Colors.white,
// titleSize: 17.sp,
// brightness: Brightness.dark,
// ),
// body:SmartRefresher(
// controller: refreshController,
// enablePullDown: true,
// enablePullUp: false,
// header: MyHeader(),
// footer: CustomFooter(
// builder: (context, mode) {
// return MyFooter(mode);
// },
// ),
// onRefresh:(){
// setState(() {
// });
// },
// physics: BouncingScrollPhysics(),
// scrollController: scrollController,
// child: Container(
// child: SingleChildScrollView(
// physics: BouncingScrollPhysics(),
// child: FutureBuilder(
// // future: querySignInfo(),
// builder: (context, snap) {
// return Column(
// children: [
// weekCoupons(),
//
// inviteFriends(),
//
// activityTask(),
// ],
// );
// },
// ),
// ),
// ),
// ),
// ),
// ],
// );
// }
Widget build(BuildContext context) {
return Container(
color: Colors.white,
child: Scaffold(
body: SmartRefresher(
controller: refreshController,
enablePullDown: true,
enablePullUp: false,
header: MyHeader(),
footer: CustomFooter(
builder: (context, mode) {
return MyFooter(mode);
},
),
onRefresh: () {},
physics: BouncingScrollPhysics(),
scrollController: scrollController,
child: Container(
child: SingleChildScrollView(
physics: BouncingScrollPhysics(),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Stack(
children: [
Container(
decoration: BoxDecoration(
image: DecorationImage(
fit: BoxFit.fill,
image: AssetImage("assets/image/welfare_zx.webp"),
),
),
width: double.infinity,
height: 385.h,
),
Container(
width: double.infinity,
margin: EdgeInsets.only(
top: 23.h + MediaQuery.of(context).padding.top,
left: 14.w,right: 14.w),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
Navigator.of(context).pop();
},
child: Container(
// color: Colors.white,
alignment: Alignment.centerLeft,
child: Icon(
Icons.arrow_back_ios,
color: Colors.white,
size: 22,
),
),
),
),
Expanded(
child: Container(
alignment: Alignment.center,
child: Text(
"福利中心",
style: TextStyle(
color: Colors.white,
fontSize: 18.sp,
fontWeight: MyFontWeight.regular,
),
)),
),
Spacer(),
],
),
weekCoupons(),
inviteFriends(),
activityTask(),
],
),
),
],
)
],
),
),
),
),
),
);
}
/// 周券包推荐
Widget weekCoupons() {
return Container(
width: double.infinity,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(6),
color: Colors.white,
),
margin: EdgeInsets.only(top: 126.h),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.symmetric(horizontal: 12.w,vertical: 16.h),
child:
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
"本周劵包 ",
style: TextStyle(
color: Color(0xFF0D0D0D),
fontSize: 15.sp,
fontWeight: MyFontWeight.bold,
),
),
Text(
"每周五上新 ",
style: TextStyle(
color: Color(0xFF4D4D4D),
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
),
),
],
)),
AspectRatio(
aspectRatio: 1.22,
child: Swiper(
viewportFraction: 0.9,
scale: 0.7,
pagination: SwiperPagination(
alignment: Alignment.bottomCenter,
builder: DotSwiperPaginationBuilder(
size: 8,
activeSize: 8,
space: 5,
activeColor: Colors.black,
color: Colors.black.withAlpha(76),
),
),
physics: BouncingScrollPhysics(),
itemBuilder: (context, position) {
return Column(
children: [
Container(
// height: 84.h,
// child: ListView.builder(
// scrollDirection: Axis.horizontal,
// physics: BouncingScrollPhysics(),
// padding: EdgeInsets.symmetric(horizontal: 12),
// itemCount:3,
// itemBuilder: (context, index) {
// return GestureDetector(
// onTap: () {
//
// },
// child: weekItem(),
// );
// },
// ),
child: weekItem(),
),
],
);
},
itemCount:3,
),
)
],
),
);
}
Widget weekItem() {
return Container(
width:double.infinity,
height:95.h,
decoration: BoxDecoration(
image: DecorationImage(
fit: BoxFit.fill,
image: AssetImage("assets/image/week_coupons.png"),
),
),
padding: EdgeInsets.symmetric(horizontal: 12.w,vertical: 12.h),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text.rich(
TextSpan(
children: [
TextSpan(
text: "¥",
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.semi_bold,
color: Color(0xFFFF4500),
),
),
TextSpan(
text: "30",
style: TextStyle(
fontSize: 26.sp,
fontWeight: MyFontWeight.semi_bold,
color: Color(0xFFFF4500),
),
),
],
),
),
Text(
"满30.1可用",
style: TextStyle(
fontSize: 14.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xFFFF4500),
),
),
],
),
SizedBox(width: 30,),
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"百年川椒(哈乐城店)",
style: TextStyle(
fontSize: 14.sp,
fontWeight: MyFontWeight.bold,
color: Color(0xFF0D0D0D),
),
),
SizedBox(height: 10,),
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),
),
),
],
),
Expanded(child:
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(12),
),
alignment: Alignment.center,
child:Text(
"领取",
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xFFFFFFFF),
),
),
))
],
),
);
}
///邀请好友
Widget inviteFriends() {
return Container(
margin: EdgeInsets.only(right:14.w,top:34.h,bottom:20.h),
child:Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"邀请好友",
style: TextStyle(
fontSize: 15.sp,
fontWeight: MyFontWeight.bold,
color: Color(0xFF0D0D0D),
),
),
SizedBox(height: 12,),
GestureDetector(
onTap: (){
Navigator.of(context).pushNamed('/router/invite_friends');
},
child:ClipRRect(
child:Image.asset(
"assets/image/icon_story_td.webp",
width:double.infinity,
fit: BoxFit.cover,
height:80.h,
),
borderRadius: BorderRadius.circular(6.w),
),
),
],
),
);
}
///活动任务
Widget activityTask() {
return Container(
margin: EdgeInsets.only(right:14.w,bottom:20.h,),
child:Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"活动任务",
style: TextStyle(
fontSize: 15.sp,
fontWeight: MyFontWeight.bold,
color: Color(0xFF0D0D0D),
),
),
Text(
"已完成0/3",
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xFF4D4D4D),
),
),
],
),
SizedBox(height: 12,),
ListView.builder(
padding: EdgeInsets.zero,
itemCount:6,
scrollDirection: Axis.vertical,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemBuilder: (context, position) {
return GestureDetector(
onTap: () {
},
child: taskItem(),
);
},
),
],
),
);
}
Widget taskItem() {
return Container(
width:double.infinity,
height:95.h,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(6),
color: Colors.white,
),
padding: EdgeInsets.symmetric(horizontal: 12.w,vertical: 12.h),
margin: EdgeInsets.only(bottom: 10.h),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Expanded(child:Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"海峡姐妹茶新品尝鲜(0/3)",
style: TextStyle(
fontSize: 14.sp,
fontWeight: MyFontWeight.bold,
color: Color(0xFF353535),
),
),
Text(
"可获得¥10代金券",
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xFF4D4D4D),
),
), Text(
"购买任意3杯新品",
style: TextStyle(
fontSize: 10.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xFFB3B3B3),
),
),
],
),),
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(12),
),
alignment: Alignment.center,
child:Text(
"领取",
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xFFFFFFFF),
),
),
)
],
),
);
}
}