diff --git a/android/app/build.gradle b/android/app/build.gradle index d4ff8d08..f0d15e6f 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -102,4 +102,4 @@ dependencies { } apply plugin: 'com.google.gms.google-services' -apply plugin: 'com.google.firebase.crashlytics' +//apply plugin: 'com.google.firebase.crashlytics' diff --git a/android/build.gradle b/android/build.gradle index 19274a58..ac5d8d30 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -12,7 +12,7 @@ buildscript { classpath 'com.android.tools.build:gradle:4.2.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'com.google.gms:google-services:4.3.5' - classpath 'com.google.firebase:firebase-crashlytics-gradle:2.5.1' +// classpath 'com.google.firebase:firebase-crashlytics-gradle:2.5.1' } } diff --git a/assets/icons/category.png b/assets/icons/icon_change_grid.png similarity index 100% rename from assets/icons/category.png rename to assets/icons/icon_change_grid.png diff --git a/lib/const/resource.dart b/lib/const/resource.dart index 3bf8846a..b0dd897c 100644 --- a/lib/const/resource.dart +++ b/lib/const/resource.dart @@ -159,9 +159,6 @@ class R { static const String ASSETS_ICONS_BORROW_SUCCESS_PNG = 'assets/icons/borrow_success.png'; - /// ![preview](file:///Users/datang/aku_community/assets/icons/category.png) - static const String ASSETS_ICONS_CATEGORY_PNG = 'assets/icons/category.png'; - /// ![preview](file:///Users/datang/aku_community/assets/icons/change.png) static const String ASSETS_ICONS_CHANGE_PNG = 'assets/icons/change.png'; @@ -334,6 +331,10 @@ class R { /// ![preview](file:///Users/datang/aku_community/assets/icons/icon_back.png) static const String ASSETS_ICONS_ICON_BACK_PNG = 'assets/icons/icon_back.png'; + /// ![preview](file:///Users/datang/aku_community/assets/icons/icon_change_grid.png) + static const String ASSETS_ICONS_ICON_CHANGE_GRID_PNG = + 'assets/icons/icon_change_grid.png'; + /// ![preview](file:///Users/datang/aku_community/assets/icons/icon_change_list.png) static const String ASSETS_ICONS_ICON_CHANGE_LIST_PNG = 'assets/icons/icon_change_list.png'; diff --git a/lib/constants/api.dart b/lib/constants/api.dart index 45c27742..1cb6b619 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -546,10 +546,12 @@ class _Market { ///jcook商城 订单 查看物流 String get findLogistics => '/user/jcookOrder/findLogistics'; - ///jcook商城 订单 确认收货 String get confirmOrder => '/user/jcookOrder/confirm'; + ///jcook商城 查询轮播图信息集合 + String get findRotationList => '/user/jcookGoods/findRotationList'; + } diff --git a/lib/generated_plugin_registrant.dart b/lib/generated_plugin_registrant.dart index 222a4e7a..b80e143d 100644 --- a/lib/generated_plugin_registrant.dart +++ b/lib/generated_plugin_registrant.dart @@ -5,7 +5,6 @@ // ignore_for_file: lines_longer_than_80_chars import 'package:device_info_plus_web/device_info_plus_web.dart'; -import 'package:firebase_core_web/firebase_core_web.dart'; import 'package:image_picker_for_web/image_picker_for_web.dart'; import 'package:package_info_plus_web/package_info_plus_web.dart'; import 'package:shared_preferences_web/shared_preferences_web.dart'; @@ -16,7 +15,6 @@ import 'package:flutter_web_plugins/flutter_web_plugins.dart'; // ignore: public_member_api_docs void registerPlugins(Registrar registrar) { DeviceInfoPlusPlugin.registerWith(registrar); - FirebaseCoreWeb.registerWith(registrar); ImagePickerPlugin.registerWith(registrar); PackageInfoPlugin.registerWith(registrar); SharedPreferencesPlugin.registerWith(registrar); diff --git a/lib/main_initialize.dart b/lib/main_initialize.dart index 1d962be4..065f6768 100644 --- a/lib/main_initialize.dart +++ b/lib/main_initialize.dart @@ -6,8 +6,8 @@ import 'package:aku_community/provider/app_provider.dart'; import 'package:aku_community/utils/message_parser.dart'; import 'package:aku_community/utils/websocket/fire_dialog.dart'; import 'package:aku_community/utils/websocket/web_socket_util.dart'; -import 'package:firebase_core/firebase_core.dart'; -import 'package:firebase_crashlytics/firebase_crashlytics.dart'; +// import 'package:firebase_core/firebase_core.dart'; +// import 'package:firebase_crashlytics/firebase_crashlytics.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; @@ -21,21 +21,21 @@ import 'package:provider/provider.dart'; class MainInitialize { ///初始化firebase - static Future initFirebase() async { - await Firebase.initializeApp(); - // web MacOS Platform not support firebase - if (!kIsWeb && !Platform.isMacOS) { - FirebaseCrashlytics.instance - .setCrashlyticsCollectionEnabled(kReleaseMode); - } - FlutterError.onError = (detail) { - LoggerData.addData(detail); - if (kReleaseMode && !kIsWeb && !Platform.isMacOS) { - FirebaseCrashlytics.instance.recordFlutterError(detail); - } - FlutterError.presentError(detail); - }; - } + // static Future initFirebase() async { + // await Firebase.initializeApp(); + // // web MacOS Platform not support firebase + // if (!kIsWeb && !Platform.isMacOS) { + // FirebaseCrashlytics.instance + // .setCrashlyticsCollectionEnabled(kReleaseMode); + // } + // FlutterError.onError = (detail) { + // LoggerData.addData(detail); + // if (kReleaseMode && !kIsWeb && !Platform.isMacOS) { + // FirebaseCrashlytics.instance.recordFlutterError(detail); + // } + // FlutterError.presentError(detail); + // }; + // } static initTheme() { SystemChrome.setSystemUIOverlayStyle(SystemStyle.initial); diff --git a/lib/model/good/category_model.dart b/lib/model/good/category_model.dart index bd18d2a1..83d73823 100644 --- a/lib/model/good/category_model.dart +++ b/lib/model/good/category_model.dart @@ -1,13 +1,20 @@ class CategoryModel { int? id; String? name; + List? imgUrls; List? categoryList; - CategoryModel({this.id, this.name, this.categoryList}); + CategoryModel({this.id, this.name, this.categoryList,this.imgUrls}); CategoryModel.fromJson(Map json) { id = json['id']; name = json['name']; + if (json['imgUrls'] != null) { + imgUrls = []; + json['imgUrls'].forEach((v) { + imgUrls!.add(v.toString()); + }); + } if (json['categoryList'] != null) { categoryList = []; json['categoryList'].forEach((v) { @@ -23,12 +30,16 @@ class CategoryModel { if (this.categoryList != null) { data['categoryList'] = this.categoryList!.map((v) => v.toJson()).toList(); } + if (this.imgUrls != null) { + data['imgUrls'] = this.imgUrls!.map((v) => v).toList(); + } return data; } } class CategoryList { int? id; + List? imgUrls; String? name; List? categoryListSecond; @@ -43,6 +54,12 @@ class CategoryList { categoryListSecond!.add(new CategoryListSecond.fromJson(v)); }); } + if (json['imgUrls'] != null) { + imgUrls = []; + json['imgUrls'].forEach((v) { + imgUrls!.add(v.toString()); + }); + } } Map toJson() { @@ -53,6 +70,9 @@ class CategoryList { data['categoryList'] = this.categoryListSecond!.map((v) => v.toJson()).toList(); } + if (this.imgUrls != null) { + data['imgUrls'] = this.imgUrls!.map((v) => v).toList(); + } return data; } } @@ -60,13 +80,19 @@ class CategoryList { class CategoryListSecond { int? id; String? name; - + List? imgUrls; CategoryListSecond({this.id, this.name,}); CategoryListSecond.fromJson(Map json) { id = json['id']; name = json['name']; + if (json['imgUrls'] != null) { + imgUrls = []; + json['imgUrls'].forEach((v) { + imgUrls!.add(v.toString()); + }); + } } @@ -74,7 +100,9 @@ class CategoryListSecond { final Map data = new Map(); data['id'] = this.id; data['name'] = this.name; - + if (this.imgUrls != null) { + data['imgUrls'] = this.imgUrls!.map((v) => v).toList(); + } return data; } } \ No newline at end of file diff --git a/lib/model/good/market_swiper_model.dart b/lib/model/good/market_swiper_model.dart new file mode 100644 index 00000000..08b3afa8 --- /dev/null +++ b/lib/model/good/market_swiper_model.dart @@ -0,0 +1,59 @@ +class MarketSwiperModel { + int? id; + int? jcookGoodsId; + int? skuId; + List? imgList; + + MarketSwiperModel({this.id, this.jcookGoodsId, this.skuId, this.imgList}); + + MarketSwiperModel.fromJson(Map json) { + id = json['id']; + jcookGoodsId = json['jcookGoodsId']; + skuId = json['skuId']; + if (json['imgList'] != null) { + imgList = []; + json['imgList'].forEach((v) { + imgList!.add(new ImgList.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['jcookGoodsId'] = this.jcookGoodsId; + data['skuId'] = this.skuId; + if (this.imgList != null) { + data['imgList'] = this.imgList!.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class ImgList { + String? url; + String? size; + int? longs; + int? paragraph; + int? sort; + + ImgList({this.url, this.size, this.longs, this.paragraph, this.sort}); + + ImgList.fromJson(Map json) { + url = json['url']; + size = json['size']; + longs = json['longs']; + paragraph = json['paragraph']; + sort = json['sort']; + } + + Map toJson() { + final Map data = new Map(); + data['url'] = this.url; + data['size'] = this.size; + data['longs'] = this.longs; + data['paragraph'] = this.paragraph; + data['sort'] = this.sort; + return data; + } +} \ No newline at end of file diff --git a/lib/pages/property/property_page.dart b/lib/pages/property/property_page.dart index 8f71234f..066e8f1c 100644 --- a/lib/pages/property/property_page.dart +++ b/lib/pages/property/property_page.dart @@ -103,40 +103,40 @@ class _PropertyPageState extends State textAlign: TextAlign.center, ), ]), - actions: [ - GestureDetector( - onTap: () { - Get.to(() => BeeSearch()); - }, - child: Image.asset(R.ASSETS_ICONS_ICON_PROPERTY_SEARCH_PNG, - height: 40.w, width: 40.w), - ), - Padding( - padding: EdgeInsets.only(right: 10.w, left: 12.w), - child: Badge( - elevation: 0, - badgeColor: Color(0xFFCF2525), - padding: sum > 9 ? EdgeInsets.all(2.w) : EdgeInsets.all(5.w), - showBadge: appProvider.messageCenterModel.commentCount != 0 || - appProvider.messageCenterModel.sysCount != 0, - position: BadgePosition.topEnd( - top: 3, - end: -5, - ), - badgeContent: Text( - (sum).toString(), - style: TextStyle(color: Colors.white, fontSize: 10.sp), - ), - child: GestureDetector( - onTap: () { - if (LoginUtil.isNotLogin) return; - Get.to(() => MessageCenterPage()); - }, - child: Image.asset(R.ASSETS_ICONS_ICON_PROPERTY_MESSAGE_PNG, - height: 40.w, width: 40.w), - )), - ), - ], + // actions: [ + // GestureDetector( + // onTap: () { + // Get.to(() => BeeSearch()); + // }, + // child: Image.asset(R.ASSETS_ICONS_ICON_PROPERTY_SEARCH_PNG, + // height: 40.w, width: 40.w), + // ), + // // Padding( + // // padding: EdgeInsets.only(right: 10.w, left: 12.w), + // // child: Badge( + // // elevation: 0, + // // badgeColor: Color(0xFFCF2525), + // // padding: sum > 9 ? EdgeInsets.all(2.w) : EdgeInsets.all(5.w), + // // showBadge: appProvider.messageCenterModel.commentCount != 0 || + // // appProvider.messageCenterModel.sysCount != 0, + // // position: BadgePosition.topEnd( + // // top: 8.w, + // // end: -4.w, + // // ), + // // badgeContent: Text( + // // (sum).toString(), + // // style: TextStyle(color: Colors.white, fontSize: 20.sp), + // // ), + // // child: GestureDetector( + // // onTap: () { + // // if (LoginUtil.isNotLogin) return; + // // Get.to(() => MessageCenterPage()); + // // }, + // // child: Image.asset(R.ASSETS_ICONS_ICON_PROPERTY_MESSAGE_PNG, + // // height: 40.w, width: 40.w), + // // )), + // // ), + // ], expandedHeight: 420.w, backgroundColor: Colors.white, flexibleSpace: Stack( @@ -156,7 +156,7 @@ class _PropertyPageState extends State bottom: 0), Positioned( child: Container( - margin: EdgeInsets.only(left: 32.w, right: 32.w), + margin: EdgeInsets.only(left: 32.w, right: 32.w,top: 10.w), width: 686.w, height: 74.w, decoration: BoxDecoration( diff --git a/lib/provider/user_provider.dart b/lib/provider/user_provider.dart index 50a3c04a..73939548 100644 --- a/lib/provider/user_provider.dart +++ b/lib/provider/user_provider.dart @@ -67,11 +67,6 @@ class UserProvider extends ChangeNotifier { Future updateProfile() async { _userInfoModel = await SignFunc.getUserInfo(); if (_userInfoModel != null && !kIsWeb && !Platform.isMacOS) { - try { - await JPush().setAlias(_userInfoModel!.id.toString()); - } catch (e) { - LoggerData.addData(e); - } } notifyListeners(); } diff --git a/lib/ui/community/community_func.dart b/lib/ui/community/community_func.dart index 28f0cfe8..5ef56757 100644 --- a/lib/ui/community/community_func.dart +++ b/lib/ui/community/community_func.dart @@ -5,6 +5,7 @@ import 'package:aku_community/model/community/community_topic_model.dart'; import 'package:aku_community/model/community/hot_news_model.dart'; import 'package:aku_community/model/community/swiper_model.dart'; import 'package:aku_community/model/good/category_model.dart'; +import 'package:aku_community/model/good/market_swiper_model.dart'; import 'package:aku_community/models/market/goods_classification.dart'; import 'package:aku_community/models/market/goods_popular_model.dart'; import 'package:aku_community/models/market/order/goods_home_model.dart'; @@ -131,6 +132,17 @@ class CommunityFunc { } } + ///获取商城的轮播图 + static Future> marketSwiper() async { + BaseModel model = await NetUtil().get( + API.market.findRotationList, + ); + if (model.data!.length == 0) + return []; + return (model.data as List) + .map((e) => MarketSwiperModel.fromJson(e)) + .toList(); + } diff --git a/lib/ui/market/category/new_category_page.dart b/lib/ui/market/category/new_category_page.dart index d3e72519..b71f0736 100644 --- a/lib/ui/market/category/new_category_page.dart +++ b/lib/ui/market/category/new_category_page.dart @@ -15,7 +15,8 @@ import 'new_category_sub_view.dart'; class NewCategoryPage extends StatefulWidget { final List models; - NewCategoryPage({Key? key, required this.models}) : super(key: key); + final int index; + NewCategoryPage({Key? key, required this.models, required this.index}) : super(key: key); @override _NewCategoryPageState createState() => _NewCategoryPageState(); @@ -28,7 +29,8 @@ class _NewCategoryPageState extends State @override void initState() { super.initState(); - _tabController = TabController(length: widget.models.length, vsync: this); + _index=widget.index; + _tabController = TabController(length: widget.models.length, vsync: this,initialIndex: widget.index); } @override diff --git a/lib/ui/market/category/new_category_sub_card.dart b/lib/ui/market/category/new_category_sub_card.dart index 4af7255e..2bc68719 100644 --- a/lib/ui/market/category/new_category_sub_card.dart +++ b/lib/ui/market/category/new_category_sub_card.dart @@ -26,7 +26,7 @@ class NewCategorySubCard extends StatelessWidget { children: [ Spacer(), FadeInImage.assetNetwork( - image:'', + image:API.image(subModels.imgUrls!.isNotEmpty? subModels.imgUrls!.first :''),//subModels.imgUrls!.isNotEmpty? subModels.imgUrls!.first :'', placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, height: 75.w, width: 75.w, @@ -49,7 +49,7 @@ class NewCategorySubCard extends StatelessWidget { ], ), onPressed: () async { - Get.to(()=> SearchGoodsPage(search:subModels.name ,)); + Get.to(()=> SearchGoodsPage(categoryName:subModels.name ,categoryId:subModels.id ,)); // await Get.to( // () => GoodsListView( // model: model, diff --git a/lib/ui/market/market_page.dart b/lib/ui/market/market_page.dart index 2f4bdec2..f4826056 100644 --- a/lib/ui/market/market_page.dart +++ b/lib/ui/market/market_page.dart @@ -5,6 +5,7 @@ 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/model/good/category_model.dart'; +import 'package:aku_community/model/good/market_swiper_model.dart'; import 'package:aku_community/models/market/goods_classification.dart'; import 'package:aku_community/models/market/goods_popular_model.dart'; import 'package:aku_community/models/market/order/goods_home_model.dart'; @@ -62,7 +63,8 @@ class _MarketPageState extends State double tabBarHeight = 40.w; late TabController _tabController; - List _swiperModels = []; + // List _swiperModels = []; + List _marketSwiperModels = []; List _categoryModels = []; @@ -176,7 +178,8 @@ class _MarketPageState extends State _refresh() async { await updateMarketInfo(); - _swiperModels = await CommunityFunc.swiper(); + //_swiperModels = await CommunityFunc.swiper(); + _marketSwiperModels = await CommunityFunc.marketSwiper(); _newTotal = await CommunityFunc.getNewProductsTodayNum(); _total = await CommunityFunc.getSkuTotal(); _brandTotal = await CommunityFunc.getSettledBrandsNum(); @@ -614,7 +617,7 @@ class _MarketPageState extends State child: Swiper( key: UniqueKey(), itemBuilder: (BuildContext context, int index) { - return getSwiperImage(_swiperModels[index]); + return getSwiperImage(_marketSwiperModels[index]); }, pagination: SwiperPagination( @@ -623,7 +626,7 @@ class _MarketPageState extends State builder: (BuildContext context, SwiperPluginConfig config) { return RectIndicator( position: config.activeIndex, - count: _swiperModels.length, + count: _marketSwiperModels.length, activeColor: Color(0x99FFFFFF), color: Color(0xD9FFFFFF), //未选中 指示器颜色,选中的颜色key为Color @@ -640,16 +643,19 @@ class _MarketPageState extends State // control: new SwiperControl(), autoplay: true, onTap: (index) { - Get.to(() => - PublicInformationDetailPage(id: _swiperModels[index].newsId!)); + if(_marketSwiperModels[index].jcookGoodsId!=null){ + Get.to( + () => GoodDetailPage(goodId: _marketSwiperModels[index].jcookGoodsId!), + ); + } }, - itemCount: _swiperModels.length, + itemCount: _marketSwiperModels.length, ), ), ); } - Widget getSwiperImage(SwiperModel swiperModel) { + Widget getSwiperImage(MarketSwiperModel swiperModel) { return Container( clipBehavior: Clip.antiAlias, decoration: BoxDecoration( @@ -657,7 +663,7 @@ class _MarketPageState extends State ), child: FadeInImage.assetNetwork( placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, - image: API.image(ImgModel.first(swiperModel.voResourcesImgList)), + image:API.image(swiperModel.imgList!.isNotEmpty? swiperModel.imgList!.first.url :''), fit: BoxFit.fill, imageErrorBuilder: (context, error, stackTrace) { return Image.asset( @@ -671,6 +677,7 @@ class _MarketPageState extends State _buttonTitle() { Container titles = Container( + key:UniqueKey(), alignment: Alignment.center, decoration: BoxDecoration( color: Colors.white, @@ -685,7 +692,7 @@ class _MarketPageState extends State if (index == 9) { return _buildAllTile(); } else { - return _buildTile(_goodsClassificationList[index]); + return _buildTile(_goodsClassificationList[index],index); } }, itemCount: 10, @@ -701,8 +708,11 @@ class _MarketPageState extends State ); } - _buildTile(GoodsClassification item) { + _buildTile(GoodsClassification item,int index) { return GestureDetector( + onTap: (){ + Get.to(() => NewCategoryPage(models: _categoryModels,index: index,)); + }, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -732,7 +742,7 @@ class _MarketPageState extends State _buildAllTile() { return GestureDetector( onTap: () async{ - Get.to(() => NewCategoryPage(models: _categoryModels)); + Get.to(() => NewCategoryPage(models: _categoryModels,index: 0,)); }, child: Column( mainAxisAlignment: MainAxisAlignment.center, @@ -840,6 +850,7 @@ class _MarketPageState extends State child: Container( width: 96.w, height: 96.w, + key:UniqueKey(), child: FadeInImage.assetNetwork( placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, image: _goodsPopularModelList[index].mainPhoto ?? '', @@ -903,6 +914,7 @@ class _MarketPageState extends State normalTypeButton, salesTypeButton, priceButton, + ], ), ), diff --git a/lib/ui/market/market_page111.dart b/lib/ui/market/market_page111.dart index 5a9ba5ee..2065ac4c 100644 --- a/lib/ui/market/market_page111.dart +++ b/lib/ui/market/market_page111.dart @@ -1,301 +1,301 @@ -// import 'package:aku_community/base/base_style.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: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:aku_community/ui/market/goods/goods_detail_page.dart'; - -// import 'package:aku_community/widget/tab_bar/bee_tab_bar.dart'; - -class MarketPage111 extends StatefulWidget { - MarketPage111({Key? key}) : super(key: key); - - @override - _MarketPageState createState() => _MarketPageState(); -} - -class _MarketPageState extends State - with AutomaticKeepAliveClientMixin { - List _marketModels = []; - List _hotItems = []; - late EasyRefreshController _refreshController; - int _pageNum = 1; - int _size = 4; - int _pageCount = 0; - - Future updateMarketInfo() async { - BaseListModel baseListModel = - await NetUtil().getList(API.market.hotTop, params: { - "pageNum": _pageNum, - "size": _size, - }); - if (baseListModel.tableList!.isNotEmpty) { - _hotItems = (baseListModel.tableList as List) - .map((e) => GoodsItem.fromJson(e)) - .toList(); - } - _pageCount = baseListModel.pageCount!; - } - - Future loadMarketInfo() async { - BaseListModel baseListModel = - await NetUtil().getList(API.market.hotTop, params: { - "pageNum": _pageNum, - "size": _size, - }); - if (baseListModel.tableList!.isNotEmpty) { - _hotItems.addAll((baseListModel.tableList as List) - .map((e) => GoodsItem.fromJson(e)) - .toList()); - } - _pageCount = baseListModel.pageCount!; - } - - @override - void initState() { - super.initState(); - _refreshController = EasyRefreshController(); - Future.delayed(Duration(milliseconds: 0), () async { - _marketModels = await DisplayCategoryModel.top8; - await updateMarketInfo(); - setState(() {}); - }); - } - - @override - void dispose() { - _refreshController.dispose(); - super.dispose(); - } - - @override - Widget build(BuildContext context) { - super.build(context); - final mediaWidth = MediaQuery.of(context).size.width; - return BeeScaffold( - leading: IconButton( - icon: Icon(CupertinoIcons.search), - onPressed: () { - Get.to(() => SearchGoodsPage()); - }, - ), - title: '商城', - actions: [ - MaterialButton( - minWidth: 108.w, - padding: EdgeInsets.zero, - onPressed: () async { - // Get.to(() => SecondHandPage()); - Get.to(() => MyOrderPage()); - }, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - mainAxisSize: MainAxisSize.max, - children: [ - Image.asset( - R.ASSETS_ICONS_SECOND_HAND_PNG, - width: 48.w, - height: 48.w, - ), - 4.hb, - // '二手'.text.size(20.sp).black.make(), - '订单'.text.size(20.sp).black.make(), - ], - ), - ), - MaterialButton( - minWidth: 108.w, - padding: EdgeInsets.zero, - onPressed: () async { - final cancel = BotToast.showLoading(); - List models = - await DisplayCategoryModel.fetchCategory(0); - cancel(); - Get.to(() => CategoryPage(models: models)); - }, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - mainAxisSize: MainAxisSize.max, - children: [ - Image.asset( - R.ASSETS_ICONS_CATEGORY_PNG, - width: 48.w, - height: 48.w, - ), - 4.hb, - '分类'.text.size(20.sp).black.make(), - ], - ), - ), - ], - body: - NestedScrollView( - headerSliverBuilder: (context, value) { - var gridItems = Material( - color: Colors.white, - clipBehavior: Clip.antiAlias, - borderRadius: BorderRadius.circular(8.w), - child: GridView( - physics: NeverScrollableScrollPhysics(), - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 4, - childAspectRatio: 1, - ), - shrinkWrap: true, - children: - _marketModels.map((e) => CategoryCard(model: e)).toList(), - ), - ); - return [ - SliverAppBar( - //AppBar top Widget height - //bottom height: 48 - // flexibleSpace的高为 (设备宽 - 边距)/4*2 + 外边距 + bottom高 + top热搜栏 - // * 热搜栏 - //expandedHeight: - //(mediaWidth - 32.w * 2) / 4 * 2 + 16.w * 2 + 48 + 68.w, - // - expandedHeight: (mediaWidth - 32.w * 2) / 4 * 2 + 16.w * 2, - backgroundColor: Colors.transparent, - elevation: 0, - flexibleSpace: FlexibleSpaceBar( - background: Container( - color: Color(0xFFF9F9F9), - padding: EdgeInsets.only( - top: 16.w, - left: 32.w, - right: 32.w, - bottom: 16.w, //底部边距需要加上bottom高 - ), - child: Column( - children: [ - // SizedBox( - // height: 58.w, - // child: Row( - // children: [ - // Text( - // '热搜:', - // style: TextStyle( - // fontSize: 20.sp, - // ), - // ), - // 20.wb, - // ListView.separated( - // scrollDirection: Axis.horizontal, - // separatorBuilder: (_, __) => 20.wb, - // itemBuilder: (context, index) { - // final item = _hotItems[index]; - // return MaterialButton( - // padding: - // EdgeInsets.symmetric(horizontal: 40.w), - // minWidth: 0, - // shape: StadiumBorder( - // side: BorderSide( - // color: ktextSubColor, - // width: 1, - // ), - // ), - // materialTapTargetSize: - // MaterialTapTargetSize.shrinkWrap, - // onPressed: () { - // Get.to(() => GoodsDetailPage(id: item.id)); - // }, - // child: Text( - // item.title, - // style: TextStyle( - // color: ktextSubColor, - // ), - // ), - // ); - // }, - // itemCount: _hotItems.length, - // ).expand(), - // ], - // ), - // ), - // 10.hb, - gridItems.expand(), - ], - ), - ), - ), - pinned: true, - toolbarHeight: 0, - // bottom: PreferredSize( - // child: Material( - // color: Color(0xFFF9F9F9), - // child: Align( - // alignment: Alignment.centerLeft, - // child: BeeTabBar( - // scrollable: true, - // controller: _tabController, - // tabs: ['社区商城', '二手市场'], - // ), - // ), - // ), - // preferredSize: Size.fromHeight(48), - // ), - ), - ]; - }, - body: EasyRefresh( - firstRefresh: false, - enableControlFinishLoad: false, - header: MaterialHeader(), - footer: MaterialFooter(), - controller: _refreshController, - onRefresh: () async { - _pageNum = 1; - await updateMarketInfo(); - setState(() {}); - }, - onLoad: () async { - _pageNum++; - await loadMarketInfo(); - if (_pageCount <= _pageNum) { - _refreshController.finishLoad(noMore: false); - } - setState(() {}); - }, - child: WaterfallFlow.builder( - gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount( - crossAxisCount: 2, - mainAxisSpacing: 20.w, - crossAxisSpacing: 20.w, - ), - padding: EdgeInsets.all(32.w), - itemBuilder: (context, index) { - return SizedBox(); - //final item = _hotItems[index]; - // return GoodsCard(item: item); - }, - itemCount: _hotItems.length, - ), - ), - ), - ); - } - - @override - bool get wantKeepAlive => true; -} +// // import 'package:aku_community/base/base_style.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: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:aku_community/ui/market/goods/goods_detail_page.dart'; +// +// // import 'package:aku_community/widget/tab_bar/bee_tab_bar.dart'; +// +// class MarketPage111 extends StatefulWidget { +// MarketPage111({Key? key}) : super(key: key); +// +// @override +// _MarketPageState createState() => _MarketPageState(); +// } +// +// class _MarketPageState extends State +// with AutomaticKeepAliveClientMixin { +// List _marketModels = []; +// List _hotItems = []; +// late EasyRefreshController _refreshController; +// int _pageNum = 1; +// int _size = 4; +// int _pageCount = 0; +// +// Future updateMarketInfo() async { +// BaseListModel baseListModel = +// await NetUtil().getList(API.market.hotTop, params: { +// "pageNum": _pageNum, +// "size": _size, +// }); +// if (baseListModel.tableList!.isNotEmpty) { +// _hotItems = (baseListModel.tableList as List) +// .map((e) => GoodsItem.fromJson(e)) +// .toList(); +// } +// _pageCount = baseListModel.pageCount!; +// } +// +// Future loadMarketInfo() async { +// BaseListModel baseListModel = +// await NetUtil().getList(API.market.hotTop, params: { +// "pageNum": _pageNum, +// "size": _size, +// }); +// if (baseListModel.tableList!.isNotEmpty) { +// _hotItems.addAll((baseListModel.tableList as List) +// .map((e) => GoodsItem.fromJson(e)) +// .toList()); +// } +// _pageCount = baseListModel.pageCount!; +// } +// +// @override +// void initState() { +// super.initState(); +// _refreshController = EasyRefreshController(); +// Future.delayed(Duration(milliseconds: 0), () async { +// _marketModels = await DisplayCategoryModel.top8; +// await updateMarketInfo(); +// setState(() {}); +// }); +// } +// +// @override +// void dispose() { +// _refreshController.dispose(); +// super.dispose(); +// } +// +// @override +// Widget build(BuildContext context) { +// super.build(context); +// final mediaWidth = MediaQuery.of(context).size.width; +// return BeeScaffold( +// leading: IconButton( +// icon: Icon(CupertinoIcons.search), +// onPressed: () { +// Get.to(() => SearchGoodsPage()); +// }, +// ), +// title: '商城', +// actions: [ +// MaterialButton( +// minWidth: 108.w, +// padding: EdgeInsets.zero, +// onPressed: () async { +// // Get.to(() => SecondHandPage()); +// Get.to(() => MyOrderPage()); +// }, +// child: Column( +// mainAxisAlignment: MainAxisAlignment.center, +// mainAxisSize: MainAxisSize.max, +// children: [ +// Image.asset( +// R.ASSETS_ICONS_SECOND_HAND_PNG, +// width: 48.w, +// height: 48.w, +// ), +// 4.hb, +// // '二手'.text.size(20.sp).black.make(), +// '订单'.text.size(20.sp).black.make(), +// ], +// ), +// ), +// MaterialButton( +// minWidth: 108.w, +// padding: EdgeInsets.zero, +// onPressed: () async { +// final cancel = BotToast.showLoading(); +// List models = +// await DisplayCategoryModel.fetchCategory(0); +// cancel(); +// Get.to(() => CategoryPage(models: models)); +// }, +// child: Column( +// mainAxisAlignment: MainAxisAlignment.center, +// mainAxisSize: MainAxisSize.max, +// children: [ +// Image.asset( +// R.ASSETS_ICONS_CATEGORY_PNG, +// width: 48.w, +// height: 48.w, +// ), +// 4.hb, +// '分类'.text.size(20.sp).black.make(), +// ], +// ), +// ), +// ], +// body: +// NestedScrollView( +// headerSliverBuilder: (context, value) { +// var gridItems = Material( +// color: Colors.white, +// clipBehavior: Clip.antiAlias, +// borderRadius: BorderRadius.circular(8.w), +// child: GridView( +// physics: NeverScrollableScrollPhysics(), +// gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( +// crossAxisCount: 4, +// childAspectRatio: 1, +// ), +// shrinkWrap: true, +// children: +// _marketModels.map((e) => CategoryCard(model: e)).toList(), +// ), +// ); +// return [ +// SliverAppBar( +// //AppBar top Widget height +// //bottom height: 48 +// // flexibleSpace的高为 (设备宽 - 边距)/4*2 + 外边距 + bottom高 + top热搜栏 +// // * 热搜栏 +// //expandedHeight: +// //(mediaWidth - 32.w * 2) / 4 * 2 + 16.w * 2 + 48 + 68.w, +// // +// expandedHeight: (mediaWidth - 32.w * 2) / 4 * 2 + 16.w * 2, +// backgroundColor: Colors.transparent, +// elevation: 0, +// flexibleSpace: FlexibleSpaceBar( +// background: Container( +// color: Color(0xFFF9F9F9), +// padding: EdgeInsets.only( +// top: 16.w, +// left: 32.w, +// right: 32.w, +// bottom: 16.w, //底部边距需要加上bottom高 +// ), +// child: Column( +// children: [ +// // SizedBox( +// // height: 58.w, +// // child: Row( +// // children: [ +// // Text( +// // '热搜:', +// // style: TextStyle( +// // fontSize: 20.sp, +// // ), +// // ), +// // 20.wb, +// // ListView.separated( +// // scrollDirection: Axis.horizontal, +// // separatorBuilder: (_, __) => 20.wb, +// // itemBuilder: (context, index) { +// // final item = _hotItems[index]; +// // return MaterialButton( +// // padding: +// // EdgeInsets.symmetric(horizontal: 40.w), +// // minWidth: 0, +// // shape: StadiumBorder( +// // side: BorderSide( +// // color: ktextSubColor, +// // width: 1, +// // ), +// // ), +// // materialTapTargetSize: +// // MaterialTapTargetSize.shrinkWrap, +// // onPressed: () { +// // Get.to(() => GoodsDetailPage(id: item.id)); +// // }, +// // child: Text( +// // item.title, +// // style: TextStyle( +// // color: ktextSubColor, +// // ), +// // ), +// // ); +// // }, +// // itemCount: _hotItems.length, +// // ).expand(), +// // ], +// // ), +// // ), +// // 10.hb, +// gridItems.expand(), +// ], +// ), +// ), +// ), +// pinned: true, +// toolbarHeight: 0, +// // bottom: PreferredSize( +// // child: Material( +// // color: Color(0xFFF9F9F9), +// // child: Align( +// // alignment: Alignment.centerLeft, +// // child: BeeTabBar( +// // scrollable: true, +// // controller: _tabController, +// // tabs: ['社区商城', '二手市场'], +// // ), +// // ), +// // ), +// // preferredSize: Size.fromHeight(48), +// // ), +// ), +// ]; +// }, +// body: EasyRefresh( +// firstRefresh: false, +// enableControlFinishLoad: false, +// header: MaterialHeader(), +// footer: MaterialFooter(), +// controller: _refreshController, +// onRefresh: () async { +// _pageNum = 1; +// await updateMarketInfo(); +// setState(() {}); +// }, +// onLoad: () async { +// _pageNum++; +// await loadMarketInfo(); +// if (_pageCount <= _pageNum) { +// _refreshController.finishLoad(noMore: false); +// } +// setState(() {}); +// }, +// child: WaterfallFlow.builder( +// gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount( +// crossAxisCount: 2, +// mainAxisSpacing: 20.w, +// crossAxisSpacing: 20.w, +// ), +// padding: EdgeInsets.all(32.w), +// itemBuilder: (context, index) { +// return SizedBox(); +// //final item = _hotItems[index]; +// // return GoodsCard(item: item); +// }, +// itemCount: _hotItems.length, +// ), +// ), +// ), +// ); +// } +// +// @override +// bool get wantKeepAlive => true; +// } diff --git a/lib/ui/market/search/search_goods_page.dart b/lib/ui/market/search/search_goods_page.dart index 8f756961..b3ecab60 100644 --- a/lib/ui/market/search/search_goods_page.dart +++ b/lib/ui/market/search/search_goods_page.dart @@ -19,7 +19,6 @@ import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:get/get.dart'; import 'package:provider/provider.dart'; - import 'package:aku_community/base/base_style.dart'; import 'package:aku_community/constants/api.dart'; import 'package:aku_community/models/market/goods_item.dart'; @@ -27,7 +26,9 @@ import 'package:aku_community/pages/things_page/widget/bee_list_view.dart'; import 'package:aku_community/ui/market/goods/goods_card.dart'; import 'package:aku_community/utils/headers.dart'; import 'package:aku_community/widget/bee_scaffold.dart'; +import 'package:waterfall_flow/waterfall_flow.dart'; +import '../search_goods_card.dart'; import 'good_detail_page.dart'; import 'goods_list_card.dart'; @@ -39,8 +40,11 @@ enum OrderType { } class SearchGoodsPage extends StatefulWidget { - final String? search; - SearchGoodsPage({Key? key, this.search}) : super(key: key); + final String? categoryName; + final int? categoryId; + + SearchGoodsPage({Key? key, this.categoryName, this.categoryId}) + : super(key: key); @override SearchGoodsPageState createState() => SearchGoodsPageState(); @@ -49,6 +53,7 @@ class SearchGoodsPage extends StatefulWidget { class SearchGoodsPageState extends State { TextEditingController _editingController = TextEditingController(); OrderType _orderType = OrderType.NORMAL; + // IconData priceIcon = CupertinoIcons.chevron_up_chevron_down; String priceIcon = R.ASSETS_ICONS_ICON_PRICE_NORMAL_PNG; EasyRefreshController _refreshController = EasyRefreshController(); @@ -58,22 +63,23 @@ class SearchGoodsPageState extends State { FocusNode _contentFocusNode = FocusNode(); bool _showList = true; bool _startSearch = false; - int? orderBySalesVolume; - int? orderByPrice; - int? brandId; - double? minPrice; - double? maxPrice; - List _models = []; - ScrollController _scrollController= new ScrollController(); + int? orderBySalesVolume; + int? orderByPrice; + int? brandId; + double? minPrice; + double? maxPrice; + List _models = []; + ScrollController _scrollController = new ScrollController(); List goodsPopularModels = []; + int? categoryThirdId; + bool _showCategory = false; + bool _showListOrGrid = true;//true list false grid @override void initState() { super.initState(); - if(widget.search!=null){ - _startSearch = true; - _searchText = widget.search??''; - _editingController.text = widget.search??''; + if (widget.categoryName != null) { + _showCategory = true; } getSearchListFromSharedPreferences(); @@ -102,11 +108,10 @@ class SearchGoodsPageState 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, ), ), @@ -118,18 +123,17 @@ class SearchGoodsPageState extends State { _orderType = OrderType.SALES; orderBySalesVolume = 2; orderByPrice = null; - priceIcon = R.ASSETS_ICONS_ICON_PRICE_NORMAL_PNG; + priceIcon = R.ASSETS_ICONS_ICON_PRICE_NORMAL_PNG; _refreshController1.callRefresh(); setState(() {}); }, 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, ), ), @@ -169,16 +173,16 @@ class SearchGoodsPageState 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, ), ), @@ -190,36 +194,114 @@ class SearchGoodsPageState extends State { // ? kBalckSubColor // : ktextPrimary, // ), - Image.asset(priceIcon,width: 32.w,height: 32.w,) + Image.asset( + priceIcon, + width: 32.w, + height: 32.w, + ) ], ), height: 80.w, materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, ); - return - BeeScaffold( + return BeeScaffold( + titleSpacing: 0, + bgColor: Color(0xFFF9F9F9), + bodyColor: Color(0xFFF9F9F9), + title: Row( + children: [ + Container( + width: 520.w, + height: 68.w, + child: TextField( + keyboardType: TextInputType.text, + onEditingComplete: () { + setState(() {}); + // _refreshController.callRefresh(); + }, + focusNode: _contentFocusNode, + onChanged: (text) { + _startSearch = false; + _searchText = text; + setState(() {}); + }, + onTap: () { + _showCategory = false; + setState(() {}); + }, + onSubmitted: (_submitted) async { + if (TextUtils.isEmpty(_searchText)) return; + _startSearch = true; + _contentFocusNode.unfocus(); + _searchText = _searchText.trimLeft(); + _searchText = _searchText.trimRight(); + remember(); + saveSearchListToSharedPreferences(_searchHistory); + _refreshController1.callRefresh(); + setState(() {}); + }, + style: TextStyle( + textBaseline: TextBaseline.ideographic, + fontSize: 32.sp, + color: Colors.black, + ), + controller: _editingController, + decoration: InputDecoration( + contentPadding: EdgeInsets.only(left: 20.w), + filled: true, + fillColor: Colors.white, + hintText: _showCategory ? '' : "请输入想要搜索的内容...", + hintStyle: TextStyle( + color: Colors.grey.shade500, + fontSize: 14, + fontWeight: FontWeight.w300), + prefixIcon: _showCategory + ? GestureDetector( + child: Container( + padding: EdgeInsets.only(left: 18.w, right: 18.w), + margin: EdgeInsets.all(12.w), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(40.w), + color: Color(0xFFF2F2F2)), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + widget.categoryName ?? '', + style: TextStyle( + color: ktextSubColor, + fontSize: 24.sp, + ), + ), + Icon( + Icons.close, + color: Colors.grey[500], + size: 30.w, + ) + ], + ), + height: 44.w, + ), + ) + : null, - titleSpacing: 0, - bgColor: Color(0xFFF9F9F9), - bodyColor: Color(0xFFF9F9F9), - title: Row( - children: [ - Container( - width: 520.w, - height: 68.w, - child: TextField( - keyboardType: TextInputType.text, - onEditingComplete: () { - setState(() {}); - // _refreshController.callRefresh(); - }, - focusNode: _contentFocusNode, - onChanged: (text) { - _startSearch = false; - _searchText = text; - setState(() {}); - }, - onSubmitted: (_submitted) async { + //isDense: true, + // prefixIcon: Icon(CupertinoIcons.search), + + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: ktextPrimary), + borderRadius: BorderRadius.circular(40.w), + ), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: Color(0xFFE52E2E)), + borderRadius: BorderRadius.circular(40.w), + ), + ), + ), + ), + 20.wb, + GestureDetector( + onTap: () { if (TextUtils.isEmpty(_searchText)) return; _startSearch = true; _contentFocusNode.unfocus(); @@ -230,259 +312,260 @@ class SearchGoodsPageState extends State { _refreshController1.callRefresh(); setState(() {}); }, - style: TextStyle( - textBaseline: TextBaseline.ideographic, - fontSize: 32.sp, - color: Colors.black, + child: Text( + '搜索', + style: TextStyle(color: ktextPrimary, fontSize: 28.sp), ), - controller: _editingController, - decoration: InputDecoration( - contentPadding: EdgeInsets.only(left: 20.w), - //filled: true, - fillColor: Color(0xFFF3F3F3), - hintText: "请输入想要搜索的内容...", - hintStyle: TextStyle( - color: Colors.grey.shade500, - fontSize: 14, - fontWeight: FontWeight.w300), - - //isDense: true, - // prefixIcon: Icon(CupertinoIcons.search), - - enabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: ktextPrimary), - borderRadius: BorderRadius.circular(40), - ), - focusedBorder: OutlineInputBorder( - borderSide: BorderSide(color: Color(0xFFE52E2E)), - borderRadius: BorderRadius.circular(40), - ), - ), - ), - ), - 20.wb, - GestureDetector( - onTap: (){ - if (TextUtils.isEmpty(_searchText)) return; - _startSearch = true; - _contentFocusNode.unfocus(); - _searchText = _searchText.trimLeft(); - _searchText = _searchText.trimRight(); - remember(); - saveSearchListToSharedPreferences(_searchHistory); - _refreshController1.callRefresh(); - setState(() {}); - }, - child: Text( - '搜索', - style: TextStyle(color: ktextPrimary, fontSize: 28.sp), ), - ), - ], - ), - - body:Stack( - - children: [ + ], + ), + body: Stack( + children: [ + (!(!TextUtils.isEmpty(_editingController.text) && _startSearch)) && + !_showCategory + ? Column( + children: [ + _searchHistoryWidget(), + 10.hb, + Row( + children: [ + 20.wb, + Text( + '热搜榜', + style: TextStyle( + color: ktextSubColor, + fontSize: 32.sp, + ), + ), + Spacer(), + GestureDetector( + child: Image.asset( + _showList + ? R.ASSETS_ICONS_XIANSHI_PNG + : R.ASSETS_ICONS_EYE_CLOSE_PNG, + width: 40.w, + height: 40.w, + ), + onTap: () { + _showList = !_showList; + setState(() {}); + }, + ), + 32.wb, + ], + ), + 10.hb, + _showList + ? Container( + color: Color(0xFFF2F3F4), + child: EasyRefresh( + firstRefresh: true, + header: MaterialHeader(), + footer: MaterialFooter(), + controller: _refreshController, + onRefresh: () async { + goodsPopularModels = + await CommunityFunc.getGoodsPopularModel( + 20); + setState(() {}); + }, + child: goodsPopularModels.isEmpty + ? Container() + : ListView.separated( + padding: EdgeInsets.symmetric( + vertical: 16.w, horizontal: 32.w), + itemBuilder: (context, index) { + return _hotGoodsCard( + goodsPopularModels[index], index); + }, + separatorBuilder: (_, __) { + return 16.w.heightBox; + }, + itemCount: goodsPopularModels.length), + ), + // BeeListView( + // path: API.market.search, + // controller: _refreshController, + // extraParams: {'searchName': ''}, + // convert: (model) => model.tableList! + // .map((e) => GoodsItem.fromJson(e)) + // .toList(), + // builder: (items) { + // return ListView.separated( + // padding: EdgeInsets.only(top: 10.w, + // left: 20.w, right: 20.w, bottom: 32.w), + // + // // gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount( + // // crossAxisCount: 2, + // // mainAxisSpacing: 20.w, + // // crossAxisSpacing: 20.w, + // // ), + // itemBuilder: (context, index) { + // final item = items[index]; + // return _hotGoodsCard( + // item, index); //GoodsCard(item: item); + // }, + // separatorBuilder: (_, __) { + // return 32.w.heightBox; + // }, + // itemCount: items.length, + // ); + // }, + // ), + ).expand() + : SizedBox(), + ], + ) + : Column( + children: [ + Row( + children: [ + normalTypeButton, + salesTypeButton, + priceButton, + Spacer(), + GestureDetector( + onTap: (){ + _showListOrGrid = !_showListOrGrid; + setState(() { + + }); + }, + child: Image.asset(_showListOrGrid? + R.ASSETS_ICONS_ICON_CHANGE_LIST_PNG: + R.ASSETS_ICONS_ICON_CHANGE_GRID_PNG,width: 40.w,height: 40.w,), + ), - !(!TextUtils.isEmpty(_editingController.text) && - _startSearch) - ? Column( - children: [ - _searchHistoryWidget(), - 10.hb, - Row( + 30.wb, + ], + ), + 10.hb, + Container( + color: Color(0xFFF2F3F4), + child: BeeListView( + path: API.market.findGoodsList, + controller: _refreshController1, + refreshExtra: (model) => + _models = model as List, + extraParams: { + "orderBySalesVolume": orderBySalesVolume, + "orderByPrice": orderByPrice, + "keyword": _searchText, + "brandId": brandId, + "minPrice": minPrice, + "maxPrice": maxPrice, + 'categoryThirdId': widget.categoryId, + }, + convert: (model) => model.tableList! + .map((e) => SearchGoodsModel.fromJson(e)) + .toList(), + builder: (items) { + return + _showListOrGrid?ListView.separated( + controller: _scrollController, + padding: EdgeInsets.only( + top: 10.w, + left: 20.w, + right: 20.w, + bottom: 32.w), + // gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount( + // crossAxisCount: 2, + // mainAxisSpacing: 20.w, + // crossAxisSpacing: 20.w, + // ), + itemBuilder: (context, index) { + final item = items[index]; + return GoodsListCard( + model: item, + refreshController: _refreshController1, + ); //GoodsCard(item: item); + }, + separatorBuilder: (_, __) { + return 32.w.heightBox; + }, + itemCount: items.length, + ):WaterfallFlow.builder( + gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + mainAxisSpacing: 20.w, + crossAxisSpacing: 20.w, + ), + padding: EdgeInsets.only( + top: 10.w, + left: 20.w, + right: 20.w, + bottom: 32.w), + itemBuilder: (context, index) { + final item = _models[index]; + return SearchGoodsCard(item: item,refreshController: _refreshController1,); + }, + itemCount: _models.length, + ); + }, + ), + ).expand(), + ], + ), + Positioned( + right: 26.w, + bottom: 92.w, + child: Column( children: [ - 20.wb, - Text( - '热搜榜', - style: TextStyle( - color: ktextSubColor, - fontSize: 32.sp, + GestureDetector( + child: Image.asset( + R.ASSETS_ICONS_COLLECT_PNG, + width: 84.w, + height: 84.w, ), + onTap: () async { + var result = await Get.to(() => MyCollectionPage()); + if (result != null) if (result) { + _refreshController1.callRefresh(); + } + }, ), - Spacer(), + 24.hb, GestureDetector( child: Image.asset( - _showList - ? R.ASSETS_ICONS_XIANSHI_PNG - : R.ASSETS_ICONS_EYE_CLOSE_PNG, - width: 40.w, - height: 40.w, + R.ASSETS_ICONS_ICON_TOTOP_PNG, + width: 84.w, + height: 84.w, ), onTap: () { - _showList = !_showList; - setState(() {}); + _scrollController.jumpToTop(); }, ), - 32.wb, ], ), - 10.hb, - _showList - ? Container( - color: Color(0xFFF2F3F4), - child: EasyRefresh( - firstRefresh: true, - header: MaterialHeader(), - footer: MaterialFooter(), - controller: _refreshController, - onRefresh: () async { - goodsPopularModels = await CommunityFunc.getGoodsPopularModel(20); - setState(() {}); - }, - child: goodsPopularModels.isEmpty - ? Container() - : ListView.separated( - padding: EdgeInsets.symmetric(vertical: 16.w, horizontal: 32.w), - itemBuilder: (context, index) { - return _hotGoodsCard(goodsPopularModels[index], index); - }, - separatorBuilder: (_, __) { - return 16.w.heightBox; - }, - itemCount: goodsPopularModels.length), - ), - // BeeListView( - // path: API.market.search, - // controller: _refreshController, - // extraParams: {'searchName': ''}, - // convert: (model) => model.tableList! - // .map((e) => GoodsItem.fromJson(e)) - // .toList(), - // builder: (items) { - // return ListView.separated( - // padding: EdgeInsets.only(top: 10.w, - // left: 20.w, right: 20.w, bottom: 32.w), - // - // // gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount( - // // crossAxisCount: 2, - // // mainAxisSpacing: 20.w, - // // crossAxisSpacing: 20.w, - // // ), - // itemBuilder: (context, index) { - // final item = items[index]; - // return _hotGoodsCard( - // item, index); //GoodsCard(item: item); - // }, - // separatorBuilder: (_, __) { - // return 32.w.heightBox; - // }, - // itemCount: items.length, - // ); - // }, - // ), - ).expand() - : SizedBox(), - ], - ):Column( - children: [ - Row( - children: [ - normalTypeButton, - salesTypeButton, - priceButton, - ], - ), - 10.hb, - Container( - color: Color(0xFFF2F3F4), - child: BeeListView( - path: API.market.findGoodsList, - controller: _refreshController1, - refreshExtra:( model) => _models = model as List, - extraParams: {"orderBySalesVolume":orderBySalesVolume,"orderByPrice":orderByPrice, - "keyword":_searchText, - "brandId":brandId,"minPrice":minPrice,"maxPrice":maxPrice,}, - convert: (model) => model.tableList! - .map((e) => SearchGoodsModel.fromJson(e)) - .toList(), - builder: (items) { - return ListView.separated( - controller: _scrollController, - padding: EdgeInsets.only(top: 10.w, - left: 20.w, right: 20.w, bottom: 32.w), - // gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount( - // crossAxisCount: 2, - // mainAxisSpacing: 20.w, - // crossAxisSpacing: 20.w, - // ), - itemBuilder: (context, index) { - final item = items[index]; - return GoodsListCard( - model: item,refreshController: _refreshController1,); //GoodsCard(item: item); - }, - separatorBuilder: (_, __) { - return 32.w.heightBox; - }, - itemCount: items.length, - ); - }, - ), - ).expand(), - ], - ), - - Positioned( - right: 26.w, - bottom: 92.w, - child: Column( - children: [ - GestureDetector( - child: Image.asset(R.ASSETS_ICONS_COLLECT_PNG,width: 84.w,height: 84.w,), - onTap: ()async{ - var result = await Get.to(() => MyCollectionPage()); - if(result!=null) - if(result){ - _refreshController1.callRefresh(); - } - }, - ), - 24.hb, - GestureDetector( - child: Image.asset(R.ASSETS_ICONS_ICON_TOTOP_PNG,width: 84.w,height: 84.w,), - onTap: (){ - _scrollController.jumpToTop(); - }, - ), - - ], ), - ), - ], - ) - - - - - - ); + ], + )); } ///保存搜索记录 remember() { - if (_searchHistory.contains(_searchText)) { - _searchHistory.remove(_searchText); - List list = [_searchText]; - list.addAll(_searchHistory); - _searchHistory = list; - } else { - List list = [_searchText]; - list.addAll(_searchHistory); - _searchHistory = list; - while (_searchHistory.length > 15) { - _searchHistory.removeLast(); - } + if (_searchHistory.contains(_searchText)) { + _searchHistory.remove(_searchText); + List list = [_searchText]; + list.addAll(_searchHistory); + _searchHistory = list; + } else { + List list = [_searchText]; + list.addAll(_searchHistory); + _searchHistory = list; + while (_searchHistory.length > 15) { + _searchHistory.removeLast(); } - saveSearchListToSharedPreferences(_searchHistory); - setState(() {}); + } + saveSearchListToSharedPreferences(_searchHistory); + setState(() {}); } _hotGoodsCard(GoodsPopularModel goodsItem, int index) { return GestureDetector( - onTap: (){ + onTap: () { Get.to( - () => GoodDetailPage(goodId: goodsItem.id!), + () => GoodDetailPage(goodId: goodsItem.id!), ); }, child: Container( @@ -497,7 +580,7 @@ class SearchGoodsPageState extends State { clipBehavior: Clip.antiAlias, child: FadeInImage.assetNetwork( placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, - image: goodsItem.mainPhoto??'', + image: goodsItem.mainPhoto ?? '', fit: BoxFit.fill, width: 124.w, height: 124.w, @@ -563,7 +646,7 @@ class SearchGoodsPageState extends State { SizedBox( width: 500.w, child: Text( - goodsItem.skuName??'', + goodsItem.skuName ?? '', maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle(color: ktextPrimary, fontSize: 28.sp), @@ -578,8 +661,11 @@ class SearchGoodsPageState extends State { ), 10.wb, Text( - goodsItem.viewsNum==null?'0':goodsItem.viewsNum.toString(), - style: TextStyle(color: Color(0xFFBBBBBB), fontSize: 24.sp), + goodsItem.viewsNum == null + ? '0' + : goodsItem.viewsNum.toString(), + style: + TextStyle(color: Color(0xFFBBBBBB), fontSize: 24.sp), ), ], ) @@ -678,12 +764,15 @@ class SearchGoodsPageState extends State { getSearchListFromSharedPreferences() async { final userProvider = Provider.of(Get.context!, listen: false); _searchHistory = HiveStore.appBox!.get( - userProvider.userInfoModel?.id.toString() ?? '' + "userSearhHistory")??''; + userProvider.userInfoModel?.id.toString() ?? + '' + "userSearhHistory") ?? + ''; if (_searchHistory == null) { _searchHistory = []; } setState(() {}); } + ///保存搜索记录 saveSearchListToSharedPreferences(List value) async { final userProvider = Provider.of(Get.context!, listen: false); @@ -692,7 +781,4 @@ class SearchGoodsPageState extends State { userProvider.userInfoModel?.id.toString() ?? '' + "userSearhHistory", value); } - - - } diff --git a/lib/ui/market/search_goods_card.dart b/lib/ui/market/search_goods_card.dart new file mode 100644 index 00000000..327f8296 --- /dev/null +++ b/lib/ui/market/search_goods_card.dart @@ -0,0 +1,289 @@ +import 'package:aku_community/models/market/order/goods_home_model.dart'; +import 'package:aku_community/models/search/search_goods_model.dart'; +import 'package:aku_community/ui/market/search/good_detail_page.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; + +import 'package:get/get.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/models/market/goods_item.dart'; +import 'package:aku_community/ui/market/goods/goods_detail_page.dart'; +import 'package:aku_community/utils/headers.dart'; + +import 'collection/collection_func.dart'; + +class SearchGoodsCard extends StatefulWidget { + final SearchGoodsModel item; + final EasyRefreshController? refreshController; + + const SearchGoodsCard({Key? key, required this.item, this.refreshController,}) + : super(key: key); + + @override + _SearchGoodsCardState createState() => _SearchGoodsCardState(); +} +class _SearchGoodsCardState extends State { + @override + Widget build(BuildContext context) { + return MaterialButton( + color: Colors.white, + elevation: 0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(24.w), + ), + padding: EdgeInsets.zero, + onPressed: () { + Get.to( + () => GoodDetailPage(goodId: widget.item.id!), + ); + }, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + clipBehavior: Clip.antiAlias, + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(24.w)), + ), + child: Stack( + children: [ + FadeInImage.assetNetwork( + placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + image: widget.item.mainPhoto ?? '', + fit: BoxFit.fill, + imageErrorBuilder: (context, error, stackTrace) { + return Image.asset(R.ASSETS_IMAGES_PLACEHOLDER_WEBP); + }, + ), + // Positioned( + // left: 0, + // right: 0, + // bottom: 0, + // child: Container( + // height: 38.w, + // color: Colors.black54, + // alignment: Alignment.centerLeft, + // padding: EdgeInsets.symmetric(horizontal: 12.w), + // child: Text( + // item.skuName??'', + // overflow: TextOverflow.ellipsis, + // style: TextStyle( + // color: Colors.white, + // fontSize: 18.sp, + // ), + // ), + // ), + // ), + ], + ), + ), + Container( + padding: EdgeInsets.only( + left: 16.w, right: 16.w, + top: 10.w, + ), + child: Text( + widget.item.skuName ?? '', + maxLines: 2, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 28.sp, + color: ktextPrimary + ), + ), + ), + + Padding( + padding: EdgeInsets.only( + left: 16.w, right: 16.w, + top: 10.w, + ), + child: Container( + child: _getIcon(widget.item.kind??0), + ) + ), + + 10.hb, + Padding( + padding: EdgeInsets.symmetric( + horizontal: 16.w, + ), + child: RichText( + text: TextSpan( + children: [ + TextSpan( + text: '¥', + style: TextStyle( + color: Colors.red, + fontSize: 28.sp, + ), + ), + TextSpan( + text: '${widget.item.sellPrice ?? ''} ', + style: TextStyle( + color: Colors.red, + fontWeight: FontWeight.bold, + fontSize: 40.sp, + ), + ), + ], + ), + ), + ), + Row( + children: [ + Column( + children: [ + Padding( + padding: EdgeInsets.symmetric( + horizontal: 16.w, + ), + child: RichText( + text: TextSpan( + children: [ + TextSpan( + text: '原价:', + style: TextStyle( + color: ktextSubColor, + fontSize: 20.sp, + + ), + ), + TextSpan( + text: widget.item.discountPrice == null ? '' : '¥${widget.item + .discountPrice ?? ''}', + style: TextStyle( + color: ktextSubColor, + fontSize: 20.sp, + decoration: TextDecoration.lineThrough, + ), + ), + ], + ), + ), + ), + Padding( + padding: EdgeInsets.symmetric( + horizontal: 16.w, + ), + child: RichText( + text: TextSpan( + children: [ + TextSpan( + text: '折扣:', + style: TextStyle( + color: ktextSubColor, + fontSize: 20.sp, + + ), + ), + TextSpan( + text: (widget.item.discountPrice ?? 0) > (widget.item.sellPrice ?? 0) + ? _getDiscount(widget.item.sellPrice ?? -1, + widget.item.discountPrice ?? -1) + : '暂无折扣', + style: TextStyle( + color: ktextSubColor, + fontSize: 20.sp, + + ), + ), + ], + ), + ), + ), + ], + ), + Spacer(), + GestureDetector( + onTap: () async { + await CollectionFunc.collection(widget.item.id!); + + if (widget.refreshController != null) { + widget.refreshController!.callRefresh(); + } + }, + child: (widget.item.isCollection ?? 0) != 0 + ? Image.asset( + R.ASSETS_ICONS_SHOP_FAVORFILL_PNG, + width: 42.w, + height: 42.w, + ) + : Image.asset( + R.ASSETS_ICONS_ICON_FAVOR_CHOOSE_PNG, + width: 42.w, + height: 42.w, + ), + ), + 20.wb, + ], + ), + + 20.hb, + ], + ), + ); + } + + _getDiscount(double sellPrice, double discountPrice) { + String count = ''; + count = ((sellPrice / discountPrice) * 10).toStringAsFixed(1); + + return count + '折'; + } + + + Widget _getIcon(int type) { + if (type == 1) { + return Container( + width: 86.w, + height: 26.w, + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(4.w),), + gradient: LinearGradient( + begin: FractionalOffset.centerLeft, + end: FractionalOffset.centerRight, + colors: [Color(0xFFEC5329), Color(0xFFF58123)], + ), + ), + child: Text( + '京东自营', + style: TextStyle( + fontSize: 18.sp, + color: kForeGroundColor + ), + ), + ); + } + else if (type == 2) { + return Container( + alignment: Alignment.center, + width: 86.w, + height: 30.w, + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(4.w),), + gradient: LinearGradient( + begin: FractionalOffset.centerLeft, + end: FractionalOffset.centerRight, + colors: [Color(0xFFF59B1C), Color(0xFFF5AF16)], + ), + ), + child: Text( + '京东POP', + style: TextStyle( + fontSize: 18.sp, + color: kForeGroundColor + ), + ), + ); + } + else + return SizedBox(); + } +} + + diff --git a/pubspec.lock b/pubspec.lock index 0d1ec43c..f8523b77 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -379,41 +379,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "6.1.2" - firebase_core: - dependency: "direct main" - description: - name: firebase_core - url: "https://pub.flutter-io.cn" - source: hosted - version: "1.4.0" - firebase_core_platform_interface: - dependency: transitive - description: - name: firebase_core_platform_interface - url: "https://pub.flutter-io.cn" - source: hosted - version: "4.0.1" - firebase_core_web: - dependency: transitive - description: - name: firebase_core_web - url: "https://pub.flutter-io.cn" - source: hosted - version: "1.1.0" - firebase_crashlytics: - dependency: "direct main" - description: - name: firebase_crashlytics - url: "https://pub.flutter-io.cn" - source: hosted - version: "2.1.1" - firebase_crashlytics_platform_interface: - dependency: transitive - description: - name: firebase_crashlytics_platform_interface - url: "https://pub.flutter-io.cn" - source: hosted - version: "3.1.0" fixnum: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 9d3cd1dd..7c94e55f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -88,9 +88,9 @@ dependencies: amap_flutter_base: ^2.0.0 #动态文字 animated_text_kit: ^4.2.1 - #谷歌崩溃记录分析 - firebase_core: ^1.1.1 - firebase_crashlytics: ^2.0.3 +# #谷歌崩溃记录分析 +# firebase_core: ^1.1.1 +# firebase_crashlytics: ^2.0.3 #分享功能 share: ^2.0.1 collection: ^1.15.0