diff --git a/android/app/build.gradle b/android/app/build.gradle index 3f6c1cba..db4e6066 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -98,6 +98,7 @@ dependencies { implementation 'com.amap.api:3dmap:latest.integration' implementation 'com.amap.api:location:latest.integration' implementation 'com.android.support:multidex:2.0.1' + } apply plugin: 'com.google.gms.google-services' diff --git a/assets/icons/collect.png b/assets/icons/collect.png new file mode 100644 index 00000000..11bf6b6c Binary files /dev/null and b/assets/icons/collect.png differ diff --git a/assets/icons/collection_setting.png b/assets/icons/collection_setting.png new file mode 100644 index 00000000..011a9b66 Binary files /dev/null and b/assets/icons/collection_setting.png differ diff --git a/assets/icons/collection_share.png b/assets/icons/collection_share.png new file mode 100644 index 00000000..09b3b614 Binary files /dev/null and b/assets/icons/collection_share.png differ diff --git a/assets/icons/delete.png b/assets/icons/delete.png new file mode 100644 index 00000000..a9cfd9ac Binary files /dev/null and b/assets/icons/delete.png differ diff --git a/assets/icons/eye_close.png b/assets/icons/eye_close.png new file mode 100644 index 00000000..26601523 Binary files /dev/null and b/assets/icons/eye_close.png differ diff --git a/assets/icons/filter.png b/assets/icons/filter.png new file mode 100644 index 00000000..e3669306 Binary files /dev/null and b/assets/icons/filter.png differ diff --git a/assets/icons/icon_change_list.png b/assets/icons/icon_change_list.png new file mode 100644 index 00000000..85cb9d89 Binary files /dev/null and b/assets/icons/icon_change_list.png differ diff --git a/assets/icons/icon_favor_choose.png b/assets/icons/icon_favor_choose.png new file mode 100644 index 00000000..0cf7090d Binary files /dev/null and b/assets/icons/icon_favor_choose.png differ diff --git a/assets/icons/icon_more.png b/assets/icons/icon_more.png new file mode 100644 index 00000000..3cf29c6c Binary files /dev/null and b/assets/icons/icon_more.png differ diff --git a/assets/icons/icon_price.png b/assets/icons/icon_price.png new file mode 100644 index 00000000..a2993579 Binary files /dev/null and b/assets/icons/icon_price.png differ diff --git a/assets/icons/icon_setting.png b/assets/icons/icon_setting.png new file mode 100644 index 00000000..7aa090e7 Binary files /dev/null and b/assets/icons/icon_setting.png differ diff --git a/assets/icons/icon_toTop.png b/assets/icons/icon_toTop.png new file mode 100644 index 00000000..a693bac5 Binary files /dev/null and b/assets/icons/icon_toTop.png differ diff --git a/assets/icons/shop_search.png b/assets/icons/shop_search.png index 233f7cdc..aea3e039 100644 Binary files a/assets/icons/shop_search.png and b/assets/icons/shop_search.png differ diff --git a/assets/icons/xianshi.png b/assets/icons/xianshi.png new file mode 100644 index 00000000..1bfb603e Binary files /dev/null and b/assets/icons/xianshi.png differ diff --git a/lib/const/resource.dart b/lib/const/resource.dart index c2a7f316..7be63ebc 100644 --- a/lib/const/resource.dart +++ b/lib/const/resource.dart @@ -165,6 +165,17 @@ class R { /// ![preview](file:///Users/datang/aku_community/assets/icons/change.png) static const String ASSETS_ICONS_CHANGE_PNG = 'assets/icons/change.png'; + /// ![preview](file:///Users/datang/aku_community/assets/icons/collect.png) + static const String ASSETS_ICONS_COLLECT_PNG = 'assets/icons/collect.png'; + + /// ![preview](file:///Users/datang/aku_community/assets/icons/collection_setting.png) + static const String ASSETS_ICONS_COLLECTION_SETTING_PNG = + 'assets/icons/collection_setting.png'; + + /// ![preview](file:///Users/datang/aku_community/assets/icons/collection_share.png) + static const String ASSETS_ICONS_COLLECTION_SHARE_PNG = + 'assets/icons/collection_share.png'; + /// ![preview](file:///Users/datang/aku_community/assets/icons/comment_notice.png) static const String ASSETS_ICONS_COMMENT_NOTICE_PNG = 'assets/icons/comment_notice.png'; @@ -181,6 +192,9 @@ class R { /// ![preview](file:///Users/datang/aku_community/assets/icons/contract.png) static const String ASSETS_ICONS_CONTRACT_PNG = 'assets/icons/contract.png'; + /// ![preview](file:///Users/datang/aku_community/assets/icons/delete.png) + static const String ASSETS_ICONS_DELETE_PNG = 'assets/icons/delete.png'; + /// ![preview](file:///Users/datang/aku_community/assets/icons/device_alarm.png) static const String ASSETS_ICONS_DEVICE_ALARM_PNG = 'assets/icons/device_alarm.png'; @@ -188,12 +202,18 @@ class R { /// ![preview](file:///Users/datang/aku_community/assets/icons/examine.png) static const String ASSETS_ICONS_EXAMINE_PNG = 'assets/icons/examine.png'; + /// ![preview](file:///Users/datang/aku_community/assets/icons/eye_close.png) + static const String ASSETS_ICONS_EYE_CLOSE_PNG = 'assets/icons/eye_close.png'; + /// ![preview](file:///Users/datang/aku_community/assets/icons/facility.png) static const String ASSETS_ICONS_FACILITY_PNG = 'assets/icons/facility.png'; /// ![preview](file:///Users/datang/aku_community/assets/icons/file.png) static const String ASSETS_ICONS_FILE_PNG = 'assets/icons/file.png'; + /// ![preview](file:///Users/datang/aku_community/assets/icons/filter.png) + static const String ASSETS_ICONS_FILTER_PNG = 'assets/icons/filter.png'; + /// ![preview](file:///Users/datang/aku_community/assets/icons/finish.png) static const String ASSETS_ICONS_FINISH_PNG = 'assets/icons/finish.png'; @@ -227,6 +247,14 @@ class R { static const String ASSETS_ICONS_HOUSE_KEEPING_PNG = 'assets/icons/house_keeping.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'; + + /// ![preview](file:///Users/datang/aku_community/assets/icons/icon_favor_choose.png) + static const String ASSETS_ICONS_ICON_FAVOR_CHOOSE_PNG = + 'assets/icons/icon_favor_choose.png'; + /// ![preview](file:///Users/datang/aku_community/assets/icons/icon_main_all.png) static const String ASSETS_ICONS_ICON_MAIN_ALL_PNG = 'assets/icons/icon_main_all.png'; @@ -271,10 +299,25 @@ class R { static const String ASSETS_ICONS_ICON_MAIN_SUBSCRIBE_PNG = 'assets/icons/icon_main_subscribe.png'; + /// ![preview](file:///Users/datang/aku_community/assets/icons/icon_more.png) + static const String ASSETS_ICONS_ICON_MORE_PNG = 'assets/icons/icon_more.png'; + /// ![preview](file:///Users/datang/aku_community/assets/icons/icon_notification.png) static const String ASSETS_ICONS_ICON_NOTIFICATION_PNG = 'assets/icons/icon_notification.png'; + /// ![preview](file:///Users/datang/aku_community/assets/icons/icon_price.png) + static const String ASSETS_ICONS_ICON_PRICE_PNG = + 'assets/icons/icon_price.png'; + + /// ![preview](file:///Users/datang/aku_community/assets/icons/icon_setting.png) + static const String ASSETS_ICONS_ICON_SETTING_PNG = + 'assets/icons/icon_setting.png'; + + /// ![preview](file:///Users/datang/aku_community/assets/icons/icon_toTop.png) + static const String ASSETS_ICONS_ICON_TOTOP_PNG = + 'assets/icons/icon_toTop.png'; + /// ![preview](file:///Users/datang/aku_community/assets/icons/img_add.png) static const String ASSETS_ICONS_IMG_ADD_PNG = 'assets/icons/img_add.png'; @@ -561,6 +604,9 @@ class R { static const String ASSETS_ICONS_USER_ICON_WDSQHD_PNG = 'assets/icons/user_icon_wdsqhd.png'; + /// ![preview](file:///Users/datang/aku_community/assets/icons/xianshi.png) + static const String ASSETS_ICONS_XIANSHI_PNG = 'assets/icons/xianshi.png'; + /// ![preview](file:///Users/datang/aku_community/assets/images/application.png) static const String ASSETS_IMAGES_APPLICATION_PNG = 'assets/images/application.png'; diff --git a/lib/constants/api.dart b/lib/constants/api.dart index b676c569..a204b9b6 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -416,6 +416,20 @@ class _Market { ///app商场中心:根据订单主键id查询订单详情 String get orderDetail => '/user/shop/findOrderDetailByOrderId'; + + + + ///接入京库客 + ///jcook商城(首页搜索):查询综合推荐商品列表 + String get findGoodsList => '/user/jcookGoods/findRecommendGoodsList'; + + ///jcook商城 加入收藏 + String get addCollection => '/user/jcookCollection/collection'; + + ///jcook商城 收藏列表 + String get collectionList => '/user/jcookCollection/myCollection'; + + } class _Upload { diff --git a/lib/models/collection/collection_goods_model.dart b/lib/models/collection/collection_goods_model.dart new file mode 100644 index 00000000..8e64b78d --- /dev/null +++ b/lib/models/collection/collection_goods_model.dart @@ -0,0 +1,44 @@ +class CollectionGoodsModel { + int? id; + String? skuName; + String? mainPhoto; + int? status; + int? shopStatus; + double? sellPrice; + double? discountPrice; + int? kind; + + CollectionGoodsModel( + {this.id, + this.skuName, + this.mainPhoto, + this.status, + this.shopStatus, + this.sellPrice, + this.discountPrice, + this.kind}); + + CollectionGoodsModel.fromJson(Map json) { + id = json['id']; + skuName = json['skuName']; + mainPhoto = json['mainPhoto']; + status = json['status']; + shopStatus = json['shopStatus']; + sellPrice = json['sellPrice']; + discountPrice = json['discountPrice']; + kind = json['kind']; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['skuName'] = this.skuName; + data['mainPhoto'] = this.mainPhoto; + data['status'] = this.status; + data['shopStatus'] = this.shopStatus; + data['sellPrice'] = this.sellPrice; + data['discountPrice'] = this.discountPrice; + data['kind'] = this.kind; + return data; + } +} \ No newline at end of file diff --git a/lib/models/search/search_goods_model.dart b/lib/models/search/search_goods_model.dart new file mode 100644 index 00000000..c3422a2a --- /dev/null +++ b/lib/models/search/search_goods_model.dart @@ -0,0 +1,40 @@ +class SearchGoodsModel { + int? id; + String? skuName; + String? mainPhoto; + double? sellPrice; + double? discountPrice; + int? kind; + int? isCollection; + + SearchGoodsModel( + {this.id, + this.skuName, + this.mainPhoto, + this.sellPrice, + this.discountPrice, + this.kind, + this.isCollection}); + + SearchGoodsModel.fromJson(Map json) { + id = json['id']; + skuName = json['skuName']; + mainPhoto = json['mainPhoto']; + sellPrice = json['sellPrice']; + discountPrice = json['discountPrice']; + kind = json['kind']; + isCollection = json['isCollection']; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['skuName'] = this.skuName; + data['mainPhoto'] = this.mainPhoto; + data['sellPrice'] = this.sellPrice; + data['discountPrice'] = this.discountPrice; + data['kind'] = this.kind; + data['isCollection'] = this.isCollection; + return data; + } +} \ No newline at end of file diff --git a/lib/pages/community_introduce/community_introduce_page.dart b/lib/pages/community_introduce/community_introduce_page.dart index 544ff1ae..d95c686b 100644 --- a/lib/pages/community_introduce/community_introduce_page.dart +++ b/lib/pages/community_introduce/community_introduce_page.dart @@ -22,7 +22,7 @@ class CommunityIntroducePage extends StatefulWidget { class _CommunityIntroducePageState extends State { CommunityIontroduceModel _model = CommunityIontroduceModel.init(); - bool _onload = false; + bool _onload = true; @override Widget build(BuildContext context) { diff --git a/lib/pages/geographic_information/geograhic_information.dart b/lib/pages/geographic_information/geograhic_information.dart index c6525af8..3d89d6ff 100644 --- a/lib/pages/geographic_information/geograhic_information.dart +++ b/lib/pages/geographic_information/geograhic_information.dart @@ -27,7 +27,7 @@ class GeographicInformationPage extends StatefulWidget { class _GeographicInformationPageState extends State { GeographicInformationModel _model = GeographicInformationModel.init(); - bool _onload = false; + bool _onload = true; @override Widget build(BuildContext context) { return BeeScaffold( diff --git a/lib/pages/home/home_page.dart b/lib/pages/home/home_page.dart index f4980912..1bc0c8c8 100644 --- a/lib/pages/home/home_page.dart +++ b/lib/pages/home/home_page.dart @@ -53,8 +53,7 @@ class HomePage extends StatefulWidget { class _HomePageState extends State with AutomaticKeepAliveClientMixin, SingleTickerProviderStateMixin { - @override - bool get wantKeepAlive => true; + int _currentIndicator = 0; ScrollController? _scrollController; @@ -530,5 +529,6 @@ class _HomePageState extends State ); } - + @override + bool get wantKeepAlive => true; } diff --git a/lib/pages/personal/personal_page.dart b/lib/pages/personal/personal_page.dart index 94453f0a..e40ce90b 100644 --- a/lib/pages/personal/personal_page.dart +++ b/lib/pages/personal/personal_page.dart @@ -3,11 +3,16 @@ import 'package:aku_community/const/resource.dart'; import 'package:aku_community/constants/api.dart'; import 'package:aku_community/constants/application_objects.dart'; import 'package:aku_community/pages/personal/user_profile_page.dart'; +import 'package:aku_community/pages/setting_page/settings_page.dart'; import 'package:aku_community/pages/sign/sign_in_page.dart'; import 'package:aku_community/painters/user_bottom_bar_painter.dart'; import 'package:aku_community/provider/user_provider.dart'; +import 'package:aku_community/ui/profile/car/car_manage_page.dart'; +import 'package:aku_community/ui/profile/car_parking/car_parking_page.dart'; +import 'package:aku_community/ui/profile/house/house_owners_page.dart'; import 'package:aku_community/ui/profile/order/order_page.dart'; import 'package:aku_community/utils/headers.dart'; +import 'package:aku_community/widget/others/user_tool.dart'; import 'package:aku_community/widget/views/application_view.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -26,14 +31,14 @@ class PersonalIndex extends StatefulWidget { } class _PersonalIndexState extends State - with SingleTickerProviderStateMixin { + with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin{ SliverAppBar _sliverAppBar(double height) { final userProvider = Provider.of(context); return SliverAppBar( - pinned: true, + pinned: false, toolbarHeight: 0, elevation: 0, - floating: true, + floating: false, expandedHeight: 450.w - height, backgroundColor: Colors.white, @@ -68,7 +73,7 @@ class _PersonalIndexState extends State child: Row( children: [ Hero( - tag: 'AVATAR', + tag: 'AVATAR1', child: ClipOval( child: FadeInImage.assetNetwork( placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, @@ -148,132 +153,630 @@ class _PersonalIndexState extends State ); } - Container _containerBar(String title) { - return Container( - color: title == '我的物业' ? Colors.white : BaseStyle.colorf9f9f9, - padding: EdgeInsets.all(title == '我的物业' ? 0 : 32.w), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - title, - style: TextStyle( - fontWeight: FontWeight.w600, - fontSize: BaseStyle.fontSize34, - color: ktextPrimary, - ), - ), - ], - ), - ); - } + // Container _containerBar(String title) { + // return Container( + // color: title == '我的物业' ? Colors.white : BaseStyle.colorf9f9f9, + // padding: EdgeInsets.all(title == '我的物业' ? 0 : 32.w), + // child: Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // children: [ + // Text( + // title, + // style: TextStyle( + // fontWeight: FontWeight.w600, + // fontSize: BaseStyle.fontSize34, + // color: ktextPrimary, + // ), + // ), + // ], + // ), + // ); + // } Widget _orderButton({ required String name, required String path, required int index, }) { - return MaterialButton( + return GestureDetector( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - Image.asset(path, height: 50.w, width: 50.w), + Image.asset(path, height: 64.w, width: 64.w), 10.hb, Text( name, style: TextStyle( color: Color(0xFF333333), - fontSize: 22.sp, + fontSize: 26.sp, ), ), ], ), - onPressed: () { + onTap: () { Get.to(() => OrderPage(initIndex: index)); }, - ); + ).expand(); } @override Widget build(BuildContext context) { final double _statusHeight = MediaQuery.of(context).padding.top; final userProvider = Provider.of(context); - var orderWidget = SliverToBoxAdapter( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - _containerBar('我的订单'), - GridView( - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 5, - ), - shrinkWrap: true, - children: [ - _orderButton( - name: '待付款', - path: R.ASSETS_ICONS_USER_ICON_DFK_PNG, - index: 1, - ), - _orderButton( - name: '待收货', - path: R.ASSETS_ICONS_USER_ICON_DSH_PNG, - index: 2, - ), - _orderButton( - name: '待评价', - path: R.ASSETS_ICONS_USER_ICON_DPJ_PNG, - index: 3, - ), - _orderButton( - name: '售后', - path: R.ASSETS_ICONS_USER_ICON_SH_PNG, - index: 4, - ), - ], - ), - ], - ), - ); + // var orderWidget = SliverToBoxAdapter( + // child: Container( + // decoration: BoxDecoration( + // color: Color(0xffffffff), + // borderRadius: BorderRadius.all(Radius.circular(8)), + // boxShadow: [ + // BoxShadow( + // color: Colors.grey.withOpacity(0.1), + // offset: Offset(1, 1), + // ), + // ], + // ), + // margin: EdgeInsets.all(20.w), + // padding: EdgeInsets.all(12.w), + // child: + // Column( + // mainAxisSize: MainAxisSize.min, + // children: [ + // _containerBar('我的订单'), + // GridView( + // gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + // crossAxisCount: 5, + // ), + // shrinkWrap: true, + // children: [ + // _orderButton( + // name: '待付款', + // path: R.ASSETS_ICONS_USER_ICON_DFK_PNG, + // index: 1, + // ), + // _orderButton( + // name: '待收货', + // path: R.ASSETS_ICONS_USER_ICON_DSH_PNG, + // index: 2, + // ), + // _orderButton( + // name: '待评价', + // path: R.ASSETS_ICONS_USER_ICON_DPJ_PNG, + // index: 3, + // ), + // _orderButton( + // name: '售后', + // path: R.ASSETS_ICONS_USER_ICON_SH_PNG, + // index: 4, + // ), + // ], + // ), + // ], + // ), + // ) + // ); return Scaffold( + body: EasyRefresh( header: MaterialHeader(), onRefresh: () async { await userProvider.updateProfile(); await userProvider.updateUserDetail(); }, - child: CustomScrollView( - slivers: [ - _sliverAppBar(_statusHeight), - // orderWidget, - SliverToBoxAdapter( - child: Container( - decoration: BoxDecoration( - color: Color(0xffffffff), - borderRadius: BorderRadius.all(Radius.circular(8)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.1), - offset: Offset(1, 1), - ), + child: Stack( + children: [ + // Container( + // + // width: double.infinity, + // height: 441.w, + // alignment: Alignment.topCenter, + // + // decoration: BoxDecoration( + // gradient: LinearGradient( + // begin: Alignment.topCenter, + // end: Alignment.bottomCenter, + // colors: [ + // Color(0xFFF9D57A), + // Color(0xFFF9D57A), + // ], + // ), + // ), + // padding: EdgeInsets.only(top: 130.w), + // child: Column( + // mainAxisAlignment: MainAxisAlignment.start, + // children: [ + // + // MaterialButton( + // padding: EdgeInsets.all(5.w), + // onPressed: () { + // if (!userProvider.isLogin) + // Get.to(() => SignInPage()); + // else + // Get.to(() => UserProfilePage()); + // }, + // child: Container( + // margin: EdgeInsets.only(left: 32.w), + // child: Row( + // children: [ + // Hero( + // tag: 'AVATAR', + // child: ClipOval( + // child: FadeInImage.assetNetwork( + // placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + // image: API.image(userProvider + // .userInfoModel!.imgUrls.isNotEmpty + // ? userProvider + // .userInfoModel!.imgUrls.first.url + // : ''), + // height: 106.w, + // width: 106.w, + // fit: BoxFit.cover, + // imageErrorBuilder: (context, error, stackTrace) { + // return Image.asset(R.ASSETS_IMAGES_PLACEHOLDER_WEBP,height: 106.w, + // width: 106.w,); + // }, + // ), + // ), + // ), + // Container( + // margin: EdgeInsets.only(left: 16.w), + // child: userProvider.isLogin + // ? Text( + // userProvider.userInfoModel?.nickName ?? + // '', + // style: TextStyle( + // fontSize: 32.sp, + // color: Color(0xffad8940), + // ), + // ) + // : Text( + // '登录/注册', + // style: TextStyle( + // fontSize: 32.sp, + // color: Color(0xffad8940), + // ), + // )), + // ], + // ), + // ), + // ), + // // Stack( + // // children: [ + // // Positioned( + // // bottom: 0, + // // left: 0, + // // right: 0, + // // child: Container( + // // height: 41.w, + // // width: double.infinity, + // // child: CustomPaint( + // // painter: UserBottomBarPainter(), + // // ), + // // ), + // // ), + // // Container( + // // margin: EdgeInsets.only( + // // top: 38.w, + // // left: 36.w, + // // right: 36.w, + // // bottom: 18.w, + // // ), + // // child: Image.asset( + // // R.ASSETS_IMAGES_MEMBER_BG_PNG, + // // width: 678.w, + // // height: 129.w, + // // ), + // // ), + // // ], + // // ), + // ], + // ), + // ), + + Container( + + width: double.infinity, + height: 441.w, + alignment: Alignment.topCenter, + + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + colors: [ + Color(0xFFF9D57A), + Color(0xFFF9D57A), ], ), - margin: EdgeInsets.all(20.w), - padding: EdgeInsets.all(12.w), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - _containerBar('我的物业'), - ApplicationView.custom( - items: userAppObjects, - needAllApp: false, + ), + padding: EdgeInsets.only(top: 100.w), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Row( + children: [ + Spacer(), + GestureDetector( + onTap: (){ + Get.to(SettingsPage()); + }, + child: Container( + width: 72.w, + height: 40.w, + alignment: Alignment.center, + child: Image.asset(R.ASSETS_ICONS_ICON_SETTING_PNG,width: 40.w,height: 40.w), + ), + ), + // 32.wb, + ], + ), + + MaterialButton( + padding: EdgeInsets.all(5.w), + onPressed: () { + if (!userProvider.isLogin) + Get.to(() => SignInPage()); + else + Get.to(() => UserProfilePage()); + }, + child: Container( + margin: EdgeInsets.only(left: 32.w), + child: Row( + children: [ + Hero( + tag: 'AVATAR', + child: ClipOval( + child: FadeInImage.assetNetwork( + placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + image: API.image(userProvider + .userInfoModel!.imgUrls.isNotEmpty + ? userProvider + .userInfoModel!.imgUrls.first.url + : ''), + height: 106.w, + width: 106.w, + fit: BoxFit.cover, + imageErrorBuilder: (context, error, stackTrace) { + return Image.asset(R.ASSETS_IMAGES_PLACEHOLDER_WEBP,height: 106.w, + width: 106.w,); + }, + ), + ), + ), + Container( + margin: EdgeInsets.only(left: 16.w), + child: userProvider.isLogin + ? Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + userProvider.userInfoModel?.nickName ?? + '', + style: TextStyle( + fontSize: 40.sp, + color: Colors.black.withOpacity(0.85), + ), + ), + 4.hb, + + Text( + '当一个新时代的有志青年', + style: TextStyle( + fontSize: 24.sp, + color: Colors.black.withOpacity(0.45), + ), + ), + + + ], + ) : Text( + '登录/注册', + style: TextStyle( + fontSize: 32.sp, + color: Color(0xffad8940), + ), + ) + + ), + ], + ), ), - ], - ), + ), + // Stack( + // children: [ + // Positioned( + // bottom: 0, + // left: 0, + // right: 0, + // child: Container( + // height: 41.w, + // width: double.infinity, + // child: CustomPaint( + // painter: UserBottomBarPainter(), + // ), + // ), + // ), + // Container( + // margin: EdgeInsets.only( + // top: 38.w, + // left: 36.w, + // right: 36.w, + // bottom: 18.w, + // ), + // child: Image.asset( + // R.ASSETS_IMAGES_MEMBER_BG_PNG, + // width: 678.w, + // height: 129.w, + // ), + // ), + // ], + // ), + ], + ), + ), + Padding( + + padding: EdgeInsets.only(top: 289.w), + child: Column( + + children: [ + Container( + width: 686.w, + height: 282.w, + decoration: BoxDecoration( + color: Color(0xffffffff), + borderRadius: BorderRadius.all(Radius.circular(8)), + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.1), + offset: Offset(1, 1), + ), + ], + ), + margin: EdgeInsets.only(left: 32.w,right: 32.w), + padding: EdgeInsets.only(top: 24.w,left: 32.w,right: 32.w), + child: + Column( + //mainAxisAlignment: MainAxisAlignment.center, + children: [ + _homeTitle('我的订单', () {}, '查看全部'), + 50.hb, + Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + + children: [ + _orderButton( + name: '待付款', + path: R.ASSETS_ICONS_USER_ICON_DFK_PNG, + index: 1, + ), + _orderButton( + name: '待收货', + path: R.ASSETS_ICONS_USER_ICON_DSH_PNG, + index: 2, + ), + _orderButton( + name: '待评价', + path: R.ASSETS_ICONS_USER_ICON_DPJ_PNG, + index: 3, + ), + _orderButton( + name: '售后', + path: R.ASSETS_ICONS_USER_ICON_SH_PNG, + index: 4, + ), + ], + ), + ], + ), + ), + Container( + decoration: BoxDecoration( + color: Color(0xffffffff), + borderRadius: BorderRadius.all(Radius.circular(8)), + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.1), + offset: Offset(1, 1), + ), + ], + ), + margin: EdgeInsets.all(32.w), + padding: EdgeInsets.all(32.w), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + _function('我的房屋', R.ASSETS_ICONS_USER_ICON_WDFW_PNG, () => HouseOwnersPage( + identify: UserTool.userProvider.userDetailModel!.type ?? 4, + ),userProvider.userDetailModel!.estateNames?[0]??'',), + 36.hb, + _function('我的车位', R.ASSETS_ICONS_USER_ICON_WDCW_PNG, () => CarParkingPage(),'B区N392号'), + 36.hb, + _function('我的车', R.ASSETS_ICONS_USER_ICON_WDC_PNG, () => CarManagePage(),'浙999999'), + 36.hb, + _myVisitor() + // + // ApplicationView.custom( + // items: userAppObjects, + // needAllApp: false, + // ), + ], + ), + ), + + ], ), ), + + ], - ), + ) + + ), ); } + _homeTitle(String title, VoidCallback onTap, String suffixTitle) { + return Row( + children: [ + title.text.size(32.sp).bold.make(), + Spacer(), + GestureDetector( + onTap: onTap, + child: Row( + children: [ + suffixTitle.text.size(24.sp).color(Color(0xFF999999)).make(), + 8.wb, + Icon( + CupertinoIcons.chevron_forward, + size: 24.w, + color: Color(0xFF999999), + ), + ], + ), + ), + //24.wb, + ], + ); + } + + _function( String title ,String path,dynamic page ,String msg,){ + return Row( + children: [ + Image.asset(path,width: 40.w,height: 40.w,fit:BoxFit.fitHeight,), + 16.wb, + Text( + title, + style: TextStyle( + fontSize: 28.sp, + color: Colors.black.withOpacity(0.85), + ), + ), + Spacer(), + Text( + msg, + style: TextStyle( + fontSize: 24.sp, + color: Colors.black.withOpacity(0.45), + ), + ), + 24.wb, + Icon( + CupertinoIcons.chevron_forward, + size: 24.w, + color: Color(0xFF999999), + ), + ], + ); + } + _myVisitor(){ + final userProvider = Provider.of(context); + return Row( + children: [ + Text( + '我的访客', + style: TextStyle( + fontSize: 28.sp, + color: Colors.black.withOpacity(0.85), + ), + ), + Spacer(), + Container( + width: 110.w, + height: 40.w, + child: Stack( + children: [ + Positioned( + + child: Hero( + tag: 'AVATAR4', + child: ClipOval( + child: FadeInImage.assetNetwork( + placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + image: API.image(userProvider + .userInfoModel!.imgUrls.isNotEmpty + ? userProvider + .userInfoModel!.imgUrls.first.url + : ''), + height: 40.w, + width: 40.w, + fit: BoxFit.cover, + imageErrorBuilder: (context, error, stackTrace) { + return Image.asset(R.ASSETS_IMAGES_PLACEHOLDER_WEBP,height: 40.w, + width: 40.w,); + }, + ), + ), + ), + top: 0, + bottom: 0, + right: 0, + ), + Positioned( + + child: Hero( + tag: 'AVATAR5', + child: ClipOval( + child: FadeInImage.assetNetwork( + placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + image: API.image(userProvider + .userInfoModel!.imgUrls.isNotEmpty + ? userProvider + .userInfoModel!.imgUrls.first.url + : ''), + height: 40.w, + width: 40.w, + fit: BoxFit.cover, + imageErrorBuilder: (context, error, stackTrace) { + return Image.asset(R.ASSETS_IMAGES_PLACEHOLDER_WEBP,height: 106.w, + width: 106.w,); + }, + ), + ), + ), + top: 0, + bottom: 0, + right: 15, + ), + Positioned( + + child: Hero( + tag: 'AVATAR6', + child: ClipOval( + child: FadeInImage.assetNetwork( + placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + image: API.image(userProvider + .userInfoModel!.imgUrls.isNotEmpty + ? userProvider + .userInfoModel!.imgUrls.first.url + : ''), + height: 40.w, + width: 40.w, + fit: BoxFit.cover, + imageErrorBuilder: (context, error, stackTrace) { + return Image.asset(R.ASSETS_IMAGES_PLACEHOLDER_WEBP,height: 106.w, + width: 106.w,); + }, + ), + ), + ), + top: 0, + bottom: 0, + right: 30, + ), + ], + ) + ), + + 24.wb, + Icon( + CupertinoIcons.chevron_forward, + size: 24.w, + color: Color(0xFF999999), + ), + ], + ); + } + @override + bool get wantKeepAlive => true; } diff --git a/lib/pages/property/property_page.dart b/lib/pages/property/property_page.dart index 27f98ec9..9c4db894 100644 --- a/lib/pages/property/property_page.dart +++ b/lib/pages/property/property_page.dart @@ -31,7 +31,7 @@ class PropertyPage extends StatefulWidget { } class _PropertyPageState extends State - with SingleTickerProviderStateMixin { + with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin { int sum = 0; int commentCount = 0; int sysCount = 0; @@ -547,4 +547,8 @@ class _PropertyPageState extends State ), ); } + + @override + bool get wantKeepAlive => true; + } diff --git a/lib/pages/things_page/widget/bee_list_view.dart b/lib/pages/things_page/widget/bee_list_view.dart index 970f2c58..31688e0c 100644 --- a/lib/pages/things_page/widget/bee_list_view.dart +++ b/lib/pages/things_page/widget/bee_list_view.dart @@ -48,6 +48,7 @@ class BeeListView extends StatefulWidget { ///... ///``` final List Function(BaseListModel model) convert; + final List Function(List model)? refreshExtra; ///子组件构造器 final Widget Function(dynamic items) builder; @@ -64,7 +65,7 @@ class BeeListView extends StatefulWidget { required this.convert, required this.builder, this.size = 10, - this.extraParams, + this.extraParams, this.refreshExtra , }) : super(key: key); @override @@ -98,6 +99,9 @@ class _BeeListViewState extends State { ); _models = widget.convert(_model) as List; widget.controller?.resetLoadState(); + if(widget.refreshExtra!=null){ + widget.refreshExtra!(_models); + } if (mounted) setState(() {}); }, firstRefresh: true, diff --git a/lib/ui/community/community_views/community_page.dart b/lib/ui/community/community_views/community_page.dart index 83b0ca73..de503e04 100644 --- a/lib/ui/community/community_views/community_page.dart +++ b/lib/ui/community/community_views/community_page.dart @@ -1,6 +1,18 @@ +import 'package:aku_community/base/base_style.dart'; +import 'package:aku_community/constants/api.dart'; +import 'package:aku_community/model/community/event_item_model.dart'; +import 'package:aku_community/ui/community/activity/activity_list_page.dart'; +import 'package:aku_community/ui/community/community_views/widgets/chat_card.dart'; +import 'package:aku_community/ui/home/home_title.dart'; +import 'package:aku_community/ui/market/search/search_goods_page.dart'; +import 'package:aku_community/utils/network/base_list_model.dart'; +import 'package:aku_community/utils/network/base_model.dart'; +import 'package:aku_community/utils/network/net_util.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:badges/badges.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:get/get.dart'; import 'package:provider/provider.dart'; @@ -27,15 +39,25 @@ class CommunityPage extends StatefulWidget { class _CommunityPageState extends State with TickerProviderStateMixin, AutomaticKeepAliveClientMixin { TabController? _tabController; + late EasyRefreshController _easyRefreshController; List _tabs = []; GlobalKey topicKey = GlobalKey(); GlobalKey myKey = GlobalKey(); GlobalKey newKey = GlobalKey(); + + List _newItems = []; + + int _pageNum = 1; + int _size = 4; + int _pageCount = 0; + bool _onload = true; + @override void initState() { super.initState(); + _easyRefreshController = EasyRefreshController(); final userProvider = Provider.of(context, listen: false); if (userProvider.isLogin) _tabs = ['最新', '话题', '我的']; if (userProvider.isNotLogin) _tabs = ['最新', '话题']; @@ -48,6 +70,7 @@ class _CommunityPageState extends State @override void dispose() { _tabController?.dispose(); + _easyRefreshController.dispose(); super.dispose(); } @@ -56,73 +79,403 @@ class _CommunityPageState extends State super.build(context); final userProvider = Provider.of(context); final appProvider = Provider.of(context); - return BeeScaffold( - title: '社区', - actions: [ - Badge( - elevation: 0, - showBadge: appProvider.messageCenterModel.commentCount != 0 || - appProvider.messageCenterModel.sysCount != 0, - position: BadgePosition.topEnd( - top: 8, - end: 8, + return Scaffold( + appBar: AppBar( + titleSpacing: 10.0, + title: Row(crossAxisAlignment: CrossAxisAlignment.center, children: [ + if (appProvider.location != null) + Padding( + padding: const EdgeInsets.only(right: 5), + child: Image.asset( + R.ASSETS_ICONS_ICON_MAIN_LOCATION_PNG, + width: 32.w, + height: 32.w, + ), + ), + Text( + appProvider.location?['city'] == null + ? '' + : appProvider.location?['city'] as String? ?? '', + style: TextStyle( + fontWeight: FontWeight.w600, + fontSize: 24.sp, + color: Color(0xff333333), + ), + textAlign: TextAlign.center, + ), + Text( + '(${appProvider.weatherType} ${appProvider.weatherTemp}℃)', + style: TextStyle( + fontSize: 24.sp, + color: Color(0xff999999), + ), + textAlign: TextAlign.center, + ), + ]), + backgroundColor: Colors.white, + actions: [ + Badge( + elevation: 0, + showBadge: appProvider.messageCenterModel.commentCount != 0 || + appProvider.messageCenterModel.sysCount != 0, + position: BadgePosition.topEnd( + top: 8, + end: 8, + ), + child: ColumnActionButton( + onPressed: () { + if (LoginUtil.isNotLogin) return; + Get.to(() => MessageCenterPage()); + }, + title: '消息', + path: R.ASSETS_ICONS_ALARM_PNG, + ), + ), + ], + bottom: PreferredSize( + preferredSize: Size.fromHeight(90.w), child: _geSearch()), + ), + floatingActionButton: FloatingActionButton( + onPressed: () async { + if (LoginUtil.isNotLogin) return; + bool? result = await Get.to(() => AddNewEventPage()); + if (result == true) { + switch (_tabController!.index) { + case 0: + newKey.currentState!.refresh(); + break; + case 1: + topicKey.currentState!.refresh(); + break; + case 2: + myKey.currentState!.refresh(); + break; + } + } + }, + heroTag: 'event_add', + child: Icon(Icons.add), + ), + + + + body: EasyRefresh( + firstRefresh: true, + header: MaterialHeader(), + controller: _easyRefreshController, + onRefresh: () async { + await (getNewInfo()); + _onload = false; + setState(() {}); + }, + child: _onload + ? SizedBox() + : ListView( + children: [ + 2.hb, + _getInfo(), + 16.hb, + _getNews(), + 16.hb, + ..._newItems.map((e) => ChatCard( + model: e, + + )).toList()], + ), + ), + + // ListView( + // children: [ + + // ], + // ) + + + // TabBarView( + // children: userProvider.isLogin + // ? [ + // NewCommunityView(key: newKey), + // TopicCommunityView(key: topicKey), + // MyCommunityView(key: myKey), + // ] + // : [ + // NewCommunityView(key: newKey), + // TopicCommunityView(key: topicKey), + // ], + // controller: _tabController, + // ), + // bodyColor: Colors.white, + ); + } + + + Future getNewInfo() async { + BaseListModel baseListModel = + await NetUtil().getList(API.community.newEventList, params: { + "pageNum": _pageNum, + "size": _size, + }); + if (baseListModel.tableList!.isNotEmpty) { + _newItems = (baseListModel.tableList as List) + .map((e) => EventItemModel.fromJson(e)) + .toList(); + } + _pageCount = baseListModel.pageCount!; + } + + Future loadNewInfo() async { + BaseListModel baseListModel = + await NetUtil().getList(API.market.hotTop, params: { + "pageNum": _pageNum, + "size": _size, + }); + if (baseListModel.tableList!.isNotEmpty) { + _newItems.addAll((baseListModel.tableList as List) + .map((e) => EventItemModel.fromJson(e)) + .toList()); + } + _pageCount = baseListModel.pageCount!; + } + + + _getInfo() { + return Container( + color: Colors.white, + padding: + EdgeInsets.only(top: 32.w, bottom: 32.w, left: 32.w, right: 32.w), + child: Column( + children: [ + _homeTitle('热门资讯', () {}, '更多'), + 32.hb, + Container( + height: 204.w, + child: ListView.separated( + padding: EdgeInsets.zero, + separatorBuilder: (context, index) { + return SizedBox( + width: 24.w, + ); + }, + scrollDirection: Axis.horizontal, + itemBuilder: (context, index) { + return Container( + width: 396.w, + child: Builder( + builder: (context) { + return _infoCard(); + }, + ), + ); + }, + itemCount: 3, + ), ), - child: ColumnActionButton( - onPressed: () { - if (LoginUtil.isNotLogin) return; - Get.to(() => MessageCenterPage()); - }, - title: '消息', - path: R.ASSETS_ICONS_ALARM_PNG, + ], + ), + ); + } + + _homeTitle(String title, VoidCallback onTap, String suffixTitle) { + return Row( + children: [ + title.text.size(32.sp).bold.make(), + Spacer(), + GestureDetector( + onTap: onTap, + child: Row( + children: [ + suffixTitle.text.size(24.sp).color(Color(0xFF999999)).make(), + 8.wb, + Icon( + CupertinoIcons.chevron_forward, + size: 24.w, + color: Color(0xFF999999), + ), + ], ), ), + //24.wb, ], - fab: FloatingActionButton( - onPressed: () async { - if (LoginUtil.isNotLogin) return; - bool? result = await Get.to(() => AddNewEventPage()); - if (result == true) { - switch (_tabController!.index) { - case 0: - newKey.currentState!.refresh(); - break; - case 1: - topicKey.currentState!.refresh(); - break; - case 2: - myKey.currentState!.refresh(); - break; - } - } + ); + } + + _infoCard() { + return Container( + width: 396.w, + height: 204.w, + padding: + EdgeInsets.only(top: 32.w, left: 40.w, right: 40.w, bottom: 32.w), + decoration: BoxDecoration( + borderRadius: BorderRadius.horizontal( + right: Radius.circular(12), + left: Radius.circular(16), + ), + color: Colors.black38, + ), + child: Column( + children: [ + Container( + width: 316.w, + alignment: Alignment.center, + child: Text( + '肖生克的救赎到底在讲人性的还是在激励人在困...', + maxLines: 2, + overflow: TextOverflow.ellipsis, + style: TextStyle( + color: Colors.white.withOpacity(0.85), + fontSize: 28.sp, + fontWeight: FontWeight.bold), + ) + ), + 24.hb, + Row( + children: [ + Text( + '271.8w浏览', + maxLines: 2, + overflow: TextOverflow.ellipsis, + style: TextStyle( + color: Colors.white.withOpacity(0.85), + fontSize: 24.sp, + ), + ), + Spacer(), + Text( + '01-03', + maxLines: 2, + overflow: TextOverflow.ellipsis, + style: TextStyle( + color: Colors.white.withOpacity(0.85), + fontSize: 24.sp, + ), + ) + ], + ) + ], + ), + ); + } + + _getNews() { + return Container( + color: Colors.white, + padding: + EdgeInsets.only(top: 32.w, bottom: 32.w,), + child: Column( + children: [ + Container( + padding: EdgeInsets.only(left: 32.w,right: 32.w), + child: _homeTitle('新鲜话题', () {}, '更多'), + ), + 32.hb, + _searchHistoryWidget() + ], + ), + ); + } + + _geSearch() { + return Container( + margin: EdgeInsets.symmetric(horizontal: 32.w), + padding: EdgeInsets.only(bottom: 20.w), + child: MaterialButton( + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + height: 74.w, + shape: StadiumBorder(), + elevation: 0, + minWidth: double.infinity, + color: Color(0xFFF3F3F3), + onPressed: () { + Get.to(() => SearchGoodsPage()); }, - heroTag: 'event_add', - child: Icon(Icons.add), + child: Row( + children: [ + Icon( + Icons.search, + size: 32.w, + color: Color(0xFF666666), + ), + 10.wb, + '请输入关键字'.text.size(28.sp).color(ktextSubColor).make().expand(), + ], + ), ), - appBarBottom: PreferredSize( - preferredSize: Size.fromHeight(48), - child: Align( - alignment: Alignment.centerLeft, - child: BeeTabBar( - controller: _tabController, - tabs: _tabs, - scrollable: true, + ); + } + + _searchHistoryWidget() { + + return Container( + //margin: EdgeInsets.symmetric(horizontal: 32.w), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Container( + //width: MediaQuery.of(context).size.width, + //padding: EdgeInsets.only(left: 10, right: 10), + child: Wrap( + children: + [_choiceChip('EDG夺冠',1),_choiceChip('双十一',2), + _choiceChip('11月吃土',2),_choiceChip('成都疫情',0),_choiceChip('万圣节',0)], + ), ), + // Spacer() + ], + ), + ); + } + + _choiceChip(String title, int type) { + return Padding( + padding: EdgeInsets.only(right: 12.w,bottom: 24.w), + child: ChoiceChip( + backgroundColor: Color(0xFFF4F7FC), + // disabledColor: Colors.blue, + labelStyle: TextStyle(fontSize: 15 * 2.sp, color: Colors.black), + + labelPadding: EdgeInsets.only(right: 12.w,left: 12.w), + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + onSelected: (bool value) {}, + label: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + '# ${title}', + style: TextStyle( + color: Colors.black.withOpacity(0.65), + fontSize: 28.sp, + fontWeight: FontWeight.w500), + ), + type==1||type==2? 8.wb:SizedBox(), + type==1||type==2?_chipType(type):SizedBox() + ], + ), + selected: false, + ), + ); + + } + + _chipType(int type) { + return Container( + width: 32.w, + height: 32.w, + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.all( + Radius.circular(6.4.w), ), + color:type == 1? Color(0xFFFFD76F):Color(0xFFFF8383), ), - body: TabBarView( - children: userProvider.isLogin - ? [ - NewCommunityView(key: newKey), - TopicCommunityView(key: topicKey), - MyCommunityView(key: myKey), - ] - : [ - NewCommunityView(key: newKey), - TopicCommunityView(key: topicKey), - ], - controller: _tabController, + child: Text( + type == 1 ? '荐' : '热', + style: TextStyle( + color: type == 1 + ? Colors.black.withOpacity(0.65) + : Colors.white.withOpacity(0.85), + fontSize: 20.sp, + fontWeight: FontWeight.w500), ), - bodyColor: Colors.white, ); } diff --git a/lib/ui/community/community_views/widgets/chat_card.dart b/lib/ui/community/community_views/widgets/chat_card.dart index 69d369dc..1ad4a469 100644 --- a/lib/ui/community/community_views/widgets/chat_card.dart +++ b/lib/ui/community/community_views/widgets/chat_card.dart @@ -41,7 +41,7 @@ class ChatCard extends StatefulWidget { _ChatCardState createState() => _ChatCardState(); } -class _ChatCardState extends State { +class _ChatCardState extends State { bool get _isMyself { final userProvider = Provider.of(context, listen: false); return (userProvider.userInfoModel?.id ?? -1) == widget.model!.createId; @@ -279,13 +279,13 @@ class _ChatCardState extends State { return DecoratedBox( decoration: BoxDecoration( color: Colors.white, - border: Border( - bottom: BorderSide( - color: widget.hideLine - ? Colors.transparent - : Color(0xFFE5E5E5).withOpacity(0.5), - ), - ), + // border: Border( + // bottom: BorderSide( + // color: widget.hideLine + // ? Colors.transparent + // : Color(0xFFE5E5E5).withOpacity(0.5), + // ), + // ), ), child: MaterialButton( padding: EdgeInsets.zero, @@ -294,85 +294,116 @@ class _ChatCardState extends State { Get.to(() => EventDetailPage(themeId: widget.model!.id)); } : null, - child: Row( + child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ + [ + Material( + color: Color(0xFFF5F5F5), + borderRadius: BorderRadius.circular(48.w), + clipBehavior: Clip.antiAlias, + child: FadeInImage.assetNetwork( + placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + image: API + .image(ImgModel.first(widget.model!.headSculptureImgUrl)), + height: 96.w, + width: 96.w, + fit: BoxFit.cover, + imageErrorBuilder: (context, error, stackTrace) { + return Image.asset(R.ASSETS_IMAGES_PLACEHOLDER_WEBP,height: 86.w, + width: 86.w,); + }, + ), + ).paddingOnly(left: 32.w), + 20.wb, + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + widget.model!.createName!, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle( + color: Colors.black.withOpacity(0.85), + fontSize: 30.sp, + fontWeight: FontWeight.w500), + ), + 12.hb, + BeeDateUtil(widget.model!.date) + .timeAgoWithHm + .text + .size(24.sp) + .color(Color(0xFF999999)) + .make(), + ], + ), + Spacer(), - Material( - color: Color(0xFFF5F5F5), - borderRadius: BorderRadius.circular(6.w), - clipBehavior: Clip.antiAlias, - child: FadeInImage.assetNetwork( - placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, - image: API - .image(ImgModel.first(widget.model!.headSculptureImgUrl)), - height: 86.w, - width: 86.w, - fit: BoxFit.cover, - imageErrorBuilder: (context, error, stackTrace) { - return Image.asset(R.ASSETS_IMAGES_PLACEHOLDER_WEBP,height: 86.w, - width: 86.w,); + PopupMenuButton( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8.w)), + itemBuilder: (context) { + return [ + PopupMenuItem( + child: '举报'.text.isIntrinsic.make(), + value: 0, + ), + ]; }, - ), - ), - 24.wb, + onSelected: (dynamic _) async { + if (LoginUtil.isNotLogin) return; + VoidCallback cancel = BotToast.showLoading(); + await Future.delayed( + Duration(milliseconds: 500 + Random().nextInt(500))); + cancel(); + BotToast.showText(text: '举报成功'); + }, + child: Container( + width: 40.w,height: 32.w, + child: Image.asset(R.ASSETS_ICONS_ICON_MORE_PNG, + width: 8.w,height: 32.w,fit: BoxFit.fitHeight,)), + + ).paddingOnly(right: 32.w), + + ].row(), + Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - [ - widget.model!.createName!.text.black - .size(36.sp) - .make() - .expand(), - PopupMenuButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8.w)), - itemBuilder: (context) { - return [ - PopupMenuItem( - child: '举报'.text.isIntrinsic.make(), - value: 0, - ), - ]; - }, - onSelected: (dynamic _) async { - if (LoginUtil.isNotLogin) return; - VoidCallback cancel = BotToast.showLoading(); - await Future.delayed( - Duration(milliseconds: 500 + Random().nextInt(500))); - cancel(); - BotToast.showText(text: '举报成功'); - }, - ), - ].row(), - 6.hb, - widget.model!.content!.text.size(32.sp).black.make(), - 20.hb, - _renderImage(), - widget.model!.gambitTitle?.isEmpty ?? true - ? SizedBox() - : Chip( - label: '#${widget.model!.gambitTitle}' - .text - .size(22.sp) - .make(), - padding: EdgeInsets.symmetric( - horizontal: 16.w, vertical: 5.w), - labelPadding: EdgeInsets.zero, - backgroundColor: Colors.transparent, - shape: StadiumBorder( - side: BorderSide(), - ), - ).pOnly(top: 10.w), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + 32.hb, + widget.model!.content!.text.size(32.sp).black.make(), + 32.hb, + _renderImage(), + widget.model!.gambitTitle?.isEmpty ?? true + ? SizedBox() + : Chip( + label: '# ${widget.model!.gambitTitle}' + .text + .color(Color(0xFF547fc0)) + .size(28.sp) + .make(), + padding: EdgeInsets.symmetric( + horizontal: 16.w, vertical: 5.w), + labelPadding: EdgeInsets.zero, + backgroundColor: Colors.transparent, + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + // shape: StadiumBorder( + // side: BorderSide(), + // ), + ).pOnly(top: 20.w), + 20.hb, + ], + ).paddingOnly(right: 32.w,left: 32.w), + + Divider(height: 1.w, thickness: 1.w), + 10.hb, Row( children: [ 64.hb, - BeeDateUtil(widget.model!.date) - .timeAgo - .text - .size(28.sp) - .color(Color(0xFF999999)) - .make(), + _isMyself ? TextButton( onPressed: () async { @@ -411,12 +442,13 @@ class _ChatCardState extends State { _buildMoreButton(), ], ), - _renderLikeAndComment(), + // _renderLikeAndComment(), + ], - ).expand(), + ), ], - ).p(20.w), + ).paddingOnly(top: 24.w,bottom: 32.w), ), - ); + ).paddingOnly(bottom: 16.w); } } diff --git a/lib/ui/market/collection/collection_func.dart b/lib/ui/market/collection/collection_func.dart new file mode 100644 index 00000000..546d0452 --- /dev/null +++ b/lib/ui/market/collection/collection_func.dart @@ -0,0 +1,90 @@ +import 'package:aku_community/constants/api.dart'; +import 'package:aku_community/models/collection/collection_goods_model.dart'; +import 'package:aku_community/models/market/goods_item.dart'; +import 'package:aku_community/models/market/order/order_detail_model.dart'; +import 'package:aku_community/utils/network/base_model.dart'; +import 'package:aku_community/utils/network/net_util.dart'; + +class CollectionFunc { + ///加入和取消收藏 + static Future collection(int jcookGoodsId) async { + await NetUtil().get(API.market.addCollection, + params: {"jcookGoodsId": jcookGoodsId}, showMessage: true); + } + + + /// 获取此供应商热度最高的商品 + static Future> getCollectionList() async { + BaseModel baseModel = + await NetUtil().get(API.market.collectionList); + if (baseModel.status == true && baseModel.data != null) { + return (baseModel.data as List) + .map((e) => CollectionGoodsModel.fromJson(e)) + .toList(); + } + return []; + } + + + // ///确认收货 + // static Future confirmReceive(int goodsAppointmentId) async { + // await NetUtil().get(API.market.confirmReceive, + // params: {"goodsAppointmentId": goodsAppointmentId}, showMessage: true); + // } + // + // ///申请退换 + // static Future refundOrder( + // int goodsAppointmentId, String reson, int type) async { + // BaseModel baseModel = await NetUtil().get(API.market.refundOrder, + // params: { + // "goodsAppointmentId": goodsAppointmentId, + // "backReason": reson, + // "backType": type + // }, + // showMessage: true); + // return baseModel; + // } + // + // ///取消预约 + // static Future cancelOrder(int goodsAppointmentId) async { + // BaseModel baseModel = await NetUtil().get(API.market.cancleOrder, + // params: {"goodsAppointmentId": goodsAppointmentId}, showMessage: true); + // return baseModel; + // } + // + // ///商品评价 + // static Future goodsEvalution( + // int goodsAppointmentId, int rating, String evaluationReason) async { + // BaseModel baseModel = await NetUtil().get(API.market.goodsEvaluation, + // params: { + // "goodsAppointmentId": goodsAppointmentId, + // "score": rating, + // "evaluationReason": evaluationReason + // }, + // showMessage: true); + // return baseModel; + // } + // + // /// 获取此供应商热度最高的商品 + // static Future> getHotTops(int supplierId) async { + // BaseModel baseModel = + // await NetUtil().get(API.market.suppliyerHotTop, params: { + // "supplierId": supplierId, + // }); + // if (baseModel.status == true && baseModel.data != null) { + // return (baseModel.data as List) + // .map((e) => GoodsItem.fromJson(e)) + // .toList(); + // } + // return []; + // } + // + // ///获取商品详情 + // static Future getOrderDetail(int goodsAppointmentId) async { + // BaseModel baseModel = await NetUtil().get(API.market.orderDetail, + // params: {"goodsAppointmentId": goodsAppointmentId}); + // if (baseModel.status! && baseModel.data != null) { + // return OrderDetailModel.fromJson(baseModel.data); + // } + // } +} diff --git a/lib/ui/market/collection/collection_list_card.dart b/lib/ui/market/collection/collection_list_card.dart new file mode 100644 index 00000000..8da85070 --- /dev/null +++ b/lib/ui/market/collection/collection_list_card.dart @@ -0,0 +1,230 @@ +import 'package:aku_community/base/base_style.dart'; +import 'package:aku_community/models/collection/collection_goods_model.dart'; +import 'package:aku_community/models/search/search_goods_model.dart'; +import 'package:flutter/material.dart'; + +import 'package:bot_toast/bot_toast.dart'; +import 'package:get/get.dart'; + +import 'package:aku_community/constants/api.dart'; + +import 'package:aku_community/utils/headers.dart'; + +class CollectionListCard extends StatelessWidget { + final CollectionGoodsModel model; + const CollectionListCard({Key? key, required this.model}) : super(key: key); + + @override + Widget build(BuildContext context) { + return GestureDetector( + child: Container( + height: 280.w, + decoration: BoxDecoration( + borderRadius: BorderRadius.all( + Radius.circular(16.w), + ), + color: Colors.white), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ClipRRect( + borderRadius: BorderRadius.all( + Radius.circular(16.w), + ), + child: FadeInImage.assetNetwork( + image: model.mainPhoto ?? '', + placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + height: 280.w, + width: 280.w, + fit: BoxFit.fill, + imageErrorBuilder: (context, error, stackTrace) { + return Image.asset( + R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + height: 280.w, + width: 280.w, + ); + }, + ), + ), + 16.wb, + Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + 8.hb, + SizedBox( + width: 400.w, + child: Text( + model.skuName ?? '', + maxLines: 2, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 28.sp, + color: ktextPrimary, + ), + ), + ), + 5.hb, + _getIcon(2), + //_getIcon(model.kind??0), + Spacer(), + 20.hb, + RichText( + text: TextSpan( + children: [ + TextSpan( + text: '¥', + style: TextStyle( + color: Colors.red, + fontSize: 28.sp, + ), + ), + TextSpan( + text: '${model.sellPrice ?? 0} ', + style: TextStyle( + color: Colors.red, + fontWeight: FontWeight.bold, + fontSize: 40.sp, + ), + ), + ], + ), + ), + + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + RichText( + text: TextSpan( + children: [ + TextSpan( + text: '官方指导价:¥', + style: TextStyle( + color: ktextSubColor, + fontSize: 20.sp, + ), + ), + TextSpan( + text: '${model.sellPrice ?? 0}', + style: TextStyle( + color: ktextSubColor, + fontSize: 20.sp, + decoration: TextDecoration.lineThrough, + ), + ), + ], + ), + ), + RichText( + text: TextSpan( + children: [ + TextSpan( + text: '折扣:', + style: TextStyle( + color: ktextSubColor, + fontSize: 20.sp, + ), + ), + TextSpan( + text: ((model.discountPrice ?? + 1 / (model.sellPrice ?? 1)) * + 10) < + 1 + ? _getDiscount(model.sellPrice ?? -1, + model.discountPrice ?? -1) + : '暂无折扣', + style: TextStyle( + color: ktextSubColor, + fontSize: 20.sp, + ), + ), + ], + ), + ), + ], + ), + Spacer(), + Row( + children: [ + GestureDetector( + child: Image.asset(R.ASSETS_ICONS_COLLECTION_SHARE_PNG,width: 44.w,height: 44.w,), + onTap: (){ + + }, + ), + 24.wb, + GestureDetector( + child: Image.asset(R.ASSETS_ICONS_COLLECTION_SETTING_PNG,width: 44.w,height: 44.w,), + onTap: (){ + + }, + ), + ], + ), + 44.wb, + ], + ), + 16.hb, + ], + ).expand(), + ], + ), + ), + ); + } + + _getDiscount(double sellPrice, double discountPrice) { + String count = ''; + count = ((discountPrice / sellPrice) * 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/lib/ui/market/collection/my_collection.dart b/lib/ui/market/collection/my_collection.dart new file mode 100644 index 00000000..db59fbbb --- /dev/null +++ b/lib/ui/market/collection/my_collection.dart @@ -0,0 +1,117 @@ +import 'package:aku_community/model/common/img_model.dart'; +import 'package:aku_community/models/collection/collection_goods_model.dart'; +import 'package:aku_community/models/search/search_goods_model.dart'; +import 'package:aku_community/provider/user_provider.dart'; +import 'package:aku_community/ui/market/search/goods_list_card.dart'; +import 'package:aku_community/utils/hive_store.dart'; +import 'package:aku_community/widget/bee_back_button.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +import 'package:flutter_easyrefresh/easy_refresh.dart'; +import 'package:get/get.dart'; +import 'package:provider/provider.dart'; +import 'package:waterfall_flow/waterfall_flow.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'; +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 'collection_func.dart'; +import 'collection_list_card.dart'; + + +class MyCollectionPage extends StatefulWidget { + MyCollectionPage({Key? key}) : super(key: key); + + @override + MyCollectionPageState createState() => MyCollectionPageState(); +} + +class MyCollectionPageState extends State { + // TextEditingController _editingController = TextEditingController(); + EasyRefreshController _refreshController = EasyRefreshController(); + // List _searchHistory = []; + String _searchText = ""; + late List _models; + bool _onload = true; + + + @override + void initState() { + super.initState(); + } + + @override + void dispose() { + _refreshController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + final userProvider = Provider.of(context, listen: false); + return BeeScaffold( + titleSpacing: 0, + bgColor: Color(0xFFF9F9F9), + bodyColor: Color(0xFFF9F9F9), + title: '收藏的商品', + body:Container( + color: Color(0xFFF2F3F4), + child: EasyRefresh( + firstRefresh: true, + header: MaterialHeader(), + controller: _refreshController, + onRefresh: () async { + _models = await CollectionFunc.getCollectionList(); + _onload = false; + setState(() {}); + }, + child: _onload + ? Container() + : ListView( + children: [..._models.map((e) => CollectionListCard( model: e,)).toList()], + ), + ), + + // BeeListView( + // path: API.market.collectionList, + // controller: _refreshController, + // extraParams: { + // "keyword":_searchText, + // }, + // convert: (model) => model.tableList! + // .map((e) => CollectionGoodsModel.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 Container(width: 100.w,height: 100.w,color: Colors.red,); + // CollectionListCard( + // model: item,); //GoodsCard(item: item); + // }, + // separatorBuilder: (_, __) { + // return 32.w.heightBox; + // }, + // itemCount: items.length, + // ); + // }, + // ), + ) + ); + } + + +} diff --git a/lib/ui/market/goods/goods_card.dart b/lib/ui/market/goods/goods_card.dart index 71420200..a9d671d5 100644 --- a/lib/ui/market/goods/goods_card.dart +++ b/lib/ui/market/goods/goods_card.dart @@ -42,7 +42,7 @@ class GoodsCard extends StatelessWidget { children: [ FadeInImage.assetNetwork( placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, - image: API.image(ImgModel.first(item.imgList)), + image: ImgModel.first(item.imgList), fit: BoxFit.fill, imageErrorBuilder: (context, error, stackTrace) { return Image.asset(R.ASSETS_IMAGES_PLACEHOLDER_WEBP); @@ -70,13 +70,13 @@ class GoodsCard extends StatelessWidget { ], ), ), - Padding( + Container( padding: EdgeInsets.only( left: 16.w,right: 16.w, top: 10.w, ), child: Text( - item.title+'98-034789reuyguiuioprguioptuiop348907r789-0re8097grt789rge978-ge', + item.title, maxLines: 2, overflow: TextOverflow.ellipsis, style: TextStyle( @@ -96,7 +96,7 @@ class GoodsCard extends StatelessWidget { ) ), - + 10.hb, Padding( padding: EdgeInsets.symmetric( horizontal: 16.w, diff --git a/lib/ui/market/market_page.dart b/lib/ui/market/market_page.dart index 8e81f6b2..685bf702 100644 --- a/lib/ui/market/market_page.dart +++ b/lib/ui/market/market_page.dart @@ -62,13 +62,16 @@ class _MarketPageState extends State double MessageHeight = 76.w; double bannerHeight = 354.w; double buttonsHeight = 334.w; - double searchHeight = 74.w.w; + double searchHeight = 74.w; double tabBarHeight = 60.w; late TabController _tabController; List _swiperModels = []; + OrderType _orderType = OrderType.NORMAL; + IconData priceIcon = CupertinoIcons.chevron_up_chevron_down; + Future updateMarketInfo() async { BaseListModel baseListModel = await NetUtil().getList(API.market.hotTop, params: { @@ -755,10 +758,12 @@ class _MarketPageState extends State alignment: Alignment.centerLeft, color: Color(0xFFF9F9F9), width: MediaQuery.of(context).size.width, - child: Container( + child: + Container( alignment: Alignment.centerLeft, height: 60.w, - child: TabBar( + child: + TabBar( onTap: (index) { // _presenter.fetchList(_category.id, 0, _sortType); setState(() {}); @@ -777,37 +782,137 @@ class _MarketPageState extends State ); } List _tabItems() { - return [_tabItem(0,'综合推荐'),_tabItem(1,'销量'),_tabItem(2,'价格')]; + return [_tabItemComprehensive(0,'综合推荐'),_tabItemSalesVolume(1,'销量'),_tabItemPrice(2,'价格')]; } - _tabItem(int index,String text) { + _tabItemComprehensive(int index,String text) { bool isChoose = index == _tabController.index; // Color textColor = index == _tabController.index // ? getCurrentThemeColor() // : Colors.black.withOpacity(0.9); return Tab( - child: Container( - alignment: Alignment.center, - width: 150.w, - // color: Colors.white, - color: Color(0xFFF9F9F9), - padding: EdgeInsets.only(left: 10.w, right: 10.w), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - text, - style: TextStyle( - fontWeight: isChoose?FontWeight.bold:FontWeight.normal, - fontSize: isChoose?32.sp:28.sp, - color: isChoose?Color(0xFF000000):Color(0xFF666666)), - ), - ], + child: GestureDetector( + onTap: (){ + _orderType = OrderType.NORMAL; + priceIcon = CupertinoIcons.chevron_up_chevron_down; + setState(() {}); + }, + child: Container( + alignment: Alignment.center, + width: 150.w, + // color: Colors.white, + color: Color(0xFFF9F9F9), + padding: EdgeInsets.only(left: 10.w, right: 10.w), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + text, + style: TextStyle( + fontWeight: isChoose?FontWeight.bold:FontWeight.normal, + fontSize: isChoose?32.sp:28.sp, + color: isChoose?Color(0xFF000000):Color(0xFF666666)), + ), + ], + ), + ), + ), + ); + } + + _tabItemSalesVolume(int index,String text) { + bool isChoose = index == _tabController.index; + // Color textColor = index == _tabController.index + // ? getCurrentThemeColor() + // : Colors.black.withOpacity(0.9); + return Tab( + child: GestureDetector( + onTap: (){ + _orderType = OrderType.SALES; + priceIcon = CupertinoIcons.chevron_up_chevron_down; + setState(() {}); + }, + child: Container( + alignment: Alignment.center, + width: 150.w, + // color: Colors.white, + color: Color(0xFFF9F9F9), + padding: EdgeInsets.only(left: 10.w, right: 10.w), + child: Row( + children: [ + Text( + text, + style: TextStyle( + fontWeight: isChoose?FontWeight.bold:FontWeight.normal, + fontSize: isChoose?32.sp:28.sp, + color: isChoose?Color(0xFF000000):Color(0xFF666666)), + ), + Icon( + priceIcon, + size: 32.w, + color: _orderType == OrderType.PRICE_HIGH || + _orderType == OrderType.PRICE_LOW + ? kDarkPrimaryColor + : ktextPrimary, + ), + ], + ), + ), + ), + ); + } + + _tabItemPrice(int index,String text) { + bool isChoose = index == _tabController.index; + // Color textColor = index == _tabController.index + // ? getCurrentThemeColor() + // : Colors.black.withOpacity(0.9); + return Tab( + child: GestureDetector( + onTap: (){ + switch (_orderType) { + case OrderType.NORMAL: + case OrderType.SALES: + _orderType = OrderType.PRICE_HIGH; + priceIcon = CupertinoIcons.chevron_up; + break; + case OrderType.PRICE_HIGH: + _orderType = OrderType.PRICE_LOW; + priceIcon = CupertinoIcons.chevron_down; + break; + case OrderType.PRICE_LOW: + _orderType = OrderType.PRICE_HIGH; + priceIcon = CupertinoIcons.chevron_up; + break; + } + setState(() {}); + }, + child: Container( + alignment: Alignment.center, + width: 150.w, + // color: Colors.white, + color: Color(0xFFF9F9F9), + padding: EdgeInsets.only(left: 10.w, right: 10.w), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + text, + style: TextStyle( + fontWeight: isChoose?FontWeight.bold:FontWeight.normal, + fontSize: isChoose?32.sp:28.sp, + color: isChoose?Color(0xFF000000):Color(0xFF666666)), + ), + ], + ), ), ), ); } + + + @override bool get wantKeepAlive => true; } diff --git a/lib/ui/market/search/goods_grid_card.dart b/lib/ui/market/search/goods_grid_card.dart new file mode 100644 index 00000000..8160638f --- /dev/null +++ b/lib/ui/market/search/goods_grid_card.dart @@ -0,0 +1,240 @@ +import 'package:flutter/material.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'; + +class GoodsCard extends StatelessWidget { + final GoodsItem item; + final bool? border; + const GoodsCard({Key? key, required this.item, this.border}) + : super(key: key); + + @override + Widget build(BuildContext context) { + return MaterialButton( + color: Colors.white, + elevation: 0, + shape: !(border ?? false) + ? null + : RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8.w), + side: BorderSide(color: Color(0xFFC4C4C4))), + padding: EdgeInsets.zero, + onPressed: () => Get.to( + () => GoodsDetailPage(id: item.id), + preventDuplicates: false, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + clipBehavior: Clip.antiAlias, + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(12.w)), + ), + child: Stack( + children: [ + FadeInImage.assetNetwork( + placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + image: API.image(ImgModel.first(item.imgList)), + 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.recommend, + 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( + item.title, + 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(1), + ) + ), + + 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: '${item.sellingPrice} ', + style: TextStyle( + color: Colors.red, + fontWeight: FontWeight.bold, + fontSize: 40.sp, + ), + ), + ], + ), + ), + ), + + Padding( + padding: EdgeInsets.symmetric( + horizontal: 16.w, + ), + child: RichText( + text: TextSpan( + children: [ + TextSpan( + text: '原价:¥', + style: TextStyle( + color: ktextSubColor, + fontSize: 20.sp, + + ), + ), + TextSpan( + text: '${item.markingPrice}', + 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: '9折', + style: TextStyle( + color: ktextSubColor, + fontSize: 20.sp, + + ), + ), + ], + ), + ), + ), + + ], + ), + ); + } + + + 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/lib/ui/market/search/goods_list_card.dart b/lib/ui/market/search/goods_list_card.dart new file mode 100644 index 00000000..7b8f7346 --- /dev/null +++ b/lib/ui/market/search/goods_list_card.dart @@ -0,0 +1,245 @@ +import 'package:aku_community/base/base_style.dart'; +import 'package:aku_community/models/search/search_goods_model.dart'; +import 'package:aku_community/ui/market/collection/collection_func.dart'; +import 'package:flutter/material.dart'; + +import 'package:bot_toast/bot_toast.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; +import 'package:get/get.dart'; + +import 'package:aku_community/constants/api.dart'; + +import 'package:aku_community/utils/headers.dart'; + +class GoodsListCard extends StatefulWidget { + final SearchGoodsModel model; + final EasyRefreshController? refreshController; + + GoodsListCard({Key? key, required this.model, this.refreshController}) + : super(key: key); + + @override + GoodsListCardState createState() => GoodsListCardState(); +} + +class GoodsListCardState extends State { + + @override + Widget build(BuildContext context) { + return GestureDetector( + child: Container( + height: 280.w, + decoration: BoxDecoration( + borderRadius: BorderRadius.all( + Radius.circular(16.w), + ), + color: Colors.white), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ClipRRect( + borderRadius: BorderRadius.all( + Radius.circular(16.w), + ), + child: FadeInImage.assetNetwork( + image: widget.model.mainPhoto ?? '', + placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + height: 280.w, + width: 280.w, + fit: BoxFit.fill, + imageErrorBuilder: (context, error, stackTrace) { + return Image.asset( + R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + height: 280.w, + width: 280.w, + ); + }, + ), + ), + 16.wb, + Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + 8.hb, + SizedBox( + width: 400.w, + child: Text( + widget.model.skuName ?? '', + maxLines: 2, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 28.sp, + color: ktextPrimary, + ), + ), + ), + 5.hb, + _getIcon(2), + //_getIcon(model.kind??0), + Spacer(), + 20.hb, + RichText( + text: TextSpan( + children: [ + TextSpan( + text: '¥', + style: TextStyle( + color: Colors.red, + fontSize: 28.sp, + ), + ), + TextSpan( + text: '${widget.model.sellPrice ?? 0} ', + style: TextStyle( + color: Colors.red, + fontWeight: FontWeight.bold, + fontSize: 40.sp, + ), + ), + ], + ), + ), + + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + RichText( + text: TextSpan( + children: [ + TextSpan( + text: '官方指导价:¥', + style: TextStyle( + color: ktextSubColor, + fontSize: 20.sp, + ), + ), + TextSpan( + text: '${widget.model.sellPrice ?? 0}', + style: TextStyle( + color: ktextSubColor, + fontSize: 20.sp, + decoration: TextDecoration.lineThrough, + ), + ), + ], + ), + ), + RichText( + text: TextSpan( + children: [ + TextSpan( + text: '折扣:', + style: TextStyle( + color: ktextSubColor, + fontSize: 20.sp, + ), + ), + TextSpan( + text: ((widget.model.discountPrice ?? + 1 / (widget.model.sellPrice ?? 1)) * + 10) < + 1 + ? _getDiscount(widget.model.sellPrice ?? -1, + widget.model.discountPrice ?? -1) + : '暂无折扣', + style: TextStyle( + color: ktextSubColor, + fontSize: 20.sp, + ), + ), + ], + ), + ), + ], + ), + Spacer(), + GestureDetector( + onTap: () async { + await CollectionFunc.collection(widget.model.id!); + + if (widget.refreshController != null) { + widget.refreshController!.callRefresh(); + } + }, + child: (widget.model.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, + ), + ), + 24.wb, + ], + ), + 16.hb, + ], + ).expand(), + ], + ), + ), + ); + } + + _getDiscount(double sellPrice, double discountPrice) { + String count = ''; + count = ((discountPrice / sellPrice) * 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/lib/ui/market/search/search_detail_page.dart b/lib/ui/market/search/search_detail_page.dart new file mode 100644 index 00000000..eea3eaf2 --- /dev/null +++ b/lib/ui/market/search/search_detail_page.dart @@ -0,0 +1,467 @@ +import 'package:aku_community/model/common/img_model.dart'; +import 'package:aku_community/provider/user_provider.dart'; +import 'package:aku_community/utils/hive_store.dart'; +import 'package:aku_community/widget/bee_back_button.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +import 'package:flutter_easyrefresh/easy_refresh.dart'; +import 'package:get/get.dart'; +import 'package:provider/provider.dart'; +import 'package:waterfall_flow/waterfall_flow.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'; +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'; + +enum OrderType { + NORMAL, + SALES, + PRICE_HIGH, + PRICE_LOW, +} + +class SearchDetailPage extends StatefulWidget { + SearchDetailPage({Key? key}) : super(key: key); + + @override + SearchDetailPageState createState() => SearchDetailPageState(); +} + +class SearchDetailPageState extends State { + TextEditingController _editingController = TextEditingController(); + OrderType _orderType = OrderType.NORMAL; + IconData priceIcon = CupertinoIcons.chevron_up_chevron_down; + EasyRefreshController _refreshController = EasyRefreshController(); + List _searchHistory = []; + String _searchText = ""; + FocusNode _contentFocusNode = FocusNode(); + bool _showList = true; + + @override + void initState() { + super.initState(); + getSearchListFromSharedPreferences(); + } + + @override + void dispose() { + _refreshController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + final userProvider = Provider.of(context, listen: false); + final normalTypeButton = MaterialButton( + onPressed: () { + _orderType = OrderType.NORMAL; + priceIcon = CupertinoIcons.chevron_up_chevron_down; + setState(() {}); + }, + child: Text( + '综合', + style: TextStyle( + color: + _orderType == OrderType.NORMAL ? kDarkPrimaryColor : ktextPrimary, + ), + ), + height: 80.w, + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + ); + final salesTypeButton = MaterialButton( + onPressed: () { + _orderType = OrderType.SALES; + priceIcon = CupertinoIcons.chevron_up_chevron_down; + setState(() {}); + }, + child: Text( + '销量', + style: TextStyle( + color: + _orderType == OrderType.SALES ? kDarkPrimaryColor : ktextPrimary, + ), + ), + height: 80.w, + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + ); + + final priceButton = MaterialButton( + onPressed: () { + switch (_orderType) { + case OrderType.NORMAL: + case OrderType.SALES: + _orderType = OrderType.PRICE_HIGH; + priceIcon = CupertinoIcons.chevron_up; + break; + case OrderType.PRICE_HIGH: + _orderType = OrderType.PRICE_LOW; + priceIcon = CupertinoIcons.chevron_down; + break; + case OrderType.PRICE_LOW: + _orderType = OrderType.PRICE_HIGH; + priceIcon = CupertinoIcons.chevron_up; + break; + } + setState(() {}); + }, + child: Row( + children: [ + Text( + '价格', + style: TextStyle( + color: _orderType == OrderType.PRICE_HIGH || + _orderType == OrderType.PRICE_LOW + ? kDarkPrimaryColor + : ktextPrimary, + ), + ), + Icon( + priceIcon, + size: 32.w, + color: _orderType == OrderType.PRICE_HIGH || + _orderType == OrderType.PRICE_LOW + ? kDarkPrimaryColor + : ktextPrimary, + ), + ], + ), + height: 80.w, + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + ); + 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) { + _searchText = text; + setState(() {}); + }, + onSubmitted: (_submitted) async { + _contentFocusNode.unfocus(); + 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(() {}); + }, + style: TextStyle( + textBaseline: TextBaseline.ideographic, + fontSize: 32.sp, + color: Colors.black, + ), + 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, + Image.asset(R.ASSETS_ICONS_ICON_CHANGE_LIST_PNG,width: 48.w,height: 48.w,), + + Text( + '搜索', + style: TextStyle(color: ktextPrimary, fontSize: 28.sp), + ), + ], + ), + body: Column( + children: [ + Row( + children: [ + normalTypeButton, + salesTypeButton, + priceButton, + ], + ), + 10.hb, + 10.hb, + _showList + ? Container( + color: Color(0xFFF2F3F4), + child: 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(), + ], + ), + ); + } + + _hotGoodsCard(GoodsItem goodsItem, int index) { + return Row( + children: [ + Stack( + children: [ + Material( + color: Color(0xFFF5F5F5), + borderRadius: BorderRadius.circular(16.w), + clipBehavior: Clip.antiAlias, + child: FadeInImage.assetNetwork( + placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + image: API.image(ImgModel.first(goodsItem.imgList)), + fit: BoxFit.fill, + width: 124.w, + height: 124.w, + imageErrorBuilder: (context, error, stackTrace) { + return Image.asset( + R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + width: 124.w, + height: 124.w, + ); + }, + ), + ), + // Image.asset( + // R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + // fit: BoxFit.fill, + // width: 124.w, + // height: 124.w, + // ), + Positioned( + left: 0, + top: 0, + child: Container( + alignment: Alignment.center, + width: 32.w, + height: 32.w, + decoration: BoxDecoration( + borderRadius: BorderRadius.only( + topLeft: Radius.circular(16.w), + topRight: Radius.circular(16.w), + bottomLeft: Radius.circular(16.w)), + gradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomCenter, + colors: index == 0 + ? [ + Color(0xFFE52E2E), + Color(0xFFF58123), + ] + : index == 1 + ? [ + Color(0xFFF58123), + Color(0xFFF5AF16), + ] + : index == 2 + ? [ + Color(0xFFF5AF16), + Color(0xFFF5AF16), + ] + : [ + Color(0xFFBBBBBB), + Color(0xFFBBBBBB), + ], + ), + ), + child: Text( + '${index + 1}', + style: TextStyle( + color: Colors.white, + fontSize: 24.sp, + ), + ), + )), + ], + ), + 32.wb, + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: 500.w, + child: Text( + goodsItem.title, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle(color: ktextPrimary, fontSize: 28.sp), + ), + ), + 8.hb, + Row( + children: [ + Text( + '人气值', + style: TextStyle(color: ktextSubColor, fontSize: 24.sp), + ), + 10.wb, + Text( + '99251', + style: TextStyle(color: Color(0xFFBBBBBB), fontSize: 24.sp), + ), + ], + ) + ], + ) + ], + ); + } + + _searchHistoryWidget() { + List choiceChipList = []; + if (_searchHistory != null && _searchHistory.length > 0) { + for (var text in _searchHistory) { + choiceChipList.add(Padding( + padding: EdgeInsets.only(right: 10, bottom: 5), + child: ChoiceChip( + backgroundColor: Colors.white, + // disabledColor: Colors.blue, + labelStyle: TextStyle(fontSize: 15 * 2.sp, color: Colors.black), + labelPadding: EdgeInsets.only(left: 20, right: 20), + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + onSelected: (bool value) { + _editingController.text = text; + _searchText = text; + FocusManager.instance.primaryFocus!.unfocus(); + setState(() {}); + }, + label: Text(text), + selected: false, + ), + )); + } + } + + return _searchHistory.length == 0 + ? SizedBox() + : Container( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + 36.hb, + Container( + child: Container( + margin: EdgeInsets.only(left: 15, bottom: 5), + child: Row( + children: [ + Text( + '历史搜索', + style: TextStyle( + color: Colors.black, + fontSize: 16, + ), + ), + Spacer(), + (_searchHistory != null && _searchHistory.length > 0) + ? GestureDetector( + onTap: () { + _searchHistory = []; + saveSearchListToSharedPreferences( + _searchHistory); + setState(() {}); + }, + child: Image.asset( + R.ASSETS_ICONS_DELETE_PNG, + width: 40.w, + height: 40.w, + ), + ) + : Container(), + 36.wb, + ], + )), + ), + Container( + width: MediaQuery.of(context).size.width, + padding: EdgeInsets.only(left: 10, right: 10), + child: Wrap( + children: choiceChipList, + ), + ), + // Spacer() + 24.hb, + ], + ), + ); + } + + getSearchListFromSharedPreferences() async { + final userProvider = Provider.of(Get.context!, listen: false); + _searchHistory = HiveStore.appBox!.get( + userProvider.userInfoModel?.id.toString() ?? '' + "userSearhHistory")!; + if (_searchHistory == null) { + _searchHistory = []; + } + setState(() {}); + } + + saveSearchListToSharedPreferences(List value) async { + final userProvider = Provider.of(Get.context!, listen: false); + + HiveStore.appBox!.put( + userProvider.userInfoModel?.id.toString() ?? '' + "userSearhHistory", + value); + } +} diff --git a/lib/ui/market/search/search_func.dart b/lib/ui/market/search/search_func.dart new file mode 100644 index 00000000..0339b51a --- /dev/null +++ b/lib/ui/market/search/search_func.dart @@ -0,0 +1,97 @@ +import 'package:aku_community/constants/api.dart'; +import 'package:aku_community/models/market/goods_item.dart'; +import 'package:aku_community/models/market/order/order_detail_model.dart'; +import 'package:aku_community/models/search/search_goods_model.dart'; +import 'package:aku_community/utils/network/base_list_model.dart'; +import 'package:aku_community/utils/network/base_model.dart'; +import 'package:aku_community/utils/network/net_util.dart'; +import 'package:aku_community/utils/text_utils.dart'; + +class SearchFunc { + /// 搜索商品 根据关键字 + static Future> getGoodsList(int pageNum,int size + ,int orderBySalesVolume,int orderByPrice,String keyword, int brandId,double minPrice,double maxPrice) async { + //orderBySalesVolume 1降序 2升序 + Map params = { + "pageNum": pageNum, + "size":size, + }; + if(orderBySalesVolume!=-1){ + params.putIfAbsent("orderBySalesVolume", () => orderBySalesVolume); + } + if(orderByPrice!=-1){ + params.putIfAbsent("orderByPrice", () => orderByPrice); + } + if (!TextUtils.isEmpty(keyword)) { + params.putIfAbsent("keyword", () => keyword); + } + if(brandId!=-1){ + params.putIfAbsent("brandId", () => brandId); + } + if(minPrice!=-1){ + params.putIfAbsent("minPrice", () => minPrice); + } + if(maxPrice!=-1){ + params.putIfAbsent("maxPrice", () => maxPrice); + } + + BaseListModel model = await NetUtil().getList( + API.market.findGoodsList, + params: params, + ); + if (model.tableList!.length == 0) return []; + return model.tableList!.map((e) => SearchGoodsModel.fromJson(e)).toList(); + } + + + + + ///确认收货 + static Future confirmReceive(int goodsAppointmentId) async { + await NetUtil().get(API.market.confirmReceive, + params: {"goodsAppointmentId": goodsAppointmentId}, showMessage: true); + } + + ///申请退换 + static Future refundOrder( + int goodsAppointmentId, String reson, int type) async { + BaseModel baseModel = await NetUtil().get(API.market.refundOrder, + params: { + "goodsAppointmentId": goodsAppointmentId, + "backReason": reson, + "backType": type + }, + showMessage: true); + return baseModel; + } + + ///取消预约 + static Future cancelOrder(int goodsAppointmentId) async { + BaseModel baseModel = await NetUtil().get(API.market.cancleOrder, + params: {"goodsAppointmentId": goodsAppointmentId}, showMessage: true); + return baseModel; + } + + ///商品评价 + static Future goodsEvalution( + int goodsAppointmentId, int rating, String evaluationReason) async { + BaseModel baseModel = await NetUtil().get(API.market.goodsEvaluation, + params: { + "goodsAppointmentId": goodsAppointmentId, + "score": rating, + "evaluationReason": evaluationReason + }, + showMessage: true); + return baseModel; + } + + + ///获取商品详情 + static Future getOrderDetail(int goodsAppointmentId) async { + BaseModel baseModel = await NetUtil().get(API.market.orderDetail, + params: {"goodsAppointmentId": goodsAppointmentId}); + if (baseModel.status! && baseModel.data != null) { + return OrderDetailModel.fromJson(baseModel.data); + } + } +} diff --git a/lib/ui/market/search/search_goods_page.dart b/lib/ui/market/search/search_goods_page.dart index 60a52066..847b9116 100644 --- a/lib/ui/market/search/search_goods_page.dart +++ b/lib/ui/market/search/search_goods_page.dart @@ -1,7 +1,23 @@ +import 'dart:math'; + +import 'package:aku_community/model/common/img_model.dart'; +import 'package:aku_community/models/search/search_goods_model.dart'; +import 'package:aku_community/provider/user_provider.dart'; +import 'package:aku_community/ui/market/collection/collection_list_card.dart'; +import 'package:aku_community/ui/market/collection/my_collection.dart'; +import 'package:aku_community/ui/market/search/search_detail_page.dart'; +import 'package:aku_community/ui/market/search/search_func.dart'; +import 'package:aku_community/utils/hive_store.dart'; +import 'package:aku_community/utils/network/base_list_model.dart'; +import 'package:aku_community/utils/network/net_util.dart'; +import 'package:aku_community/utils/text_utils.dart'; +import 'package:aku_community/widget/bee_back_button.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; +import 'package:get/get.dart'; +import 'package:provider/provider.dart'; import 'package:waterfall_flow/waterfall_flow.dart'; import 'package:aku_community/base/base_style.dart'; @@ -12,6 +28,8 @@ 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 'goods_list_card.dart'; + enum OrderType { NORMAL, SALES, @@ -31,15 +49,38 @@ class SearchGoodsPageState extends State { OrderType _orderType = OrderType.NORMAL; IconData priceIcon = CupertinoIcons.chevron_up_chevron_down; EasyRefreshController _refreshController = EasyRefreshController(); + EasyRefreshController _refreshController1 = EasyRefreshController(); + List _searchHistory = []; + String _searchText = ""; + FocusNode _contentFocusNode = FocusNode(); + bool _showList = true; + bool _startSearch = false; + int? orderBySalesVolume; + int? orderByPrice; + int? brandId; + double? minPrice; + double? maxPrice; + late List _models; + ScrollController _scrollController= new ScrollController(); + + @override + void initState() { + super.initState(); + + getSearchListFromSharedPreferences(); + } @override void dispose() { _refreshController.dispose(); + _refreshController1.dispose(); + _scrollController.dispose(); super.dispose(); } @override Widget build(BuildContext context) { + final userProvider = Provider.of(context, listen: false); final normalTypeButton = MaterialButton( onPressed: () { _orderType = OrderType.NORMAL; @@ -116,59 +157,485 @@ class SearchGoodsPageState extends State { height: 80.w, materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, ); - return BeeScaffold( - title: Padding( - padding: EdgeInsets.symmetric(vertical: 12.w), - child: TextField( - onEditingComplete: () { - setState(() {}); - _refreshController.callRefresh(); - }, - controller: _editingController, - decoration: InputDecoration( - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(40), + return + BeeScaffold( + // fab: FloatingActionButton( + // backgroundColor: Colors.transparent, + // foregroundColor: Colors.transparent, + // elevation: 0, + // highlightElevation: 0, + // shape: new , + // onPressed: () { + // }, + // child: Column( + // children: [ + // Image.asset(R.ASSETS_ICONS_COLLECT_PNG,width: 84.w,height: 84.w,), + // 24.hb, + // Image.asset(R.ASSETS_ICONS_ICON_TOTOP_PNG,width: 84.w,height: 84.w,), + // ], + // ), + // ), + 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 { + 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: 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), + ), + ), ), - filled: true, - fillColor: Color(0xFFF3F3F3), - isDense: true, - prefixIcon: Icon(CupertinoIcons.search), ), - ), + 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), + ), + ), + ], ), - //TODO 列表排序 - // appBarBottom: PreferredSize( - // child: Row( - // children: [ - // normalTypeButton, - // salesTypeButton, - // priceButton, - // ], - // ), - // preferredSize: Size.fromHeight(80.w), - // ), - body: BeeListView( - path: API.market.search, - controller: _refreshController, - extraParams: {'searchName': _editingController.text}, - convert: (model) => - model.tableList!.map((e) => GoodsItem.fromJson(e)).toList(), - builder: (items) { - return WaterfallFlow.builder( - padding: EdgeInsets.all(32.w), - gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount( - crossAxisCount: 2, - mainAxisSpacing: 20.w, - crossAxisSpacing: 20.w, + + body:Stack( + + children: [ + + !(!TextUtils.isEmpty(_editingController.text) && + _startSearch) + ? 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: 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,); //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: (){ + Get.to(() => MyCollectionPage()); + + }, + ), + 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(); + } + } + saveSearchListToSharedPreferences(_searchHistory); + setState(() {}); + } + + _hotGoodsCard(GoodsItem goodsItem, int index) { + return Row( + children: [ + Stack( + children: [ + Material( + color: Color(0xFFF5F5F5), + borderRadius: BorderRadius.circular(16.w), + clipBehavior: Clip.antiAlias, + child: FadeInImage.assetNetwork( + placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + image: API.image(ImgModel.first(goodsItem.imgList)), + fit: BoxFit.fill, + width: 124.w, + height: 124.w, + imageErrorBuilder: (context, error, stackTrace) { + return Image.asset( + R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + width: 124.w, + height: 124.w, + ); + }, + ), ), - itemBuilder: (context, index) { - final item = items[index]; - return GoodsCard(item: item); + Positioned( + left: 0, + top: 0, + child: Container( + alignment: Alignment.center, + width: 32.w, + height: 32.w, + decoration: BoxDecoration( + borderRadius: BorderRadius.only( + topLeft: Radius.circular(16.w), + topRight: Radius.circular(16.w), + bottomLeft: Radius.circular(16.w)), + gradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomCenter, + colors: index == 0 + ? [ + Color(0xFFE52E2E), + Color(0xFFF58123), + ] + : index == 1 + ? [ + Color(0xFFF58123), + Color(0xFFF5AF16), + ] + : index == 2 + ? [ + Color(0xFFF5AF16), + Color(0xFFF5AF16), + ] + : [ + Color(0xFFBBBBBB), + Color(0xFFBBBBBB), + ], + ), + ), + child: Text( + '${index + 1}', + style: TextStyle( + color: Colors.white, + fontSize: 24.sp, + ), + ), + )), + ], + ), + 32.wb, + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: 500.w, + child: Text( + goodsItem.title, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle(color: ktextPrimary, fontSize: 28.sp), + ), + ), + 8.hb, + Row( + children: [ + Text( + '人气值', + style: TextStyle(color: ktextSubColor, fontSize: 24.sp), + ), + 10.wb, + Text( + '99251', + style: TextStyle(color: Color(0xFFBBBBBB), fontSize: 24.sp), + ), + ], + ) + ], + ) + ], + ); + } + + ///搜索记录 + _searchHistoryWidget() { + List choiceChipList = []; + if (_searchHistory != null && _searchHistory.length > 0) { + for (var text in _searchHistory) { + choiceChipList.add(Padding( + padding: EdgeInsets.only(right: 10, bottom: 5), + child: ChoiceChip( + backgroundColor: Colors.white, + // disabledColor: Colors.blue, + labelStyle: TextStyle(fontSize: 15 * 2.sp, color: Colors.black), + labelPadding: EdgeInsets.only(left: 20, right: 20), + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + onSelected: (bool value) { + _startSearch = true; + _editingController.text = text; + _searchText = text; + setState(() {}); + + FocusManager.instance.primaryFocus!.unfocus(); + _refreshController1.callRefresh(); }, - itemCount: items.length, + label: Text(text), + selected: false, + ), + )); + } + } + + return _searchHistory.length == 0 + ? SizedBox() + : Container( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + 36.hb, + Container( + child: Container( + margin: EdgeInsets.only(left: 15, bottom: 5), + child: Row( + children: [ + Text( + '历史搜索', + style: TextStyle( + color: Colors.black, + fontSize: 16, + ), + ), + Spacer(), + (_searchHistory != null && _searchHistory.length > 0) + ? GestureDetector( + onTap: () { + _searchHistory = []; + saveSearchListToSharedPreferences( + _searchHistory); + setState(() {}); + }, + child: Image.asset( + R.ASSETS_ICONS_DELETE_PNG, + width: 40.w, + height: 40.w, + ), + ) + : Container(), + 36.wb, + ], + )), + ), + Container( + width: MediaQuery.of(context).size.width, + padding: EdgeInsets.only(left: 10, right: 10), + child: Wrap( + children: choiceChipList, + ), + ), + // Spacer() + 24.hb, + ], + ), ); - }, - ), - ); } + + ///获取搜索记录 + getSearchListFromSharedPreferences() async { + final userProvider = Provider.of(Get.context!, listen: false); + _searchHistory = HiveStore.appBox!.get( + userProvider.userInfoModel?.id.toString() ?? '' + "userSearhHistory")??''; + if (_searchHistory == null) { + _searchHistory = []; + } + setState(() {}); + } + ///保存搜索记录 + saveSearchListToSharedPreferences(List value) async { + final userProvider = Provider.of(Get.context!, listen: false); + + HiveStore.appBox!.put( + userProvider.userInfoModel?.id.toString() ?? '' + "userSearhHistory", + value); + } + + + } diff --git a/lib/ui/market/user/adress/my_adress.dart b/lib/ui/market/user/adress/my_adress.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/utils/bee_date_util.dart b/lib/utils/bee_date_util.dart index 4d0cc6e1..e76f0d95 100644 --- a/lib/utils/bee_date_util.dart +++ b/lib/utils/bee_date_util.dart @@ -28,4 +28,17 @@ class BeeDateUtil { else return DateUtil.formatDate(date, format: 'yyyy-MM-dd'); } + + String get timeAgoWithHm { + Duration duration = _now.difference(date!); + if (duration.inSeconds <= 60) return '${duration.inSeconds}秒前'; + if (duration.inMinutes <= 60) return '${duration.inMinutes}分钟前'; + if (duration.inHours <= 12) return '${duration.inHours}小时前'; + if (isYesterday) return '昨天'; + if (isDoubleYesterday) return '前天'; + if (duration.inDays <= 30) + return '${duration.inDays}天前'; + else + return DateUtil.formatDate(date, format: 'yyyy-MM-dd HH-mm'); + } } diff --git a/lib/widget/bee_scaffold.dart b/lib/widget/bee_scaffold.dart index cc438eeb..b6ed8626 100644 --- a/lib/widget/bee_scaffold.dart +++ b/lib/widget/bee_scaffold.dart @@ -19,6 +19,8 @@ class BeeScaffold extends StatelessWidget { final Widget? bottomNavi; final PreferredSizeWidget? appBarBottom; final FloatingActionButton? fab; + final double? titleSpacing; + final SystemUiOverlayStyle systemStyle; BeeScaffold({ @@ -32,7 +34,9 @@ class BeeScaffold extends StatelessWidget { this.bottomNavi, this.appBarBottom, this.fab, + this.titleSpacing, this.systemStyle = SystemStyle.initial, + }) : super(key: key); BeeScaffold.white({ @@ -45,6 +49,7 @@ class BeeScaffold extends StatelessWidget { this.bottomNavi, this.appBarBottom, this.fab, + this.titleSpacing, this.systemStyle = SystemStyle.initial, }) : this.bodyColor = Colors.white, super(key: key); @@ -66,6 +71,7 @@ class BeeScaffold extends StatelessWidget { leading: leading ?? BeeBackButton(), actions: actions, bottom: appBarBottom, + titleSpacing: titleSpacing, ); return AnnotatedRegion( @@ -76,6 +82,7 @@ class BeeScaffold extends StatelessWidget { body: body, bottomNavigationBar: bottomNavi, floatingActionButton: fab, + ), ); } diff --git a/pubspec.yaml b/pubspec.yaml index 438e6d6d..a24a4a08 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -113,6 +113,7 @@ dependencies: #划动组件 carousel_slider: ^4.0.0-nullsafety.0 + dev_dependencies: flutter_test: sdk: flutter