diff --git a/.gitignore b/.gitignore index 69906469..5bce8333 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,7 @@ /dev/docs/pubspec.yaml /packages/flutter/coverage/ version +/tool/config.dart # packages file containing multi-root paths .packages.generated diff --git a/assets/images/shop_car_empty.png b/assets/images/shop_car_empty.png new file mode 100644 index 00000000..0abaf232 Binary files /dev/null and b/assets/images/shop_car_empty.png differ diff --git a/lib/constants/api.dart b/lib/constants/api.dart index eba2d65c..5240d0e2 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -338,15 +338,11 @@ class _Manager { String get sharePayRecord => '/user/meterReadingShareDetails/findAllMeterShareOrderByTel'; - ///查询所有的已发布的户型说明 - String get houseType => - '/user/houseTypeDescription/list'; - + String get houseType => '/user/houseTypeDescription/list'; ///查询所有的周边企业信息 - String get surroundingEnterprises => - '/user/surroundingEnterprises/list'; + String get surroundingEnterprises => '/user/surroundingEnterprises/list'; ///生活缴费:查询未缴金额(日常缴费+公摊费) String get findUnpaidAmount => @@ -465,8 +461,6 @@ class _Market { ///app商场中心:根据订单主键id查询订单详情 String get orderDetail => '/user/shop/findOrderDetailByOrderId'; - - ///接入京库客 ///jcook商城(首页搜索):查询综合推荐商品列表 String get findGoodsList => '/user/jcookGoods/findRecommendGoodsList'; @@ -480,11 +474,9 @@ class _Market { ///jcook商城 查询品牌入驻数 String get settledBrandsNum => '/user/jcookGoods/settledBrandsNum'; - ///jcook商城 查询已上架的SKU总数 String get skuTotal => '/user/jcookGoods/skuTotal'; - ///jcook商城 查询今日上新的产品数量 String get newProductsTodayNum => '/user/jcookGoods/newProductsTodayNum'; @@ -492,16 +484,19 @@ class _Market { String get findMaxPopularity => '/user/jcookGoods/findMaxPopularity'; ///jcook商城 根据商品分类父类主键id查询首页所有显示的商品分类 - String get findAllCategoryByParentId => '/user/jcookGoods/findAllCategoryByParentId'; + String get findAllCategoryByParentId => + '/user/jcookGoods/findAllCategoryByParentId'; ///jcook商城 查询商品详情 bigInfo大图信息【加载太慢了所以异步查询该接口】 - String get findGoodsDetailBigInfo => '/user/jcookGoods/findGoodsDetailBigInfo'; + String get findGoodsDetailBigInfo => + '/user/jcookGoods/findGoodsDetailBigInfo'; ///jcook商城 查询所有品牌 String get findAllBrand => '/user/jcookGoods/findAllBrand'; ///jcook商城 查询综合推荐列表 - String get findRecommendGoodsList => '/user/jcookGoods/findRecommendGoodsList'; + String get findRecommendGoodsList => + '/user/jcookGoods/findRecommendGoodsList'; ///jcook商城 查询商品详情 String get findGoodsDetail => '/user/jcookGoods/findGoodsDetail'; @@ -513,7 +508,8 @@ class _Market { String get insertShoppingCart => '/user/jcookShoppingCat/insertShoppingCart'; ///jcook商城 更改购物车商品数量 - String get updateShoppingCartNum => '/user/jcookShoppingCat/updateShoppingCartNum'; + String get updateShoppingCartNum => + '/user/jcookShoppingCat/updateShoppingCartNum'; ///jcook商城 删除购物车商品 String get deleteShoppingCart => '/user/jcookShoppingCat/deleteShoppingCart'; @@ -524,12 +520,24 @@ class _Market { ///jcook商城 我的订单 String get myOrder => '/user/jcookOrder/myOrder'; + ///jcook商城(购物车):我的购物车 + String get shopCarList => '/user/jcookShoppingCat/myShoppingCart'; + + ///jcook商城(购物车):加入购物车 + String get shopCarAdd => '/user/jcookShoppingCat/insertShoppingCart'; ///jcook商城 查询所有的可显示的分类信息 需要4秒 进入商场页面的时候加载 String get findAllCategoryInfo => '/user/jcookGoods/findAllCategoryInfo'; + ///jcook商城(购物车):更改购物车商品数量 + String get shopCarChangeNum => '/user/jcookShoppingCat/updateShoppingCartNum'; + + ///jcook商城(购物车):删除购物车商品 + String get shopCarDelete => '/user/jcookShoppingCat/deleteShoppingCart'; + ///jcook商城(购物车):购物车结算 + String get shopCarSettlement => '/user/jcookShoppingCat/settlement'; } class _Upload { diff --git a/lib/models/market/shop_car/shop_car_list_model.dart b/lib/models/market/shop_car/shop_car_list_model.dart new file mode 100644 index 00000000..ca595e0e --- /dev/null +++ b/lib/models/market/shop_car/shop_car_list_model.dart @@ -0,0 +1,38 @@ +import 'package:aku_community/ui/market/shop_car/shop_car_func.dart'; +import 'package:json_annotation/json_annotation.dart'; + +part 'shop_car_list_model.g.dart'; + +@JsonSerializable() +class ShopCarListModel { + final int id; + final String skuName; + final String mainPhoto; + //0.下架,1.上架(当该状态下架,商品直接下架,不考虑小蜜蜂商品状态) + final int status; + //0.下架,1.上架(当jcook商品状态为上架才生效) + final int shopStatus; + final double sellPrice; + final double discountPrice; + final String unit; + // 0=未知 1=自营 2=其 他,商品类别 + final int kind; + final double weight; + final int num; + factory ShopCarListModel.fromJson(Map json) => + _$ShopCarListModelFromJson(json); + GoodStatus get goodStatus => ShopCarFunc.getGoodsStatus(status, shopStatus); + const ShopCarListModel({ + required this.id, + required this.skuName, + required this.mainPhoto, + required this.status, + required this.shopStatus, + required this.sellPrice, + required this.discountPrice, + required this.unit, + required this.kind, + required this.weight, + required this.num, + }); +} diff --git a/lib/models/market/shop_car/shop_car_list_model.g.dart b/lib/models/market/shop_car/shop_car_list_model.g.dart new file mode 100644 index 00000000..a5359a83 --- /dev/null +++ b/lib/models/market/shop_car/shop_car_list_model.g.dart @@ -0,0 +1,23 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'shop_car_list_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +ShopCarListModel _$ShopCarListModelFromJson(Map json) { + return ShopCarListModel( + id: json['id'] as int, + skuName: json['skuName'] as String, + mainPhoto: json['mainPhoto'] as String, + status: json['status'] as int, + shopStatus: json['shopStatus'] as int, + sellPrice: (json['sellPrice'] as num).toDouble(), + discountPrice: (json['discountPrice'] as num).toDouble(), + unit: json['unit'] as String, + kind: json['kind'] as int, + weight: (json['weight'] as num).toDouble(), + num: json['num'] as int, + ); +} diff --git a/lib/pages/home/home_page.dart b/lib/pages/home/home_page.dart index bfb05a69..8e2672b6 100644 --- a/lib/pages/home/home_page.dart +++ b/lib/pages/home/home_page.dart @@ -1,48 +1,46 @@ // Dart imports: -import 'package:aku_community/constants/application_objects.dart'; +import 'package:aku_community/const/resource.dart'; +import 'package:aku_community/constants/api.dart'; import 'package:aku_community/model/common/img_model.dart'; +import 'package:aku_community/model/community/activity_item_model.dart'; +import 'package:aku_community/model/community/board_model.dart'; import 'package:aku_community/model/community/swiper_model.dart'; +import 'package:aku_community/pages/home/widget/animate_app_bar.dart'; import 'package:aku_community/pages/life_pay/life_pay_choose_page.dart'; +import 'package:aku_community/pages/message_center_page/message_center_page.dart'; import 'package:aku_community/pages/one_alarm/widget/alarm_page.dart'; import 'package:aku_community/pages/things_page/fixed_submit_page.dart'; import 'package:aku_community/pages/visitor_access_page/visitor_access_page.dart'; +import 'package:aku_community/provider/app_provider.dart'; +import 'package:aku_community/ui/community/activity/activity_card.dart'; +import 'package:aku_community/ui/community/activity/activity_list_page.dart'; +import 'package:aku_community/ui/community/community_func.dart'; import 'package:aku_community/ui/community/facility/facility_appointment_page.dart'; import 'package:aku_community/ui/home/application/all_application.dart'; +import 'package:aku_community/ui/home/home_notification.dart'; +import 'package:aku_community/ui/home/home_title.dart'; import 'package:aku_community/ui/home/public_infomation/public_information_detail_page.dart'; import 'package:aku_community/ui/manager/advice/advice_page.dart'; import 'package:aku_community/ui/search/bee_search.dart'; +import 'package:aku_community/utils/headers.dart'; +import 'package:aku_community/utils/login_util.dart'; import 'package:aku_community/widget/animated/OverlayWidget.dart'; import 'package:aku_community/widget/others/rectIndicator.dart'; -import 'package:cached_network_image/cached_network_image.dart'; +import 'package:aku_community/widget/others/user_tool.dart'; +import 'package:badges/badges.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; - -import 'package:badges/badges.dart'; -import 'package:bot_toast/bot_toast.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:flutter_swiper_null_safety/flutter_swiper_null_safety.dart'; import 'package:get/get.dart'; +import 'package:jpush_flutter/jpush_flutter.dart'; +import 'package:power_logger/power_logger.dart'; import 'package:provider/provider.dart'; import 'package:velocity_x/velocity_x.dart'; -import 'package:aku_community/const/resource.dart'; -import 'package:aku_community/constants/api.dart'; -import 'package:aku_community/model/community/activity_item_model.dart'; -import 'package:aku_community/model/community/board_model.dart'; -import 'package:aku_community/pages/home/widget/animate_app_bar.dart'; -import 'package:aku_community/pages/message_center_page/message_center_page.dart'; -import 'package:aku_community/provider/app_provider.dart'; -import 'package:aku_community/ui/community/activity/activity_card.dart'; -import 'package:aku_community/ui/community/activity/activity_list_page.dart'; -import 'package:aku_community/ui/community/community_func.dart'; -import 'package:aku_community/ui/home/home_notification.dart'; -import 'package:aku_community/ui/home/home_title.dart'; -import 'package:aku_community/utils/headers.dart'; -import 'package:aku_community/utils/login_util.dart'; import 'widget/home_search.dart'; -import 'package:flutter_swiper_null_safety/flutter_swiper_null_safety.dart'; - class HomePage extends StatefulWidget { HomePage({Key? key}) : super(key: key); @@ -53,7 +51,6 @@ class HomePage extends StatefulWidget { class _HomePageState extends State with AutomaticKeepAliveClientMixin, SingleTickerProviderStateMixin { - int _currentIndicator = 0; ScrollController? _scrollController; @@ -66,6 +63,7 @@ class _HomePageState extends State int commentCount = 0; int sysCount = 0; int sum = 0; + // ActivityItemModel? _activityItemModel; List _activityItemModels = []; List _boardItemModels = []; @@ -74,6 +72,15 @@ class _HomePageState extends State @override void initState() { super.initState(); + if (UserTool.userProvider.isLogin) { + try { + JPush().setAlias(UserTool.userProvider.userInfoModel!.id.toString()); + LoggerData.addData( + 'setAlias ${UserTool.userProvider.userInfoModel!.id} ${DateTime.now()}'); + } catch (e) { + LoggerData.addData('${e.toString()} ${DateTime.now()}'); + } + } _scrollController = ScrollController(); _refreshController = EasyRefreshController(); } @@ -96,7 +103,7 @@ class _HomePageState extends State extendBodyBehindAppBar: true, appBar: AnimateAppBar( scrollController: _scrollController, - actions: [ + actions: [ GestureDetector( onTap: () { Get.to(() => BeeSearch()); @@ -171,8 +178,7 @@ class _HomePageState extends State HomeSwiper(), //要做点击事件 // SizedBox(height: 100.w), Container( - padding: EdgeInsets.only( - top: 24.w, bottom: 32.w), + padding: EdgeInsets.only(top: 24.w, bottom: 32.w), child: getFunction(), //ApplicationView(), decoration: BoxDecoration( color: Colors.white, @@ -194,7 +200,8 @@ class _HomePageState extends State SliverToBoxAdapter( child: Container( height: 40, - margin: EdgeInsets.only(left: 32.w, right: 32.w, top: 24.w), + margin: + EdgeInsets.only(left: 32.w, right: 32.w, top: 24.w), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(8)), @@ -219,9 +226,9 @@ class _HomePageState extends State height: 150, decoration: BoxDecoration( image: DecorationImage( - fit: BoxFit.fill, - image: - AssetImage(R.ASSETS_IMAGES_CARD_YELLOW_PNG),)), + fit: BoxFit.fill, + image: AssetImage(R.ASSETS_IMAGES_CARD_YELLOW_PNG), + )), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -236,50 +243,53 @@ class _HomePageState extends State Text( '一键分享', style: TextStyle( - color: Color(0x73000000), - fontSize: 20.sp, - ), + color: Color(0x73000000), + fontSize: 20.sp, + ), ), Text( '让拜访不再是难事', style: TextStyle( - color: Color(0x73000000), - fontSize: 20.sp, - ), + color: Color(0x73000000), + fontSize: 20.sp, + ), ), Spacer(), - Image.asset(R.ASSETS_ICONS_ICON_MAIN_INVITE_PNG,width: 100.w,height: 100.w,), + Image.asset( + R.ASSETS_ICONS_ICON_MAIN_INVITE_PNG, + width: 100.w, + height: 100.w, + ), 30.hb, ], ), ), - onTap: (){ + onTap: () { Get.to(VisitorAccessPage()); }, ), 25.wb, Container( - margin: EdgeInsets.only(top: 24.w), child: Column( children: [ GestureDetector( - child: Container( width: 190, height: 69, decoration: BoxDecoration( - image: DecorationImage( - fit: BoxFit.fill, - image: AssetImage(R.ASSETS_IMAGES_CARD_PINK_PNG), + fit: BoxFit.fill, + image: + AssetImage(R.ASSETS_IMAGES_CARD_PINK_PNG), )), child: Row( mainAxisAlignment: MainAxisAlignment.start, children: [ 20.wb, Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ 20.hb, Text( @@ -300,12 +310,16 @@ class _HomePageState extends State ], ), Spacer(), - Image.asset(R.ASSETS_ICONS_ICON_MAIN_POLICE_PNG,width: 98.w,height: 98.w,), + Image.asset( + R.ASSETS_ICONS_ICON_MAIN_POLICE_PNG, + width: 98.w, + height: 98.w, + ), 20.wb, ], ), ), - onTap: (){ + onTap: () { Get.to(AlarmPage()); }, ), @@ -316,15 +330,17 @@ class _HomePageState extends State height: 69, decoration: BoxDecoration( image: DecorationImage( - fit: BoxFit.fill, - image: AssetImage(R.ASSETS_IMAGES_CARD_BLUE_PNG), - )), + fit: BoxFit.fill, + image: + AssetImage(R.ASSETS_IMAGES_CARD_BLUE_PNG), + )), child: Row( mainAxisAlignment: MainAxisAlignment.start, children: [ 20.wb, Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ 20.hb, Text( @@ -345,79 +361,81 @@ class _HomePageState extends State ], ), Spacer(), - Image.asset(R.ASSETS_ICONS_ICON_MAIN_CONSULT_PNG,width: 98.w,height: 98.w,), + Image.asset( + R.ASSETS_ICONS_ICON_MAIN_CONSULT_PNG, + width: 98.w, + height: 98.w, + ), 20.wb, ], ), ), - onTap: (){ + onTap: () { Get.to(AdvicePage(type: AdviceType.SUGGESTION)); }, ) - ], ), ) ], ), ), - SliverToBoxAdapter( - child: Column( - children: [ - // HomeTitle( - // title: '公共资讯', - // suffixTitle: '更多资讯', - // onTap: () async { - // final cancel = BotToast.showLoading(); - // BaseModel model = await NetUtil().get(API.news.category); - // List? category; - // if (model.status == true && model.data != null) { - // category = (model.data as List) - // .map((e) => NewsCategoryModel.fromJson(e)) - // .toList(); - // } - // cancel(); - // Get.to( - // () => PublicInfomationPage(models: category ?? [])); - // }, - // ), - HomeTitle( - title: '社区活动', - suffixTitle: '查看全部', - onTap: () => Get.to(() => ActivityListPage()), - ), - _activityItemModels == [] - ? SizedBox() - :Container( - height: 400.w, - padding: EdgeInsets.only(left: 32.w), - child: ListView.separated( - padding: EdgeInsets.zero, - separatorBuilder: (context, index) { - return SizedBox(width: 16.w,); - }, - scrollDirection: Axis.horizontal, - itemBuilder: (context, index) { - return Container( - width: 500.w, - child: Builder( - builder: (context) { - - return ActivityCard(model: _activityItemModels[index]); - - }, - ), - ); - }, - itemCount: _activityItemModels.length, - ), - ), - // : ActivityCard(model: _activityItemModel) - // .pSymmetric(h: 24.w, v: 24.w), - ], - ) - ), + child: Column( + children: [ + // HomeTitle( + // title: '公共资讯', + // suffixTitle: '更多资讯', + // onTap: () async { + // final cancel = BotToast.showLoading(); + // BaseModel model = await NetUtil().get(API.news.category); + // List? category; + // if (model.status == true && model.data != null) { + // category = (model.data as List) + // .map((e) => NewsCategoryModel.fromJson(e)) + // .toList(); + // } + // cancel(); + // Get.to( + // () => PublicInfomationPage(models: category ?? [])); + // }, + // ), + HomeTitle( + title: '社区活动', + suffixTitle: '查看全部', + onTap: () => Get.to(() => ActivityListPage()), + ), + _activityItemModels == [] + ? SizedBox() + : Container( + height: 400.w, + padding: EdgeInsets.only(left: 32.w), + child: ListView.separated( + padding: EdgeInsets.zero, + separatorBuilder: (context, index) { + return SizedBox( + width: 16.w, + ); + }, + scrollDirection: Axis.horizontal, + itemBuilder: (context, index) { + return Container( + width: 500.w, + child: Builder( + builder: (context) { + return ActivityCard( + model: _activityItemModels[index]); + }, + ), + ); + }, + itemCount: _activityItemModels.length, + ), + ), + // : ActivityCard(model: _activityItemModel) + // .pSymmetric(h: 24.w, v: 24.w), + ], + )), ], ), ), @@ -473,8 +491,7 @@ class _HomePageState extends State Widget getSwiperImage(SwiperModel swiperModel) { return Container( - child: - FadeInImage.assetNetwork( + child: FadeInImage.assetNetwork( placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, image: API.image(ImgModel.first(swiperModel.voResourcesImgList)), fit: BoxFit.fill, diff --git a/lib/pages/splash/splash_page.dart b/lib/pages/splash/splash_page.dart index bf2e92eb..ebb72747 100644 --- a/lib/pages/splash/splash_page.dart +++ b/lib/pages/splash/splash_page.dart @@ -3,12 +3,14 @@ import 'dart:io'; import 'package:aku_community/const/resource.dart'; import 'package:aku_community/constants/api.dart'; import 'package:aku_community/model/user/ProvinceModel.dart'; +import 'package:aku_community/main_initialize.dart'; import 'package:aku_community/pages/setting_page/agreement_page/agreement_page.dart'; import 'package:aku_community/pages/setting_page/agreement_page/privacy_page.dart'; import 'package:aku_community/pages/tab_navigator.dart'; import 'package:aku_community/provider/app_provider.dart'; import 'package:aku_community/provider/user_provider.dart'; import 'package:aku_community/utils/developer_util.dart'; +import 'package:aku_community/utils/headers.dart'; import 'package:aku_community/utils/hive_store.dart'; import 'package:aku_community/utils/network/base_model.dart'; import 'package:aku_community/utils/network/net_util.dart'; @@ -23,11 +25,6 @@ import 'package:hive_flutter/hive_flutter.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:power_logger/power_logger.dart'; import 'package:provider/provider.dart'; -import 'package:velocity_x/velocity_x.dart'; - -import 'package:aku_community/utils/headers.dart'; - - class SplashPage extends StatefulWidget { SplashPage({Key? key}) : super(key: key); @@ -116,7 +113,7 @@ class _SplashPageState extends State { super.initState(); PowerLogger.start( context, - debug:true //DeveloperUtil.dev, + debug: DeveloperUtil.dev, ); Future.delayed(Duration(milliseconds: 0), () async { List _province = []; @@ -154,73 +151,110 @@ class _SplashPageState extends State { await Permission.locationWhenInUse.request(); } await _initOp(); + MainInitialize.initTheme(); + MainInitialize.initWechat(); + MainInitialize.initWebSocket(); Get.offAll(() => TabNavigator()); }); - } @override Widget build(BuildContext context) { return Scaffold( body: Container( - color: Colors.white, child: Stack( - children: [ Align( - alignment: Alignment.topCenter, - child: - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - - - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - - Text('追\n求',style: TextStyle(color:Color(0xFF000000),fontSize: 40.sp,height: 1.15),), - ], + alignment: Alignment.topCenter, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + '追\n求', + style: TextStyle( + color: Color(0xFF000000), + fontSize: 40.sp, + height: 1.15), + ), + ], + ), + margin: EdgeInsets.only(top: 450.w), ), - margin: EdgeInsets.only(top: 450.w), - - ), - 25.wb, - Container( - child: - Column( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - - Text('更\n便\n捷\n的\n生\n活\n方\n程\n式',style: TextStyle(color:Color(0xFF000000),fontSize: 40.sp,height: 1.15),), - - ], - ), - margin: EdgeInsets.only(top: 530.w), - ), - 25.wb, - Container( - height: 400.w, - width: 2.w, - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [Color(0x99000000), Color(0x00000000)], - begin: Alignment.topCenter, - end: Alignment.bottomCenter), - borderRadius: BorderRadius.circular(2.w), - ), + 25.wb, + Container( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + '更\n便\n捷\n的\n生\n活\n方\n程\n式', + style: TextStyle( + color: Color(0xFF000000), + fontSize: 40.sp, + height: 1.15), + ), + ], ), - - - ], - ) + margin: EdgeInsets.only(top: 530.w), + ), + 25.wb, + Container( + height: 400.w, + width: 2.w, + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [Color(0x99000000), Color(0x00000000)], + begin: Alignment.topCenter, + end: Alignment.bottomCenter), + borderRadius: BorderRadius.circular(2.w), + ), + ), + ], + )), + Positioned( + child: Image.asset( + R.ASSETS_IMAGES_CIRCLE_TEXT_PNG, + width: 61.w, + height: 72.w, + fit: BoxFit.fill, + ), + top: 410.w, + left: 275.w, + ), + Positioned( + child: Image.asset( + R.ASSETS_IMAGES_CIRCLE_RIGHT_TOP_PNG, + width: 185.w, + height: 249.w, + fit: BoxFit.fill, + ), + top: 0.w, + right: 0.w, + ), + Positioned( + child: Image.asset( + R.ASSETS_IMAGES_CIRCLE_LEFT_BOTTOM_PNG, + width: 270.w, + height: 504.w, + fit: BoxFit.fill, + ), + bottom: 224.w, + left: 0.w, + ), + Positioned( + child: Image.asset( + R.ASSETS_IMAGES_CIRCLE_RIGHT_BOTTOM_PNG, + width: 88.w, + height: 180.w, + fit: BoxFit.fill, + ), + bottom: 150.w, + right: 0.w, ), - Positioned(child: Image.asset(R.ASSETS_IMAGES_CIRCLE_TEXT_PNG,width: 61.w,height: 72.w,fit: BoxFit.fill,),top: 410.w,left: 275.w,), - Positioned(child: Image.asset(R.ASSETS_IMAGES_CIRCLE_RIGHT_TOP_PNG,width: 185.w,height: 249.w,fit: BoxFit.fill,),top: 0.w,right: 0.w,), - Positioned(child: Image.asset(R.ASSETS_IMAGES_CIRCLE_LEFT_BOTTOM_PNG,width: 270.w,height: 504.w,fit: BoxFit.fill,),bottom: 224.w,left: 0.w,), - Positioned(child: Image.asset(R.ASSETS_IMAGES_CIRCLE_RIGHT_BOTTOM_PNG,width: 88.w,height: 180.w,fit: BoxFit.fill,),bottom: 150.w,right: 0.w,), Align( alignment: Alignment.bottomCenter, child: Container( @@ -229,11 +263,20 @@ class _SplashPageState extends State { child: Column( mainAxisAlignment: MainAxisAlignment.end, children: [ - Image.asset(R.ASSETS_IMAGES_SPLASH_LOGO_PNG,width: 140.w,height: 140.w,fit: BoxFit.fill,), - - Text('小蜜蜂智慧社区',style: TextStyle(color:Color(0xD9000000),fontSize: 32.sp,fontWeight: FontWeight.bold),), + Image.asset( + R.ASSETS_IMAGES_SPLASH_LOGO_PNG, + width: 140.w, + height: 140.w, + fit: BoxFit.fill, + ), + Text( + '小蜜蜂智慧社区', + style: TextStyle( + color: Color(0xD9000000), + fontSize: 32.sp, + fontWeight: FontWeight.bold), + ), ], - ), ), ) diff --git a/lib/ui/market/market_page.dart b/lib/ui/market/market_page.dart index 62f5b63c..b36338fa 100644 --- a/lib/ui/market/market_page.dart +++ b/lib/ui/market/market_page.dart @@ -1,6 +1,7 @@ // import 'package:aku_community/base/base_style.dart'; import 'package:aku_community/base/base_style.dart'; +import 'package:aku_community/constants/api.dart'; import 'package:aku_community/model/common/img_model.dart'; import 'package:aku_community/model/community/swiper_model.dart'; import 'package:aku_community/models/market/goods_classification.dart'; @@ -9,37 +10,22 @@ import 'package:aku_community/models/market/order/goods_home_model.dart'; import 'package:aku_community/provider/app_provider.dart'; import 'package:aku_community/ui/community/community_func.dart'; import 'package:aku_community/ui/home/public_infomation/public_information_detail_page.dart'; +import 'package:aku_community/ui/market/search/search_goods_page.dart'; +import 'package:aku_community/ui/market/shop_car/shop_car_page.dart'; import 'package:aku_community/ui/market/widget/animated_home_background.dart'; -import 'package:aku_community/ui/search/bee_search.dart'; +import 'package:aku_community/utils/headers.dart'; +import 'package:aku_community/utils/network/base_list_model.dart'; +import 'package:aku_community/utils/network/net_util.dart'; import 'package:aku_community/widget/home/home_sliver_app_bar.dart'; import 'package:aku_community/widget/others/rectIndicator.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; - -import 'package:bot_toast/bot_toast.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_swiper_null_safety/flutter_swiper_null_safety.dart'; import 'package:get/get.dart'; -import 'package:waterfall_flow/waterfall_flow.dart'; - -import 'package:aku_community/constants/api.dart'; -import 'package:aku_community/models/market/display_category_model.dart'; -import 'package:aku_community/models/market/goods_item.dart'; -import 'package:aku_community/models/market/market_category_model.dart'; -import 'package:aku_community/ui/market/category/category_card.dart'; -import 'package:aku_community/ui/market/category/category_page.dart'; -import 'package:aku_community/ui/market/goods/goods_card.dart'; -import 'package:aku_community/ui/market/order/my_order_page.dart'; -import 'package:aku_community/ui/market/search/search_goods_page.dart'; -import 'package:aku_community/utils/headers.dart'; -import 'package:aku_community/utils/network/base_list_model.dart'; -import 'package:aku_community/utils/network/net_util.dart'; -import 'package:aku_community/widget/bee_scaffold.dart'; import 'package:provider/provider.dart'; -import 'package:aku_community/provider/app_provider.dart'; - import 'market_home_goods_card.dart'; // import 'package:aku_community/ui/market/goods/goods_detail_page.dart'; @@ -54,7 +40,7 @@ class MarketPage extends StatefulWidget { } class _MarketPageState extends State - with TickerProviderStateMixin,AutomaticKeepAliveClientMixin{ + with TickerProviderStateMixin, AutomaticKeepAliveClientMixin { late EasyRefreshController _refreshController; late ScrollController _sliverListController; GlobalKey _sliverAppBarGlobalKey = GlobalKey(); @@ -88,11 +74,14 @@ class _MarketPageState extends State int? orderByPrice; Future updateMarketInfo() async { - - BaseListModel baseListModel = - await NetUtil().getList( API.market.findRecommendGoodsList, - params: {'pageNum': _pageNum, 'size': _size, - 'orderBySalesVolume': orderBySalesVolume,'orderByPrice': orderByPrice,}, + BaseListModel baseListModel = await NetUtil().getList( + API.market.findRecommendGoodsList, + params: { + 'pageNum': _pageNum, + 'size': _size, + 'orderBySalesVolume': orderBySalesVolume, + 'orderByPrice': orderByPrice, + }, ); if (baseListModel.tableList!.isNotEmpty) { _goodsHomeModelList = (baseListModel.tableList as List) @@ -103,10 +92,14 @@ class _MarketPageState extends State } Future loadMarketInfo() async { - BaseListModel baseListModel = - await NetUtil().getList( API.market.findRecommendGoodsList, - params: {'pageNum': _pageNum, 'size': _size, - 'orderBySalesVolume': orderBySalesVolume,'orderByPrice': orderByPrice,}, + BaseListModel baseListModel = await NetUtil().getList( + API.market.findRecommendGoodsList, + params: { + 'pageNum': _pageNum, + 'size': _size, + 'orderBySalesVolume': orderBySalesVolume, + 'orderByPrice': orderByPrice, + }, ); if (baseListModel.tableList!.isNotEmpty) { _goodsHomeModelList = (baseListModel.tableList as List) @@ -119,18 +112,19 @@ class _MarketPageState extends State @override void initState() { super.initState(); - for(int i=0;i<10;i++){ - _goodsClassificationList.add(GoodsClassification(id: 0,name: '',imgUrls: null)); + for (int i = 0; i < 10; i++) { + _goodsClassificationList + .add(GoodsClassification(id: 0, name: '', imgUrls: null)); } - for(int i=0;i<6;i++){ - _goodsPopularModelList.add(GoodsPopularModel(id: 0,skuName: '',mainPhoto: '',viewsNum: 0)); + for (int i = 0; i < 6; i++) { + _goodsPopularModelList.add( + GoodsPopularModel(id: 0, skuName: '', mainPhoto: '', viewsNum: 0)); } - _refreshController = EasyRefreshController(); _sliverListController = ScrollController(); - _tabController = TabController( - initialIndex: 0, length: 3, vsync: this); + _tabController = TabController(initialIndex: 0, length: 3, vsync: this); + ///动态appbar导致 refresh组件刷新判出现问题 首次刷新手动触发 Future.delayed(Duration(milliseconds: 0), () async { await updateMarketInfo(); @@ -149,11 +143,11 @@ class _MarketPageState extends State @override Widget build(BuildContext context) { - // super.build(context); + super.build(context); final mediaWidth = MediaQuery.of(context).size.width; return Scaffold( - body:EasyRefresh( + body: EasyRefresh( firstRefresh: false, enableControlFinishLoad: false, header: MaterialHeader(), @@ -170,31 +164,25 @@ class _MarketPageState extends State } setState(() {}); }, - child: _buildBody(context), - + child: _buildBody(context), ), - - - ); } - - - _refresh() async{ + _refresh() async { _pageNum = 1; await updateMarketInfo(); _swiperModels = await CommunityFunc.swiper(); _newTotal = await CommunityFunc.getNewProductsTodayNum(); _total = await CommunityFunc.getSkuTotal(); _brandTotal = await CommunityFunc.getSettledBrandsNum(); - _goodsClassificationList = await CommunityFunc.getGoodsClassificationList(0);//0获取根目录下的分类 + _goodsClassificationList = + await CommunityFunc.getGoodsClassificationList(0); //0获取根目录下的分类 //_goodsPopularModelList = await CommunityFunc.getGoodsPopularModel(6); setState(() {}); } - Widget _buildBody(BuildContext context) { final normalTypeButton = MaterialButton( onPressed: () async { @@ -208,11 +196,10 @@ class _MarketPageState extends State child: Text( '综合', style: TextStyle( - color: - _orderType == OrderType.NORMAL ? kBalckSubColor : ktextPrimary, + color: _orderType == OrderType.NORMAL ? kBalckSubColor : ktextPrimary, fontSize: _orderType == OrderType.NORMAL ? 32.sp : 28.sp, fontWeight: _orderType == OrderType.NORMAL - ?FontWeight.bold + ? FontWeight.bold : FontWeight.normal, ), ), @@ -231,11 +218,10 @@ class _MarketPageState extends State child: Text( '销量', style: TextStyle( - color: - _orderType == OrderType.SALES ? kBalckSubColor : ktextPrimary, + color: _orderType == OrderType.SALES ? kBalckSubColor : ktextPrimary, fontSize: _orderType == OrderType.SALES ? 32.sp : 28.sp, fontWeight: _orderType == OrderType.SALES - ?FontWeight.bold + ? FontWeight.bold : FontWeight.normal, ), ), @@ -275,16 +261,16 @@ class _MarketPageState extends State '价格', style: TextStyle( color: _orderType == OrderType.PRICE_HIGH || - _orderType == OrderType.PRICE_LOW + _orderType == OrderType.PRICE_LOW ? kBalckSubColor : ktextPrimary, fontSize: _orderType == OrderType.PRICE_HIGH || - _orderType == OrderType.PRICE_LOW + _orderType == OrderType.PRICE_LOW ? 32.sp : 28.sp, fontWeight: _orderType == OrderType.PRICE_HIGH || - _orderType == OrderType.PRICE_LOW - ?FontWeight.bold + _orderType == OrderType.PRICE_LOW + ? FontWeight.bold : FontWeight.normal, ), ), @@ -292,7 +278,7 @@ class _MarketPageState extends State priceIcon, size: 32.w, color: _orderType == OrderType.PRICE_HIGH || - _orderType == OrderType.PRICE_LOW + _orderType == OrderType.PRICE_LOW ? kBalckSubColor : ktextPrimary, ), @@ -309,63 +295,67 @@ class _MarketPageState extends State actions: _actionsWidget(), title: _buildTitle(), backgroundColor: Colors.red, - expandedHeight: MessageHeight+ - bannerHeight + - buttonsHeight+ - searchHeight +tabBarHeight+ScreenUtil().statusBarHeight +kToolbarHeight+280.w, + expandedHeight: MessageHeight + + bannerHeight + + buttonsHeight + + searchHeight + + tabBarHeight + + ScreenUtil().statusBarHeight + + kToolbarHeight + + 280.w, flexibleSpace: _flexibleSpaceBar(context), - - bottom: PreferredSize( - preferredSize: Size.fromHeight(tabBarHeight), - child: _goodsTitle( normalTypeButton, salesTypeButton, priceButton,) - )), + bottom: PreferredSize( + preferredSize: Size.fromHeight(tabBarHeight), + child: _goodsTitle( + normalTypeButton, + salesTypeButton, + priceButton, + ))), SliverPadding( padding: EdgeInsets.all(10.w), ), SliverPadding( - padding: EdgeInsets.only(left: 20.w,right: 20.w), + padding: EdgeInsets.only(left: 20.w, right: 20.w), sliver: buildSliverGrid(), ), - ], ); } SliverGrid buildSliverGrid() { return SliverGrid( - - // child: WaterfallFlow.builder( - // gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount( - // crossAxisCount: 2, - // mainAxisSpacing: 20.w, - // crossAxisSpacing: 20.w, - // ), - // padding: EdgeInsets.all(32.w), - // itemBuilder: (context, index) { - // final item = _hotItems[index]; - // return GoodsCard(item: item); - // }, - // itemCount: _hotItems.length, - // ), + // child: WaterfallFlow.builder( + // gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount( + // crossAxisCount: 2, + // mainAxisSpacing: 20.w, + // crossAxisSpacing: 20.w, + // ), + // padding: EdgeInsets.all(32.w), + // itemBuilder: (context, index) { + // final item = _hotItems[index]; + // return GoodsCard(item: item); + // }, + // itemCount: _hotItems.length, + // ), gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 2, - mainAxisSpacing: 20.w, - crossAxisSpacing: 20.w, - childAspectRatio:0.57, + crossAxisCount: 2, + mainAxisSpacing: 20.w, + crossAxisSpacing: 20.w, + childAspectRatio: 0.57, ), ///子Item构建器 delegate: new SliverChildBuilderDelegate( - (BuildContext context, int index) { - + (BuildContext context, int index) { ///每一个子Item的样式 - return MarketHomeGoodsCard(item: _goodsHomeModelList[index]); - // return Container( - // width: 200.w, - // height: 200.w, - // color: Colors.blue, - // ); + return MarketHomeGoodsCard(item: _goodsHomeModelList[index]); + // return Container( + // width: 200.w, + // height: 200.w, + // color: Colors.blue, + // ); }, + ///子Item的个数 childCount: _goodsHomeModelList.length, ), @@ -376,13 +366,13 @@ class _MarketPageState extends State return [ GestureDetector( onTap: () { - //Get.to(() => BeeSearch()); 购物车 + Get.to(() => ShopCarPage()); // 购物车 }, - child: Image.asset(R.ASSETS_ICONS_SHOP_CAR_PNG, - height: 40.w, width: 40.w), + child: + Image.asset(R.ASSETS_ICONS_SHOP_CAR_PNG, height: 40.w, width: 40.w), ), Padding( - padding: EdgeInsets.only( left: 32.w,right: 32.w), + padding: EdgeInsets.only(left: 32.w, right: 32.w), child: GestureDetector( onTap: () { //Get.to(() => BeeSearch()); 订单 @@ -403,36 +393,36 @@ class _MarketPageState extends State //color: Colors.blue, child: Column( mainAxisAlignment: MainAxisAlignment.center, - children:[ + children: [ Container( height: 40.w, child: Flex( direction: Axis.horizontal, children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - if (appProvider.location != null) - Padding( - padding:EdgeInsets.only(right: 5.w,top: 5.w), - child: Image.asset( - R.ASSETS_ICONS_SHOP_LOCATION_PNG, - width: 40.w, - height: 40.w, - fit: BoxFit.fitHeight, - //color: Colors.white, - ), - ), - Text( - appProvider.location?['city']==null?'':appProvider.location?['city'] as String? ?? '', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 28.sp, - color: Colors.white, - ), - //textAlign: TextAlign.center, + Row(crossAxisAlignment: CrossAxisAlignment.center, children: [ + if (appProvider.location != null) + Padding( + padding: EdgeInsets.only(right: 5.w, top: 5.w), + child: Image.asset( + R.ASSETS_ICONS_SHOP_LOCATION_PNG, + width: 40.w, + height: 40.w, + fit: BoxFit.fitHeight, + //color: Colors.white, ), - ]), + ), + Text( + appProvider.location?['city'] == null + ? '' + : appProvider.location?['city'] as String? ?? '', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 28.sp, + color: Colors.white, + ), + //textAlign: TextAlign.center, + ), + ]), // Expanded( // child: ges, // ) @@ -449,25 +439,24 @@ class _MarketPageState extends State } FlexibleSpaceBar _flexibleSpaceBar(context) { - return FlexibleSpaceBar( collapseMode: CollapseMode.pin, background: Container( - //头部整个背景颜色 + //头部整个背景颜色 height: double.infinity, - color: Color(0xFFF9F9F9), + color: Color(0xFFF9F9F9), // color: Colors.white, child: Stack( children: [ AnimatedHomeBackground( key: _animatedBackgroundState, height: 530.w, - backgroundColor: Colors.white , + backgroundColor: Colors.white, ), Column( children: [ Container( - height: ScreenUtil().statusBarHeight +kToolbarHeight, + height: ScreenUtil().statusBarHeight + kToolbarHeight, ), geSearch(), 20.hb, @@ -478,7 +467,6 @@ class _MarketPageState extends State _buttonTitle(), 20.hb, _recommend(), - ], ), ], @@ -486,11 +474,10 @@ class _MarketPageState extends State ); } - - geSearch(){ - return Container( - margin: EdgeInsets.symmetric(horizontal: 24.w), - child: MaterialButton( + geSearch() { + return Container( + margin: EdgeInsets.symmetric(horizontal: 24.w), + child: MaterialButton( materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, height: 74.w, shape: StadiumBorder(), @@ -512,63 +499,73 @@ class _MarketPageState extends State ], ), ), - ); + ); } - getNum(){ + getNum() { return Container( - margin: EdgeInsets.only(left: 18.w,right: 18.w), - padding: EdgeInsets.only(right:8.w ), + margin: EdgeInsets.only(left: 18.w, right: 18.w), + padding: EdgeInsets.only(right: 8.w), height: 76.w, width: double.infinity, alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: BorderRadius.horizontal(right: Radius.circular(12),left:Radius.circular(12), ), + borderRadius: BorderRadius.horizontal( + right: Radius.circular(12), + left: Radius.circular(12), + ), gradient: LinearGradient( - begin: FractionalOffset.centerRight, - end: FractionalOffset.centerLeft, + begin: FractionalOffset.centerRight, + end: FractionalOffset.centerLeft, colors: [Color(0xFFAD2222), Color(0xFFCD392B)], ), ), child: Stack( children: [ Positioned( - bottom: 5, + bottom: 5, right: 0, top: 5, child: Container( - padding: EdgeInsets.only(top: 5.w,bottom: 5.w), + padding: EdgeInsets.only(top: 5.w, bottom: 5.w), alignment: Alignment.center, height: 61.w, width: 694.w, decoration: BoxDecoration( color: Color(0xFFFDEEBF), - borderRadius: BorderRadius.horizontal(right: Radius.circular(12),left:Radius.circular(12) ), - + borderRadius: BorderRadius.horizontal( + right: Radius.circular(12), left: Radius.circular(12)), ), child: Container( height: 50.w, width: 682.w, decoration: BoxDecoration( //color: Color(0x99F5AF16), - borderRadius: BorderRadius.horizontal(right: Radius.circular(12),left:Radius.circular(12)), - border: Border.all(width: 2.w,color: Color(0x99F5AF16)), - + borderRadius: BorderRadius.horizontal( + right: Radius.circular(12), left: Radius.circular(12)), + border: Border.all(width: 2.w, color: Color(0x99F5AF16)), ), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ 80.wb, - Image.asset(R.ASSETS_ICONS_SHOP_LABA_PNG,width: 36.w,height: 34.w,), + Image.asset( + R.ASSETS_ICONS_SHOP_LABA_PNG, + width: 36.w, + height: 34.w, + ), 20.wb, - Text('今日上新${_total}件',style: TextStyle(color: Color(0xFFD0564B),fontSize: 24.sp,height: 1.05),), + Text( + '今日上新${_total}件', + style: TextStyle( + color: Color(0xFFD0564B), + fontSize: 24.sp, + height: 1.05), + ), ], ), ), - ) - - ), + )), Positioned( left: 0, top: 0, @@ -577,25 +574,28 @@ class _MarketPageState extends State height: 76.w, width: 258.w, decoration: BoxDecoration( - gradient: LinearGradient( - begin: FractionalOffset.centerLeft, - end: FractionalOffset.centerRight, - colors: [Color(0xFFAD2222), Color(0xFFCD392B)], - ), - borderRadius: BorderRadius.horizontal(right: Radius.circular(50),left: Radius.circular(24)) - ), + gradient: LinearGradient( + begin: FractionalOffset.centerLeft, + end: FractionalOffset.centerRight, + colors: [Color(0xFFAD2222), Color(0xFFCD392B)], + ), + borderRadius: BorderRadius.horizontal( + right: Radius.circular(50), left: Radius.circular(24))), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, children: [ - Text('SKU总数:${_newTotal}',style: TextStyle(color: Colors.white,fontSize: 24.sp),), - Text('入驻品牌数:${_brandTotal}',style: TextStyle(color: Colors.white,fontSize: 24.sp),) + Text( + 'SKU总数:${_newTotal}', + style: TextStyle(color: Colors.white, fontSize: 24.sp), + ), + Text( + '入驻品牌数:${_brandTotal}', + style: TextStyle(color: Colors.white, fontSize: 24.sp), + ) ], ), - )), - - - + )), ], ), ); @@ -618,21 +618,21 @@ class _MarketPageState extends State alignment: Alignment.bottomRight, builder: SwiperCustomPagination( builder: (BuildContext context, SwiperPluginConfig config) { - return RectIndicator( - position: config.activeIndex, - count: _swiperModels.length, - activeColor: Color(0x99FFFFFF), - color: Color(0xD9FFFFFF), - //未选中 指示器颜色,选中的颜色key为Color - width: 4, - //指示器宽度 - activeWidth: 14, - //选中的指示器宽度 - radius: 4, - //指示器圆角角度 - height: 4, - ); //指示器高度 - })), + return RectIndicator( + position: config.activeIndex, + count: _swiperModels.length, + activeColor: Color(0x99FFFFFF), + color: Color(0xD9FFFFFF), + //未选中 指示器颜色,选中的颜色key为Color + width: 4, + //指示器宽度 + activeWidth: 14, + //选中的指示器宽度 + radius: 4, + //指示器圆角角度 + height: 4, + ); //指示器高度 + })), scrollDirection: Axis.horizontal, // control: new SwiperControl(), autoplay: true, @@ -652,12 +652,10 @@ class _MarketPageState extends State decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(12.w)), ), - child: - FadeInImage.assetNetwork( + child: FadeInImage.assetNetwork( placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, image: API.image(ImgModel.first(swiperModel.voResourcesImgList)), fit: BoxFit.fill, - imageErrorBuilder: (context, error, stackTrace) { return Image.asset( R.ASSETS_IMAGES_PLACEHOLDER_WEBP, @@ -668,7 +666,6 @@ class _MarketPageState extends State ); } - _buttonTitle() { Container titles = Container( alignment: Alignment.center, @@ -676,23 +673,21 @@ class _MarketPageState extends State color: Colors.white, borderRadius: BorderRadius.circular(12.w), ), - child: - GridView.builder( + child: GridView.builder( padding: EdgeInsets.zero, physics: NeverScrollableScrollPhysics(), gridDelegate: - SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 5), + SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 5), itemBuilder: (context, index) { - if(index == 9){ + if (index == 9) { return _buildAllTile(); - }else{ + } else { return _buildTile(_goodsClassificationList[index]); } }, itemCount: 10, shrinkWrap: true, ), - ); return Container( alignment: Alignment.center, @@ -703,10 +698,8 @@ class _MarketPageState extends State ); } - _buildTile(GoodsClassification item) { return GestureDetector( - child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -716,15 +709,18 @@ class _MarketPageState extends State height: 88.w, image: API.image(ImgModel.first(item.imgUrls)), imageErrorBuilder: (context, error, stackTrace) { - return Image.asset(R.ASSETS_IMAGES_PLACEHOLDER_WEBP,height: 88.w, - width: 88.w,); + return Image.asset( + R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + height: 88.w, + width: 88.w, + ); }, ), 8.hb, - Text( (item.name??'').replaceAll('、', ''),style: TextStyle( - fontSize: 28.sp, - color: ktextPrimary - ),) + Text( + (item.name ?? '').replaceAll('、', ''), + style: TextStyle(fontSize: 28.sp, color: ktextPrimary), + ) ], ), ); @@ -735,13 +731,16 @@ class _MarketPageState extends State child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - Image.asset(R.ASSETS_ICONS_TEST_KINGCION_PNG,height: 88.w, - width: 88.w,), + Image.asset( + R.ASSETS_ICONS_TEST_KINGCION_PNG, + height: 88.w, + width: 88.w, + ), 8.hb, - Text( '全部分类',style: TextStyle( - fontSize: 28.sp, - color: ktextPrimary - ),) + Text( + '全部分类', + style: TextStyle(fontSize: 28.sp, color: ktextPrimary), + ) ], ), ); @@ -750,14 +749,13 @@ class _MarketPageState extends State Widget getkingCoin() { return Container( alignment: Alignment.center, - padding: EdgeInsets.symmetric(horizontal: 20.w,vertical: 20.w), + padding: EdgeInsets.symmetric(horizontal: 20.w, vertical: 20.w), width: double.infinity, height: buttonsHeight, - child:_buttonTitleRow(), + child: _buttonTitleRow(), ); } - _buttonTitleRow({onPressed}) { return Expanded( child: CupertinoButton( @@ -765,21 +763,22 @@ class _MarketPageState extends State child: Column( children: [ Container( + width: 88.w, + height: 88.w, + child: Image.asset( + R.ASSETS_IMAGES_PLACEHOLDER_WEBP, width: 88.w, height: 88.w, - child: Image.asset(R.ASSETS_IMAGES_PLACEHOLDER_WEBP,width: 88.w,height: 88.w,), - // FadeInImage.assetNetwork( - // placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, - // image: Api.getImgUrl(kingCoin.url),) + ), + // FadeInImage.assetNetwork( + // placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + // image: Api.getImgUrl(kingCoin.url),) ), Container( margin: EdgeInsets.only(top: 6.w), child: Text( '数码产品', - style: TextStyle( - - fontSize: 28.sp, - color: Color(0xFF333333)), + style: TextStyle(fontSize: 28.sp, color: Color(0xFF333333)), ), ) ], @@ -793,122 +792,110 @@ class _MarketPageState extends State ); } - - _recommend(){ + _recommend() { return Container( height: 184.w, - margin: EdgeInsets.only(left: 20.w,right: 20.w), - padding: EdgeInsets.only(top: 8.w,left: 16.w,right: 16.w), + margin: EdgeInsets.only(left: 20.w, right: 20.w), + padding: EdgeInsets.only(top: 8.w, left: 16.w, right: 16.w), alignment: Alignment.center, decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(12.w), - ), - child: - Column( - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.start, + color: Colors.white, + borderRadius: BorderRadius.circular(12.w), + ), + child: Column( children: [ - Text( - '爆款推荐', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 28.sp, - color: ktextPrimary), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + '爆款推荐', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 28.sp, + color: ktextPrimary), + ), + ], ), - ], - ), - GridView.builder( - padding: EdgeInsets.zero, - physics: NeverScrollableScrollPhysics(), - gridDelegate: - SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 6), - itemBuilder: (context, index) { - return Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - width: 96.w, + GridView.builder( + padding: EdgeInsets.zero, + physics: NeverScrollableScrollPhysics(), + gridDelegate: + SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 6), + itemBuilder: (context, index) { + return Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + width: 96.w, + height: 96.w, + child: FadeInImage.assetNetwork( + placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + image: _goodsPopularModelList[index].mainPhoto ?? '', + imageErrorBuilder: (context, error, stackTrace) { + return Image.asset( + R.ASSETS_IMAGES_PLACEHOLDER_WEBP, height: 96.w, - child:FadeInImage.assetNetwork( - placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, - image: _goodsPopularModelList[index].mainPhoto??'', - imageErrorBuilder: (context, error, stackTrace) { - return Image.asset(R.ASSETS_IMAGES_PLACEHOLDER_WEBP,height: 96.w, - width: 96.w,); - }, - ), - ), - - ], - ); - }, - itemCount: 6, - shrinkWrap: true, - ), - // Row( - // mainAxisAlignment: MainAxisAlignment.center, - // children: [ - // ..._goodsPopularModelList.map((e) => Row( - // children: [ - // Container( - // width: 96.w, - // height: 96.w, - // child:FadeInImage.assetNetwork( - // placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, - // image: e.mainPhoto??'', - // imageErrorBuilder: (context, error, stackTrace) { - // return Image.asset(R.ASSETS_IMAGES_PLACEHOLDER_WEBP,height: 96.w, - // width: 96.w,); - // }, - // ), - // ), - // 20.wb, - // ], - // ),) - // ], - // ).expand(), - ], - ) - ); + width: 96.w, + ); + }, + ), + ), + ], + ); + }, + itemCount: 6, + shrinkWrap: true, + ), + // Row( + // mainAxisAlignment: MainAxisAlignment.center, + // children: [ + // ..._goodsPopularModelList.map((e) => Row( + // children: [ + // Container( + // width: 96.w, + // height: 96.w, + // child:FadeInImage.assetNetwork( + // placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + // image: e.mainPhoto??'', + // imageErrorBuilder: (context, error, stackTrace) { + // return Image.asset(R.ASSETS_IMAGES_PLACEHOLDER_WEBP,height: 96.w, + // width: 96.w,); + // }, + // ), + // ), + // 20.wb, + // ], + // ),) + // ], + // ).expand(), + ], + )); } - - - - - - - _goodsTitle(Widget normalTypeButton,Widget salesTypeButton,Widget priceButton,){ + _goodsTitle( + Widget normalTypeButton, + Widget salesTypeButton, + Widget priceButton, + ) { return Container( height: 90.w, alignment: Alignment.centerLeft, - color: Color(0xFFF9F9F9), + color: Color(0xFFF9F9F9), width: MediaQuery.of(context).size.width, - child: - Container( + child: Container( alignment: Alignment.centerLeft, height: 60.w, - child:Row( + child: Row( children: [ normalTypeButton, salesTypeButton, priceButton, ], ), - ), ); } - - - - - - - @override bool get wantKeepAlive => true; } diff --git a/lib/ui/market/shop_car/shop_car_func.dart b/lib/ui/market/shop_car/shop_car_func.dart new file mode 100644 index 00000000..262317a0 --- /dev/null +++ b/lib/ui/market/shop_car/shop_car_func.dart @@ -0,0 +1,18 @@ +class ShopCarFunc { + static GoodStatus getGoodsStatus(int jcook, int bee) { + if (jcook == 0) { + return GoodStatus.unSell; + } else { + if (bee == 0) { + return GoodStatus.unSell; + } else { + return GoodStatus.onSell; + } + } + } +} + +enum GoodStatus { + onSell, + unSell, +} diff --git a/lib/ui/market/shop_car/shop_car_page.dart b/lib/ui/market/shop_car/shop_car_page.dart new file mode 100644 index 00000000..ee1a19a0 --- /dev/null +++ b/lib/ui/market/shop_car/shop_car_page.dart @@ -0,0 +1,496 @@ +import 'package:aku_community/base/base_style.dart'; +import 'package:aku_community/const/resource.dart'; +import 'package:aku_community/constants/api.dart'; +import 'package:aku_community/models/market/shop_car/shop_car_list_model.dart'; +import 'package:aku_community/ui/market/shop_car/shop_car_func.dart'; +import 'package:aku_community/utils/network/net_util.dart'; +import 'package:aku_community/widget/buttons/bee_check_radio.dart'; +import 'package:aku_community/widget/buttons/end_button.dart'; +import 'package:bot_toast/bot_toast.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; +import 'package:velocity_x/velocity_x.dart'; + +class ShopCarPage extends StatefulWidget { + const ShopCarPage({Key? key}) : super(key: key); + + @override + _ShopCarPageState createState() => _ShopCarPageState(); +} + +class _ShopCarPageState extends State { + bool _editStatus = false; + List _controllers = []; + List _models = []; + + //选中的model下表 + List _selectIndex = []; + + bool get _allSelect => + _selectIndex.length == _models.length && _selectIndex.length != 0; + + double get total { + var num = 0.0; + _selectIndex.forEach((element) { + num += _models[element].sellPrice; + }); + return num; + } + + @override + void dispose() { + _controllers.forEach((element) { + element.dispose(); + }); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + automaticallyImplyLeading: false, + backgroundColor: Color(0xFFF9F9F9), + titleSpacing: 0, + title: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + GestureDetector( + onTap: () { + Get.back(); + }, + child: Material( + child: Align( + alignment: Alignment.centerLeft, + child: Icon( + CupertinoIcons.back, + size: 48.w, + ), + ), + ), + ), + '购物车'.text.size(32.sp).black.bold.make(), + ], + ), + actions: [ + TextButton( + onPressed: () { + _editStatus = !_editStatus; + }, + child: (_editStatus ? '完成' : '管理') + .text + .size(32.sp) + .black + .bold + .make()) + ], + ), + body: SafeArea( + child: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + 10.widthBox, + '共${_models.length}件商品'.text.size(28.sp).black.make(), + ], + ), + 16.heightBox, + Expanded( + child: EasyRefresh( + firstRefresh: true, + header: MaterialHeader(), + onRefresh: () async { + var base = await NetUtil().get(API.market.shopCarList); + if (base.status ?? false) { + _models = (base.data as List) + .map((e) => ShopCarListModel.fromJson(e)) + .toList(); + _controllers.forEach((element) { + element.dispose(); + }); + _controllers.clear(); + _models.forEach((element) { + _controllers.add( + TextEditingController(text: element.num.toString())); + }); + } + if (mounted) { + setState(() {}); + } + }, + child: _models.isEmpty + ? _emptyWidget() + : ListView( + shrinkWrap: true, + children: _models + .mapIndexed((e, index) => _goodCard(e, index)) + .toList()), + ), + ) + ], + ), + ), + bottomNavigationBar: Container( + width: double.infinity, + height: 100.w, + color: Colors.white, + child: Row( + children: [ + 10.widthBox, + GestureDetector( + onTap: () { + if (_allSelect) { + _selectIndex.clear(); + } else { + _selectIndex.clear(); + _selectIndex + .addAll(List.generate(_models.length, (index) => index)); + } + setState(() {}); + }, + child: Container( + width: 44.w, + height: 44.w, + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(22.w), + border: Border.all(color: Color(0xFFBBBBBB))), + child: AnimatedOpacity( + duration: Duration(milliseconds: 500), + opacity: _allSelect ? 1 : 0, + child: Container( + width: 24.w, + height: 24.w, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(12.w), + color: Color(0xFFE52E2E), + ), + ), + ), + ), + ), + 8.w.widthBox, + Spacer(), + Offstage( + offstage: _editStatus, + child: '合计:' + .richText + .withTextSpanChildren([ + '¥${total}' + .textSpan + .color(ktextSubColor) + .size(28.sp) + .make(), + ]) + .black + .size(28.sp) + .make(), + ), + 20.widthBox, + EndButton( + onPressed: _editStatus ? _delete : _settleEnd, + text: (_editStatus ? '删除' : '结算') + .text + .size(32.sp) + .color(Colors.white) + .make()), + 10.widthBox, + ], + ), + ), + ); + } + + Future _settleEnd() async {} + + Future _delete() async { + await NetUtil().post( + API.market.shopCarDelete, + params: { + 'jcookGoodsIds': _selectIndex.map((e) => _models[e].id).toList() + }, + showMessage: true, + ); + } + + Widget _goodCard(ShopCarListModel model, int index) { + var top = RichText( + text: TextSpan(children: [ + WidgetSpan( + child: _getKindWd(model.kind), + ), + TextSpan( + text: model.skuName, + style: TextStyle(fontSize: 28.sp, color: ktextPrimary)), + ]), + maxLines: 2, + overflow: TextOverflow.ellipsis, + ); + var mid = Container( + padding: EdgeInsets.symmetric(horizontal: 8.w, vertical: 10.w), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(4.w), color: Color(0xFFF2F3F4)), + child: '规格:${model.weight}kg/${model.unit}' + .text + .size(24.sp) + .color(Color(0xFFBBBBBB)) + .make(), + ); + var bottom = Row( + children: [ + '¥' + .richText + .withTextSpanChildren([ + model.sellPrice + .toInt() + .toString() + .textSpan + .size(40.sp) + .color(Color(0xFFE52E2E)) + .make(), + '.${_getPointBehind(model.sellPrice)}' + .textSpan + .size(28.sp) + .color(Color(0xFFE52E2E)) + .make() + ]) + .color(Color(0xFFE52E2E)) + .size(28.sp) + .make(), + Spacer(), + _getBottomSuffix(model.goodStatus, model.id, index) + ], + ); + return Container( + alignment: Alignment.center, + height: 260.w, + margin: EdgeInsets.symmetric(horizontal: 20.w), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(16.w), + ), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + GestureDetector( + onTap: () { + if (_selectIndex.contains(model.id)) { + _selectIndex.remove(index); + } else { + _selectIndex.add(index); + } + setState(() {}); + }, + child: Container( + padding: EdgeInsets.symmetric(horizontal: 16.w), + height: double.infinity, + alignment: Alignment.center, + child: BeeCheckRadio( + value: model.id, + groupValue: _selectIndex, + backColor: Colors.white, + indent: Container( + width: 24.w, + height: 24.w, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(12.w), + color: Color(0xFFE52E2E), + ), + ), + ), + ), + ), + Container( + width: 220.w, + height: 220.w, + clipBehavior: Clip.antiAlias, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(16.w), + image: DecorationImage( + fit: BoxFit.scaleDown, + image: NetworkImage(API.image(model.mainPhoto)))), + child: _getGoodsStatusImg(model.goodStatus), + ), + 16.widthBox, + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + 20.heightBox, + top, + 8.heightBox, + mid, + Spacer(), + bottom, + 10.heightBox, + ], + ).expand(), + 16.widthBox, + ], + ), + ); + } + + String _getPointBehind(double num) { + var str = (num - num.toInt().toDouble()).toStringAsFixed(2); + return str.substring(str.length - 2); + } + + Widget _getKindWd(int kind) { + switch (kind) { + case 1: + return Container( + // width: 90.w, + // height: 26.w, + padding: EdgeInsets.symmetric(horizontal: 6.w, vertical: 2.w), + margin: EdgeInsets.only(right: 10.w), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(4.w), + gradient: LinearGradient( + begin: Alignment.centerLeft, + end: Alignment.centerRight, + colors: [Color(0xFFEC5329), Color(0xFFF58123)])), + child: '京东自营'.text.size(18.sp).color(Colors.white).make()); + case 2: + return Container( + width: 90.w, + height: 26.w, + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.centerLeft, + end: Alignment.centerRight, + colors: [Color(0xFFEC5329), Color(0xFFF58123)])), + child: '其他'.text.size(18.sp).color(Colors.white).make()); + default: + return SizedBox(); + } + } + + Widget? _getGoodsStatusImg(GoodStatus status) { + switch (status) { + case GoodStatus.onSell: + return Container( + width: double.infinity, + height: double.infinity, + color: Color(0xFF000000).withOpacity(0.5), + alignment: Alignment.center, + child: Text( + '已下架', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 28.sp, + color: Colors.white), + ), + ); + case GoodStatus.unSell: + return null; + } + } + + Widget _getBottomSuffix(GoodStatus status, int id, int index) { + switch (status) { + case GoodStatus.onSell: + return Container( + width: 108.w + 64.w, + height: 40.w, + child: Row( + children: [ + GestureDetector( + onTap: () async { + int num = int.parse(_controllers[index].text); + var result = await changeNum(id, num - 1); + if (result) { + _controllers[index].text = (num - 1).toString(); + } + setState(() {}); + }, + child: Padding( + padding: EdgeInsets.only(right: 12.w), + child: Icon( + CupertinoIcons.minus, + size: 30.w, + ), + ), + ), + Container( + width: 84.w, + height: 40.w, + decoration: BoxDecoration( + color: Color(0xFFF2F2F2), + borderRadius: BorderRadius.circular(4.w)), + child: TextField( + inputFormatters: [FilteringTextInputFormatter.digitsOnly], + onChanged: (text) async { + var result = await changeNum(id, int.parse(text)); + if (!result) { + // _controllers[index].text= + } + + setState(() {}); + }, + controller: _controllers[index], + textAlign: TextAlign.center, + decoration: InputDecoration( + border: InputBorder.none, + isDense: true, + contentPadding: EdgeInsets.zero, + ), + ), + ), + GestureDetector( + onTap: () async { + var result = await changeNum( + id, int.parse(_controllers[index].text) + 1); + if (result) { + _controllers[index].text = + (int.parse(_controllers[index].text) + 1).toString(); + } + setState(() {}); + }, + child: Padding( + padding: EdgeInsets.only(left: 12.w), + child: Icon( + CupertinoIcons.plus, + size: 30.w, + ), + ), + ) + ], + ), + ); + case GoodStatus.unSell: + return '商品已下架'.text.size(24.sp).color(Color(0x80000000)).make(); + } + } + + Widget _emptyWidget() { + return Center( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Image.asset( + R.ASSETS_IMAGES_SHOP_CAR_EMPTY_PNG, + width: 400.w, + height: 400.w, + ), + '暂时没有加购商品'.text.size(28.sp).color(Color(0xFFBBBBBB)).make() + ], + ), + ); + } + + Future changeNum(int jcookGoodsId, int num) async { + var cancel = BotToast.showLoading(); + var base = await NetUtil().post(API.market.shopCarChangeNum, + params: {'jcookGoodsId': jcookGoodsId, 'num': num}); + if (!(base.status ?? false)) { + BotToast.showText(text: base.message ?? ''); + } + cancel(); + return base.status ?? false; + } +} diff --git a/lib/widget/buttons/bee_check_radio.dart b/lib/widget/buttons/bee_check_radio.dart index 45040a08..ffd25563 100644 --- a/lib/widget/buttons/bee_check_radio.dart +++ b/lib/widget/buttons/bee_check_radio.dart @@ -1,13 +1,17 @@ -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; - import 'package:aku_community/base/base_style.dart'; import 'package:aku_community/utils/headers.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; class BeeCheckRadio extends StatefulWidget { final T? value; final List? groupValue; - BeeCheckRadio({Key? key, this.value, this.groupValue}) : super(key: key); + final Widget? indent; + final Color? backColor; + + BeeCheckRadio( + {Key? key, this.value, this.groupValue, this.indent, this.backColor}) + : super(key: key); @override _BeeCheckRadioState createState() => _BeeCheckRadioState(); @@ -28,9 +32,11 @@ class _BeeCheckRadioState extends State { height: 40.w, width: 40.w, decoration: BoxDecoration( - color: kPrimaryColor.withOpacity(_selected ? 1 : 0), + color: widget.backColor ?? kPrimaryColor.withOpacity(_selected ? 1 : 0), border: Border.all( - color: _selected ? kPrimaryColor : Color(0xFF979797), + color: widget.backColor != null + ? Color(0xFFBBBBBB) + : (_selected ? kPrimaryColor : Color(0xFF979797)), width: 3.w, ), borderRadius: BorderRadius.circular(20.w), @@ -39,14 +45,15 @@ class _BeeCheckRadioState extends State { curve: Curves.easeInOutCubic, alignment: Alignment.center, child: AnimatedOpacity( - duration: Duration(milliseconds: 300), + duration: Duration(milliseconds: 500), curve: Curves.easeInOutCubic, opacity: _selected ? 1 : 0, - child: Icon( - CupertinoIcons.checkmark, - color: Colors.white, - size: 28.w, - ), + child: widget.indent ?? + Icon( + CupertinoIcons.checkmark, + color: Colors.white, + size: 28.w, + ), ), ); } diff --git a/lib/widget/buttons/end_button.dart b/lib/widget/buttons/end_button.dart new file mode 100644 index 00000000..6be40e61 --- /dev/null +++ b/lib/widget/buttons/end_button.dart @@ -0,0 +1,36 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; + +class EndButton extends StatelessWidget { + final VoidCallback onPressed; + final Widget text; + final double? width; + final EdgeInsetsGeometry? padding; + final Color? color; + const EndButton( + {Key? key, + required this.onPressed, + required this.text, + this.width, + this.padding, + this.color}) + : super(key: key); + + @override + Widget build(BuildContext context) { + return MaterialButton( + elevation: 0, + focusElevation: 0, + highlightElevation: 0, + disabledElevation: 0, + disabledTextColor: Colors.white.withOpacity(0.3), + minWidth: width ?? 220.w, + padding: + padding ?? EdgeInsets.symmetric(horizontal: 48.w, vertical: 20.w), + color: color ?? Colors.red, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(42.w)), + onPressed: onPressed, + child: text, + ); + } +}