|
|
@ -26,7 +26,9 @@ import 'package:shared_preferences/shared_preferences.dart'; |
|
|
|
|
|
|
|
|
|
|
|
class HomePage extends StatefulWidget { |
|
|
|
class HomePage extends StatefulWidget { |
|
|
|
final GestureTapCallback callback; |
|
|
|
final GestureTapCallback callback; |
|
|
|
|
|
|
|
|
|
|
|
HomePage(this.callback); |
|
|
|
HomePage(this.callback); |
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@override |
|
|
|
State<StatefulWidget> createState() { |
|
|
|
State<StatefulWidget> createState() { |
|
|
|
return _HomePage(callback); |
|
|
|
return _HomePage(callback); |
|
|
@ -36,6 +38,7 @@ class HomePage extends StatefulWidget { |
|
|
|
class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin { |
|
|
|
class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin { |
|
|
|
ApiService apiService; |
|
|
|
ApiService apiService; |
|
|
|
final GestureTapCallback callback; |
|
|
|
final GestureTapCallback callback; |
|
|
|
|
|
|
|
|
|
|
|
_HomePage(this.callback); |
|
|
|
_HomePage(this.callback); |
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@override |
|
|
@ -43,12 +46,12 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin { |
|
|
|
super.initState(); |
|
|
|
super.initState(); |
|
|
|
|
|
|
|
|
|
|
|
SharedPreferences.getInstance().then((value) => { |
|
|
|
SharedPreferences.getInstance().then((value) => { |
|
|
|
apiService = ApiService(Dio(), |
|
|
|
apiService = ApiService(Dio(), |
|
|
|
context: context, |
|
|
|
context: context, |
|
|
|
token: value.getString('token'), |
|
|
|
token: value.getString('token'), |
|
|
|
showLoading: false), |
|
|
|
showLoading: false), |
|
|
|
queryHome(), |
|
|
|
queryHome(), |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
eventBus.on<EventType>().listen((event) { |
|
|
|
eventBus.on<EventType>().listen((event) { |
|
|
|
if (event.type < 3) { |
|
|
|
if (event.type < 3) { |
|
|
@ -219,46 +222,54 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin { |
|
|
|
), |
|
|
|
), |
|
|
|
brands(), |
|
|
|
brands(), |
|
|
|
Container( |
|
|
|
Container( |
|
|
|
margin: EdgeInsets.only(left:16.5,right: 16.5,bottom: 40), |
|
|
|
margin: EdgeInsets.only(left: 16.5.w, right: 16.5.w, bottom: 40.h), |
|
|
|
padding: EdgeInsets.only(bottom: 10), |
|
|
|
padding: EdgeInsets.only(bottom: 10.h), |
|
|
|
decoration: BoxDecoration( |
|
|
|
decoration: BoxDecoration( |
|
|
|
borderRadius: BorderRadius.all( |
|
|
|
borderRadius: BorderRadius.all( |
|
|
|
Radius.circular(4), |
|
|
|
Radius.circular(4), |
|
|
|
), |
|
|
|
), |
|
|
|
boxShadow: [ |
|
|
|
boxShadow: [ |
|
|
|
BoxShadow( |
|
|
|
BoxShadow( |
|
|
|
color: Colors.black.withAlpha(12), |
|
|
|
color: Colors.black.withAlpha(12), |
|
|
|
offset: Offset(0, 3), |
|
|
|
offset: Offset(0, 3), |
|
|
|
blurRadius: 14, |
|
|
|
blurRadius: 14, |
|
|
|
spreadRadius: 0, |
|
|
|
spreadRadius: 0, |
|
|
|
) |
|
|
|
) |
|
|
|
], |
|
|
|
], |
|
|
|
color: Colors.white), |
|
|
|
color: Colors.white, |
|
|
|
|
|
|
|
), |
|
|
|
child: Column( |
|
|
|
child: Column( |
|
|
|
children: [ |
|
|
|
children: [ |
|
|
|
Row( |
|
|
|
Row( |
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
|
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
|
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
|
|
children: [ |
|
|
|
children: [ |
|
|
|
Expanded(flex: 1,child:ItemTitle( |
|
|
|
Expanded( |
|
|
|
text: S.of(context).jifenshangcheng, |
|
|
|
flex: 1, |
|
|
|
imgPath: "assets/image/icon_points_mall.png", |
|
|
|
child: ItemTitle( |
|
|
|
)), |
|
|
|
text: S.of(context).jifenshangcheng, |
|
|
|
|
|
|
|
imgPath: "assets/image/icon_points_mall.png", |
|
|
|
|
|
|
|
)), |
|
|
|
GestureDetector( |
|
|
|
GestureDetector( |
|
|
|
onTap: callback, |
|
|
|
onTap: callback, |
|
|
|
child:Container( |
|
|
|
child: Container( |
|
|
|
padding: EdgeInsets.only(left:8,right: 8,top:3,bottom: 3), |
|
|
|
padding: EdgeInsets.only( |
|
|
|
margin:EdgeInsets.only(right: 16), |
|
|
|
left: 8.w, right: 8.w, top: 3.h, bottom: 3.h), |
|
|
|
|
|
|
|
margin: EdgeInsets.only(right: 16.w), |
|
|
|
decoration: BoxDecoration( |
|
|
|
decoration: BoxDecoration( |
|
|
|
borderRadius: BorderRadius.all( |
|
|
|
borderRadius: BorderRadius.circular(11.5), |
|
|
|
Radius.circular(11.5), |
|
|
|
color: Color(0xFF32A060), |
|
|
|
), |
|
|
|
), |
|
|
|
color: Color(0xFF32A060)), |
|
|
|
|
|
|
|
child: Row( |
|
|
|
child: Row( |
|
|
|
children: [ |
|
|
|
children: [ |
|
|
|
Text("GO",style: TextStyle( |
|
|
|
Text( |
|
|
|
fontSize: 14,fontWeight: FontWeight.bold,color: Colors.white |
|
|
|
"GO", |
|
|
|
),), |
|
|
|
style: TextStyle( |
|
|
|
|
|
|
|
fontSize: 14.sp, |
|
|
|
|
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
|
|
|
|
color: Colors.white, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
), |
|
|
|
Icon( |
|
|
|
Icon( |
|
|
|
Icons.chevron_right, |
|
|
|
Icons.chevron_right, |
|
|
|
color: Colors.white, |
|
|
|
color: Colors.white, |
|
|
@ -272,14 +283,13 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin { |
|
|
|
), |
|
|
|
), |
|
|
|
Divider( |
|
|
|
Divider( |
|
|
|
// indent: 0.0, |
|
|
|
// indent: 0.0, |
|
|
|
thickness:1, |
|
|
|
thickness: 1, |
|
|
|
color: Color(0xffF2F2F2), |
|
|
|
color: Color(0xffF2F2F2), |
|
|
|
), |
|
|
|
), |
|
|
|
points(), |
|
|
|
integralStore(), |
|
|
|
], |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
|
|
|
|
|
|
|
|
// integralStore(), |
|
|
|
// integralStore(), |
|
|
|
], |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
@ -288,7 +298,6 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin { |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Widget hotList() { |
|
|
|
Widget hotList() { |
|
|
|
return AspectRatio( |
|
|
|
return AspectRatio( |
|
|
|
aspectRatio: 2.47, |
|
|
|
aspectRatio: 2.47, |
|
|
@ -358,8 +367,7 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin { |
|
|
|
textBaseline: TextBaseline.alphabetic, |
|
|
|
textBaseline: TextBaseline.alphabetic, |
|
|
|
children: [ |
|
|
|
children: [ |
|
|
|
Expanded( |
|
|
|
Expanded( |
|
|
|
child: |
|
|
|
child: Row( |
|
|
|
Row( |
|
|
|
|
|
|
|
children: [ |
|
|
|
children: [ |
|
|
|
Text( |
|
|
|
Text( |
|
|
|
"创始人的故事-", |
|
|
|
"创始人的故事-", |
|
|
@ -407,32 +415,11 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin { |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Widget points() { |
|
|
|
// Widget points() { |
|
|
|
return Container( |
|
|
|
// return Container( |
|
|
|
child: Column( |
|
|
|
// child: integralStore(), |
|
|
|
children: [ |
|
|
|
// ); |
|
|
|
Container( |
|
|
|
// } |
|
|
|
height: 219.h, |
|
|
|
|
|
|
|
child: Swiper( |
|
|
|
|
|
|
|
key: UniqueKey(), |
|
|
|
|
|
|
|
itemCount: articles != null ? articles.length : 0, |
|
|
|
|
|
|
|
viewportFraction: 0.95, |
|
|
|
|
|
|
|
scale: 1, |
|
|
|
|
|
|
|
loop: false, |
|
|
|
|
|
|
|
physics: BouncingScrollPhysics(), |
|
|
|
|
|
|
|
itemBuilder: (context, position) { |
|
|
|
|
|
|
|
return Container( |
|
|
|
|
|
|
|
// margin: EdgeInsets.symmetric(vertical: 15.h, horizontal: 4.5.w), |
|
|
|
|
|
|
|
child:integralStore(), |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Widget integralStore() { |
|
|
|
Widget integralStore() { |
|
|
|
return GridView.builder( |
|
|
|
return GridView.builder( |
|
|
@ -448,13 +435,13 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin { |
|
|
|
//垂直子Widget之间间距 |
|
|
|
//垂直子Widget之间间距 |
|
|
|
mainAxisSpacing: 16, |
|
|
|
mainAxisSpacing: 16, |
|
|
|
//子Widget宽高比例 |
|
|
|
//子Widget宽高比例 |
|
|
|
childAspectRatio: 0.67, |
|
|
|
childAspectRatio: 0.88, |
|
|
|
), |
|
|
|
), |
|
|
|
itemBuilder: (contetx, index) { |
|
|
|
itemBuilder: (contetx, index) { |
|
|
|
return GestureDetector( |
|
|
|
return GestureDetector( |
|
|
|
onTap: () { |
|
|
|
onTap: () { |
|
|
|
// Navigator.of(context).pushNamed('/router/integral_store_page', |
|
|
|
Navigator.of(context).pushNamed('/router/integral_store_page', |
|
|
|
// arguments: {"goodsId": gooods[index].id}); |
|
|
|
arguments: {"goodsId": gooods[index].id}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
child: buildItem(gooods[index]), |
|
|
|
child: buildItem(gooods[index]), |
|
|
|
); |
|
|
|
); |
|
|
@ -465,24 +452,11 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin { |
|
|
|
Widget buildItem(Goods goods) { |
|
|
|
Widget buildItem(Goods goods) { |
|
|
|
return Container( |
|
|
|
return Container( |
|
|
|
alignment: Alignment.center, |
|
|
|
alignment: Alignment.center, |
|
|
|
// decoration: BoxDecoration( |
|
|
|
|
|
|
|
// borderRadius: BorderRadius.all( |
|
|
|
|
|
|
|
// Radius.circular(4), |
|
|
|
|
|
|
|
// ), |
|
|
|
|
|
|
|
// boxShadow: [ |
|
|
|
|
|
|
|
// BoxShadow( |
|
|
|
|
|
|
|
// color: Colors.black.withAlpha(12), |
|
|
|
|
|
|
|
// offset: Offset(0, 3), |
|
|
|
|
|
|
|
// blurRadius: 14, |
|
|
|
|
|
|
|
// spreadRadius: 0, |
|
|
|
|
|
|
|
// ) |
|
|
|
|
|
|
|
// ], |
|
|
|
|
|
|
|
// color: Colors.white), |
|
|
|
|
|
|
|
child: Column( |
|
|
|
child: Column( |
|
|
|
children: [ |
|
|
|
children: [ |
|
|
|
MImage( |
|
|
|
MImage( |
|
|
|
goods.mainImgPath, |
|
|
|
goods.mainImgPath, |
|
|
|
aspectRatio: 5/3, |
|
|
|
aspectRatio: 5 / 3, |
|
|
|
radius: BorderRadius.only( |
|
|
|
radius: BorderRadius.only( |
|
|
|
topLeft: Radius.circular(4), |
|
|
|
topLeft: Radius.circular(4), |
|
|
|
topRight: Radius.circular(4), |
|
|
|
topRight: Radius.circular(4), |
|
|
@ -502,19 +476,22 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin { |
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly, |
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly, |
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
children: [ |
|
|
|
children: [ |
|
|
|
SizedBox(height: 14,), |
|
|
|
SizedBox( |
|
|
|
|
|
|
|
height: 14, |
|
|
|
|
|
|
|
), |
|
|
|
Row( |
|
|
|
Row( |
|
|
|
children: [ |
|
|
|
children: [ |
|
|
|
Expanded(flex: 1,child:Text( |
|
|
|
Expanded( |
|
|
|
goods.name, |
|
|
|
flex: 1, |
|
|
|
overflow: TextOverflow.ellipsis, |
|
|
|
child: Text( |
|
|
|
style: TextStyle( |
|
|
|
goods.name, |
|
|
|
color: Color(0xff353535), |
|
|
|
overflow: TextOverflow.ellipsis, |
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 14.sp, |
|
|
|
color: Color(0xff353535), |
|
|
|
), |
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
) ) |
|
|
|
fontSize: 14.sp, |
|
|
|
, |
|
|
|
), |
|
|
|
|
|
|
|
)), |
|
|
|
BorderText( |
|
|
|
BorderText( |
|
|
|
padding: EdgeInsets.all(2.h), |
|
|
|
padding: EdgeInsets.all(2.h), |
|
|
|
text: S.of(context).haowu, |
|
|
|
text: S.of(context).haowu, |
|
|
@ -535,8 +512,7 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin { |
|
|
|
style: TextStyle( |
|
|
|
style: TextStyle( |
|
|
|
color: Color(0xFF727272), |
|
|
|
color: Color(0xFF727272), |
|
|
|
fontSize: 12.sp, |
|
|
|
fontSize: 12.sp, |
|
|
|
fontWeight: FontWeight.w500 |
|
|
|
fontWeight: FontWeight.w500), |
|
|
|
), |
|
|
|
|
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
@ -636,7 +612,7 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin { |
|
|
|
); |
|
|
|
); |
|
|
|
}, |
|
|
|
}, |
|
|
|
itemCount: |
|
|
|
itemCount: |
|
|
|
(brandData != null && brandData.length > 0) ? brandData.length : 0, |
|
|
|
(brandData != null && brandData.length > 0) ? brandData.length : 0, |
|
|
|
), |
|
|
|
), |
|
|
|
// child: AspectRatio( |
|
|
|
// child: AspectRatio( |
|
|
|
// aspectRatio: 4.16, |
|
|
|
// aspectRatio: 4.16, |
|
|
|