Browse Source

safety

master
fmk 3 years ago
parent
commit
bbe5b5a744
  1. 27
      lib/home/activity_list_page.dart
  2. 599
      lib/home/home_page.dart
  3. 84
      lib/home/home_view/brand_view.dart
  4. 143
      lib/home/home_view/founder_store.dart
  5. 101
      lib/home/home_view/home_banner.dart
  6. 205
      lib/home/home_view/home_integral_store.dart
  7. 68
      lib/home/home_view/hot_article.dart
  8. 108
      lib/home/home_view/sign_view.dart
  9. 408
      lib/home/huixiang_brand_page.dart
  10. 94
      lib/home/huixiang_view/huixiang_banner.dart
  11. 306
      lib/home/huixiang_view/origin_info.dart
  12. 2
      lib/home/main_home_page.dart
  13. 488
      lib/home/points_mall_page.dart
  14. 152
      lib/home/points_mall_view/point_mall_user.dart
  15. 111
      lib/home/points_mall_view/points_goods_title.dart
  16. 181
      lib/home/points_mall_view/points_goods_view.dart
  17. 99
      lib/home/points_mall_view/points_mall_banner.dart
  18. 510
      lib/mine/mine_page.dart
  19. 158
      lib/mine/mine_view/mine_item.dart
  20. 184
      lib/mine/mine_view/mine_view.dart
  21. 121
      lib/mine/mine_view/order_card_view.dart
  22. 21
      lib/mine/mine_vip_level_page.dart
  23. 17
      lib/utils/flutter_utils.dart
  24. 52
      lib/view_widget/mine_vip_view.dart

27
lib/home/activity_list_page.dart

@ -42,7 +42,8 @@ class _ActivityListPage extends State<ActivityListPage>
queryActivity() async {
final SharedPreferences value = await SharedPreferences.getInstance();
apiService = ApiService(Dio(), context: context, token: value.getString('token'));
apiService =
ApiService(Dio(), context: context, token: value.getString('token'));
BaseData<PageInfo<Activity>> baseData = await apiService.informationList({
"pageNum": 1,
"pageSize": 10,
@ -89,7 +90,8 @@ class _ActivityListPage extends State<ActivityListPage>
itemBuilder: (context, position) {
return InkWell(
onTap: () {
Navigator.of(context).pushNamed('/router/store_detail_page',
Navigator.of(context).pushNamed(
'/router/store_detail_page',
arguments: {"activityId": activityList[position].id});
},
child: FrameSeparateWidget(
@ -97,8 +99,8 @@ class _ActivityListPage extends State<ActivityListPage>
placeHolder: AspectRatio(
aspectRatio: 1.34,
child: Container(
margin: EdgeInsets.only(
left: 16.w, right: 16.w, top: 8.h, bottom: 8.h),
margin: EdgeInsets.symmetric(
horizontal: 16.w, vertical: 8.h),
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
@ -126,7 +128,12 @@ class _ActivityListPage extends State<ActivityListPage>
Widget activityItem(Activity activity) {
return Container(
margin: EdgeInsets.only(left: 16.w, right: 16.w, top: 8.h, bottom: 12.h),
margin: EdgeInsets.only(
left: 16.w,
right: 16.w,
top: 8.h,
bottom: 12.h,
),
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
@ -154,7 +161,11 @@ class _ActivityListPage extends State<ActivityListPage>
),
Container(
padding: EdgeInsets.only(
left: 16.w, right: 16.w, top: 8.h, bottom: 12.h),
left: 16.w,
right: 16.w,
top: 8.h,
bottom: 12.h,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
@ -226,13 +237,13 @@ class _ActivityListPage extends State<ActivityListPage>
),
),
],
)
),
],
),
),
],
),
)
),
],
),
);

599
lib/home/home_page.dart

@ -5,6 +5,9 @@ import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/home/home_view/home_banner.dart';
import 'package:huixiang/home/home_view/home_integral_store.dart';
import 'package:huixiang/home/home_view/sign_view.dart';
import 'package:huixiang/main.dart';
import 'package:huixiang/retrofit/data/article.dart';
import 'package:huixiang/retrofit/data/banner.dart';
@ -27,6 +30,10 @@ import 'package:huixiang/view_widget/login_tips.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'home_view/brand_view.dart';
import 'home_view/founder_store.dart';
import 'home_view/hot_article.dart';
class HomePage extends StatefulWidget {
final GestureTapCallback callback;
@ -55,20 +62,6 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin {
});
}
loginTips() {
SmartDialog.show(
widget: LoginTips(
click: () {
SharedPreferences.getInstance()
.then((value) => value.setString("token", ""));
Navigator.of(context)
.pushNamed('/router/login_page', arguments: {"login": "login"});
},
),
clickBgDismissTemp: false,
);
}
SwiperController controller = SwiperController();
List<BannerData> bannerData = [];
@ -78,7 +71,6 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin {
Founder founder;
queryHome() async {
// SmartDialog.showLoading(msg: S.of(context).zhengzaijiazai);
EasyLoading.show(status: S.of(context).zhengzaijiazai);
final SharedPreferences value = await SharedPreferences.getInstance();
@ -147,7 +139,7 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin {
refreshController.dispose();
}
RefreshController refreshController = RefreshController();
final RefreshController refreshController = RefreshController();
@override
Widget build(BuildContext context) {
@ -169,578 +161,27 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin {
builder: (context, snapshot) {
return Column(
children: [
banner(),
SizedBox(
height: 20.h,
),
ItemTitle(
text: S.of(context).jinrihuiyuanrenwu,
imgPath: "assets/image/icon_today_task.png",
moreText: S.of(context).renwuzhongxin,
onTap: () {
SharedPreferences.getInstance().then((value) {
if (value.getString('token') == null ||
value.getString('token') == "") {
loginTips();
} else {
Navigator.of(context)
.pushNamed('/router/integral_page');
}
});
},
),
InkWell(
onTap: () {
SharedPreferences.getInstance().then((value) {
if (value.getString('token') == null ||
value.getString('token') == "") {
loginTips();
} else {
Navigator.of(context)
.pushNamed('/router/integral_page');
}
});
},
child: signIn(),
),
SizedBox(
height: 12.h,
),
ItemTitle(
text: S.of(context).huixiangtoutiao,
imgPath: "assets/image/icon_today_video.png",
moreText: S.of(context).chakangengduo,
onTap: () {
Navigator.of(context)
.pushNamed('/router/hot_article_page');
},
),
hotList(),
ItemTitle(
text: S.of(context).chuangshirendegushi1,
imgPath: "assets/image/icon_founder.png",
),
GestureDetector(
onTap: () {
Navigator.of(context)
.pushNamed('/router/founder_story_page');
},
child: founderStore(),
),
ItemTitle(
text: S.of(context).pinpaijieshao,
imgPath: "assets/image/icon_brand_introduction.png",
),
brands(),
// ban(),
Container(
margin: EdgeInsets.only(
left: 16.5.w, right: 16.5.w, bottom: 40.h, top: 10.h),
padding: EdgeInsets.only(bottom: 10.h, top: 16.h),
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: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
flex: 1,
child: ItemTitle(
text: S.of(context).jifenshangcheng,
imgPath: "assets/image/icon_points_mall.png",
),
),
GestureDetector(
onTap: callback,
child: Container(
padding: EdgeInsets.symmetric(
vertical: 3.h, horizontal: 8.w),
margin: EdgeInsets.only(right: 16.w),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(11.5),
color: Color(0xFF32A060),
),
child: Row(
children: [
Text(
"GO",
style: TextStyle(
fontSize: 14.sp,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
Icon(
Icons.chevron_right,
color: Colors.white,
size: 18,
),
],
),
),
),
],
),
SizedBox(
height: 14.h,
),
Divider(
// indent: 0.0,
thickness: 1,
color: Color(0xffF2F2F2),
),
integralStore(),
],
),
),
// integralStore(),
],
);
},
),
),
),
);
}
Widget hotList() {
return Container(
child: ListView.builder(
shrinkWrap: true,
itemCount: articles != null
? ((articles.length > 3) ? 3 : articles.length)
: 0,
physics: BouncingScrollPhysics(),
scrollDirection: Axis.vertical,
padding: EdgeInsets.symmetric(vertical: 12.h),
itemBuilder: (context, position) {
return AspectRatio(
aspectRatio: position == 0 ? 1.38 : 3.56,
child: Container(
height: position == 0 ? 247.h : 96.h,
margin: EdgeInsets.symmetric(vertical: 6.h, horizontal: 16.w),
child: HotArticleItem(
article: articles[position], isHot: position == 0),
),
);
},
),
);
}
Widget founderStore() {
return Container(
margin: EdgeInsets.only(left: 16.w, right: 16.w, top: 22.h, bottom: 28.h),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(25),
offset: Offset(0, 3),
blurRadius: 14,
spreadRadius: 0,
),
],
),
child: Stack(
alignment: Alignment.bottomCenter,
clipBehavior: Clip.hardEdge,
children: [
MImage(
founder != null ? founder.imgUrl : "",
aspectRatio: 2,
radius: BorderRadius.circular(4.w),
fit: BoxFit.cover,
errorSrc: "assets/image/default_2_1.png",
fadeSrc: "assets/image/default_2_1.png",
),
Container(
padding: EdgeInsets.all(8.w),
decoration: BoxDecoration(
color: Colors.black.withAlpha(153),
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(4.w),
bottomRight: Radius.circular(4.w),
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.baseline,
textBaseline: TextBaseline.alphabetic,
children: [
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.baseline,
textBaseline: TextBaseline.alphabetic,
children: [
Expanded(
child: Row(
children: [
Text(
S.of(context).chuangshirendegushi,
style: TextStyle(
fontSize: 14.sp,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
Text(
founder != null ? founder.name : "",
style: TextStyle(
fontSize: 14.sp,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
],
),
flex: 1,
),
Row(
children: [
Text(
S.of(context).chakanxiangqing,
style: TextStyle(
fontSize: 10.sp,
fontWeight: MyFontWeight.medium,
color: Colors.white,
),
),
Icon(
Icons.keyboard_arrow_right,
size: 12,
color: Colors.white,
),
],
),
],
),
flex: 1,
),
],
),
),
],
),
);
}
// Widget points() {
// return Container(
// child: integralStore(),
// );
// }
Widget integralStore() {
return GridView.builder(
itemCount: gooods != null ? gooods.length : 0,
padding: EdgeInsets.all(13.w),
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
//Widget数量
crossAxisCount: 2,
//Widget之间间距
crossAxisSpacing: 13,
//Widget之间间距
mainAxisSpacing: 16,
//Widget宽高比例
childAspectRatio: AppUtils.textScale(context) > 1
? (1 - ((AppUtils.textScale(context) - 1)))
: 0.85,
),
itemBuilder: (contetx, index) {
return GestureDetector(
onTap: () {
Navigator.of(context).pushNamed('/router/integral_store_page',
arguments: {"goodsId": gooods[index].id});
},
child: buildItem(gooods[index]),
);
},
);
}
Widget buildItem(Goods goods) {
return Container(
alignment: Alignment.center,
child: Column(
children: [
MImage(
goods.mainImgPath,
aspectRatio: 5 / 3,
radius: BorderRadius.circular(4),
fit: BoxFit.cover,
errorSrc: "assets/image/default_1.png",
fadeSrc: "assets/image/default_1.png",
),
SizedBox(
height: 4.h,
),
Container(
margin: EdgeInsets.only(left: 8.w, right: 8.w),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 14.h,
),
Row(
children: [
Expanded(
flex: 1,
child: Text(
goods.name,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Color(0xff353535),
fontWeight: MyFontWeight.regular,
fontSize: 14.sp,
),
),
),
BorderText(
padding: EdgeInsets.all(2.h),
text: S.of(context).haowu,
fontSize: 12.sp,
fontWeight: FontWeight.bold,
textColor: Color(0xFF32A060),
borderColor: Color(0xFF32A060),
borderWidth: 1.w,
),
],
),
SizedBox(
height: 5.h,
),
Text(
goods.description,
overflow: TextOverflow.ellipsis,
maxLines: 2,
style: TextStyle(
color: Color(0xFF727272),
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
),
),
],
),
)
///banner
HomeBanner(bannerData, controller),
///
SignView(),
///
HotArticle(articles),
///
FounderStore(founder),
///
BrandView(brandData),
///
HomeIntegralStore(gooods, callback),
],
),
);
}
///view
Widget signIn() {
return Container(
padding: EdgeInsets.only(left: 12.w, top: 8.h, bottom: 8.h, right: 12.w),
margin: EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(12),
offset: Offset(0, 3),
blurRadius: 14,
spreadRadius: 0,
)
],
borderRadius: BorderRadius.circular(4),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Image.asset(
"assets/image/icon_calendar_today_sharp.png",
width: 20.w,
height: 20.h,
),
SizedBox(
width: 8.w,
),
Text(
S.of(context).qiandaolingqujinfen,
style: TextStyle(
color: Colors.black,
fontSize: 14.sp,
fontWeight: MyFontWeight.regular),
),
],
),
Text(
S.of(context).quqiandao,
style: TextStyle(
color: Color(0xFF727272),
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,),
),
],
),
);
}
brands() {
return Container(
height: 90.h,
margin: EdgeInsets.only(bottom: 18.h),
child: Swiper(
physics: BouncingScrollPhysics(),
viewportFraction: 0.32,
scale: 0.7,
loop: true,
itemBuilder: (context, position) {
return Container(
// height: 60.h,
// width: 120.w,
margin: EdgeInsets.symmetric(horizontal: 3.w, vertical: 15.h),
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(37),
offset: Offset(0, 2),
blurRadius: 5,
spreadRadius: 0,
)
],
borderRadius: BorderRadius.circular(8),
),
child: MImage(
brandData != null ? brandData[position].image : "",
radius: BorderRadius.circular(8),
fit: BoxFit.cover,
errorSrc: "assets/image/default_2_1.png",
fadeSrc: "assets/image/default_2_1.png",
),
);
},
itemCount:
(brandData != null && brandData.length > 0) ? brandData.length : 0,
),
// child: ListView.builder(
// padding: EdgeInsets.only(left: 10.w, right: 10.w),
// scrollDirection: Axis.horizontal,
// physics: BouncingScrollPhysics(),
// itemBuilder: (context, position) {
// return Container(
// height: 60.h,
// width: 120.w,
// margin: EdgeInsets.symmetric(horizontal: 3.w, vertical: 15.h),
// decoration: BoxDecoration(
// color: Colors.white,
// boxShadow: [
// BoxShadow(
// color: Colors.black.withAlpha(37),
// offset: Offset(0, 2),
// blurRadius: 5,
// spreadRadius: 0,
// )
// ],
// borderRadius: BorderRadius.circular(8),
// ),
// child: MImage(
// brandData != null ? brandData[position].image : "",
// radius: BorderRadius.circular(8),
// fit: BoxFit.cover,
// errorSrc: "assets/image/default_2_1.png",
// fadeSrc: "assets/image/default_2_1.png",
// ),
// );
// },
// itemCount: (brandData != null && brandData.length > 0) ? brandData.length : 0,
// ),
);
}
banner() {
return Container(
child: AspectRatio(
aspectRatio: 2,
child: Swiper(
pagination: SwiperPagination(
margin: EdgeInsets.only(bottom: 20.h),
alignment: Alignment.bottomCenter,
builder: DotSwiperPaginationBuilder(
size: 8,
activeSize: 8,
space: 5,
activeColor: Colors.white,
color: Colors.white.withAlpha(76),
),
),
controller: controller,
physics: BouncingScrollPhysics(),
itemBuilder: (context, position) {
return InkWell(
onTap: () {
bannerClick(bannerData[position]);
},
child: Container(
margin: EdgeInsets.all(16),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
),
child: MImage(
(bannerData != null && position < bannerData.length)
? bannerData[position].imgUrl ?? ""
: "",
radius: BorderRadius.circular(8),
fit: BoxFit.cover,
errorSrc: "assets/image/default_2_1.png",
fadeSrc: "assets/image/default_2_1.png",
),
),
);
},
itemCount: (bannerData != null && bannerData.length > 0)
? bannerData.length
: 1,
),
),
);
}
/// contentType 0123
bannerClick(BannerData bannerData) async {
switch (bannerData.contentType) {
case 1:
Navigator.of(context).pushNamed('/router/integral_store_page',
arguments: {"goodsId": bannerData.content});
break;
case 2:
Navigator.of(context)
.pushNamed('/router/store_detail_page', arguments: {
"activityId": bannerData.content,
});
break;
case 3:
Navigator.of(context)
.pushNamed('/router/store_detail_page', arguments: {
"articleId": bannerData.content,
});
break;
}
}
@override
bool get wantKeepAlive => true;
}

84
lib/home/home_view/brand_view.dart

@ -0,0 +1,84 @@
import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/data/brand.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:huixiang/view_widget/item_title.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class BrandView extends StatefulWidget {
final List<Brand> brandData;
BrandView(this.brandData);
@override
State<StatefulWidget> createState() {
return _BrandView();
}
}
class _BrandView extends State<BrandView> {
@override
Widget build(BuildContext context) {
return Column(
children: [
ItemTitle(
text: S.of(context).pinpaijieshao,
imgPath: "assets/image/icon_brand_introduction.png",
),
brands(),
],
);
}
brands() {
return Container(
height: 90.h,
margin: EdgeInsets.only(bottom: 18.h),
child: Swiper(
physics: BouncingScrollPhysics(),
viewportFraction: 0.32,
scale: 0.7,
loop: true,
itemBuilder: (context, position) {
return Container(
// height: 60.h,
// width: 120.w,
margin: EdgeInsets.symmetric(horizontal: 3.w, vertical: 15.h),
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(37),
offset: Offset(0, 2),
blurRadius: 5,
spreadRadius: 0,
)
],
borderRadius: BorderRadius.circular(8),
),
child: MImage(
widget.brandData != null ? widget.brandData[position].image : "",
radius: BorderRadius.circular(8),
fit: BoxFit.cover,
errorSrc: "assets/image/default_2_1.png",
fadeSrc: "assets/image/default_2_1.png",
),
);
},
itemCount:
(widget.brandData != null && widget.brandData.length > 0) ? widget.brandData.length : 0,
),
);
}
}

143
lib/home/home_view/founder_store.dart

@ -0,0 +1,143 @@
import 'package:flutter/material.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/data/founder.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:huixiang/view_widget/item_title.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class FounderStore extends StatefulWidget {
final Founder founder;
FounderStore(this.founder);
@override
State<StatefulWidget> createState() {
return _FounderStore();
}
}
class _FounderStore extends State<FounderStore> {
@override
Widget build(BuildContext context) {
return Column(
children: [
ItemTitle(
text: S.of(context).chuangshirendegushi1,
imgPath: "assets/image/icon_founder.png",
),
GestureDetector(
onTap: () {
Navigator.of(context)
.pushNamed('/router/founder_story_page');
},
child: founderStore(),
),
],
);
}
Widget founderStore() {
return Container(
margin: EdgeInsets.only(left: 16.w, right: 16.w, top: 22.h, bottom: 28.h),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(25),
offset: Offset(0, 3),
blurRadius: 14,
spreadRadius: 0,
),
],
),
child: Stack(
alignment: Alignment.bottomCenter,
clipBehavior: Clip.hardEdge,
children: [
MImage(
widget.founder != null ? widget.founder.imgUrl : "",
aspectRatio: 2,
radius: BorderRadius.circular(4.w),
fit: BoxFit.cover,
errorSrc: "assets/image/default_2_1.png",
fadeSrc: "assets/image/default_2_1.png",
),
Container(
padding: EdgeInsets.all(8.w),
decoration: BoxDecoration(
color: Colors.black.withAlpha(153),
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(4.w),
bottomRight: Radius.circular(4.w),
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.baseline,
textBaseline: TextBaseline.alphabetic,
children: [
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.baseline,
textBaseline: TextBaseline.alphabetic,
children: [
Expanded(
child: Row(
children: [
Text(
S.of(context).chuangshirendegushi,
style: TextStyle(
fontSize: 14.sp,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
Text(
widget.founder != null ? widget.founder.name : "",
style: TextStyle(
fontSize: 14.sp,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
],
),
flex: 1,
),
Row(
children: [
Text(
S.of(context).chakanxiangqing,
style: TextStyle(
fontSize: 10.sp,
fontWeight: MyFontWeight.medium,
color: Colors.white,
),
),
Icon(
Icons.keyboard_arrow_right,
size: 12,
color: Colors.white,
),
],
),
],
),
flex: 1,
),
],
),
),
],
),
);
}
}

101
lib/home/home_view/home_banner.dart

@ -0,0 +1,101 @@
import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:huixiang/retrofit/data/banner.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class HomeBanner extends StatefulWidget {
final List<BannerData> bannerData;
final SwiperController controller;
HomeBanner(this.bannerData, this.controller);
@override
State<StatefulWidget> createState() {
return _HomeBanner();
}
}
class _HomeBanner extends State<HomeBanner> {
@override
Widget build(BuildContext context) {
return Container(
child: AspectRatio(
aspectRatio: 2,
child: Swiper(
pagination: SwiperPagination(
margin: EdgeInsets.only(bottom: 20.h),
alignment: Alignment.bottomCenter,
builder: DotSwiperPaginationBuilder(
size: 8,
activeSize: 8,
space: 5,
activeColor: Colors.white,
color: Colors.white.withAlpha(76),
),
),
controller: widget.controller,
physics: BouncingScrollPhysics(),
itemBuilder: (context, position) {
return InkWell(
onTap: () {
bannerClick(widget.bannerData[position]);
},
child: Container(
margin: EdgeInsets.all(16),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
),
child: MImage(
(widget.bannerData != null && position < widget.bannerData.length)
? widget.bannerData[position].imgUrl ?? ""
: "",
radius: BorderRadius.circular(8),
fit: BoxFit.cover,
errorSrc: "assets/image/default_2_1.png",
fadeSrc: "assets/image/default_2_1.png",
),
),
);
},
itemCount: (widget.bannerData != null && widget.bannerData.length > 0)
? widget.bannerData.length
: 1,
),
),
);
}
/// contentType 0123
bannerClick(BannerData bannerData) async {
switch (bannerData.contentType) {
case 1:
Navigator.of(context).pushNamed('/router/integral_store_page',
arguments: {"goodsId": bannerData.content});
break;
case 2:
Navigator.of(context)
.pushNamed('/router/store_detail_page', arguments: {
"activityId": bannerData.content,
});
break;
case 3:
Navigator.of(context)
.pushNamed('/router/store_detail_page', arguments: {
"articleId": bannerData.content,
});
break;
}
}
}

205
lib/home/home_view/home_integral_store.dart

@ -0,0 +1,205 @@
import 'package:flutter/material.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/data/goods.dart';
import 'package:huixiang/utils/flutter_utils.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/view_widget/border_text.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:huixiang/view_widget/item_title.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class HomeIntegralStore extends StatefulWidget {
final GestureTapCallback callback;
final List<Goods> gooods;
HomeIntegralStore(this.gooods, this.callback);
@override
State<StatefulWidget> createState() {
return _HomeIntegralStore();
}
}
class _HomeIntegralStore extends State<HomeIntegralStore> {
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.only(
left: 16.5.w, right: 16.5.w, bottom: 40.h, top: 10.h),
padding: EdgeInsets.only(bottom: 10.h, top: 16.h),
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: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
flex: 1,
child: ItemTitle(
text: S.of(context).jifenshangcheng,
imgPath: "assets/image/icon_points_mall.png",
),
),
GestureDetector(
onTap: widget.callback,
child: Container(
padding: EdgeInsets.symmetric(
vertical: 3.h, horizontal: 8.w,),
margin: EdgeInsets.only(right: 16.w),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(11.5),
color: Color(0xFF32A060),
),
child: Row(
children: [
Text(
"GO",
style: TextStyle(
fontSize: 14.sp,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
Icon(
Icons.chevron_right,
color: Colors.white,
size: 18,
),
],
),
),
),
],
),
SizedBox(
height: 14.h,
),
Divider(
// indent: 0.0,
thickness: 1,
color: Color(0xffF2F2F2),
),
integralStore(),
],
),
);
}
Widget integralStore() {
return GridView.builder(
itemCount: widget.gooods != null ? widget.gooods.length : 0,
padding: EdgeInsets.all(13.w),
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
//Widget数量
crossAxisCount: 2,
//Widget之间间距
crossAxisSpacing: 13,
//Widget之间间距
mainAxisSpacing: 16,
//Widget宽高比例
childAspectRatio: AppUtils.textScale(context) > 1
? (1 - ((AppUtils.textScale(context) - 1)))
: 0.85,
),
itemBuilder: (contetx, index) {
return GestureDetector(
onTap: () {
Navigator.of(context).pushNamed('/router/integral_store_page',
arguments: {"goodsId": widget.gooods[index].id});
},
child: buildItem(widget.gooods[index]),
);
},
);
}
Widget buildItem(Goods goods) {
return Container(
alignment: Alignment.center,
child: Column(
children: [
MImage(
goods.mainImgPath,
aspectRatio: 5 / 3,
radius: BorderRadius.circular(4),
fit: BoxFit.cover,
errorSrc: "assets/image/default_1.png",
fadeSrc: "assets/image/default_1.png",
),
SizedBox(
height: 4.h,
),
Container(
margin: EdgeInsets.only(left: 8.w, right: 8.w),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 14.h,
),
Row(
children: [
Expanded(
flex: 1,
child: Text(
goods.name,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Color(0xff353535),
fontWeight: MyFontWeight.regular,
fontSize: 14.sp,
),
),
),
BorderText(
padding: EdgeInsets.all(2.h),
text: S.of(context).haowu,
fontSize: 12.sp,
fontWeight: FontWeight.bold,
textColor: Color(0xFF32A060),
borderColor: Color(0xFF32A060),
borderWidth: 1.w,
),
],
),
SizedBox(
height: 5.h,
),
Text(
goods.description,
overflow: TextOverflow.ellipsis,
maxLines: 2,
style: TextStyle(
color: Color(0xFF727272),
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
),
),
],
),
)
],
),
);
}
}

68
lib/home/home_view/hot_article.dart

@ -0,0 +1,68 @@
import 'package:flutter/material.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/data/article.dart';
import 'package:huixiang/view_widget/hot_item.dart';
import 'package:huixiang/view_widget/item_title.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class HotArticle extends StatefulWidget {
final List<Article> articles;
HotArticle(this.articles);
@override
State<StatefulWidget> createState() {
return _HotArticle();
}
}
class _HotArticle extends State<HotArticle> {
@override
Widget build(BuildContext context) {
return Column(
children: [
ItemTitle(
text: S.of(context).huixiangtoutiao,
imgPath: "assets/image/icon_today_video.png",
moreText: S.of(context).chakangengduo,
onTap: () {
Navigator.of(context)
.pushNamed('/router/hot_article_page');
},
),
hotList(),
],
);
}
Widget hotList() {
return Container(
child: ListView.builder(
shrinkWrap: true,
itemCount: widget.articles != null
? ((widget.articles.length > 3) ? 3 : widget.articles.length)
: 0,
physics: BouncingScrollPhysics(),
scrollDirection: Axis.vertical,
padding: EdgeInsets.symmetric(vertical: 12.h),
itemBuilder: (context, position) {
return AspectRatio(
aspectRatio: position == 0 ? 1.38 : 3.56,
child: Container(
height: position == 0 ? 247.h : 96.h,
margin: EdgeInsets.symmetric(vertical: 6.h, horizontal: 16.w),
child: HotArticleItem(
article: widget.articles[position], isHot: position == 0),
),
);
},
),
);
}
}

108
lib/home/home_view/sign_view.dart

@ -0,0 +1,108 @@
import 'package:flutter/material.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/utils/flutter_utils.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/view_widget/item_title.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class SignView extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Column(
children: [
SizedBox(
height: 20.h,
),
ItemTitle(
text: S.of(context).jinrihuiyuanrenwu,
imgPath: "assets/image/icon_today_task.png",
moreText: S.of(context).renwuzhongxin,
onTap: () {
SharedPreferences.getInstance().then((value) {
if (value.getString('token') == null ||
value.getString('token') == "") {
AppUtils.loginTips(context);
} else {
Navigator.of(context).pushNamed('/router/integral_page');
}
});
},
),
InkWell(
onTap: () {
SharedPreferences.getInstance().then((value) {
if (value.getString('token') == null ||
value.getString('token') == "") {
AppUtils.loginTips(context);
} else {
Navigator.of(context).pushNamed('/router/integral_page');
}
});
},
child: signIn(context),
),
SizedBox(
height: 12.h,
),
],
);
}
///view
Widget signIn(BuildContext context) {
return Container(
padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 8.h),
margin: EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(12),
offset: Offset(0, 3),
blurRadius: 14,
spreadRadius: 0,
)
],
borderRadius: BorderRadius.circular(4),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Image.asset(
"assets/image/icon_calendar_today_sharp.png",
width: 20.w,
height: 20.h,
),
SizedBox(
width: 8.w,
),
Text(
S.of(context).qiandaolingqujinfen,
style: TextStyle(
color: Colors.black,
fontSize: 14.sp,
fontWeight: MyFontWeight.regular,
),
),
],
),
Text(
S.of(context).quqiandao,
style: TextStyle(
color: Color(0xFF727272),
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
),
),
],
),
);
}
}

408
lib/home/huixiang_brand_page.dart

@ -25,6 +25,9 @@ import 'package:huixiang/view_widget/store_title_tab.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'huixiang_view/huixiang_banner.dart';
import 'huixiang_view/origin_info.dart';
class BrandPage extends StatefulWidget {
@override
State<StatefulWidget> createState() {
@ -43,7 +46,6 @@ class _BrandPage extends State<BrandPage>
List<GlobalKey> globaKeys = [];
List<BannerData> bannerData = [];
var isShowMore = false;
Future queryHome() async {
EasyLoading.show(status: S.current.zhengzaijiazai);
@ -103,7 +105,6 @@ class _BrandPage extends State<BrandPage>
});
queryHome();
}
@override
@ -171,8 +172,10 @@ class _BrandPage extends State<BrandPage>
List<Widget> homeChildItem() {
var widgets = <Widget>[
banner(),
buildInfo(),
///banner
HuiXiangBanner(bannerData),
///
OriginInfo(brandData),
StoreTitleTab(
brands,
globaKeys,
@ -182,7 +185,8 @@ class _BrandPage extends State<BrandPage>
];
if (brands == null) return widgets;
brands.forEach((value) {
widgets.add(Container(
widgets.add(
Container(
key: globaKeys[brands.indexOf(value)],
child: Container(
color: Colors.white,
@ -200,404 +204,12 @@ class _BrandPage extends State<BrandPage>
},
),
),
));
});
return widgets;
}
Widget buildInfo() {
return Container(
margin: EdgeInsets.only(bottom: 20, top: 16),
padding: EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(12),
offset: Offset(0, 2),
blurRadius: 14,
spreadRadius: 0,
)
],
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
GestureDetector(
onTap: () {
Navigator.of(context).pushNamed('/router/founder_story_page');
},
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ClipOval(
child: MImage(
brandData == null ? "" : brandData.originAvatar,
fit: BoxFit.cover,
width: 60,
height: 60,
errorSrc: "assets/image/default_1.png",
fadeSrc: "assets/image/default_1.png",
),
clipBehavior: Clip.hardEdge,
),
SizedBox(
width: 16.w,
),
Expanded(
child: Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text.rich(
TextSpan(children: [
TextSpan(
text:
brandData == null ? "" : brandData.originator,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14.sp,
color: Colors.black,
),
),
TextSpan(
text: " ${S.of(context).jituanchuangbanren}",
style: TextStyle(
fontSize: 10.sp,
color: Colors.black,
),
),
]),
textDirection: TextDirection.ltr,
),
Text(
brandData == null ? "" : brandData.originDesc,
overflow: isShowMore
? TextOverflow.visible
: TextOverflow.ellipsis,
maxLines: isShowMore ? 10 : 2,
style: TextStyle(
fontSize: 12.sp,
color: Colors.black,
),
),
SizedBox(height: 3.h),
GestureDetector(
onTap: () {
setState(() {
isShowMore = !isShowMore;
});
},
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
children: [
Text(
S.of(context).gengduo,
style: TextStyle(
fontSize: 12.sp,
color: Colors.black,
),
),
Icon(
(isShowMore != null && !isShowMore)
? Icons.chevron_right
: Icons.keyboard_arrow_up,
color: Colors.black,
size: 18,
),
],
),
),
],
),
),
flex: 1,
),
],
),
),
SizedBox(
height: 40.h,
),
InkWell(
onTap: () {
Navigator.of(context).pushNamed('/router/founder_story_page');
},
child: Text(
brandData == null ? "" : brandData.company,
style: TextStyle(
fontSize: 16.sp,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
),
SizedBox(
height: 20.h,
),
InkWell(
onTap: () {
Navigator.of(context).pushNamed('/router/founder_story_page');
},
child: Text(
brandData == null ? "" : brandData.companyDesc,
textAlign: TextAlign.justify,
style: TextStyle(
fontSize: 12.sp,
color: Color(0xFF353535),
),
),
),
SizedBox(
height: 40.h,
),
Text(
S.of(context).linian,
style: TextStyle(
fontSize: 16.sp,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
SizedBox(
height: 20.h,
),
InkWell(
onTap: () {
Navigator.of(context).pushNamed('/router/founder_story_page');
},
child: Column(
children: [
Row(
children: [
_ideaWidget("友爱", "assets/image/icon_idea_ya.png"),
_ideaWidget("纯净", "assets/image/icon_idea_cj.png"),
_ideaWidget("健康", "assets/image/icon_idea_jk.png"),
],
),
SizedBox(
height: 18.h,
),
Row(
children: [
_ideaWidget("有机", "assets/image/icon_idea_yj.png"),
_ideaWidget("环保", "assets/image/icon_idea_hb.png"),
_ideaWidget("智慧", "assets/image/icon_idea_zh.png"),
],
),
],
),
),
],
),
);
}
//
// List<Widget> buildIdea() {
// if (brandData == null) return [];
// var ideas = <Widget>[];
// (brandData.ideals as Map<String, dynamic>).forEach((key, value) {
// ideas.add(idea(key, value));
// });
// return ideas;
// }
Widget _ideaWidget(var text, String img) {
return Expanded(
flex: 1,
child: Stack(
alignment: Alignment.center,
children: [
Container(
width: 63,
height: 63.h,
child: Stack(
alignment: Alignment.center,
children: [
Align(
child: CircleAvatar(
child: Image.asset(img),
radius: 100,
),
),
Text(
text,
style: TextStyle(
fontSize: 18,
fontWeight: MyFontWeight.light,
color: Colors.white),
)
],
),
// CircleAvatar(
// radius: 100,
// backgroundImage: Image.asset(img),
// child: Container(
// alignment: Alignment.center,
// child: Text(
// text,
// style: TextStyle(
// fontSize: 18,
// fontWeight: FontWeight.w300,
// color: Colors.white),
// )),
// ),
),
Container(
width: 73,
height: 73.h,
child: CustomPaint(
painter: MyPainter(
lineColor: Color(0xff32A060), width: 2, isDividerRound: true),
),
)
],
),
);
}
banner() {
return Container(
child: AspectRatio(
aspectRatio: 2.08,
child: Swiper(
viewportFraction: 0.88,
scale: 0.93,
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 InkWell(
onTap: () {
bannerClick(bannerData[position]);
},
child: MImage(
(bannerData != null && position < bannerData.length)
? bannerData[position].imgUrl
: "",
fit: BoxFit.cover,
radius: BorderRadius.circular(8),
errorSrc: "assets/image/default_2_1.png",
fadeSrc: "assets/image/default_2_1.png",
),
);
},
itemCount: (bannerData != null && bannerData.length > 0)
? bannerData.length
: 1),
),
);
}
/// contentType 0123
bannerClick(BannerData bannerData) async {
switch (bannerData.contentType) {
case 1:
Navigator.of(context).pushNamed('/router/integral_store_page',
arguments: {"goodsId": bannerData.content});
break;
case 2:
Navigator.of(context)
.pushNamed('/router/store_detail_page', arguments: {
"activityId": bannerData.content,
});
break;
case 3:
Navigator.of(context)
.pushNamed('/router/store_detail_page', arguments: {
"articleId": bannerData.content,
});
break;
}
return widgets;
}
Widget idea(key, value) {
return Expanded(
flex: 1,
child: Stack(
alignment: Alignment.center,
children: [
Container(
width: 63.w,
height: 63.h,
child: CircleAvatar(
radius: 100,
backgroundImage: NetworkImage(value),
child: Container(
alignment: Alignment.center,
child: Text(
key,
style: TextStyle(
fontSize: 16.sp,
fontWeight: MyFontWeight.light,
color: Colors.white,
),
),
),
),
),
Container(
width: 73.w,
height: 73.h,
child: CustomPaint(
painter: MyPainter(
lineColor: Color(0xff32A060),
width: 2.w,
isDividerRound: true,
),
),
)
],
),
);
// Stack(
// children: [
// MImage(
// value,
// width: 71,
// height: 71,
// fit: BoxFit.cover,
// errorSrc: "assets/image/default_1.png",
// fadeSrc: "assets/image/default_1.png",
// ),
// Positioned(
// bottom: 0,
// child: Container(
// width: 71,
// decoration: BoxDecoration(
// color: Colors.black.withAlpha(125),
// borderRadius: BorderRadius.only(
// bottomRight: Radius.circular(4),
// bottomLeft: Radius.circular(4),
// ),
// ),
// padding: EdgeInsets.symmetric(vertical: 2),
// alignment: Alignment.center,
// child: Text(
// key,
// style: TextStyle(
// color: Colors.white,
// fontSize: 12.sp,
// ),
// ),
// ),
// )
// ],
// );
}
@override
bool get wantKeepAlive => true;

94
lib/home/huixiang_view/huixiang_banner.dart

@ -0,0 +1,94 @@
import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:huixiang/retrofit/data/banner.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class HuiXiangBanner extends StatefulWidget {
final List<BannerData> bannerData;
HuiXiangBanner(this.bannerData);
@override
State<StatefulWidget> createState() {
return _HuiXiangBanner();
}
}
class _HuiXiangBanner extends State<HuiXiangBanner> {
@override
Widget build(BuildContext context) {
return Container(
child: AspectRatio(
aspectRatio: 2.08,
child: Swiper(
viewportFraction: 0.88,
scale: 0.93,
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 InkWell(
onTap: () {
bannerClick(widget.bannerData[position]);
},
child: MImage(
(widget.bannerData != null && position < widget.bannerData.length)
? widget.bannerData[position].imgUrl
: "",
fit: BoxFit.cover,
radius: BorderRadius.circular(8),
errorSrc: "assets/image/default_2_1.png",
fadeSrc: "assets/image/default_2_1.png",
),
);
},
itemCount: (widget.bannerData != null && widget.bannerData.length > 0)
? widget.bannerData.length
: 1),
),
);
}
/// contentType 0123
bannerClick(BannerData bannerData) async {
switch (bannerData.contentType) {
case 1:
Navigator.of(context).pushNamed('/router/integral_store_page',
arguments: {"goodsId": bannerData.content});
break;
case 2:
Navigator.of(context)
.pushNamed('/router/store_detail_page', arguments: {
"activityId": bannerData.content,
});
break;
case 3:
Navigator.of(context)
.pushNamed('/router/store_detail_page', arguments: {
"articleId": bannerData.content,
});
break;
}
}
}

306
lib/home/huixiang_view/origin_info.dart

@ -0,0 +1,306 @@
import 'package:flutter/material.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/data/brand_data.dart';
import 'package:huixiang/utils/MyPainter.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class OriginInfo extends StatefulWidget {
final BrandData brandData;
OriginInfo(this.brandData);
@override
State<StatefulWidget> createState() {
return _OriginInfo();
}
}
class _OriginInfo extends State<OriginInfo> {
var isShowMore = false;
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.only(bottom: 20.h, top: 16.h),
padding: EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(12),
offset: Offset(0, 2),
blurRadius: 14,
spreadRadius: 0,
)
],
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
GestureDetector(
onTap: () {
Navigator.of(context).pushNamed('/router/founder_story_page');
},
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ClipOval(
child: MImage(
widget.brandData == null
? ""
: widget.brandData.originAvatar,
fit: BoxFit.cover,
width: 60,
height: 60,
errorSrc: "assets/image/default_1.png",
fadeSrc: "assets/image/default_1.png",
),
clipBehavior: Clip.hardEdge,
),
SizedBox(
width: 16.w,
),
Expanded(
child: Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text.rich(
TextSpan(children: [
TextSpan(
text: widget.brandData == null
? ""
: widget.brandData.originator,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14.sp,
color: Colors.black,
),
),
TextSpan(
text: " ${S.of(context).jituanchuangbanren}",
style: TextStyle(
fontSize: 10.sp,
color: Colors.black,
),
),
]),
textDirection: TextDirection.ltr,
),
Text(
widget.brandData == null
? ""
: widget.brandData.originDesc,
overflow: isShowMore
? TextOverflow.visible
: TextOverflow.ellipsis,
maxLines: isShowMore ? 10 : 2,
style: TextStyle(
fontSize: 12.sp,
color: Colors.black,
),
),
SizedBox(height: 3.h),
GestureDetector(
onTap: () {
setState(() {
isShowMore = !isShowMore;
});
},
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
children: [
Text(
S.of(context).gengduo,
style: TextStyle(
fontSize: 12.sp,
color: Colors.black,
),
),
Icon(
(isShowMore != null && !isShowMore)
? Icons.chevron_right
: Icons.keyboard_arrow_up,
color: Colors.black,
size: 18,
),
],
),
),
],
),
),
flex: 1,
),
],
),
),
SizedBox(
height: 40.h,
),
InkWell(
onTap: () {
Navigator.of(context).pushNamed('/router/founder_story_page');
},
child: Text(
widget.brandData == null ? "" : widget.brandData.company,
style: TextStyle(
fontSize: 16.sp,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
),
SizedBox(
height: 20.h,
),
InkWell(
onTap: () {
Navigator.of(context).pushNamed('/router/founder_story_page');
},
child: Text(
widget.brandData == null ? "" : widget.brandData.companyDesc,
textAlign: TextAlign.justify,
style: TextStyle(
fontSize: 12.sp,
color: Color(0xFF353535),
),
),
),
SizedBox(
height: 40.h,
),
Text(
S.of(context).linian,
style: TextStyle(
fontSize: 16.sp,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
SizedBox(
height: 20.h,
),
InkWell(
onTap: () {
Navigator.of(context).pushNamed('/router/founder_story_page');
},
child: Column(
children: [
Row(
children: [
_ideaWidget("友爱", "assets/image/icon_idea_ya.png"),
_ideaWidget("纯净", "assets/image/icon_idea_cj.png"),
_ideaWidget("健康", "assets/image/icon_idea_jk.png"),
],
),
SizedBox(
height: 18.h,
),
Row(
children: [
_ideaWidget("有机", "assets/image/icon_idea_yj.png"),
_ideaWidget("环保", "assets/image/icon_idea_hb.png"),
_ideaWidget("智慧", "assets/image/icon_idea_zh.png"),
],
),
],
),
),
],
),
);
}
Widget _ideaWidget(var text, String img) {
return Expanded(
flex: 1,
child: Stack(
alignment: Alignment.center,
children: [
Container(
width: 63.h,
height: 63.h,
child: Stack(
alignment: Alignment.center,
children: [
Align(
child: CircleAvatar(
child: Image.asset(img),
radius: 100,
),
),
Text(
text,
style: TextStyle(
fontSize: 18,
fontWeight: MyFontWeight.light,
color: Colors.white,
),
)
],
),
),
Container(
width: 73,
height: 73.h,
child: CustomPaint(
painter: MyPainter(
lineColor: Color(0xff32A060),
width: 2,
isDividerRound: true,
),
),
)
],
),
);
}
Widget idea(key, value) {
return Expanded(
flex: 1,
child: Stack(
alignment: Alignment.center,
children: [
Container(
width: 63.w,
height: 63.h,
child: CircleAvatar(
radius: 100,
backgroundImage: NetworkImage(value),
child: Container(
alignment: Alignment.center,
child: Text(
key,
style: TextStyle(
fontSize: 16.sp,
fontWeight: MyFontWeight.light,
color: Colors.white,
),
),
),
),
),
Container(
width: 73.w,
height: 73.h,
child: CustomPaint(
painter: MyPainter(
lineColor: Color(0xff32A060),
width: 2.w,
isDividerRound: true,
),
),
),
],
),
);
}
}

2
lib/home/main_home_page.dart

@ -26,9 +26,7 @@ class _MainHomePage extends State<MainHomePage>
super.initState();
if (tabcontroller == null)
tabcontroller = TabController(length: 3, vsync: this);
tabcontroller.addListener(() => () {});
//NoDataView(),
_widgetOptions = <Widget>[
HomePage(() {
setState(() {

488
lib/home/points_mall_page.dart

@ -7,6 +7,10 @@ import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/home/points_mall_view/point_mall_user.dart';
import 'package:huixiang/home/points_mall_view/points_goods_title.dart';
import 'package:huixiang/home/points_mall_view/points_goods_view.dart';
import 'package:huixiang/home/points_mall_view/points_mall_banner.dart';
import 'package:huixiang/main.dart';
import 'package:huixiang/retrofit/data/banner.dart';
import 'package:huixiang/retrofit/data/base_data.dart';
@ -37,18 +41,8 @@ class PointsMallPage extends StatefulWidget {
class _PointsMallPage extends State<PointsMallPage>
with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin {
var _itemText = S.current.morenpaixu;
ApiService client;
RefreshController _refreshController = RefreshController(
initialRefresh: false, initialLoadStatus: LoadStatus.canLoading);
List<String> sortString = [
S.current.morenpaixu,
// S.current.duihuanlianggaodaodi,
// S.current.duihuanliangdidaogao,
S.current.jifengaodaodi,
S.current.jifendidaogao,
];
final RefreshController _refreshController = RefreshController();
@override
void dispose() {
@ -79,7 +73,7 @@ class _PointsMallPage extends State<PointsMallPage>
bool orderDesc = true;
List<Goods> goods = [];
List<GoodsCategory> gooodsCategorys = [];
UserInfo userinfo;
UserInfo userInfo;
List<BannerData> bannerData = [];
queryUser() async {
@ -87,14 +81,18 @@ class _PointsMallPage extends State<PointsMallPage>
"model": {"type": "CREDIT_INDEX"},
});
if (banner != null) {
if (banner != null &&
banner.isSuccess &&
banner.data != null &&
banner.data.records != null &&
banner.data.records.length > 0) {
bannerData.clear();
bannerData.addAll(banner.data.records);
}
BaseData<UserInfo> baseData = await client.queryInfo();
if (baseData != null && baseData.isSuccess) {
userinfo = baseData.data;
userInfo = baseData.data;
SharedPreferences.getInstance().then((value) => {
value.setString('user', jsonEncode(baseData.data)),
});
@ -123,7 +121,11 @@ class _PointsMallPage extends State<PointsMallPage>
_refreshController.refreshFailed();
});
if (dataCategory != null && dataCategory.isSuccess) {
if (dataCategory != null &&
dataCategory.isSuccess &&
dataCategory.data != null &&
dataCategory.data.records != null &&
dataCategory.data.records.length > 0) {
gooodsCategorys.clear();
gooodsCategorys.add(GoodsCategory(name: S.of(context).quanbu));
gooodsCategorys.addAll(dataCategory.data.records);
@ -137,8 +139,8 @@ class _PointsMallPage extends State<PointsMallPage>
"pageSize": 10,
"state": 1
};
BaseData<PageInfo<Goods>> baseData =
await client.creditGoods(param).catchError((onError) {
BaseData<PageInfo<Goods>> baseData = await client.creditGoods(param)
.catchError((onError) {
_refreshController.loadFailed();
_refreshController.refreshFailed();
});
@ -193,93 +195,39 @@ class _PointsMallPage extends State<PointsMallPage>
builder: (context, snapshot) {
return Column(
children: [
banner(),
userItem(),
ItemTitle(
text: S.of(context).jifenshangcheng,
imgPath: "assets/image/icon_points_mall.png",
moreText: _itemText,
moreType: 1,
items: sortString
.map((e) => DropdownMenuItem(
value: e,
child: Text(
e,
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.medium,
color: Color(0xff353535)),
),
),
)
.toList(),
onChanged: _sortChange,
),
Container(
alignment: Alignment.centerLeft,
child: DefaultTabController(
length: gooodsCategorys == null
? 0
: gooodsCategorys.length,
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) => Tab(text: e.name))
.toList(),
onTap: (index) {
///banner
PointMallBanner(bannerData),
///
PointMallUser(userInfo),
///Tab
PointsGoodsTitle(
gooodsCategorys,
(orderType, orderDesc) {
this.orderType = orderType;
this.orderDesc = orderDesc;
setState(() {});
},
(index) {
categoryId = gooodsCategorys[index].id;
pageNum = 1;
setState(() {});;
setState(() {});
},
),
),
),
GridView.builder(
itemCount: goods == null ? 0 : goods.length,
padding: EdgeInsets.only(
left: 16.w, right: 16.w, top: 13.h, bottom: 16.h),
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
//Widget数量
crossAxisCount: 2,
//Widget之间间距
crossAxisSpacing: 11.w,
//Widget之间间距
mainAxisSpacing: 16.w,
//Widget宽高比例 0.59
childAspectRatio: 166 /
(281 / 2 +
(281 / 2) * AppUtils.textScale(context)),
),
itemBuilder: (contetx, index) {
return GestureDetector(
onTap: () {
///
PointGoods(
goods,
(index) {
_toDetails(index);
},
child: buildItem(goods[index]),
);
})
),
],
);
},
)),
),
),
),
);
}
@ -292,355 +240,7 @@ class _PointsMallPage extends State<PointsMallPage>
if (token != null && token != "") queryUser();
}
_sortChange(item) {
var index = sortString.indexOf(item);
switch (index) {
case 0:
orderType = 1;
break;
//
// case 1:
// orderType = 2;
// orderDesc = true;
// break;
// case 2:
// orderType = 2;
// orderDesc = false;
// break;
case 1:
orderType = 3;
orderDesc = true;
break;
case 2:
orderType = 3;
orderDesc = false;
break;
}
creditGoods();
setState(() {
_itemText = item;
});
}
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(
mainAxisSize: MainAxisSize.max,
children: [
MImage(
goods.mainImgPath,
aspectRatio: 1,
radius: BorderRadius.only(
topLeft: Radius.circular(4),
topRight: Radius.circular(4),
),
fit: BoxFit.cover,
errorSrc: "assets/image/default_1.png",
fadeSrc: "assets/image/default_1.png",
),
Expanded(
child: Container(
margin: EdgeInsets.only(
left: 12.w,
right: 12.w,
top: 10.h,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
goods.name,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Color(0xff353535),
fontWeight: MyFontWeight.medium,
fontSize: 16.sp,
),
),
SizedBox(
height: 5.h,
),
Container(
height: 35.h * AppUtils.textScale(context),
child: Text(
goods.description,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Color(0xFF727272),
fontWeight: MyFontWeight.regular,
fontSize: 12.sp,
),
),
),
SizedBox(
height: 4.h,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Expanded(
child: Text(
S.of(context).yuan_(goods.worth),
style: TextStyle(
color: Color(0xFF585858),
decoration: TextDecoration.lineThrough,
decorationColor: Color(0xFF585858),
fontWeight: MyFontWeight.regular,
fontSize: 12.sp,
),
),
flex: 1,
),
Text(
S.of(context).jifen_(goods.price),
style: TextStyle(
color: Color(0xFF32A060),
fontSize: 14.sp,
fontWeight: MyFontWeight.semi_bold,
),
),
],
),
],
),
),
flex: 1,
),
SizedBox(
height: 10.h,
),
],
),
Visibility(
visible: goods.isHot,
child: ClipRRect(
borderRadius: BorderRadius.only(topRight: Radius.circular(4)),
child: Image.asset(
"assets/image/icon_hot_right_top.png",
width: 36,
height: 36,
fit: BoxFit.cover,
),
),
),
],
),
);
}
Widget userItem() {
return InkWell(
onTap: () {
SharedPreferences.getInstance().then((value) {
if (value.getString("token") == null ||
value.getString("token") == "") {
Navigator.of(context)
.pushNamed('/router/login_page', arguments: {"login": "login"});
}
});
},
child: Container(
margin: EdgeInsets.all(16),
child: Row(
children: [
MImage(
userinfo != null ? userinfo.headimg : "",
width: 50,
height: 50,
isCircle: true,
fit: BoxFit.cover,
errorSrc: "assets/image/default_user.png",
fadeSrc: "assets/image/default_user.png",
),
Expanded(
child: Container(
margin: EdgeInsets.only(left: 15.w),
height: 50.h,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
userinfo == null
? Text(
S.of(context).denglu,
style: TextStyle(
fontSize: 16.sp,
fontWeight: MyFontWeight.medium,
color: Color(0xFF353535)),
)
: Row(
children: [
Text(
userinfo.nickname,
style: TextStyle(
fontSize: 16.sp,
fontWeight: MyFontWeight.medium,
color: Color(0xFF353535)),
),
SizedBox(
width: 4.w,
),
Image.asset(
"assets/image/icon_user.png",
width: 18.w,
height: 18.h,
),
],
),
SizedBox(
height: 2.h,
),
userinfo == null
? Text(
S.of(context).weidengluxinxi,
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xFF2F2F2F),
),
)
: Text(
userinfo == null ? "" : "NO.${userinfo.vipNo}",
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xFF2F2F2F),
),
),
],
),
),
flex: 1,
),
userinfo == null
? Icon(
Icons.keyboard_arrow_right,
size: 20,
color: Colors.black,
)
: Container(
margin: EdgeInsets.only(left: 15.w),
height: 50.h,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
S.of(context).yiyoujifen,
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.medium,
color: Color(0xFF4C4C4C),
),
),
SizedBox(
height: 4.h,
),
Text(
(userinfo != null) ? "${userinfo.points}" : "",
style: TextStyle(
fontSize: 16.sp,
color: Color(0xFFF8BA61),
fontWeight: FontWeight.bold,
),
),
],
),
)
],
),
),
);
}
banner() {
return Container(
margin: EdgeInsets.only(top: 16.h),
child: AspectRatio(
aspectRatio: 2.0,
child: Swiper(
pagination: SwiperPagination(
alignment: Alignment.bottomCenter,
builder: DotSwiperPaginationBuilder(
size: 8,
activeSize: 8,
space: 5,
activeColor: Colors.black,
color: Colors.black.withAlpha(76),
),
),
viewportFraction: 0.7,
scale: 0.7,
physics: BouncingScrollPhysics(),
itemBuilder: (context, position) {
return InkWell(
onTap: () {
bannerClick(bannerData[position]);
},
child: Container(
margin: EdgeInsets.only(bottom: 40.h),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
),
child: MImage(
bannerData != null && position < bannerData.length
? bannerData[position].imgUrl
: "",
radius: BorderRadius.circular(8),
fit: BoxFit.cover,
errorSrc: "assets/image/default_2_1.png",
fadeSrc: "assets/image/default_2_1.png",
),
),
);
},
itemCount: (bannerData != null && bannerData.length > 0) ? bannerData.length : 1,
),
),
);
}
/// contentType 0123
bannerClick(BannerData bannerData) async {
switch (bannerData.contentType) {
case 1:
Navigator.of(context).pushNamed('/router/integral_store_page',
arguments: {"goodsId": bannerData.content});
break;
case 2:
Navigator.of(context)
.pushNamed('/router/store_detail_page', arguments: {
"activityId": bannerData.content,
});
break;
case 3:
Navigator.of(context)
.pushNamed('/router/store_detail_page', arguments: {
"articleId": bannerData.content,
});
break;
}
}
@override
bool get wantKeepAlive => true;
}

152
lib/home/points_mall_view/point_mall_user.dart

@ -0,0 +1,152 @@
import 'package:flutter/material.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/data/user_info.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class PointMallUser extends StatefulWidget {
final UserInfo userInfo;
PointMallUser(this.userInfo);
@override
State<StatefulWidget> createState() {
return _PointMallUser();
}
}
class _PointMallUser extends State<PointMallUser> {
@override
Widget build(BuildContext context) {
return InkWell(
onTap: () {
SharedPreferences.getInstance().then((value) {
if (value.getString("token") == null ||
value.getString("token") == "") {
Navigator.of(context)
.pushNamed('/router/login_page', arguments: {"login": "login"});
}
});
},
child: Container(
margin: EdgeInsets.all(16),
child: Row(
children: [
MImage(
widget.userInfo != null ? widget.userInfo.headimg : "",
width: 50,
height: 50,
isCircle: true,
fit: BoxFit.cover,
errorSrc: "assets/image/default_user.png",
fadeSrc: "assets/image/default_user.png",
),
Expanded(
child: Container(
margin: EdgeInsets.only(left: 15.w),
height: 50.h,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
widget.userInfo == null
? Text(
S.of(context).denglu,
style: TextStyle(
fontSize: 16.sp,
fontWeight: MyFontWeight.medium,
color: Color(0xFF353535),
),
)
: Row(
children: [
Text(
widget.userInfo.nickname,
style: TextStyle(
fontSize: 16.sp,
fontWeight: MyFontWeight.medium,
color: Color(0xFF353535),
),
),
SizedBox(
width: 4.w,
),
Image.asset(
"assets/image/icon_user.png",
width: 18.w,
height: 18.h,
),
],
),
SizedBox(
height: 2.h,
),
widget.userInfo == null
? Text(
S.of(context).weidengluxinxi,
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xFF2F2F2F),
),
)
: Text(
widget.userInfo == null
? ""
: "NO.${widget.userInfo.vipNo}",
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xFF2F2F2F),
),
),
],
),
),
flex: 1,
),
widget.userInfo == null
? Icon(
Icons.keyboard_arrow_right,
size: 20,
color: Colors.black,
)
: Container(
margin: EdgeInsets.only(left: 15.w),
height: 50.h,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
S.of(context).yiyoujifen,
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.medium,
color: Color(0xFF4C4C4C),
),
),
SizedBox(
height: 4.h,
),
Text(
(widget.userInfo != null)
? "${widget.userInfo.points}"
: "",
style: TextStyle(
fontSize: 16.sp,
color: Color(0xFFF8BA61),
fontWeight: FontWeight.bold,
),
),
],
),
)
],
),
),
);
}
}

111
lib/home/points_mall_view/points_goods_title.dart

@ -0,0 +1,111 @@
import 'package:flutter/material.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/data/goods_category.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/view_widget/item_title.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class PointsGoodsTitle extends StatefulWidget {
final ValueChanged<int> onTap;
final Function(int orderType, bool orderDesc) sortChange;
final List<GoodsCategory> gooodsCategorys;
PointsGoodsTitle(this.gooodsCategorys, this.sortChange, this.onTap);
@override
State<StatefulWidget> createState() {
return _PointsGoodsTitle();
}
}
class _PointsGoodsTitle extends State<PointsGoodsTitle> {
var _itemText = S.current.morenpaixu;
List<String> sortString = [
S.current.morenpaixu,
S.current.jifengaodaodi,
S.current.jifendidaogao,
];
@override
Widget build(BuildContext context) {
return Column(
children: [
ItemTitle(
text: S.of(context).jifenshangcheng,
imgPath: "assets/image/icon_points_mall.png",
moreText: _itemText,
moreType: 1,
items: sortString
.map(
(e) => DropdownMenuItem(
value: e,
child: Text(
e,
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.medium,
color: Color(0xff353535),
),
),
),
)
.toList(),
onChanged: _sortChange,
),
Container(
alignment: Alignment.centerLeft,
child: DefaultTabController(
length: widget.gooodsCategorys == null
? 0
: widget.gooodsCategorys.length,
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: widget.gooodsCategorys == null
? []
: widget.gooodsCategorys
.map((e) => Tab(text: e.name))
.toList(),
onTap: widget.onTap,
),
),
),
],
);
}
_sortChange(item) {
var index = sortString.indexOf(item);
switch (index) {
case 0:
widget.sortChange(1, true);
break;
case 1:
widget.sortChange(3, true);
break;
case 2:
widget.sortChange(3, false);
break;
}
setState(() {
_itemText = item;
});
}
}

181
lib/home/points_mall_view/points_goods_view.dart

@ -0,0 +1,181 @@
import 'package:flutter/material.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/data/goods.dart';
import 'package:huixiang/utils/flutter_utils.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class PointGoods extends StatefulWidget {
final List<Goods> goods;
final ValueChanged onTap;
PointGoods(this.goods, this.onTap);
@override
State<StatefulWidget> createState() {
return _PointGoods();
}
}
class _PointGoods extends State<PointGoods> {
@override
Widget build(BuildContext context) {
return GridView.builder(
itemCount: widget.goods == null ? 0 : widget.goods.length,
padding: EdgeInsets.only(
left: 16.w,
right: 16.w,
top: 13.h,
bottom: 16.h,
),
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
//Widget数量
crossAxisCount: 2,
//Widget之间间距
crossAxisSpacing: 11.w,
//Widget之间间距
mainAxisSpacing: 16.w,
//Widget宽高比例 0.59
childAspectRatio:
166 / (281 / 2 + (281 / 2) * AppUtils.textScale(context)),
),
itemBuilder: (context, index) {
return GestureDetector(
onTap: () {
widget.onTap(index);
},
child: buildItem(widget.goods[index]),
);
},
);
}
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(
mainAxisSize: MainAxisSize.max,
children: [
MImage(
goods.mainImgPath,
aspectRatio: 1,
radius: BorderRadius.only(
topLeft: Radius.circular(4),
topRight: Radius.circular(4),
),
fit: BoxFit.cover,
errorSrc: "assets/image/default_1.png",
fadeSrc: "assets/image/default_1.png",
),
Expanded(
child: Container(
margin: EdgeInsets.only(
left: 12.w,
right: 12.w,
top: 10.h,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
goods.name,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Color(0xff353535),
fontWeight: MyFontWeight.medium,
fontSize: 16.sp,
),
),
SizedBox(
height: 5.h,
),
Container(
height: 35.h * AppUtils.textScale(context),
child: Text(
goods.description,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Color(0xFF727272),
fontWeight: MyFontWeight.regular,
fontSize: 12.sp,
),
),
),
SizedBox(
height: 4.h,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Expanded(
child: Text(
S.of(context).yuan_(goods.worth),
style: TextStyle(
color: Color(0xFF585858),
decoration: TextDecoration.lineThrough,
decorationColor: Color(0xFF585858),
fontWeight: MyFontWeight.regular,
fontSize: 12.sp,
),
),
flex: 1,
),
Text(
S.of(context).jifen_(goods.price),
style: TextStyle(
color: Color(0xFF32A060),
fontSize: 14.sp,
fontWeight: MyFontWeight.semi_bold,
),
),
],
),
],
),
),
flex: 1,
),
SizedBox(
height: 10.h,
),
],
),
Visibility(
visible: goods.isHot,
child: ClipRRect(
borderRadius: BorderRadius.only(topRight: Radius.circular(4)),
child: Image.asset(
"assets/image/icon_hot_right_top.png",
width: 36,
height: 36,
fit: BoxFit.cover,
),
),
),
],
),
);
}
}

99
lib/home/points_mall_view/points_mall_banner.dart

@ -0,0 +1,99 @@
import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:huixiang/retrofit/data/banner.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class PointMallBanner extends StatefulWidget {
final List<BannerData> bannerData;
PointMallBanner(this.bannerData);
@override
State<StatefulWidget> createState() {
return _PointMallBanner();
}
}
class _PointMallBanner extends State<PointMallBanner> {
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.only(top: 16.h),
child: AspectRatio(
aspectRatio: 2.0,
child: Swiper(
pagination: SwiperPagination(
alignment: Alignment.bottomCenter,
builder: DotSwiperPaginationBuilder(
size: 8,
activeSize: 8,
space: 5,
activeColor: Colors.black,
color: Colors.black.withAlpha(76),
),
),
viewportFraction: 0.7,
scale: 0.7,
physics: BouncingScrollPhysics(),
itemBuilder: (context, position) {
return InkWell(
onTap: () {
bannerClick(widget.bannerData[position]);
},
child: Container(
margin: EdgeInsets.only(bottom: 40.h),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
),
child: MImage(
widget.bannerData != null && position < widget.bannerData.length
? widget.bannerData[position].imgUrl
: "",
radius: BorderRadius.circular(8),
fit: BoxFit.cover,
errorSrc: "assets/image/default_2_1.png",
fadeSrc: "assets/image/default_2_1.png",
),
),
);
},
itemCount: (widget.bannerData != null && widget.bannerData.length > 0) ? widget.bannerData.length : 1,
),
),
);
}
/// contentType 0123
bannerClick(BannerData bannerData) async {
switch (bannerData.contentType) {
case 1:
Navigator.of(context).pushNamed('/router/integral_store_page',
arguments: {"goodsId": bannerData.content});
break;
case 2:
Navigator.of(context)
.pushNamed('/router/store_detail_page', arguments: {
"activityId": bannerData.content,
});
break;
case 3:
Navigator.of(context)
.pushNamed('/router/store_detail_page', arguments: {
"articleId": bannerData.content,
});
break;
}
}
}

510
lib/mine/mine_page.dart

@ -11,6 +11,7 @@ import 'package:huixiang/retrofit/data/rank.dart';
import 'package:huixiang/retrofit/data/user_info.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/event_type.dart';
import 'package:huixiang/utils/flutter_utils.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/view_widget/classic_header.dart';
import 'package:huixiang/view_widget/custom_image.dart';
@ -21,6 +22,10 @@ import 'package:shared_preferences/shared_preferences.dart';
import 'package:dio/dio.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'mine_view/mine_item.dart';
import 'mine_view/mine_view.dart';
import 'mine_view/order_card_view.dart';
class MinePage extends StatefulWidget {
@override
State<StatefulWidget> createState() {
@ -31,7 +36,6 @@ class MinePage extends StatefulWidget {
class _MinePage extends State<MinePage> with AutomaticKeepAliveClientMixin {
ApiService apiService;
UserInfo userinfo;
int rankLevel = 1;
List<Rank> ranks = [];
final RefreshController _refreshController = RefreshController();
@ -43,21 +47,7 @@ class _MinePage extends State<MinePage> with AutomaticKeepAliveClientMixin {
return;
}
await Navigator.of(context).pushNamed('/router/user_info_page');
setState(() {});;
}
loginTips() {
SmartDialog.show(
widget: LoginTips(
click: () {
SharedPreferences.getInstance()
.then((value) => value..setString("token", ""));
Navigator.of(context)
.pushNamed('/router/login_page', arguments: {"login": "login"});
},
),
clickBgDismissTemp: false,
);
setState(() {});
}
@override
@ -76,7 +66,7 @@ class _MinePage extends State<MinePage> with AutomaticKeepAliveClientMixin {
setState(() {});
}
if (event.type == 3) {
setState(() {});;
setState(() {});
}
});
}
@ -90,8 +80,8 @@ class _MinePage extends State<MinePage> with AutomaticKeepAliveClientMixin {
value.getString('user') != "") {
userinfo = UserInfo.fromJson(jsonDecode(value.getString('user')));
}
apiService = ApiService(Dio(), context: context,
token: value.getString('token'), showLoading: false);
apiService = ApiService(Dio(),
context: context, token: value.getString('token'), showLoading: false);
BaseData<List<Rank>> rankData = await apiService.rankList();
if (rankData != null && rankData.isSuccess) {
@ -102,14 +92,7 @@ class _MinePage extends State<MinePage> with AutomaticKeepAliveClientMixin {
BaseData<UserInfo> baseDate = await apiService.queryInfo();
if (baseDate != null && baseDate.isSuccess) {
userinfo = baseDate.data;
if (userinfo != null &&
userinfo.memberRankVo != null &&
ranks != null &&
ranks.length > 0) {
rankLevel = (ranks.indexWhere(
(element) => element.id == userinfo.memberRankVo.id) +
1);
}
SharedPreferences.getInstance().then(
(value) => {
value.setString('user', jsonEncode(baseDate.data)),
@ -150,67 +133,17 @@ class _MinePage extends State<MinePage> with AutomaticKeepAliveClientMixin {
builder: (context, snapshot) {
return Column(
children: [
Container(
margin: EdgeInsets.only(right: 16.w),
alignment: Alignment.centerRight,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
// Container(
// margin: EdgeInsets.all(8.h),
// child: Image.asset(
// "assets/image/icon_notices.png",
// width: 24.w,
// height: 24.h,
// ),
// ),
InkWell(
onTap: () {},
child: Container(
margin: EdgeInsets.all(8.h),
child: Image.asset(
"assets/image/icon_scan_qr_code.png",
width: 24.w,
height: 24.h,
),
),
),
],
),
),
InkWell(
onTap: _toUserInfo,
child: mineView(),
),
SizedBox(
height: 22.h,
///
MineView(
userinfo,
_toUserInfo,
toIntegralPage,
),
GestureDetector(
onTap: () {
SharedPreferences.getInstance().then((value) {
if (value.getString("token") == null ||
value.getString("token") == "") {
loginTips();
return;
}
Navigator.of(context).pushNamed(
'/router/mine_vip_level_page',
arguments: {
"rankLevel": rankLevel,
"createTime": (userinfo != null)
? "${userinfo.createTime}"
: "",
"points": (userinfo != null)
? int.tryParse(userinfo.points)
: 0,
});
});
},
child: Hero(
tag: "vip",
child: MineVipView(
rankLevel,
curLevel: rankLevel,
/// VIP等级信息
MineVipView(
ranks: ranks,
userInfo: userinfo,
rank: (userinfo != null)
? int.tryParse(userinfo.points)
: 0,
@ -218,17 +151,19 @@ class _MinePage extends State<MinePage> with AutomaticKeepAliveClientMixin {
userinfo.memberRankVo != null)
? userinfo.memberRankVo.rankOrigin
: 0,
createTime: (userinfo != null)
? userinfo.createTime
: "",
),
),
createTime:
(userinfo != null) ? userinfo.createTime : "",
),
orderOrCard(),
mineList(context),
///
OrderCard(),
/// item
MineItem(),
],
);
}),
},
),
// buildNotice(),
],
),
@ -312,395 +247,14 @@ class _MinePage extends State<MinePage> with AutomaticKeepAliveClientMixin {
);
}
///
Widget mineList(BuildContext context) {
return Container(
margin: EdgeInsets.fromLTRB(16.w, 10.h, 16.w, 28.h),
padding: EdgeInsets.fromLTRB(20.w, 12.h, 20.w, 12.h),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(12),
offset: Offset(0, 3),
blurRadius: 14,
spreadRadius: 0,
)
],
),
child: Column(
children: [
InkWell(
onTap: () {
SharedPreferences.getInstance().then((value) {
if (value.getString("token") == null ||
value.getString("token") == "") {
loginTips();
return;
}
Navigator.of(context).pushNamed('/router/mine_wallet');
});
},
child: mineItem(
S.of(context).wodeqianbao,
"assets/image/icon_mine_wallet.png",
),
),
InkWell(
onTap: () {
SharedPreferences.getInstance().then((value) {
if (value.getString("token") == null ||
value.getString("token") == "") {
loginTips();
return;
}
Navigator.of(context)
.pushNamed('/router/exchange_history_page');
});
},
child: mineItem(
S.of(context).duihuanlishi,
"assets/image/icon_mine_records_of_consumption.png",
),
),
InkWell(
onTap: () {
SharedPreferences.getInstance().then((value) {
if (value.getString("token") == null ||
value.getString("token") == "") {
loginTips();
return;
}
Navigator.of(context).pushNamed('/router/roll_center_page');
});
},
child: mineItem(
S.of(context).lingquanzhongxin,
"assets/image/icon_mine_invoice_assistant.png",
),
),
InkWell(
onTap: () {
SharedPreferences.getInstance().then((value) {
if (value.getString("token") == null ||
value.getString("token") == "") {
loginTips();
return;
}
Navigator.of(context).pushNamed('/router/manage_address_page');
});
},
child: mineItem(
S.of(context).guanlidizhi,
"assets/image/icon_location_address.png",
),
),
InkWell(
onTap: () {
Navigator.of(context).pushNamed('/router/setting_page');
},
child: mineItem(
S.of(context).shezhi,
"assets/image/icon_mine_setting.png",
),
),
// mineItem(
// S.of(context).bangzhuyufankui,
// "assets/image/icon_mine_feedback.png",
// ),
],
),
);
}
///
Widget mineItem(text, icon) {
return Container(
margin: EdgeInsets.only(top: 8.h, bottom: 8.h),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Image.asset(
icon,
width: 28.w,
height: 28.h,
),
SizedBox(
width: 12.w,
),
Expanded(
flex: 1,
child: Text(
text,
style: TextStyle(
fontWeight: MyFontWeight.medium,
fontSize: 16.sp,
color: Color(0xFF353535),
),
),
),
Icon(
Icons.keyboard_arrow_right,
size: 20,
color: Colors.black,
)
],
),
);
}
///
Widget orderOrCard() {
return Container(
margin: EdgeInsets.fromLTRB(16.w, 12.h, 16.w, 10.h),
padding: EdgeInsets.fromLTRB(20.w, 12.h, 20.w, 12.h),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(12),
offset: Offset(0, 3),
blurRadius: 14,
spreadRadius: 0,
)
],
),
child: Row(
children: [
Expanded(
flex: 1,
child: GestureDetector(
onTap: () {
SharedPreferences.getInstance().then((value) {
if (value.getString("token") == null ||
value.getString("token") == "") {
loginTips();
return;
}
Navigator.of(context).pushNamed('/router/mine_card');
});
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Image.asset(
"assets/image/icon_mine_card.png",
width: 32.w,
height: 32.h,
),
SizedBox(
width: 12.w,
),
Text(
S.of(context).kaquan,
style: TextStyle(
fontWeight: MyFontWeight.medium,
fontSize: 16.sp,
color: Color(0xFF353535),
),
)
],
),
),
),
Container(
width: 2.w,
height: 32.h,
margin: EdgeInsets.only(left: 20.w, right: 20.w),
color: Color(0xFFF7F7F7),
),
Expanded(
flex: 1,
child: GestureDetector(
onTap: () {
SharedPreferences.getInstance().then((value) {
if (value.getString("token") == null ||
value.getString("token") == "") {
loginTips();
return;
}
Navigator.of(context).pushNamed('/router/order_history_page');
});
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Image.asset(
"assets/image/icon_mine_order.png",
width: 32.w,
height: 32.h,
),
SizedBox(
width: 12.w,
),
Text(
S.of(context).dingdan,
style: TextStyle(
fontWeight: MyFontWeight.medium,
fontSize: 16.sp,
color: Color(0xFF353535),
),
),
],
),
),
),
],
),
);
}
///
Widget mineView() {
return Container(
alignment: Alignment.center,
margin: EdgeInsets.symmetric(horizontal: 16.w),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
MImage(
userinfo == null ? "" : userinfo.headimg,
isCircle: true,
width: 50,
height: 50,
fit: BoxFit.cover,
errorSrc: "assets/image/default_user.png",
fadeSrc: "assets/image/default_user.png",
),
SizedBox(
width: 10.w,
),
Expanded(
flex: 1,
child: Container(
height: 50.h,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
userinfo == null
? Text(
S.of(context).denglu,
style: TextStyle(
fontSize: 16.sp,
fontWeight: MyFontWeight.medium,
color: Color(0xFF353535),
),
)
: Row(
children: [
InkWell(
onTap: () {
if (userinfo == null) {
SmartDialog.show(
widget: LoginTips(
click: () {
SharedPreferences.getInstance()
.then((value) => value.clear());
Navigator.of(context).pushNamed(
'/router/login_page',
arguments: {"login": "login"});
},
),
clickBgDismissTemp: false,
);
}
},
child: Text(
userinfo == null
? S.of(context).denglu
: "${userinfo.nickname}",
style: TextStyle(
fontSize: 16.sp,
fontWeight: FontWeight.bold,
color: Color(0xFF353535),
),
),
),
Image.asset(
"assets/image/icon_user.png",
width: 18.w,
height: 18.h,
),
],
),
userinfo == null
? Text(
S.of(context).weidengluxinxi,
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xFF2F2F2F),
),
)
: Text(
userinfo == null ? "" : "NO.${userinfo.vipNo}",
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xFF2F2F2F),
),
),
],
),
),
),
userinfo == null
? Container(
alignment: Alignment.center,
height: 50.h,
child: Icon(
Icons.keyboard_arrow_right,
size: 20,
color: Colors.black,
),
)
: Container(
alignment: Alignment.bottomRight,
height: 50.h,
child: GestureDetector(
onTap: () {
toIntegralPage();
},
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Text(
S.of(context).jifenxiangqing,
style: TextStyle(
color: Colors.black,
fontSize: 12.sp,
fontWeight: MyFontWeight.semi_bold,
),
),
Icon(
Icons.keyboard_arrow_right,
size: 16,
color: Colors.black,
)
],
),
),
),
],
),
);
}
toIntegralPage() async {
SharedPreferences shared = await SharedPreferences.getInstance();
if (shared.getString("token") == null || shared.getString("token") == "") {
loginTips();
AppUtils.loginTips(context);
return;
}
await Navigator.of(context).pushNamed('/router/integral_page');
setState(() {});;
setState(() {});
}
@override

158
lib/mine/mine_view/mine_item.dart

@ -0,0 +1,158 @@
import 'package:flutter/material.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/utils/flutter_utils.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class MineItem extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return _MineItem();
}
}
class _MineItem extends State<MineItem> {
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.fromLTRB(16.w, 10.h, 16.w, 28.h),
padding: EdgeInsets.fromLTRB(20.w, 12.h, 20.w, 12.h),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(12),
offset: Offset(0, 3),
blurRadius: 14,
spreadRadius: 0,
)
],
),
child: Column(
children: [
InkWell(
onTap: () {
SharedPreferences.getInstance().then((value) {
if (value.getString("token") == null ||
value.getString("token") == "") {
AppUtils.loginTips(context);
return;
}
Navigator.of(context).pushNamed('/router/mine_wallet');
});
},
child: mineItem(
S.of(context).wodeqianbao,
"assets/image/icon_mine_wallet.png",
),
),
InkWell(
onTap: () {
SharedPreferences.getInstance().then((value) {
if (value.getString("token") == null ||
value.getString("token") == "") {
AppUtils.loginTips(context);
return;
}
Navigator.of(context)
.pushNamed('/router/exchange_history_page');
});
},
child: mineItem(
S.of(context).duihuanlishi,
"assets/image/icon_mine_records_of_consumption.png",
),
),
InkWell(
onTap: () {
SharedPreferences.getInstance().then((value) {
if (value.getString("token") == null ||
value.getString("token") == "") {
AppUtils.loginTips(context);
return;
}
Navigator.of(context).pushNamed('/router/roll_center_page');
});
},
child: mineItem(
S.of(context).lingquanzhongxin,
"assets/image/icon_mine_invoice_assistant.png",
),
),
InkWell(
onTap: () {
SharedPreferences.getInstance().then((value) {
if (value.getString("token") == null ||
value.getString("token") == "") {
AppUtils.loginTips(context);
return;
}
Navigator.of(context).pushNamed('/router/manage_address_page');
});
},
child: mineItem(
S.of(context).guanlidizhi,
"assets/image/icon_location_address.png",
),
),
InkWell(
onTap: () {
Navigator.of(context).pushNamed('/router/setting_page');
},
child: mineItem(
S.of(context).shezhi,
"assets/image/icon_mine_setting.png",
),
),
// mineItem(
// S.of(context).bangzhuyufankui,
// "assets/image/icon_mine_feedback.png",
// ),
],
),
);
}
///
Widget mineItem(text, icon) {
return Container(
margin: EdgeInsets.only(top: 8.h, bottom: 8.h),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Image.asset(
icon,
width: 28.w,
height: 28.h,
),
SizedBox(
width: 12.w,
),
Expanded(
flex: 1,
child: Text(
text,
style: TextStyle(
fontWeight: MyFontWeight.medium,
fontSize: 16.sp,
color: Color(0xFF353535),
),
),
),
Icon(
Icons.keyboard_arrow_right,
size: 20,
color: Colors.black,
)
],
),
);
}
}

184
lib/mine/mine_view/mine_view.dart

@ -0,0 +1,184 @@
import 'package:flutter/material.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/data/user_info.dart';
import 'package:huixiang/utils/flutter_utils.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class MineView extends StatefulWidget {
final UserInfo userInfo;
final Function toUserInfo;
final Function toIntegralPage;
MineView(this.userInfo, this.toUserInfo, this.toIntegralPage);
@override
State<StatefulWidget> createState() {
return _MineView();
}
}
class _MineView extends State<MineView> {
@override
Widget build(BuildContext context) {
return Column(
children: [
Container(
margin: EdgeInsets.only(right: 16.w),
alignment: Alignment.centerRight,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
InkWell(
onTap: () {},
child: Container(
margin: EdgeInsets.all(8.h),
child: Image.asset(
"assets/image/icon_scan_qr_code.png",
width: 24.w,
height: 24.h,
),
),
),
],
),
),
InkWell(
onTap: widget.toUserInfo,
child: mineView(),
),
SizedBox(
height: 22.h,
),
],
);
}
///
Widget mineView() {
return Container(
alignment: Alignment.center,
margin: EdgeInsets.symmetric(horizontal: 16.w),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
MImage(
widget.userInfo == null ? "" : widget.userInfo.headimg,
isCircle: true,
width: 50,
height: 50,
fit: BoxFit.cover,
errorSrc: "assets/image/default_user.png",
fadeSrc: "assets/image/default_user.png",
),
SizedBox(
width: 10.w,
),
Expanded(
flex: 1,
child: Container(
height: 50.h,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
widget.userInfo == null
? Text(
S.of(context).denglu,
style: TextStyle(
fontSize: 16.sp,
fontWeight: MyFontWeight.medium,
color: Color(0xFF353535),
),
)
: Row(
children: [
InkWell(
onTap: () {
if (widget.userInfo == null) {
AppUtils.loginTips(context);
}
},
child: Text(
widget.userInfo == null
? S.of(context).denglu
: "${widget.userInfo.nickname}",
style: TextStyle(
fontSize: 16.sp,
fontWeight: FontWeight.bold,
color: Color(0xFF353535),
),
),
),
Image.asset(
"assets/image/icon_user.png",
width: 18.w,
height: 18.h,
),
],
),
widget.userInfo == null
? Text(
S.of(context).weidengluxinxi,
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xFF2F2F2F),
),
)
: Text(
widget.userInfo == null
? ""
: "NO.${widget.userInfo.vipNo}",
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xFF2F2F2F),
),
),
],
),
),
),
widget.userInfo == null
? Container(
alignment: Alignment.center,
height: 50.h,
child: Icon(
Icons.keyboard_arrow_right,
size: 20,
color: Colors.black,
),
)
: Container(
alignment: Alignment.bottomRight,
height: 50.h,
child: GestureDetector(
onTap: widget.toIntegralPage(),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Text(
S.of(context).jifenxiangqing,
style: TextStyle(
color: Colors.black,
fontSize: 12.sp,
fontWeight: MyFontWeight.semi_bold,
),
),
Icon(
Icons.keyboard_arrow_right,
size: 16,
color: Colors.black,
)
],
),
),
),
],
),
);
}
}

121
lib/mine/mine_view/order_card_view.dart

@ -0,0 +1,121 @@
import 'package:flutter/material.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/utils/flutter_utils.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class OrderCard extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return _OrderCard();
}
}
class _OrderCard extends State<OrderCard> {
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.fromLTRB(16.w, 12.h, 16.w, 10.h),
padding: EdgeInsets.fromLTRB(20.w, 12.h, 20.w, 12.h),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(12),
offset: Offset(0, 3),
blurRadius: 14,
spreadRadius: 0,
)
],
),
child: Row(
children: [
Expanded(
flex: 1,
child: GestureDetector(
onTap: () {
SharedPreferences.getInstance().then((value) {
if (value.getString("token") == null ||
value.getString("token") == "") {
AppUtils.loginTips(context);
return;
}
Navigator.of(context).pushNamed('/router/mine_card');
});
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Image.asset(
"assets/image/icon_mine_card.png",
width: 32.w,
height: 32.h,
),
SizedBox(
width: 12.w,
),
Text(
S.of(context).kaquan,
style: TextStyle(
fontWeight: MyFontWeight.medium,
fontSize: 16.sp,
color: Color(0xFF353535),
),
)
],
),
),
),
Container(
width: 2.w,
height: 32.h,
margin: EdgeInsets.only(left: 20.w, right: 20.w),
color: Color(0xFFF7F7F7),
),
Expanded(
flex: 1,
child: GestureDetector(
onTap: () {
SharedPreferences.getInstance().then((value) {
if (value.getString("token") == null ||
value.getString("token") == "") {
AppUtils.loginTips(context);
return;
}
Navigator.of(context).pushNamed('/router/order_history_page');
});
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Image.asset(
"assets/image/icon_mine_order.png",
width: 32.w,
height: 32.h,
),
SizedBox(
width: 12.w,
),
Text(
S.of(context).dingdan,
style: TextStyle(
fontWeight: MyFontWeight.medium,
fontSize: 16.sp,
color: Color(0xFF353535),
),
),
],
),
),
),
],
),
);
}
}

21
lib/mine/mine_vip_level_page.dart

@ -74,32 +74,17 @@ class _MineVipLevelPage extends State<MineVipLevelPage> {
physics: BouncingScrollPhysics(),
controller: controller,
itemBuilder: (context, position) {
if (widget.arguments["rankLevel"] == (position + 1) || !(ranks != null && ranks.isNotEmpty)) {
return Hero(
tag: "vip",
child: MineVipView(
!(ranks != null && ranks.isNotEmpty) ? widget.arguments["rankLevel"] : position + 1,
return MineVipView(
vipLevel: !(ranks != null && ranks.isNotEmpty) ? widget.arguments["rankLevel"] : position + 1,
curLevel: widget.arguments["rankLevel"],
tag: (widget.arguments["rankLevel"] == (position + 1) || !(ranks != null && ranks.isNotEmpty)) ? "vip" : "",
padding: 6.w,
rank: !(ranks != null && ranks.isNotEmpty) ? 0 : widget.arguments["points"],
rankMax: !(ranks != null && ranks.isNotEmpty) ? 0 : (position < (ranks.length - 1))
? ranks[position + 1].rankOrigin
: ranks[position].rankOrigin,
createTime: widget.arguments["createTime"],
),
);
} else {
return MineVipView(
position + 1,
curLevel: widget.arguments["rankLevel"],
padding: 6.w,
rank: widget.arguments["points"],
rankMax: (position < (ranks.length - 1))
? ranks[position + 1].rankOrigin
: ranks[position].rankOrigin,
createTime: widget.arguments["createTime"],
);
}
},
itemCount: (ranks != null && ranks.isNotEmpty) ? ranks.length : 1,
),

17
lib/utils/flutter_utils.dart

@ -3,8 +3,11 @@ import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart';
import 'package:flutter_baidu_mapapi_utils/flutter_baidu_mapapi_utils.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:huixiang/view_widget/login_tips.dart';
import 'package:intl/intl.dart';
import 'package:path_provider/path_provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
class AppUtils {
@ -21,6 +24,20 @@ class AppUtils {
return textScaleFactor > 1.15 ? 1.15 : textScaleFactor;
}
static void loginTips(context) {
SmartDialog.show(
widget: LoginTips(
click: () {
SharedPreferences.getInstance()
.then((value) => value.setString("token", ""));
Navigator.of(context)
.pushNamed('/router/login_page', arguments: {"login": "login"});
},
),
clickBgDismissTemp: false,
);
}
static String getAge(DateTime brt) {
int age = 0;

52
lib/view_widget/mine_vip_view.dart

@ -1,19 +1,29 @@
import 'package:flutter/material.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:huixiang/retrofit/data/rank.dart';
import 'package:huixiang/retrofit/data/user_info.dart';
import 'package:huixiang/utils/flutter_utils.dart';
import 'package:shared_preferences/shared_preferences.dart';
class MineVipView extends StatelessWidget {
final int vipLevel;
final int curLevel;
int vipLevel;
int curLevel;
final int rankMax;
final int rank;
final String createTime;
final String tag;
final double padding;
final UserInfo userInfo;
final List<Rank> ranks;
MineVipView(
this.vipLevel, {
MineVipView({
this.vipLevel,
this.ranks,
this.tag = "",
this.userInfo,
this.padding = 16,
this.curLevel,
this.curLevel = 1,
this.rankMax = 0,
this.rank = 0,
this.createTime = "",
@ -31,6 +41,16 @@ class MineVipView extends StatelessWidget {
Color levelColor = Color(0xFF558B87);
Color textColor = Colors.white;
if (userInfo != null &&
userInfo.memberRankVo != null &&
ranks != null &&
ranks.length > 0) {
curLevel = (ranks.indexWhere(
(element) => element.id == userInfo.memberRankVo.id) +
1);
vipLevel = curLevel;
}
if (curLevel == vipLevel) {
topLeft = S.of(context).dangqiandengji;
} else if (vipLevel < curLevel) {
@ -92,7 +112,25 @@ class MineVipView extends StatelessWidget {
break;
}
}
return Container(
return GestureDetector(
onTap: () {
SharedPreferences.getInstance().then((value) {
if (value.getString("token") == null ||
value.getString("token") == "") {
AppUtils.loginTips(context);
return;
}
Navigator.of(context)
.pushNamed('/router/mine_vip_level_page', arguments: {
"rankLevel": curLevel,
"createTime": (userInfo != null) ? "${userInfo.createTime}" : "",
"points": (userInfo != null) ? int.tryParse(userInfo.points) : 0,
});
});
},
child: Hero(
tag: tag,
child: Container(
margin: EdgeInsets.fromLTRB(padding.w, 16.h, padding.w, 8.h),
width: MediaQuery.of(context).size.width - 32.w,
height: 200.h,
@ -256,6 +294,8 @@ class MineVipView extends StatelessWidget {
),
],
),
),
),
);
}
}

Loading…
Cancel
Save