|
|
|
@ -16,8 +16,10 @@ import 'package:huixiang/utils/font_weight.dart';
|
|
|
|
|
import 'package:huixiang/view_widget/classic_header.dart'; |
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
|
import 'package:huixiang/view_widget/custom_image.dart'; |
|
|
|
|
import 'package:huixiang/view_widget/item_title.dart'; |
|
|
|
|
import 'package:huixiang/view_widget/my_appbar.dart'; |
|
|
|
|
import 'package:huixiang/view_widget/my_footer.dart'; |
|
|
|
|
import 'package:huixiang/view_widget/my_tab.dart'; |
|
|
|
|
import 'package:huixiang/view_widget/no_data_view.dart'; |
|
|
|
|
import 'package:pull_to_refresh/pull_to_refresh.dart'; |
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart'; |
|
|
|
@ -34,8 +36,10 @@ class _WelfareExchange extends State<WelfareExchange> {
|
|
|
|
|
final ScrollController scrollController = ScrollController(); |
|
|
|
|
final RefreshController refreshController = RefreshController(); |
|
|
|
|
int pageNum = 1; |
|
|
|
|
|
|
|
|
|
//排序类型枚举:1-自然排序,2-销量,3-价格 |
|
|
|
|
int orderType = 1; |
|
|
|
|
|
|
|
|
|
//是否降序排列 |
|
|
|
|
bool orderDesc = true; |
|
|
|
|
List<Goods> goods = []; |
|
|
|
@ -43,6 +47,12 @@ class _WelfareExchange extends State<WelfareExchange> {
|
|
|
|
|
List<GoodsCategory> gooodsCategorys = []; |
|
|
|
|
UserInfo userInfo; |
|
|
|
|
String categoryId; |
|
|
|
|
var _itemText = S.current.morenpaixu; |
|
|
|
|
List<String> sortString = [ |
|
|
|
|
S.current.morenpaixu, |
|
|
|
|
S.current.jifengaodaodi, |
|
|
|
|
S.current.jifendidaogao, |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
void dispose() { |
|
|
|
@ -65,6 +75,7 @@ class _WelfareExchange extends State<WelfareExchange> {
|
|
|
|
|
await apiService.queryInfo().catchError((onError) {}); |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
userInfo = baseData.data; |
|
|
|
|
setState(() {}); |
|
|
|
|
SharedPreferences.getInstance().then((value) => { |
|
|
|
|
value.setString('user', jsonEncode(baseData.data)), |
|
|
|
|
}); |
|
|
|
@ -147,6 +158,7 @@ class _WelfareExchange extends State<WelfareExchange> {
|
|
|
|
|
refreshController.loadFailed(); |
|
|
|
|
refreshController.refreshFailed(); |
|
|
|
|
} |
|
|
|
|
setState(() {}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_onRefresh() { |
|
|
|
@ -155,9 +167,38 @@ class _WelfareExchange extends State<WelfareExchange> {
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
Widget build(BuildContext context) { |
|
|
|
|
return Container( |
|
|
|
|
color: Color(0xFFF7F7F7), |
|
|
|
|
child: Stack( |
|
|
|
|
return Scaffold( |
|
|
|
|
backgroundColor: Colors.transparent, |
|
|
|
|
body: NestedScrollView( |
|
|
|
|
headerSliverBuilder: (context, inner) { |
|
|
|
|
return [ |
|
|
|
|
SliverAppBar( |
|
|
|
|
pinned: true, |
|
|
|
|
backgroundColor: Colors.white, |
|
|
|
|
elevation: 0, |
|
|
|
|
title: Text( |
|
|
|
|
"福利兑换", |
|
|
|
|
style: |
|
|
|
|
TextStyle(fontWeight: FontWeight.w500, color: Colors.white), |
|
|
|
|
), |
|
|
|
|
centerTitle: true, |
|
|
|
|
leading: GestureDetector( |
|
|
|
|
onTap: () { |
|
|
|
|
Navigator.of(context).pop(); |
|
|
|
|
}, |
|
|
|
|
child: Container( |
|
|
|
|
alignment: Alignment.centerRight, |
|
|
|
|
margin: EdgeInsets.only(left: 10), |
|
|
|
|
padding: EdgeInsets.all(6), |
|
|
|
|
child: Icon( |
|
|
|
|
Icons.arrow_back_ios, |
|
|
|
|
color: Colors.white, |
|
|
|
|
size: 24, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
flexibleSpace: FlexibleSpaceBar( |
|
|
|
|
background: Stack( |
|
|
|
|
children: [ |
|
|
|
|
Container( |
|
|
|
|
// padding: EdgeInsets.only(top: 40.h), |
|
|
|
@ -171,86 +212,74 @@ class _WelfareExchange extends State<WelfareExchange> {
|
|
|
|
|
bottomLeft: Radius.circular(40), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
// child: ClipPath( |
|
|
|
|
// 只裁切底部的方法 |
|
|
|
|
// clipper: BottonClipper(), |
|
|
|
|
// child: Container( |
|
|
|
|
// color: Colors.deepOrange, |
|
|
|
|
// height: 300, |
|
|
|
|
// ), |
|
|
|
|
// ), |
|
|
|
|
), |
|
|
|
|
Scaffold( |
|
|
|
|
backgroundColor: Colors.transparent, |
|
|
|
|
appBar: MyAppBar( |
|
|
|
|
background: Colors.transparent, |
|
|
|
|
leadingColor: Colors.white, |
|
|
|
|
title: "福利兑换", |
|
|
|
|
titleColor: Colors.white, |
|
|
|
|
titleSize: 18.sp, |
|
|
|
|
brightness: Brightness.dark, |
|
|
|
|
), |
|
|
|
|
body: SmartRefresher( |
|
|
|
|
controller: refreshController, |
|
|
|
|
enablePullDown: true, |
|
|
|
|
enablePullUp: false, |
|
|
|
|
header: MyHeader(), |
|
|
|
|
footer: CustomFooter( |
|
|
|
|
builder: (context, mode) { |
|
|
|
|
return MyFooter(mode); |
|
|
|
|
}, |
|
|
|
|
Container( |
|
|
|
|
alignment: Alignment.topCenter, |
|
|
|
|
margin: EdgeInsets.only(top: 106.h), |
|
|
|
|
child: pointUser(), |
|
|
|
|
), |
|
|
|
|
onRefresh: () { |
|
|
|
|
setState(() { |
|
|
|
|
_onRefresh(); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
physics: BouncingScrollPhysics(), |
|
|
|
|
scrollController: scrollController, |
|
|
|
|
], |
|
|
|
|
)), |
|
|
|
|
expandedHeight: 258.h, |
|
|
|
|
bottom: PreferredSize( |
|
|
|
|
preferredSize: Size(double.infinity, 0), |
|
|
|
|
child: DefaultTabController( |
|
|
|
|
length: gooodsCategorys == null ? 0 : gooodsCategorys.length, |
|
|
|
|
child: Container( |
|
|
|
|
child: SingleChildScrollView( |
|
|
|
|
physics: BouncingScrollPhysics(), |
|
|
|
|
child: FutureBuilder( |
|
|
|
|
future: creditGoods(), |
|
|
|
|
builder: (context, snap) { |
|
|
|
|
return Column( |
|
|
|
|
children: [ |
|
|
|
|
///积分商城的用户信息 |
|
|
|
|
pointUser(), |
|
|
|
|
|
|
|
|
|
Container( |
|
|
|
|
color: Colors.white, |
|
|
|
|
child: Column( |
|
|
|
|
children: [ |
|
|
|
|
///积分商品头Tab |
|
|
|
|
PointsGoodsTitle( |
|
|
|
|
gooodsCategorys, |
|
|
|
|
(orderType, orderDesc) { |
|
|
|
|
this.orderType = orderType; |
|
|
|
|
this.orderDesc = orderDesc; |
|
|
|
|
setState(() {}); |
|
|
|
|
}, |
|
|
|
|
(index) { |
|
|
|
|
child: TabBar( |
|
|
|
|
isScrollable: true, |
|
|
|
|
//可滚动 |
|
|
|
|
indicatorColor: Color(0xff39B54A), |
|
|
|
|
labelColor: Color(0xff32A060), |
|
|
|
|
labelStyle: TextStyle( |
|
|
|
|
fontSize: 14.sp, |
|
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
|
), |
|
|
|
|
unselectedLabelStyle: TextStyle( |
|
|
|
|
fontSize: 14.sp, |
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
|
), |
|
|
|
|
// controller: tabController, |
|
|
|
|
//未选中文字颜色 |
|
|
|
|
unselectedLabelColor: Color(0xff4D4D4D), |
|
|
|
|
indicatorSize: TabBarIndicatorSize.label, |
|
|
|
|
//指示器与文字等宽 |
|
|
|
|
tabs: gooodsCategorys == null |
|
|
|
|
? [] |
|
|
|
|
: gooodsCategorys |
|
|
|
|
.map((e) => MyTab(text: e.name)) |
|
|
|
|
.toList(), |
|
|
|
|
onTap: (index) { |
|
|
|
|
categoryId = gooodsCategorys[index].id; |
|
|
|
|
pageNum = 1; |
|
|
|
|
creditGoods(); |
|
|
|
|
setState(() {}); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
|
|
|
|
|
///积分商品列表, |
|
|
|
|
pointList() |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
) |
|
|
|
|
], |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
]; |
|
|
|
|
}, |
|
|
|
|
body: SmartRefresher( |
|
|
|
|
controller: refreshController, |
|
|
|
|
enablePullDown: true, |
|
|
|
|
enablePullUp: true, |
|
|
|
|
physics: ClampingScrollPhysics(), |
|
|
|
|
header: MyHeader(), |
|
|
|
|
footer: CustomFooter( |
|
|
|
|
builder: (context, mode) { |
|
|
|
|
return MyFooter(mode); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
onRefresh: _onRefresh, |
|
|
|
|
child: Container( |
|
|
|
|
color: Colors.white, |
|
|
|
|
padding: EdgeInsets.only(top: 19.h), |
|
|
|
|
child: pointList(), |
|
|
|
|
)), |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
@ -347,8 +376,9 @@ class _WelfareExchange extends State<WelfareExchange> {
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.end, |
|
|
|
|
children: [ |
|
|
|
|
GestureDetector( |
|
|
|
|
onTap: (){ |
|
|
|
|
Navigator.of(context).pushNamed('/router/integral_detailed_page'); |
|
|
|
|
onTap: () { |
|
|
|
|
Navigator.of(context) |
|
|
|
|
.pushNamed('/router/integral_detailed_page'); |
|
|
|
|
}, |
|
|
|
|
child: Row( |
|
|
|
|
children: [ |
|
|
|
@ -368,7 +398,7 @@ class _WelfareExchange extends State<WelfareExchange> {
|
|
|
|
|
color: Color(0xFF32A060), |
|
|
|
|
borderRadius: BorderRadius.circular(10), |
|
|
|
|
), |
|
|
|
|
child:Icon( |
|
|
|
|
child: Icon( |
|
|
|
|
Icons.keyboard_arrow_right, |
|
|
|
|
size: 20, |
|
|
|
|
color: Colors.white, |
|
|
|
@ -390,7 +420,9 @@ class _WelfareExchange extends State<WelfareExchange> {
|
|
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
SizedBox(width: 6,), |
|
|
|
|
SizedBox( |
|
|
|
|
width: 6, |
|
|
|
|
), |
|
|
|
|
Image.asset( |
|
|
|
|
"assets/image/icon_gold_coin.webp", |
|
|
|
|
width: 18, |
|
|
|
@ -406,16 +438,18 @@ class _WelfareExchange extends State<WelfareExchange> {
|
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Widget pointList(){ |
|
|
|
|
Widget pointList() { |
|
|
|
|
return Container( |
|
|
|
|
child: (goods == null || goods.length == 0)? NoDataView( |
|
|
|
|
child: (goods == null || goods.length == 0) |
|
|
|
|
? NoDataView( |
|
|
|
|
src: "assets/image/xiao_fei.webp", |
|
|
|
|
isShowBtn: false, |
|
|
|
|
text: "当前分类暂无商品", |
|
|
|
|
fontSize: 16.sp, |
|
|
|
|
margin: EdgeInsets.only(top: 120.h,left: 60.w,right: 60.w), |
|
|
|
|
):GridView.builder( |
|
|
|
|
itemCount:goods == null ? 0 : goods.length, |
|
|
|
|
margin: EdgeInsets.only(top: 120.h, left: 60.w, right: 60.w), |
|
|
|
|
) |
|
|
|
|
: GridView.builder( |
|
|
|
|
itemCount: goods == null ? 0 : goods.length, |
|
|
|
|
padding: EdgeInsets.only( |
|
|
|
|
left: 16.w, |
|
|
|
|
right: 16.w, |
|
|
|
@ -433,7 +467,7 @@ class _WelfareExchange extends State<WelfareExchange> {
|
|
|
|
|
mainAxisSpacing: 16.w, |
|
|
|
|
//子Widget宽高比例 0.59 |
|
|
|
|
childAspectRatio: |
|
|
|
|
200 / (285 / 2 + (285 / 2) * AppUtils.textScale(context)), |
|
|
|
|
200 / (266 / 2 + (266 / 2) * AppUtils.textScale(context)), |
|
|
|
|
), |
|
|
|
|
itemBuilder: (context, index) { |
|
|
|
|
return GestureDetector( |
|
|
|
@ -490,10 +524,8 @@ class _WelfareExchange extends State<WelfareExchange> {
|
|
|
|
|
margin: EdgeInsets.only( |
|
|
|
|
right: 12.w, |
|
|
|
|
top: 10.h, |
|
|
|
|
),padding: EdgeInsets.only( |
|
|
|
|
bottom: 8.h, |
|
|
|
|
left: 8.w |
|
|
|
|
), |
|
|
|
|
padding: EdgeInsets.only(bottom: 8.h, left: 8.w), |
|
|
|
|
child: Column( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround, |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
@ -501,7 +533,7 @@ class _WelfareExchange extends State<WelfareExchange> {
|
|
|
|
|
Text( |
|
|
|
|
goods.name, |
|
|
|
|
overflow: TextOverflow.ellipsis, |
|
|
|
|
maxLines: 2, |
|
|
|
|
maxLines: 1, |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Color(0xFF0D0D0D), |
|
|
|
|
height: 1.2, |
|
|
|
@ -532,17 +564,21 @@ class _WelfareExchange extends State<WelfareExchange> {
|
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
String pointPrice(Goods goods){ |
|
|
|
|
if(goods == null) |
|
|
|
|
return ""; |
|
|
|
|
if(goods?.onePrice!=null && goods?.onePrice!="0"){ |
|
|
|
|
String pointPrice(Goods goods) { |
|
|
|
|
if (goods == null) return ""; |
|
|
|
|
if (goods?.onePrice != null && goods?.onePrice != "0") { |
|
|
|
|
return S.of(context).jifen_(goods?.onePrice); |
|
|
|
|
}else if((goods?.onePrice == null || goods?.onePrice == "0") && ((goods?.price != null && goods?.price != "0") || (goods?.money != null && goods?.money != "0.00"))){ |
|
|
|
|
return (goods?.price== "0"|| goods?.price == null ? "" : S.of(context).jifen_(goods?.price)) + (goods?.money== "0"|| goods?.money == null ? "" : " + ${AppUtils.calculateDouble(double.tryParse(goods?.money) ?? 0)}元"); |
|
|
|
|
}else if(goods.oneMoney != null && goods.oneMoney != "0.00"){ |
|
|
|
|
} else if ((goods?.onePrice == null || goods?.onePrice == "0") && |
|
|
|
|
((goods?.price != null && goods?.price != "0") || |
|
|
|
|
(goods?.money != null && goods?.money != "0.00"))) { |
|
|
|
|
return (goods?.price == "0" || goods?.price == null |
|
|
|
|
? "" |
|
|
|
|
: S.of(context).jifen_(goods?.price)) + |
|
|
|
|
(goods?.money == "0" || goods?.money == null |
|
|
|
|
? "" |
|
|
|
|
: " + ${AppUtils.calculateDouble(double.tryParse(goods?.money) ?? 0)}元"); |
|
|
|
|
} else if (goods.oneMoney != null && goods.oneMoney != "0.00") { |
|
|
|
|
return "${AppUtils.calculateDouble(double.tryParse(goods.oneMoney) ?? 0)}元"; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|