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.
623 lines
21 KiB
623 lines
21 KiB
import 'dart:io'; |
|
|
|
import 'package:dio/dio.dart'; |
|
import 'package:flutter/material.dart'; |
|
import 'package:flutter/services.dart'; |
|
import 'package:flutter_easyloading/flutter_easyloading.dart'; |
|
import 'package:flutter_html/flutter_html.dart'; |
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; |
|
import 'package:fluwx/fluwx.dart'; |
|
import 'package:huixiang/generated/l10n.dart'; |
|
import 'package:huixiang/home/points_mall_view/points_goods_view.dart'; |
|
import 'package:huixiang/retrofit/data/base_data.dart'; |
|
import 'package:huixiang/retrofit/data/goods.dart'; |
|
import 'package:huixiang/retrofit/data/page.dart'; |
|
import 'package:huixiang/retrofit/data/recharge_list.dart'; |
|
import 'package:huixiang/retrofit/data/user_info.dart'; |
|
import 'package:huixiang/retrofit/data/vip_benefit_list.dart'; |
|
import 'package:huixiang/retrofit/data/vip_rule_details.dart'; |
|
import 'package:huixiang/retrofit/data/wx_pay.dart'; |
|
import 'package:huixiang/retrofit/retrofit_api.dart'; |
|
import 'package:huixiang/utils/flutter_utils.dart'; |
|
import 'package:huixiang/utils/font_weight.dart'; |
|
import 'package:huixiang/utils/min.dart'; |
|
import 'package:huixiang/view_widget/classic_header.dart'; |
|
import 'package:huixiang/view_widget/custom_image.dart'; |
|
import 'package:huixiang/view_widget/item_input_widget.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:huixiang/view_widget/round_button.dart'; |
|
import 'package:pull_to_refresh/pull_to_refresh.dart'; |
|
import 'package:shared_preferences/shared_preferences.dart'; |
|
|
|
class MineGreenery extends StatefulWidget { |
|
@override |
|
State<StatefulWidget> createState() { |
|
return _MineGreenery(); |
|
} |
|
} |
|
|
|
class _MineGreenery extends State<MineGreenery> { |
|
ApiService apiService; |
|
final RefreshController refreshController = RefreshController(); |
|
final ScrollController scrollController = ScrollController(); |
|
int pageNum = 1; |
|
String categoryId; |
|
bool orderDesc = true; |
|
int orderType = 1; |
|
List<Goods> goods = []; |
|
|
|
@override |
|
void initState() { |
|
super.initState(); |
|
|
|
SharedPreferences.getInstance().then((value) => { |
|
apiService = ApiService(Dio(), context: context, token: value.getString("token")), |
|
pointGoodsList(), |
|
}); |
|
} |
|
|
|
pointGoodsList() async { |
|
var param = { |
|
"categoryId": categoryId ?? "", |
|
"orderDesc": orderDesc, |
|
"orderType": orderType, |
|
"pageNum": pageNum, |
|
"pageSize": 10, |
|
"state": 1 |
|
}; |
|
BaseData<PageInfo<Goods>> pageGoods = |
|
await apiService.creditGoods(param).catchError((onError) { |
|
refreshController.loadFailed(); |
|
refreshController.refreshFailed(); |
|
}); |
|
EasyLoading.dismiss(); |
|
if (pageGoods != null && pageGoods.isSuccess) { |
|
setState(() { |
|
if (pageNum == 1) { |
|
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(); |
|
} |
|
} |
|
|
|
@override |
|
Widget build(BuildContext context) { |
|
return Container( |
|
// color: Color(0xFF32A060), |
|
child: SmartRefresher( |
|
controller: refreshController, |
|
enablePullDown: true, |
|
enablePullUp: false, |
|
header: MyHeader(), |
|
footer: CustomFooter( |
|
builder: (context, mode) { |
|
return MyFooter(mode); |
|
}, |
|
), |
|
onRefresh: () { |
|
setState(() { |
|
pointGoodsList(); |
|
}); |
|
}, |
|
physics: BouncingScrollPhysics(), |
|
scrollController: scrollController, |
|
child: Container(color: Color(0xFF32A060), |
|
child: Stack( |
|
children: [ |
|
Container( |
|
width: double.infinity, |
|
height: 340.h, |
|
decoration: BoxDecoration( |
|
image: DecorationImage( |
|
fit: BoxFit.cover, |
|
image: AssetImage("assets/image/s_bg.webp"), |
|
), |
|
), |
|
padding: EdgeInsets.only( |
|
top: 23.h + MediaQuery.of(context).padding.top, |
|
left: 14.w,right: 14.w), |
|
child: |
|
Column( |
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
children: [ |
|
Spacer(), |
|
Container( |
|
alignment: Alignment.bottomCenter, |
|
child:Column( |
|
children: [ |
|
Image.asset( |
|
"assets/image/shu3.webp", |
|
width: 225, |
|
height: 225, |
|
), |
|
Text( |
|
"已获得2片绿叶", |
|
style: TextStyle( |
|
fontSize: 14.sp, |
|
fontWeight: MyFontWeight.regular, |
|
color: Color(0xFFFFFFFF), |
|
), |
|
), |
|
], |
|
) |
|
), |
|
], |
|
), |
|
), |
|
Container( |
|
child: SingleChildScrollView( |
|
physics: BouncingScrollPhysics(), |
|
child: Column( |
|
mainAxisAlignment: MainAxisAlignment.start, |
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
children: [ |
|
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: [ |
|
GestureDetector( |
|
onTap: (){ |
|
Navigator.of(context).pop(); |
|
}, |
|
child: Row( |
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
children: [ |
|
Icon( |
|
Icons.arrow_back_ios, |
|
size: 24, |
|
), |
|
Spacer(), |
|
Text( |
|
"我的绿叶", |
|
style: TextStyle( |
|
fontSize: 17.sp, |
|
fontWeight: MyFontWeight.regular, |
|
color: Color(0xFF0D0D0D), |
|
), |
|
), |
|
Spacer() |
|
], |
|
), |
|
), |
|
goodsRecommendList(), |
|
spreadImage(), |
|
billDetailed(), |
|
], |
|
), |
|
), |
|
], |
|
), |
|
), |
|
) |
|
], |
|
), |
|
), |
|
), |
|
); |
|
} |
|
|
|
|
|
///大家都在买 |
|
Widget goodsRecommendList() { |
|
return Container( |
|
child: Stack( |
|
children: [ |
|
Container( |
|
width: double.infinity, |
|
height: 497.h, |
|
margin: EdgeInsets.only(top:310.h), |
|
decoration: BoxDecoration( |
|
color: Colors.white, |
|
borderRadius: BorderRadius.all(Radius.circular(6)), |
|
), |
|
padding: EdgeInsets.only(top:16.h), |
|
child: Column( |
|
mainAxisAlignment: MainAxisAlignment.start, |
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
children: [ |
|
Expanded(child: |
|
GridView.builder( |
|
itemCount:goods == null ? 0 :goods.length, |
|
padding: EdgeInsets.only( |
|
left: 16.w, |
|
right: 16.w, |
|
top: 18.h, |
|
bottom: 16.h, |
|
), |
|
shrinkWrap: true, |
|
physics: BouncingScrollPhysics(), |
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( |
|
//一行的Widget数量 |
|
crossAxisCount: 2, |
|
//水平子Widget之间间距 |
|
crossAxisSpacing: 11.w, |
|
//垂直子Widget之间间距 |
|
mainAxisSpacing: 16.w, |
|
//子Widget宽高比例 0.59 |
|
childAspectRatio: |
|
200 / (281 / 2 + (281 / 2) * AppUtils.textScale(context)), |
|
), |
|
itemBuilder: (context, index) { |
|
return GestureDetector( |
|
onTap: () { |
|
|
|
}, |
|
child: buildItem(goods[index]), |
|
); |
|
}, |
|
)), |
|
], |
|
), |
|
), |
|
Container( |
|
margin: EdgeInsets.only(top:295.h), |
|
child: |
|
Row( |
|
mainAxisAlignment: MainAxisAlignment.center, |
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
children: [ |
|
Image.asset( |
|
"assets/image/yz_l.webp", |
|
fit: BoxFit.fill, |
|
height: 20, |
|
width: 21, |
|
), |
|
Container( |
|
width: 100.w, |
|
height: 34.h, |
|
alignment: Alignment.center, |
|
decoration: BoxDecoration( |
|
borderRadius: BorderRadius.all(Radius.circular(8)), |
|
gradient: new LinearGradient( |
|
begin: Alignment.centerRight, |
|
end: Alignment.centerLeft, |
|
colors: [ |
|
Color(0xFF32A060), |
|
Color(0xFF9DF531), |
|
]), |
|
), |
|
child: Text( |
|
"大家都在买", |
|
style: TextStyle( |
|
fontSize: 15.sp, |
|
fontWeight: MyFontWeight.semi_bold, |
|
color: Color(0xFFFFFFFF), |
|
), |
|
), |
|
), |
|
Image.asset( |
|
"assets/image/yz_r.webp", |
|
fit: BoxFit.fill, |
|
height: 20, |
|
width: 21, |
|
), |
|
], |
|
), |
|
), |
|
], |
|
), |
|
); |
|
} |
|
|
|
Widget buildItem(Goods goods) { |
|
return Container( |
|
alignment: Alignment.center, |
|
decoration: BoxDecoration( |
|
borderRadius: BorderRadius.circular(4), |
|
boxShadow: [ |
|
BoxShadow( |
|
color: Colors.black.withAlpha(12), |
|
offset: Offset(0, 3), |
|
blurRadius: 14, |
|
spreadRadius: 0, |
|
) |
|
], |
|
// color: Colors.white, |
|
), |
|
child: Stack( |
|
alignment: AlignmentDirectional.topEnd, |
|
fit: StackFit.loose, |
|
children: [ |
|
Column( |
|
mainAxisAlignment: MainAxisAlignment.start, |
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
mainAxisSize: MainAxisSize.max, |
|
children: [ |
|
MImage( |
|
goods.mainImgPath, |
|
aspectRatio: 1.1, |
|
fit: BoxFit.cover, |
|
radius: BorderRadius.only( |
|
topLeft: Radius.circular(4), |
|
topRight: Radius.circular(4), |
|
), |
|
errorSrc: "assets/image/default_1.webp", |
|
fadeSrc: "assets/image/default_1.webp", |
|
), |
|
Expanded( |
|
child: Container( |
|
margin: EdgeInsets.only( |
|
right: 12.w, |
|
top: 10.h, |
|
),padding: EdgeInsets.only( |
|
bottom: 8 |
|
), |
|
child: Column( |
|
mainAxisAlignment: MainAxisAlignment.spaceAround, |
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
children: [ |
|
Text( |
|
goods.name, |
|
overflow: TextOverflow.ellipsis, |
|
maxLines: 2, |
|
style: TextStyle( |
|
color: Color(0xFF0D0D0D), |
|
fontWeight: MyFontWeight.regular, |
|
fontSize: 13.sp, |
|
), |
|
), |
|
Spacer(), |
|
Expanded(child:Row( |
|
mainAxisAlignment: MainAxisAlignment.center, |
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
children: [ |
|
Text( |
|
(goods?.price == null || goods.price == "0"?"":S.of(context).jifen_(goods.price)) + (goods?.money == null|| goods.money == "0.00" ?"":" + ${goods.money}元"), |
|
style: TextStyle( |
|
color: Color(0xFFE5600D), |
|
fontSize: 16.sp, |
|
fontWeight: MyFontWeight.semi_bold, |
|
), |
|
), |
|
Text( |
|
"+", |
|
style: TextStyle( |
|
color: Color(0xFFE5600D), |
|
fontSize: 16.sp, |
|
fontWeight: MyFontWeight.semi_bold, |
|
), |
|
), |
|
Image.asset( |
|
"assets/image/green_leaf.webp", |
|
fit: BoxFit.cover, |
|
width: 12, |
|
height: 12, |
|
), |
|
Text( |
|
"+x100", |
|
overflow: TextOverflow.ellipsis, |
|
maxLines: 2, |
|
style: TextStyle( |
|
color: Color(0xFF32A060), |
|
fontWeight: MyFontWeight.semi_bold, |
|
fontSize: 16.sp, |
|
), |
|
), |
|
], |
|
)), |
|
], |
|
), |
|
), |
|
flex: 1, |
|
), |
|
], |
|
), |
|
], |
|
), |
|
); |
|
} |
|
|
|
///推广图 |
|
Widget spreadImage() { |
|
return Container( |
|
margin: EdgeInsets.symmetric(vertical: 24.h), |
|
child: GestureDetector( |
|
onTap: (){ |
|
Navigator.of(context).pushNamed('/router/invite_friends'); |
|
}, |
|
child:ClipRRect( |
|
child:Image.asset( |
|
"assets/image/welfare_spread.webp", |
|
width:double.infinity, |
|
fit: BoxFit.fill, |
|
height:80.h, |
|
), |
|
borderRadius: BorderRadius.circular(6), |
|
), |
|
), |
|
); |
|
} |
|
|
|
///收支明细 |
|
Widget billDetailed() { |
|
return Container( |
|
child: Stack( |
|
children: [ |
|
Container( |
|
width: double.infinity, |
|
height: 260.h, |
|
decoration: BoxDecoration( |
|
color: Colors.white, |
|
borderRadius: BorderRadius.all(Radius.circular(6)), |
|
), |
|
padding: EdgeInsets.only(top:16.h), |
|
margin: EdgeInsets.only(bottom: 34.h,top: 16), |
|
child: Column( |
|
mainAxisAlignment: MainAxisAlignment.start, |
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
children: [ |
|
Expanded(child: |
|
ListView.builder( |
|
padding: EdgeInsets.zero, |
|
itemCount:6, |
|
scrollDirection: Axis.vertical, |
|
shrinkWrap: true, |
|
physics: BouncingScrollPhysics(), |
|
itemBuilder: (context, position) { |
|
return GestureDetector( |
|
onTap: () { |
|
}, |
|
child: billDetailedItem(), |
|
); |
|
}, |
|
),) |
|
], |
|
), |
|
), |
|
Container( |
|
child: |
|
Row( |
|
mainAxisAlignment: MainAxisAlignment.center, |
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
children: [ |
|
Image.asset( |
|
"assets/image/yz_l.webp", |
|
fit: BoxFit.fill, |
|
height: 20, |
|
width: 21, |
|
), |
|
Container( |
|
width: 100.w, |
|
height: 34.h, |
|
alignment: Alignment.center, |
|
decoration: BoxDecoration( |
|
borderRadius: BorderRadius.all(Radius.circular(8)), |
|
gradient: new LinearGradient( |
|
begin: Alignment.centerRight, |
|
end: Alignment.centerLeft, |
|
colors: [ |
|
Color(0xFF32A060), |
|
Color(0xFF9DF531), |
|
]), |
|
), |
|
child: Text( |
|
"绿叶收支明细", |
|
style: TextStyle( |
|
fontSize: 15.sp, |
|
fontWeight: MyFontWeight.semi_bold, |
|
color: Color(0xFFFFFFFF), |
|
), |
|
), |
|
), |
|
Image.asset( |
|
"assets/image/yz_r.webp", |
|
fit: BoxFit.fill, |
|
height: 20, |
|
width: 21, |
|
), |
|
], |
|
), |
|
), |
|
], |
|
), |
|
); |
|
} |
|
|
|
///收支明细 |
|
Widget billDetailedItem() { |
|
return Container( |
|
width: double.infinity, |
|
margin: EdgeInsets.only(top: 16.h), |
|
padding: EdgeInsets.symmetric(horizontal: 14.w), |
|
child: Column( |
|
mainAxisAlignment: MainAxisAlignment.start, |
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
children: [ |
|
Row( |
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
children: [ |
|
Column( |
|
mainAxisAlignment: MainAxisAlignment.start, |
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
children: [ |
|
Row( |
|
children: [ |
|
Text( |
|
"购物得绿叶", |
|
overflow: TextOverflow.ellipsis, |
|
maxLines: 1, |
|
style: TextStyle( |
|
color: Color(0xFF262626), |
|
fontWeight: MyFontWeight.semi_bold, |
|
fontSize: 14.sp, |
|
), |
|
), |
|
SizedBox(width:5.w,), |
|
Text( |
|
"(商品号1234567)", |
|
overflow: TextOverflow.ellipsis, |
|
maxLines: 1, |
|
style: TextStyle( |
|
color: Color(0xFF262626), |
|
fontWeight: MyFontWeight.semi_bold, |
|
fontSize: 14.sp, |
|
), |
|
), |
|
], |
|
), |
|
SizedBox(height: 8.h,), |
|
Text( |
|
"2022-09-09 19:22:23", |
|
overflow: TextOverflow.ellipsis, |
|
maxLines: 1, |
|
style: TextStyle( |
|
color: Color(0xFF262626), |
|
fontWeight: MyFontWeight.regular, |
|
fontSize: 12.sp, |
|
), |
|
), |
|
], |
|
), |
|
Row( |
|
children: [ |
|
Text( |
|
"+12", |
|
style: TextStyle( |
|
color: Color(0xFF32A060), |
|
fontWeight: MyFontWeight.bold, |
|
fontSize: 15.sp, |
|
), |
|
), |
|
Image.asset( |
|
"assets/image/green_leaf.webp", |
|
fit: BoxFit.cover, |
|
width: 14, |
|
height: 14, |
|
), |
|
], |
|
) |
|
], |
|
), |
|
Container( |
|
width: double.infinity, |
|
height: 1.h, |
|
color: Color(0xFFF2F2F2), |
|
margin: EdgeInsets.only(top: 12.h), |
|
) |
|
], |
|
), |
|
); |
|
} |
|
|
|
}
|
|
|