Browse Source

Merge branch 'master' into dev

# Conflicts:
#	lib/mine/vip_card_page.dart
master
w-R 3 years ago
parent
commit
26e55abdcd
  1. 10
      ios/Podfile.lock
  2. 27
      lib/home/activity_list_page.dart
  3. 599
      lib/home/home_page.dart
  4. 84
      lib/home/home_view/brand_view.dart
  5. 143
      lib/home/home_view/founder_store.dart
  6. 101
      lib/home/home_view/home_banner.dart
  7. 205
      lib/home/home_view/home_integral_store.dart
  8. 68
      lib/home/home_view/hot_article.dart
  9. 109
      lib/home/home_view/sign_view.dart
  10. 409
      lib/home/huixiang_brand_page.dart
  11. 94
      lib/home/huixiang_view/huixiang_banner.dart
  12. 306
      lib/home/huixiang_view/origin_info.dart
  13. 2
      lib/home/main_home_page.dart
  14. 499
      lib/home/points_mall_page.dart
  15. 152
      lib/home/points_mall_view/point_mall_user.dart
  16. 111
      lib/home/points_mall_view/points_goods_title.dart
  17. 181
      lib/home/points_mall_view/points_goods_view.dart
  18. 99
      lib/home/points_mall_view/points_mall_banner.dart
  19. 5
      lib/main.dart
  20. 546
      lib/mine/mine_page.dart
  21. 159
      lib/mine/mine_view/mine_item.dart
  22. 189
      lib/mine/mine_view/mine_view.dart
  23. 122
      lib/mine/mine_view/order_card_view.dart
  24. 21
      lib/mine/mine_vip_level_page.dart
  25. 56
      lib/mine/vip_card_page.dart
  26. 27
      lib/retrofit/retrofit_api.dart
  27. 1
      lib/union/union_page.dart
  28. 1
      lib/utils/flutter_utils.dart
  29. 2
      lib/view_widget/custom_image.dart
  30. 50
      lib/view_widget/login_tips_dialog.dart
  31. 53
      lib/view_widget/mine_vip_view.dart
  32. 1
      lib/view_widget/store_title_tab.dart
  33. 7
      pubspec.lock
  34. 2
      pubspec.yaml

10
ios/Podfile.lock

@ -7,6 +7,7 @@ PODS:
- BaiduMapKit/Utils (6.2.0):
- BaiduMapKit/Base
- BMKLocationKit (2.0.0)
- Bugly (2.5.90)
- Flutter (1.0.0)
- flutter_baidu_mapapi_base (2.0.0):
- BaiduMapKit/Utils (= 6.2.0)
@ -26,6 +27,9 @@ PODS:
- flutter_bmflocation (1.0.3):
- BMKLocationKit
- Flutter
- flutter_bugly (0.0.1):
- Bugly
- Flutter
- fluwx (0.0.1):
- Flutter
- WechatOpenSDK (= 1.8.7.1)
@ -104,6 +108,7 @@ DEPENDENCIES:
- flutter_baidu_mapapi_search (from `.symlinks/plugins/flutter_baidu_mapapi_search/ios`)
- flutter_baidu_mapapi_utils (from `.symlinks/plugins/flutter_baidu_mapapi_utils/ios`)
- flutter_bmflocation (from `.symlinks/plugins/flutter_bmflocation/ios`)
- flutter_bugly (from `.symlinks/plugins/flutter_bugly/ios`)
- fluwx (from `.symlinks/plugins/fluwx/ios`)
- image_cropper (from `.symlinks/plugins/image_cropper/ios`)
- image_picker (from `.symlinks/plugins/image_picker/ios`)
@ -124,6 +129,7 @@ SPEC REPOS:
trunk:
- BaiduMapKit
- BMKLocationKit
- Bugly
- FMDB
- mob_sharesdk
- MOBFoundation
@ -145,6 +151,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/flutter_baidu_mapapi_utils/ios"
flutter_bmflocation:
:path: ".symlinks/plugins/flutter_bmflocation/ios"
flutter_bugly:
:path: ".symlinks/plugins/flutter_bugly/ios"
fluwx:
:path: ".symlinks/plugins/fluwx/ios"
image_cropper:
@ -177,12 +185,14 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
BaiduMapKit: 907c6d9b74f66c3ff4741fc4b568ae0b339917f8
BMKLocationKit: 097814ef672b1e57e86e6c1968d7892fb78002bf
Bugly: 88bc32c0acc6fef7b74d610f0319ee7560d6b9fe
Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c
flutter_baidu_mapapi_base: 90fddba11ec4435406a7211d6ee905b4311c31db
flutter_baidu_mapapi_map: 771bf00671832b1fcddb17733518cd631529df16
flutter_baidu_mapapi_search: 4cffaa74e739a4114595c4f82f790e1783bb612d
flutter_baidu_mapapi_utils: a5bd582b91ecd35be1bc45558b38f49d5684f70a
flutter_bmflocation: 12f1ba91bae4b16d78d4f475023e0254ed351f1c
flutter_bugly: c9800f4d5bc5bdc27ffdde3417a26ba44266e0c3
fluwx: 07a55ed66bf3a4961e836a2a411b02dcada32902
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
image_cropper: f1668dd8d2cad2d357955caad15a40547856edcb

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),
),
);
},
),
);
}
}

109
lib/home/home_view/sign_view.dart

@ -0,0 +1,109 @@
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:huixiang/view_widget/login_tips_dialog.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') == "") {
LoginTipsDialog().show(context);
} else {
Navigator.of(context).pushNamed('/router/integral_page');
}
});
},
),
InkWell(
onTap: () {
SharedPreferences.getInstance().then((value) {
if (value.getString('token') == null ||
value.getString('token') == "") {
LoginTipsDialog().show(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,
),
),
],
),
);
}
}

409
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);
@ -87,7 +89,6 @@ class _BrandPage extends State<BrandPage>
}
EasyLoading.dismiss();
refreshController.refreshCompleted();
print("huixiang_______");
if (mounted) setState(() {});
}
@ -103,7 +104,6 @@ class _BrandPage extends State<BrandPage>
});
queryHome();
}
@override
@ -171,8 +171,10 @@ class _BrandPage extends State<BrandPage>
List<Widget> homeChildItem() {
var widgets = <Widget>[
banner(),
buildInfo(),
///banner
HuiXiangBanner(bannerData),
///
OriginInfo(brandData),
StoreTitleTab(
brands,
globaKeys,
@ -182,7 +184,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 +203,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(() {

499
lib/home/points_mall_page.dart

@ -4,9 +4,11 @@ import 'dart:ui';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
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';
@ -16,14 +18,9 @@ import 'package:huixiang/retrofit/data/page.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';
import 'package:huixiang/view_widget/item_title.dart';
import 'package:huixiang/view_widget/my_footer.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:dio/dio.dart';
import 'package:shared_preferences/shared_preferences.dart';
@ -37,18 +34,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 +66,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 +74,20 @@ 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();
BaseData<UserInfo> baseData = await client.queryInfo().catchError((onError){
});
if (baseData != null && baseData.isSuccess) {
userinfo = baseData.data;
userInfo = baseData.data;
SharedPreferences.getInstance().then((value) => {
value.setString('user', jsonEncode(baseData.data)),
});
@ -123,7 +116,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 +134,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 +190,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 +235,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;
}
}
}

5
lib/main.dart

@ -6,6 +6,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bmflocation/bdmap_location_flutter_plugin.dart';
import 'package:flutter_bugly/flutter_bugly.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:huixiang/address/address_map_page.dart';
@ -87,7 +88,11 @@ void main() async {
initSdk();
bool isFirst = sharedPreferences.getBool("isFirst");
print("isFirst:$isFirst");
FlutterBugly.postCatchedException((){
runApp(MyApp(locale, isFirst));
});
FlutterBugly.init(androidAppId: "204f207673",iOSAppId: "8bb92ba0f6");
}
XgFlutterPlugin xgFlutterPlugin = XgFlutterPlugin();

546
lib/mine/mine_page.dart

@ -11,16 +11,22 @@ 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';
import 'package:huixiang/view_widget/login_tips.dart';
import 'package:huixiang/view_widget/login_tips_dialog.dart';
import 'package:huixiang/view_widget/mine_vip_view.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
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() {
@ -30,8 +36,7 @@ class MinePage extends StatefulWidget {
class _MinePage extends State<MinePage> with AutomaticKeepAliveClientMixin {
ApiService apiService;
UserInfo userinfo;
int rankLevel = 1;
UserInfo userInfo;
List<Rank> ranks = [];
final RefreshController _refreshController = RefreshController();
@ -43,21 +48,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 +67,7 @@ class _MinePage extends State<MinePage> with AutomaticKeepAliveClientMixin {
setState(() {});
}
if (event.type == 3) {
setState(() {});;
setState(() {});
}
});
}
@ -88,28 +79,28 @@ class _MinePage extends State<MinePage> with AutomaticKeepAliveClientMixin {
if (value.containsKey('user') &&
value.getString('user') != null &&
value.getString('user') != "") {
userinfo = UserInfo.fromJson(jsonDecode(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();
BaseData<List<Rank>> rankData =
await apiService.rankList().catchError((onError) {
_refreshController.refreshFailed();
});
if (rankData != null && rankData.isSuccess) {
ranks.clear();
ranks.addAll(rankData.data);
}
BaseData<UserInfo> baseDate = await apiService.queryInfo();
BaseData<UserInfo> baseDate =
await apiService.queryInfo().catchError((onError) {
_refreshController.refreshFailed();
});
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);
}
userInfo = baseDate.data;
SharedPreferences.getInstance().then(
(value) => {
value.setString('user', jsonEncode(baseDate.data)),
@ -150,85 +141,41 @@ 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,
),
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,
});
});
///
MineView(
userInfo,
() {
_toUserInfo();
},
child: Hero(
tag: "vip",
child: MineVipView(
rankLevel,
curLevel: rankLevel,
rank: (userinfo != null)
? int.tryParse(userinfo.points)
() {
toIntegralPage();
},
),
/// VIP等级信息
MineVipView(
ranks: ranks,
userInfo: userInfo,
rank: (userInfo != null)
? int.tryParse(userInfo.points)
: 0,
rankMax: (userinfo != null &&
userinfo.memberRankVo != null)
? userinfo.memberRankVo.rankOrigin
rankMax: (userInfo != null &&
userInfo.memberRankVo != null)
? userInfo.memberRankVo.rankOrigin
: 0,
createTime: (userinfo != null)
? userinfo.createTime
: "",
createTime:
(userInfo != null) ? userInfo.createTime : "",
),
),
),
orderOrCard(),
mineList(context),
///
OrderCard(),
/// item
MineItem(),
],
);
}),
},
),
// buildNotice(),
],
),
@ -274,7 +221,8 @@ class _MinePage extends State<MinePage> with AutomaticKeepAliveClientMixin {
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 12.sp,
color: Colors.black),
color: Colors.black,
),
),
Icon(
Icons.keyboard_arrow_right,
@ -298,7 +246,6 @@ class _MinePage extends State<MinePage> with AutomaticKeepAliveClientMixin {
)
],
shape: BoxShape.circle,
// borderRadius: BorderRadius.all(Radius.circular(2)),
),
child: Image.asset(
"assets/image/icon_mine_motorcycle.png",
@ -312,395 +259,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();
LoginTipsDialog().show(context);
return;
}
await Navigator.of(context).pushNamed('/router/integral_page');
setState(() {});;
setState(() {});
}
@override

159
lib/mine/mine_view/mine_item.dart

@ -0,0 +1,159 @@
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/login_tips_dialog.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") == "") {
LoginTipsDialog().show(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") == "") {
LoginTipsDialog().show(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") == "") {
LoginTipsDialog().show(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") == "") {
LoginTipsDialog().show(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,
)
],
),
);
}
}

189
lib/mine/mine_view/mine_view.dart

@ -0,0 +1,189 @@
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';
import 'package:huixiang/view_widget/login_tips_dialog.dart';
class MineView extends StatefulWidget {
final UserInfo userInfo;
final GestureTapCallback toUserInfo;
final GestureTapCallback 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) {
LoginTipsDialog().show(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,
)
],
),
),
),
],
),
);
}
}

122
lib/mine/mine_view/order_card_view.dart

@ -0,0 +1,122 @@
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/login_tips_dialog.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") == "") {
LoginTipsDialog().show(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") == "") {
LoginTipsDialog().show(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,
),

56
lib/mine/vip_card_page.dart

@ -32,7 +32,8 @@ class _VipCardPage extends State<VipCardPage> {
_refreshController = RefreshController();
SharedPreferences.getInstance().then((value) {
apiService = ApiService(Dio(), context: context, token: value.getString("token"));
apiService =
ApiService(Dio(), context: context, token: value.getString("token"));
queryVipCard();
});
}
@ -40,7 +41,8 @@ class _VipCardPage extends State<VipCardPage> {
List<VipCard> coupons = [];
queryVipCard() async {
BaseData<List<VipCard>> baseData = await apiService.vipList({}).catchError((error) {
BaseData<List<VipCard>> baseData =
await apiService.vipList({}).catchError((error) {
_refreshController.refreshFailed();
});
if (baseData != null && baseData.isSuccess) {
@ -70,19 +72,22 @@ class _VipCardPage extends State<VipCardPage> {
controller: _refreshController,
onRefresh: queryVipCard,
physics: BouncingScrollPhysics(),
child: (coupons != null && coupons.length > 0) ? ListView.builder(
child: (coupons != null && coupons.length > 0)
? ListView.builder(
padding: EdgeInsets.symmetric(vertical: 8.h),
itemBuilder: (context, position) {
return GestureDetector(
onTap: () {
Navigator.of(context).pushNamed('/router/vip_details_page',
Navigator.of(context).pushNamed(
'/router/vip_details_page',
arguments: {"id": coupons[position].id});
},
child: vipCardItem(coupons[position]),
);
},
itemCount: coupons != null ? coupons.length : 0,
) : NoDataView(
)
: NoDataView(
isShowBtn: false,
text: "还没有会员卡~",
fontSize: 16.sp,
@ -107,7 +112,7 @@ class _VipCardPage extends State<VipCardPage> {
Widget vipCardItem(VipCard vipCard) {
return Container(
margin: EdgeInsets.fromLTRB(16.w, 8.h, 16.w, 8.h),
margin: EdgeInsets.symmetric(horizontal: 16.w, vertical: 8.h),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.w),
color: Colors.white,
@ -118,7 +123,8 @@ class _VipCardPage extends State<VipCardPage> {
blurRadius: 14,
spreadRadius: 0,
)
],),
],
),
child: Stack(
children: [
Positioned(
@ -144,7 +150,9 @@ class _VipCardPage extends State<VipCardPage> {
Row(
children: [
MImage(
(vipCard?.storeList?.length ?? 0) > 0 ? vipCard.storeList[0].logo : "",
(vipCard?.storeList?.length ?? 0) > 0
? vipCard.storeList[0].logo
: "",
width: 54,
height: 54,
fit: BoxFit.cover,
@ -185,7 +193,8 @@ class _VipCardPage extends State<VipCardPage> {
],
),
Text.rich(
TextSpan(children: [
TextSpan(
children: [
TextSpan(
text: S.of(context).huiyuanka,
style: TextStyle(
@ -194,7 +203,8 @@ class _VipCardPage extends State<VipCardPage> {
color: Colors.black,
),
),
],),
],
),
textDirection: TextDirection.ltr,
),
],
@ -214,16 +224,18 @@ class _VipCardPage extends State<VipCardPage> {
size: 24,
),
Text.rich(
TextSpan(children: [
TextSpan(
children: [
TextSpan(
text: S.of(context).chakanxiangqing,
style: TextStyle(
fontSize: 12.sp,
fontWeight: FontWeight.bold,
fontWeight: MyFontWeight.semi_bold,
color: Colors.black,
),
),
],),
],
),
),
],
),
@ -237,7 +249,8 @@ class _VipCardPage extends State<VipCardPage> {
Expanded(
flex: 1,
child: Text.rich(
TextSpan(children: [
TextSpan(
children: [
TextSpan(
text: "No.${vipCard.id}",
style: TextStyle(
@ -246,11 +259,13 @@ class _VipCardPage extends State<VipCardPage> {
color: Colors.black,
),
),
],),
],
),
),
),
Text.rich(
TextSpan(children: [
TextSpan(
children: [
TextSpan(
text: S.of(context).youxiaoqixian,
style: TextStyle(
@ -259,10 +274,12 @@ class _VipCardPage extends State<VipCardPage> {
color: Color(0Xff353535),
),
),
],),
],
),
),
Text.rich(
TextSpan(children: [
TextSpan(
children: [
TextSpan(
text: S.of(context).changqiyouxiao,
style: TextStyle(
@ -271,7 +288,8 @@ class _VipCardPage extends State<VipCardPage> {
color: Color(0Xff353535),
),
),
],),
],
),
),
],
),

27
lib/retrofit/retrofit_api.dart

@ -13,7 +13,9 @@ import 'package:huixiang/retrofit/data/article.dart';
import 'package:huixiang/retrofit/data/base_data.dart';
import 'package:huixiang/retrofit/data/coupon.dart';
import 'package:huixiang/retrofit/data/order_info.dart';
import 'package:huixiang/utils/flutter_utils.dart';
import 'package:huixiang/view_widget/login_tips.dart';
import 'package:huixiang/view_widget/login_tips_dialog.dart';
import 'package:retrofit/retrofit.dart';
import 'package:shared_preferences/shared_preferences.dart';
@ -49,6 +51,7 @@ const baseUrl = "https://pos.platform.lotus-wallet.com/app/"; ///正式
@RestApi(baseUrl: baseUrl)
abstract class ApiService {
factory ApiService(Dio dio,
{String baseUrl,
BuildContext context,
@ -89,24 +92,14 @@ abstract class ApiService {
debugPrint("code = ${response.statusCode}");
p(jsonEncode(response.data));
Map map = response.data;
if (map["code"] != 0) {
EasyLoading.dismiss();
}
if (map["code"] == 40005 || map["code"] == 40001) {
SmartDialog.show(
widget: LoginTips(
click: () {
SharedPreferences.getInstance().then((value) {
value.setString("token", "");
value.setString("user", "");
value.setString("userJson", "");
value.setString("userId", "");
value.setString("mobile", "");
value.setString("nick", "");
});
Navigator.of(context).pushNamed('/router/login_page',
arguments: {"login": "login"});
},
),
clickBgDismissTemp: false,
);
if (!LoginTipsDialog().isShow) {
print("show: ${LoginTipsDialog().isShow}");
LoginTipsDialog().show(context);
}
} else if (map["code"] != 0 && response.request.baseUrl == baseUrl) {
///poi服务请求不需要toast
SmartDialog.showToast(map["msg"], alignment: Alignment.center);

1
lib/union/union_page.dart

@ -112,6 +112,7 @@ class _UnionPage extends State<UnionPage>
"union: Location result ${value.latitude} "
"${value.longitude}",
);
Location.getInstance().stopLocation();
queryStore(
"${value.latitude}",
"${value.longitude}",

1
lib/utils/flutter_utils.dart

@ -21,7 +21,6 @@ class AppUtils {
return textScaleFactor > 1.15 ? 1.15 : textScaleFactor;
}
static String getAge(DateTime brt) {
int age = 0;
DateTime dateTime = DateTime.now();

2
lib/view_widget/custom_image.dart

@ -13,7 +13,7 @@ class MImage extends StatelessWidget {
final BoxFit fit;
final bool isCircle;
double scaleIndex = 3.5;
double scaleIndex = 2.5;
MImage(
this.src, {

50
lib/view_widget/login_tips_dialog.dart

@ -0,0 +1,50 @@
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'login_tips.dart';
class LoginTipsDialog {
static LoginTipsDialog _instance;
factory LoginTipsDialog() {
if (_instance == null) {
_instance = LoginTipsDialog._internal();
}
return _instance;
}
LoginTipsDialog._internal();
bool isShow = false;
show(context) {
SmartDialog.dismiss();
isShow = true;
SmartDialog.show(
widget: LoginTips(
click: () {
SharedPreferences.getInstance().then((value) {
value.setString("token", "");
value.setString("user", "");
value.setString("userJson", "");
value.setString("userId", "");
value.setString("mobile", "");
value.setString("nick", "");
});
Navigator.of(context).pushNamed('/router/login_page',
arguments: {"login": "login"});
},
),
onDismiss: (){
isShow = false;
},
clickBgDismissTemp: false,
);
}
}

53
lib/view_widget/mine_vip_view.dart

@ -1,19 +1,30 @@
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:huixiang/view_widget/login_tips_dialog.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 = 1,
this.ranks,
this.tag = "",
this.userInfo,
this.padding = 16,
this.curLevel,
this.curLevel = 1,
this.rankMax = 0,
this.rank = 0,
this.createTime = "",
@ -31,6 +42,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 +113,25 @@ class MineVipView extends StatelessWidget {
break;
}
}
return Container(
return GestureDetector(
onTap: () {
SharedPreferences.getInstance().then((value) {
if (value.getString("token") == null ||
value.getString("token") == "") {
LoginTipsDialog().show(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 +295,8 @@ class MineVipView extends StatelessWidget {
),
],
),
),
),
);
}
}

1
lib/view_widget/store_title_tab.dart

@ -165,7 +165,6 @@ class _StoreTitleTab extends State<StoreTitleTab> {
int clickIndex = -1;
Widget item(Brand text, isSelected, index) {
print("selectedIndex: $selectedIndex");
return GestureDetector(
onTap: () {
FlexParentData parentData = widget.globaKeys[index].currentContext.findRenderObject().parentData;

7
pubspec.lock

@ -321,6 +321,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.4"
flutter_bugly:
dependency: "direct main"
description:
name: flutter_bugly
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.3.3"
flutter_cache_manager:
dependency: transitive
description:

2
pubspec.yaml

@ -92,6 +92,8 @@ dependencies:
rive: ^0.6.8
flare_flutter: ^3.0.2
flutter_bugly: ^0.3.3
dev_dependencies:
flutter_test:
sdk: flutter

Loading…
Cancel
Save