diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 8d00ae52..1d24a7a8 100644 --- a/ios/Podfile.lock +++ b/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 diff --git a/lib/home/activity_list_page.dart b/lib/home/activity_list_page.dart index 37db22d1..fd388ad7 100644 --- a/lib/home/activity_list_page.dart +++ b/lib/home/activity_list_page.dart @@ -42,7 +42,8 @@ class _ActivityListPage extends State 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> baseData = await apiService.informationList({ "pageNum": 1, "pageSize": 10, @@ -89,7 +90,8 @@ class _ActivityListPage extends State 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 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 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 ), 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 ), ), ], - ) + ), ], ), ), ], ), - ) + ), ], ), ); diff --git a/lib/home/home_page.dart b/lib/home/home_page.dart index 7e5adf87..f1dee7c3 100644 --- a/lib/home/home_page.dart +++ b/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 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 = []; @@ -78,7 +71,6 @@ class _HomePage extends State 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 with AutomaticKeepAliveClientMixin { refreshController.dispose(); } - RefreshController refreshController = RefreshController(); + final RefreshController refreshController = RefreshController(); @override Widget build(BuildContext context) { @@ -159,7 +151,7 @@ class _HomePage extends State with AutomaticKeepAliveClientMixin { enablePullUp: false, header: MyHeader(), physics: BouncingScrollPhysics(), - onRefresh: (){ + onRefresh: () { setState(() {}); }, child: SingleChildScrollView( @@ -169,143 +161,18 @@ class _HomePage extends State 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(), + ///banner + HomeBanner(bannerData, controller), + ///签到 + SignView(), + ///热门文章 + HotArticle(articles), + ///创始人故事 + FounderStore(founder), + ///品牌介绍 + BrandView(brandData), + ///积分商城 + HomeIntegralStore(gooods, callback), ], ); }, @@ -315,432 +182,6 @@ class _HomePage extends State with AutomaticKeepAliveClientMixin { ); } - 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, - ), - ), - ], - ), - ) - ], - ), - ); - } - - ///签到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 跳转类型(0:不跳转,1:积分商品,2:活动,3:文章) - 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; } diff --git a/lib/home/home_view/brand_view.dart b/lib/home/home_view/brand_view.dart new file mode 100644 index 00000000..1da0f3e3 --- /dev/null +++ b/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 brandData; + + BrandView(this.brandData); + + @override + State createState() { + return _BrandView(); + } + +} + +class _BrandView extends State { + @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, + ), + ); + } + + +} + + diff --git a/lib/home/home_view/founder_store.dart b/lib/home/home_view/founder_store.dart new file mode 100644 index 00000000..503e6fd1 --- /dev/null +++ b/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 createState() { + return _FounderStore(); + } + +} + +class _FounderStore extends State { + @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, + ), + ], + ), + ), + ], + ), + ); + } + + +} \ No newline at end of file diff --git a/lib/home/home_view/home_banner.dart b/lib/home/home_view/home_banner.dart new file mode 100644 index 00000000..3d31264e --- /dev/null +++ b/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; + final SwiperController controller; + + HomeBanner(this.bannerData, this.controller); + + @override + State createState() { + return _HomeBanner(); + } + +} + +class _HomeBanner extends State { + @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 跳转类型(0:不跳转,1:积分商品,2:活动,3:文章) + 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; + } + } + + +} + + + + + + diff --git a/lib/home/home_view/home_integral_store.dart b/lib/home/home_view/home_integral_store.dart new file mode 100644 index 00000000..fc3ba1b2 --- /dev/null +++ b/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 gooods; + + HomeIntegralStore(this.gooods, this.callback); + + @override + State createState() { + return _HomeIntegralStore(); + } + +} + +class _HomeIntegralStore extends State { + @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, + ), + ), + ], + ), + ) + ], + ), + ); + } + +} diff --git a/lib/home/home_view/hot_article.dart b/lib/home/home_view/hot_article.dart new file mode 100644 index 00000000..46262212 --- /dev/null +++ b/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
articles; + + HotArticle(this.articles); + + @override + State createState() { + return _HotArticle(); + } + +} + +class _HotArticle extends State { + @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), + ), + ); + }, + ), + ); + } + + +} diff --git a/lib/home/home_view/sign_view.dart b/lib/home/home_view/sign_view.dart new file mode 100644 index 00000000..a3e4dcf0 --- /dev/null +++ b/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, + ), + ), + ], + ), + ); + } +} diff --git a/lib/home/huixiang_brand_page.dart b/lib/home/huixiang_brand_page.dart index dea92d49..81e6d053 100644 --- a/lib/home/huixiang_brand_page.dart +++ b/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 createState() { @@ -43,7 +46,6 @@ class _BrandPage extends State List globaKeys = []; List bannerData = []; - var isShowMore = false; Future queryHome() async { EasyLoading.show(status: S.current.zhengzaijiazai); @@ -87,8 +89,7 @@ class _BrandPage extends State } EasyLoading.dismiss(); refreshController.refreshCompleted(); - print("huixiang_______"); - if(mounted) setState(() {}); + if (mounted) setState(() {}); } @override @@ -103,7 +104,6 @@ class _BrandPage extends State }); queryHome(); - } @override @@ -171,8 +171,10 @@ class _BrandPage extends State List homeChildItem() { var widgets = [ - banner(), - buildInfo(), + ///回乡banner + HuiXiangBanner(bannerData), + ///公司信息 + OriginInfo(brandData), StoreTitleTab( brands, globaKeys, @@ -182,422 +184,31 @@ class _BrandPage extends State ]; if (brands == null) return widgets; brands.forEach((value) { - widgets.add(Container( - key: globaKeys[brands.indexOf(value)], - child: Container( - color: Colors.white, - child: Html( - data: value.content, - customImageRenders: { - base64DataUriMatcher(): base64ImageRender(), - assetUriMatcher(): assetImageRender(), - networkSourceMatcher(extension: "svg"): svgNetworkImageRender(), - networkSourceMatcher(): networkImageRender( - loadingWidget: () { - return Container(); - }, - ), - }, + widgets.add( + Container( + key: globaKeys[brands.indexOf(value)], + child: Container( + color: Colors.white, + child: Html( + data: value.content, + customImageRenders: { + base64DataUriMatcher(): base64ImageRender(), + assetUriMatcher(): assetImageRender(), + networkSourceMatcher(extension: "svg"): svgNetworkImageRender(), + networkSourceMatcher(): networkImageRender( + loadingWidget: () { + return Container(); + }, + ), + }, + ), ), ), - )); + ); }); 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 buildIdea() { - // if (brandData == null) return []; - // var ideas = []; - // (brandData.ideals as Map).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 跳转类型(0:不跳转,1:积分商品,2:活动,3:文章) - 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; - } - } - - 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; diff --git a/lib/home/huixiang_view/huixiang_banner.dart b/lib/home/huixiang_view/huixiang_banner.dart new file mode 100644 index 00000000..c013beaa --- /dev/null +++ b/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; + + HuiXiangBanner(this.bannerData); + + @override + State createState() { + return _HuiXiangBanner(); + } + +} + +class _HuiXiangBanner extends State { + @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 跳转类型(0:不跳转,1:积分商品,2:活动,3:文章) + 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; + } + } + + + +} + + + + + + diff --git a/lib/home/huixiang_view/origin_info.dart b/lib/home/huixiang_view/origin_info.dart new file mode 100644 index 00000000..e31a0e5b --- /dev/null +++ b/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 createState() { + return _OriginInfo(); + } +} + +class _OriginInfo extends State { + 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, + ), + ), + ), + ], + ), + ); + } +} diff --git a/lib/home/main_home_page.dart b/lib/home/main_home_page.dart index 01069c1e..40eac444 100644 --- a/lib/home/main_home_page.dart +++ b/lib/home/main_home_page.dart @@ -26,9 +26,7 @@ class _MainHomePage extends State super.initState(); if (tabcontroller == null) tabcontroller = TabController(length: 3, vsync: this); - tabcontroller.addListener(() => () {}); - //NoDataView(), _widgetOptions = [ HomePage(() { setState(() { diff --git a/lib/home/points_mall_page.dart b/lib/home/points_mall_page.dart index 869cbe81..4e18c64f 100644 --- a/lib/home/points_mall_page.dart +++ b/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 with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin { - var _itemText = S.current.morenpaixu; - ApiService client; - RefreshController _refreshController = RefreshController( - initialRefresh: false, initialLoadStatus: LoadStatus.canLoading); - List 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 bool orderDesc = true; List goods = []; List gooodsCategorys = []; - UserInfo userinfo; + UserInfo userInfo; List bannerData = []; queryUser() async { @@ -87,14 +74,20 @@ class _PointsMallPage extends State "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 baseData = await client.queryInfo(); + BaseData 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 _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 "pageSize": 10, "state": 1 }; - BaseData> baseData = - await client.creditGoods(param).catchError((onError) { + BaseData> baseData = await client.creditGoods(param) + .catchError((onError) { _refreshController.loadFailed(); _refreshController.refreshFailed(); }); @@ -187,99 +184,45 @@ class _PointsMallPage extends State }, child: SingleChildScrollView( child: Container( - color: Color(0xFFFAFAFA), - child: FutureBuilder( - future: creditGoods(), - 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) { - categoryId = gooodsCategorys[index].id; - pageNum = 1; - 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: () { - _toDetails(index); - }, - child: buildItem(goods[index]), - ); - }) - ], - ); - }, - )), + color: Color(0xFFFAFAFA), + child: FutureBuilder( + future: creditGoods(), + builder: (context, snapshot) { + return Column( + children: [ + ///积分商城的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(() {}); + }, + ), + + ///积分商品列表 + PointGoods( + goods, + (index) { + _toDetails(index); + }, + ), + ], + ); + }, + ), + ), ), ); } @@ -292,355 +235,7 @@ class _PointsMallPage extends State 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 跳转类型(0:不跳转,1:积分商品,2:活动,3:文章) - 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; + } diff --git a/lib/home/points_mall_view/point_mall_user.dart b/lib/home/points_mall_view/point_mall_user.dart new file mode 100644 index 00000000..6e3e78dc --- /dev/null +++ b/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 createState() { + return _PointMallUser(); + } +} + +class _PointMallUser extends State { + @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, + ), + ), + ], + ), + ) + ], + ), + ), + ); + } +} diff --git a/lib/home/points_mall_view/points_goods_title.dart b/lib/home/points_mall_view/points_goods_title.dart new file mode 100644 index 00000000..89617030 --- /dev/null +++ b/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 onTap; + final Function(int orderType, bool orderDesc) sortChange; + final List gooodsCategorys; + + PointsGoodsTitle(this.gooodsCategorys, this.sortChange, this.onTap); + + @override + State createState() { + return _PointsGoodsTitle(); + } +} + +class _PointsGoodsTitle extends State { + + var _itemText = S.current.morenpaixu; + List 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; + }); + } + +} diff --git a/lib/home/points_mall_view/points_goods_view.dart b/lib/home/points_mall_view/points_goods_view.dart new file mode 100644 index 00000000..4e434a37 --- /dev/null +++ b/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; + final ValueChanged onTap; + + PointGoods(this.goods, this.onTap); + + @override + State createState() { + return _PointGoods(); + } +} + +class _PointGoods extends State { + @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, + ), + ), + ), + ], + ), + ); + } +} diff --git a/lib/home/points_mall_view/points_mall_banner.dart b/lib/home/points_mall_view/points_mall_banner.dart new file mode 100644 index 00000000..ab695a84 --- /dev/null +++ b/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; + + PointMallBanner(this.bannerData); + + @override + State createState() { + return _PointMallBanner(); + } + +} + +class _PointMallBanner extends State { + @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 跳转类型(0:不跳转,1:积分商品,2:活动,3:文章) + 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; + } + } + + +} + + + + + + diff --git a/lib/main.dart b/lib/main.dart index 74b01e1d..6c97f288 100644 --- a/lib/main.dart +++ b/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"); - runApp(MyApp(locale, isFirst)); + + FlutterBugly.postCatchedException((){ + runApp(MyApp(locale, isFirst)); + }); + FlutterBugly.init(androidAppId: "204f207673",iOSAppId: "8bb92ba0f6"); } XgFlutterPlugin xgFlutterPlugin = XgFlutterPlugin(); diff --git a/lib/mine/mine_page.dart b/lib/mine/mine_page.dart index e97924cb..a38c8f8d 100644 --- a/lib/mine/mine_page.dart +++ b/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 createState() { @@ -30,8 +36,7 @@ class MinePage extends StatefulWidget { class _MinePage extends State with AutomaticKeepAliveClientMixin { ApiService apiService; - UserInfo userinfo; - int rankLevel = 1; + UserInfo userInfo; List ranks = []; final RefreshController _refreshController = RefreshController(); @@ -43,21 +48,7 @@ class _MinePage extends State 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 with AutomaticKeepAliveClientMixin { setState(() {}); } if (event.type == 3) { - setState(() {});; + setState(() {}); } }); } @@ -88,28 +79,28 @@ class _MinePage extends State 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> rankData = await apiService.rankList(); + BaseData> rankData = + await apiService.rankList().catchError((onError) { + _refreshController.refreshFailed(); + }); if (rankData != null && rankData.isSuccess) { ranks.clear(); ranks.addAll(rankData.data); } - BaseData baseDate = await apiService.queryInfo(); + BaseData 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)), @@ -146,89 +137,45 @@ class _MinePage extends State with AutomaticKeepAliveClientMixin { alignment: Alignment.centerRight, children: [ FutureBuilder( - future: queryUserInfo(), - 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, - }); - }); - }, - child: Hero( - tag: "vip", - child: MineVipView( - rankLevel, - curLevel: rankLevel, - rank: (userinfo != null) - ? int.tryParse(userinfo.points) - : 0, - rankMax: (userinfo != null && - userinfo.memberRankVo != null) - ? userinfo.memberRankVo.rankOrigin - : 0, - createTime: (userinfo != null) - ? userinfo.createTime - : "", - ), - ), - ), - orderOrCard(), - mineList(context), - ], - ); - }), + future: queryUserInfo(), + builder: (context, snapshot) { + return Column( + children: [ + ///我的 用户信息 + MineView( + userInfo, + () { + _toUserInfo(); + }, + () { + toIntegralPage(); + }, + ), + + ///我的 VIP等级信息 + MineVipView( + ranks: ranks, + userInfo: userInfo, + rank: (userInfo != null) + ? int.tryParse(userInfo.points) + : 0, + rankMax: (userInfo != null && + userInfo.memberRankVo != null) + ? userInfo.memberRankVo.rankOrigin + : 0, + createTime: + (userInfo != null) ? userInfo.createTime : "", + ), + + /// 订单或会员卡 + OrderCard(), + + ///我的 下面item + MineItem(), + ], + ); + }, + ), // buildNotice(), ], ), @@ -272,9 +219,10 @@ class _MinePage extends State with AutomaticKeepAliveClientMixin { Text( S.of(context).ninyouyigedingdanyaolingqu, style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 12.sp, - color: Colors.black), + fontWeight: FontWeight.bold, + fontSize: 12.sp, + color: Colors.black, + ), ), Icon( Icons.keyboard_arrow_right, @@ -298,7 +246,6 @@ class _MinePage extends State 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 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 diff --git a/lib/mine/mine_view/mine_item.dart b/lib/mine/mine_view/mine_item.dart new file mode 100644 index 00000000..d4121b54 --- /dev/null +++ b/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 createState() { + return _MineItem(); + } + +} + +class _MineItem extends State { + @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, + ) + ], + ), + ); + } + + +} diff --git a/lib/mine/mine_view/mine_view.dart b/lib/mine/mine_view/mine_view.dart new file mode 100644 index 00000000..3747182b --- /dev/null +++ b/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 createState() { + return _MineView(); + } +} + +class _MineView extends State { + @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, + ) + ], + ), + ), + ), + ], + ), + ); + } +} diff --git a/lib/mine/mine_view/order_card_view.dart b/lib/mine/mine_view/order_card_view.dart new file mode 100644 index 00000000..44d0ff6d --- /dev/null +++ b/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 createState() { + return _OrderCard(); + } +} + +class _OrderCard extends State { + @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), + ), + ), + ], + ), + ), + ), + ], + ), + ); + } + +} diff --git a/lib/mine/mine_vip_level_page.dart b/lib/mine/mine_vip_level_page.dart index 9a64530a..2b115a1e 100644 --- a/lib/mine/mine_vip_level_page.dart +++ b/lib/mine/mine_vip_level_page.dart @@ -74,32 +74,17 @@ class _MineVipLevelPage extends State { 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, - curLevel: widget.arguments["rankLevel"], - 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"], - ); - } + 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"], + ); }, itemCount: (ranks != null && ranks.isNotEmpty) ? ranks.length : 1, ), diff --git a/lib/mine/vip_card_page.dart b/lib/mine/vip_card_page.dart index d66e9ddf..55cb6dfd 100644 --- a/lib/mine/vip_card_page.dart +++ b/lib/mine/vip_card_page.dart @@ -32,7 +32,8 @@ class _VipCardPage extends State { _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 { List coupons = []; queryVipCard() async { - BaseData> baseData = await apiService.vipList({}).catchError((error) { + BaseData> baseData = + await apiService.vipList({}).catchError((error) { _refreshController.refreshFailed(); }); if (baseData != null && baseData.isSuccess) { @@ -70,24 +72,27 @@ class _VipCardPage extends State { controller: _refreshController, onRefresh: queryVipCard, physics: BouncingScrollPhysics(), - 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', - arguments: {"id": coupons[position].id}); - }, - child: vipCardItem(coupons[position]), - ); - }, - itemCount: coupons != null ? coupons.length : 0, - ) : NoDataView( - isShowBtn: false, - text: "还没有会员卡~", - fontSize: 16.sp, - margin: EdgeInsets.only(top: 120.h), - ), + 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', + arguments: {"id": coupons[position].id}); + }, + child: vipCardItem(coupons[position]), + ); + }, + itemCount: coupons != null ? coupons.length : 0, + ) + : NoDataView( + isShowBtn: false, + text: "还没有会员卡~", + fontSize: 16.sp, + margin: EdgeInsets.only(top: 120.h), + ), ), ), ); @@ -107,18 +112,19 @@ class _VipCardPage extends State { 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, - boxShadow: [ - BoxShadow( - color: Colors.black.withAlpha(12), - offset: Offset(0, 3), - blurRadius: 14, - spreadRadius: 0, - ) - ],), + borderRadius: BorderRadius.circular(8.w), + color: Colors.white, + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(12), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, + ) + ], + ), child: Stack( children: [ Positioned( @@ -144,7 +150,9 @@ class _VipCardPage extends State { 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,16 +193,18 @@ class _VipCardPage extends State { ], ), Text.rich( - TextSpan(children: [ - TextSpan( - text:S.of(context).huiyuanka, - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.medium, - color: Colors.black, + TextSpan( + children: [ + TextSpan( + text: S.of(context).huiyuanka, + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + color: Colors.black, + ), ), - ), - ],), + ], + ), textDirection: TextDirection.ltr, ), ], @@ -214,16 +224,18 @@ class _VipCardPage extends State { size: 24, ), Text.rich( - TextSpan(children: [ - TextSpan( - text:S.of(context).chakanxiangqing, - style: TextStyle( - fontSize: 12.sp, - fontWeight: FontWeight.bold, - color: Colors.black, + TextSpan( + children: [ + TextSpan( + text: S.of(context).chakanxiangqing, + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.semi_bold, + color: Colors.black, + ), ), - ), - ],), + ], + ), ), ], ), @@ -237,41 +249,47 @@ class _VipCardPage extends State { Expanded( flex: 1, child: Text.rich( - TextSpan(children: [ + TextSpan( + children: [ + TextSpan( + text: "No.${vipCard.id}", + style: TextStyle( + fontSize: 14.sp, + fontWeight: MyFontWeight.regular, + color: Colors.black, + ), + ), + ], + ), + ), + ), + Text.rich( + TextSpan( + children: [ TextSpan( - text: "No.${vipCard.id}", + text: S.of(context).youxiaoqixian, style: TextStyle( - fontSize: 14.sp, + fontSize: 12.sp, fontWeight: MyFontWeight.regular, - color: Colors.black, + color: Color(0Xff353535), ), ), - ],), + ], ), ), Text.rich( - TextSpan(children: [ - TextSpan( - text: S.of(context).youxiaoqixian, - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: Color(0Xff353535), - ), - ), - ],), - ), - Text.rich( - TextSpan(children: [ - TextSpan( - text: S.of(context).changqiyouxiao, - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: Color(0Xff353535), + TextSpan( + children: [ + TextSpan( + text: S.of(context).changqiyouxiao, + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: Color(0Xff353535), + ), ), - ), - ],), + ], + ), ), ], ), diff --git a/lib/retrofit/retrofit_api.dart b/lib/retrofit/retrofit_api.dart index c38538eb..73b003d5 100644 --- a/lib/retrofit/retrofit_api.dart +++ b/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); diff --git a/lib/union/union_page.dart b/lib/union/union_page.dart index e5322e7d..0ecea3e4 100644 --- a/lib/union/union_page.dart +++ b/lib/union/union_page.dart @@ -112,6 +112,7 @@ class _UnionPage extends State "union: Location result ${value.latitude} " "${value.longitude}", ); + Location.getInstance().stopLocation(); queryStore( "${value.latitude}", "${value.longitude}", diff --git a/lib/utils/flutter_utils.dart b/lib/utils/flutter_utils.dart index 6c6d7da4..5866d9d9 100644 --- a/lib/utils/flutter_utils.dart +++ b/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(); diff --git a/lib/view_widget/custom_image.dart b/lib/view_widget/custom_image.dart index 589216a1..1eccbb72 100644 --- a/lib/view_widget/custom_image.dart +++ b/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, { diff --git a/lib/view_widget/login_tips_dialog.dart b/lib/view_widget/login_tips_dialog.dart new file mode 100644 index 00000000..e2d4199f --- /dev/null +++ b/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, + ); + } + +} \ No newline at end of file diff --git a/lib/view_widget/mine_vip_view.dart b/lib/view_widget/mine_vip_view.dart index d51439a8..8f25ee71 100644 --- a/lib/view_widget/mine_vip_view.dart +++ b/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 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,169 +113,189 @@ class MineVipView extends StatelessWidget { break; } } - return Container( - margin: EdgeInsets.fromLTRB(padding.w, 16.h, padding.w, 8.h), - width: MediaQuery.of(context).size.width - 32.w, - height: 200.h, - decoration: BoxDecoration( - gradient: LinearGradient( - colors: linearColor, - begin: Alignment.topLeft, - end: Alignment.bottomRight, - ), - borderRadius: BorderRadius.circular(8), - boxShadow: [ - BoxShadow( - color: Colors.black.withAlpha(12), - offset: Offset(0, 3), - blurRadius: 14, - spreadRadius: 0, + 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, + decoration: BoxDecoration( + gradient: LinearGradient( + colors: linearColor, + begin: Alignment.topLeft, + end: Alignment.bottomRight, + ), + borderRadius: BorderRadius.circular(8), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(12), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, + ), + ], ), - ], - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( + child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Container( - height: 95.h, - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.max, - children: [ - Container( - padding: EdgeInsets.fromLTRB(9.w, 4.h, 8.w, 4.h), - decoration: BoxDecoration( - color: levelColor, - borderRadius: BorderRadius.only( - topLeft: Radius.circular(8), - bottomRight: Radius.circular(8), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + height: 95.h, + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.max, + children: [ + Container( + padding: EdgeInsets.fromLTRB(9.w, 4.h, 8.w, 4.h), + decoration: BoxDecoration( + color: levelColor, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(8), + bottomRight: Radius.circular(8), + ), + ), + child: Text( + topLeft, + style: TextStyle( + fontSize: 12.sp, + fontWeight: FontWeight.bold, + color: Colors.white, + ), + ), ), - ), - child: Text( - topLeft, - style: TextStyle( - fontSize: 12.sp, - fontWeight: FontWeight.bold, - color: Colors.white, + Container( + margin: EdgeInsets.only(left: 13.w), + child: Text( + levelText, + style: TextStyle( + color: textColor, + fontWeight: FontWeight.bold, + fontSize: 23.sp, + ), + ), ), - ), + ], ), - Container( - margin: EdgeInsets.only(left: 13.w), - child: Text( - levelText, - style: TextStyle( - color: textColor, - fontWeight: FontWeight.bold, - fontSize: 23.sp, - ), - ), + ), + Container( + margin: EdgeInsets.only(right: 11.w, bottom: 9.h), + child: Image.asset( + "assets/image/icon_mine_huixiang_logo.png", + width: 86.w, + height: 86.h, + fit: BoxFit.contain, ), - ], - ), + ), + ], ), Container( - margin: EdgeInsets.only(right: 11.w, bottom: 9.h), - child: Image.asset( - "assets/image/icon_mine_huixiang_logo.png", - width: 86.w, - height: 86.h, - fit: BoxFit.contain, - ), - ), - ], - ), - Container( - margin: EdgeInsets.only(left: 13.w, right: 12.w, bottom: 12.h), - child: Column( - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.baseline, - textBaseline: TextBaseline.alphabetic, + margin: EdgeInsets.only(left: 13.w, right: 12.w, bottom: 12.h), + child: Column( children: [ - Expanded( - child: Text( - rank > rankMax - ? S.of(context).dangqiandengji - : "${S.of(context).jifen_(rankMax - rank)} ${S.of(context).daoxiayidengji}", - overflow: TextOverflow.ellipsis, - style: TextStyle( - color: textColor, - fontWeight: FontWeight.w400, - fontSize: 14.sp, - ), - ), - flex: 1, - ), - Text.rich( - TextSpan( - children: [ - TextSpan( - text: "$rank", + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.baseline, + textBaseline: TextBaseline.alphabetic, + children: [ + Expanded( + child: Text( + rank > rankMax + ? S.of(context).dangqiandengji + : "${S.of(context).jifen_(rankMax - rank)} ${S.of(context).daoxiayidengji}", + overflow: TextOverflow.ellipsis, style: TextStyle( - fontSize: 26.sp, - fontWeight: FontWeight.bold, color: textColor, + fontWeight: FontWeight.w400, + fontSize: 14.sp, ), ), - if (rank <= rankMax) - TextSpan( - // string - text: rankMax > 0 ? "/$rankMax" : "/0", - style: TextStyle( - fontSize: 14.sp, - fontWeight: FontWeight.w400, - color: textColor, + flex: 1, + ), + Text.rich( + TextSpan( + children: [ + TextSpan( + text: "$rank", + style: TextStyle( + fontSize: 26.sp, + fontWeight: FontWeight.bold, + color: textColor, + ), ), - ), - ], - ), - ), - ], - ), - Container( - margin: EdgeInsets.only(top: 12.h, bottom: 12.h), - height: 8.h, - child: ClipRRect( - borderRadius: BorderRadius.circular(6.5), - child: LinearProgressIndicator( - value: rankMax > 0 ? rank / rankMax : 0, - backgroundColor: Colors.white, - color: levelColor, + if (rank <= rankMax) + TextSpan( + // string + text: rankMax > 0 ? "/$rankMax" : "/0", + style: TextStyle( + fontSize: 14.sp, + fontWeight: FontWeight.w400, + color: textColor, + ), + ), + ], + ), + ), + ], ), - ), - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Text( - S.of(context).kaitongriqi( - (createTime != null && createTime != "") - ? createTime.split(" ")[0] - : "$createTime"), - style: TextStyle( - color: textColor, - fontWeight: FontWeight.w400, - fontSize: 12.sp, + Container( + margin: EdgeInsets.only(top: 12.h, bottom: 12.h), + height: 8.h, + child: ClipRRect( + borderRadius: BorderRadius.circular(6.5), + child: LinearProgressIndicator( + value: rankMax > 0 ? rank / rankMax : 0, + backgroundColor: Colors.white, + color: levelColor, + ), ), ), - Icon( - Icons.qr_code, - size: 24, - color: Colors.white, + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + S.of(context).kaitongriqi( + (createTime != null && createTime != "") + ? createTime.split(" ")[0] + : "$createTime"), + style: TextStyle( + color: textColor, + fontWeight: FontWeight.w400, + fontSize: 12.sp, + ), + ), + Icon( + Icons.qr_code, + size: 24, + color: Colors.white, + ), + ], ), ], ), - ], - ), + ), + ], ), - ], + ), ), ); } diff --git a/lib/view_widget/store_title_tab.dart b/lib/view_widget/store_title_tab.dart index e8155750..08c6e48a 100644 --- a/lib/view_widget/store_title_tab.dart +++ b/lib/view_widget/store_title_tab.dart @@ -165,7 +165,6 @@ class _StoreTitleTab extends State { int clickIndex = -1; Widget item(Brand text, isSelected, index) { - print("selectedIndex: $selectedIndex"); return GestureDetector( onTap: () { FlexParentData parentData = widget.globaKeys[index].currentContext.findRenderObject().parentData; diff --git a/pubspec.lock b/pubspec.lock index ef77fc11..853abd16 100644 --- a/pubspec.lock +++ b/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: diff --git a/pubspec.yaml b/pubspec.yaml index a3a4639d..1bfe3480 100644 --- a/pubspec.yaml +++ b/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