diff --git a/assets/icons/icon_back.png b/assets/icons/icon_back.png new file mode 100644 index 00000000..220edd2d Binary files /dev/null and b/assets/icons/icon_back.png differ diff --git a/assets/icons/icon_good_car.png b/assets/icons/icon_good_car.png new file mode 100644 index 00000000..8598cfb9 Binary files /dev/null and b/assets/icons/icon_good_car.png differ diff --git a/assets/icons/icon_good_favor.png b/assets/icons/icon_good_favor.png new file mode 100644 index 00000000..0a1599b9 Binary files /dev/null and b/assets/icons/icon_good_favor.png differ diff --git a/assets/icons/icon_good_location.png b/assets/icons/icon_good_location.png new file mode 100644 index 00000000..766e6bf7 Binary files /dev/null and b/assets/icons/icon_good_location.png differ diff --git a/assets/icons/icon_good_my.png b/assets/icons/icon_good_my.png new file mode 100644 index 00000000..bd232981 Binary files /dev/null and b/assets/icons/icon_good_my.png differ diff --git a/assets/icons/icon_price_bottom.png b/assets/icons/icon_price_bottom.png new file mode 100644 index 00000000..d3b6a0f2 Binary files /dev/null and b/assets/icons/icon_price_bottom.png differ diff --git a/assets/icons/icon_price_normal.png b/assets/icons/icon_price_normal.png new file mode 100644 index 00000000..e341d0e8 Binary files /dev/null and b/assets/icons/icon_price_normal.png differ diff --git a/assets/icons/icon_price_top.png b/assets/icons/icon_price_top.png new file mode 100644 index 00000000..7786a57e Binary files /dev/null and b/assets/icons/icon_price_top.png differ diff --git a/lib/const/resource.dart b/lib/const/resource.dart index 2858bedf..697223d8 100644 --- a/lib/const/resource.dart +++ b/lib/const/resource.dart @@ -331,6 +331,9 @@ class R { static const String ASSETS_ICONS_ICON_ADDRESS_NOT_PNG = 'assets/icons/icon_address_not.png'; + /// ![preview](file:///Users/datang/aku_community/assets/icons/icon_back.png) + static const String ASSETS_ICONS_ICON_BACK_PNG = 'assets/icons/icon_back.png'; + /// ![preview](file:///Users/datang/aku_community/assets/icons/icon_change_list.png) static const String ASSETS_ICONS_ICON_CHANGE_LIST_PNG = 'assets/icons/icon_change_list.png'; @@ -343,6 +346,22 @@ class R { static const String ASSETS_ICONS_ICON_FAVOR_CHOOSE_PNG = 'assets/icons/icon_favor_choose.png'; + /// ![preview](file:///Users/datang/aku_community/assets/icons/icon_good_car.png) + static const String ASSETS_ICONS_ICON_GOOD_CAR_PNG = + 'assets/icons/icon_good_car.png'; + + /// ![preview](file:///Users/datang/aku_community/assets/icons/icon_good_favor.png) + static const String ASSETS_ICONS_ICON_GOOD_FAVOR_PNG = + 'assets/icons/icon_good_favor.png'; + + /// ![preview](file:///Users/datang/aku_community/assets/icons/icon_good_location.png) + static const String ASSETS_ICONS_ICON_GOOD_LOCATION_PNG = + 'assets/icons/icon_good_location.png'; + + /// ![preview](file:///Users/datang/aku_community/assets/icons/icon_good_my.png) + static const String ASSETS_ICONS_ICON_GOOD_MY_PNG = + 'assets/icons/icon_good_my.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'; @@ -422,6 +441,18 @@ class R { static const String ASSETS_ICONS_ICON_PRICE_PNG = 'assets/icons/icon_price.png'; + /// ![preview](file:///Users/datang/aku_community/assets/icons/icon_price_bottom.png) + static const String ASSETS_ICONS_ICON_PRICE_BOTTOM_PNG = + 'assets/icons/icon_price_bottom.png'; + + /// ![preview](file:///Users/datang/aku_community/assets/icons/icon_price_normal.png) + static const String ASSETS_ICONS_ICON_PRICE_NORMAL_PNG = + 'assets/icons/icon_price_normal.png'; + + /// ![preview](file:///Users/datang/aku_community/assets/icons/icon_price_top.png) + static const String ASSETS_ICONS_ICON_PRICE_TOP_PNG = + 'assets/icons/icon_price_top.png'; + /// ![preview](file:///Users/datang/aku_community/assets/icons/icon_property_location.png) static const String ASSETS_ICONS_ICON_PROPERTY_LOCATION_PNG = 'assets/icons/icon_property_location.png'; diff --git a/lib/model/good/good_detail_model.dart b/lib/model/good/good_detail_model.dart new file mode 100644 index 00000000..02bcd02d --- /dev/null +++ b/lib/model/good/good_detail_model.dart @@ -0,0 +1,158 @@ +class GoodDetailModel { + List? goodsDetailImageVos; + double? sellPrice; + double? discountPrice; + String? skuName; + int? sellNum; + int? kind; + String? defaultLocation; + String? defaultAddressDetail; + int? stockStatus; + List? goodsDetailSpecificationVoList; + int? isCollection; + + GoodDetailModel( + {this.goodsDetailImageVos, + this.sellPrice, + this.discountPrice, + this.skuName, + this.sellNum, + this.kind, + this.defaultLocation, + this.defaultAddressDetail, + this.stockStatus, + this.goodsDetailSpecificationVoList, + this.isCollection}); + + factory GoodDetailModel.fail() => GoodDetailModel(goodsDetailImageVos: [],sellPrice: 0,discountPrice: 0,skuName: '', + sellNum: 0,kind: 0,defaultLocation: '',defaultAddressDetail: '',stockStatus: 0,goodsDetailSpecificationVoList: [],isCollection: 0 + ); + + GoodDetailModel.fromJson(Map json) { + if (json['goodsDetailImageVos'] != null) { + goodsDetailImageVos = []; + json['goodsDetailImageVos'].forEach((v) { + goodsDetailImageVos!.add(new GoodsDetailImageVos.fromJson(v)); + }); + } else + goodsDetailImageVos = []; + + sellPrice = json['sellPrice']; + discountPrice = json['discountPrice']; + skuName = json['skuName']; + sellNum = json['sellNum']; + kind = json['kind']; + defaultLocation = json['defaultLocation']; + defaultAddressDetail = json['defaultAddressDetail']; + stockStatus = json['stockStatus']; + + if (json['goodsDetailSpecificationVoList'] != null) { + goodsDetailSpecificationVoList = []; + json['goodsDetailSpecificationVoList'].forEach((v) { + goodsDetailSpecificationVoList!.add(new GoodsDetailSpecificationVoList.fromJson(v)); + }); + } else + goodsDetailSpecificationVoList = []; + + isCollection = json['isCollection']; + } + + Map toJson() { + final Map data = new Map(); + if (this.goodsDetailImageVos != null) { + data['goodsDetailImageVos'] = + this.goodsDetailImageVos!.map((v) => v.toJson()).toList(); + } + data['sellPrice'] = this.sellPrice; + data['discountPrice'] = this.discountPrice; + data['skuName'] = this.skuName; + data['sellNum'] = this.sellNum; + data['kind'] = this.kind; + data['defaultLocation'] = this.defaultLocation; + data['defaultAddressDetail'] = this.defaultAddressDetail; + data['stockStatus'] = this.stockStatus; + if (this.goodsDetailSpecificationVoList != null) { + data['goodsDetailSpecificationVoList'] = + this.goodsDetailSpecificationVoList!.map((v) => v.toJson()).toList(); + } + data['isCollection'] = this.isCollection; + return data; + } +} + +class GoodsDetailImageVos { + int? id; + int? jcookGoodsId; + String? url; + int? isPrimer; + int? orderSort; + + GoodsDetailImageVos( + {this.id, this.jcookGoodsId, this.url, this.isPrimer, this.orderSort}); + + GoodsDetailImageVos.fromJson(Map json) { + id = json['id']; + jcookGoodsId = json['jcookGoodsId']; + url = json['url']; + isPrimer = json['isPrimer']; + orderSort = json['orderSort']; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['jcookGoodsId'] = this.jcookGoodsId; + data['url'] = this.url; + data['isPrimer'] = this.isPrimer; + data['orderSort'] = this.orderSort; + return data; + } +} + +class GoodsDetailSpecificationVoList { + String? groupName; + List? attribute; + + GoodsDetailSpecificationVoList({this.groupName, this.attribute}); + + GoodsDetailSpecificationVoList.fromJson(Map json) { + groupName = json['groupName']; + + if (json['attribute'] != null) { + attribute = []; + json['attribute'].forEach((v) { + attribute!.add(new Attribute.fromJson(v)); + }); + } else + attribute = []; + + } + + Map toJson() { + final Map data = new Map(); + data['groupName'] = this.groupName; + if (this.attribute != null) { + data['attribute'] = this.attribute!.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class Attribute { + String? name; + String? value; + + Attribute({this.name, this.value}); + + Attribute.fromJson(Map json) { + name = json['name']; + value = json['value']; + } + + Map toJson() { + final Map data = new Map(); + data['name'] = this.name; + data['value'] = this.value; + return data; + } +} \ No newline at end of file diff --git a/lib/ui/market/collection/collection_list_card.dart b/lib/ui/market/collection/collection_list_card.dart index 8da85070..9adefeac 100644 --- a/lib/ui/market/collection/collection_list_card.dart +++ b/lib/ui/market/collection/collection_list_card.dart @@ -1,9 +1,11 @@ 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: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'; @@ -12,13 +14,15 @@ import 'package:aku_community/utils/headers.dart'; class CollectionListCard extends StatelessWidget { final CollectionGoodsModel model; - const CollectionListCard({Key? key, required this.model}) : super(key: key); + final EasyRefreshController refreshController; + const CollectionListCard({Key? key, required this.model, required this.refreshController}) : super(key: key); @override Widget build(BuildContext context) { return GestureDetector( child: Container( height: 280.w, + margin: EdgeInsets.only(top: 20.w), decoration: BoxDecoration( borderRadius: BorderRadius.all( Radius.circular(16.w), @@ -129,10 +133,7 @@ class CollectionListCard extends StatelessWidget { ), ), TextSpan( - text: ((model.discountPrice ?? - 1 / (model.sellPrice ?? 1)) * - 10) < - 1 + text: (model.discountPrice??0)<(model.sellPrice??0) ? _getDiscount(model.sellPrice ?? -1, model.discountPrice ?? -1) : '暂无折扣', @@ -149,18 +150,26 @@ class CollectionListCard extends StatelessWidget { 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_SHARE_PNG,width: 44.w,height: 44.w,), - onTap: (){ + onTap: () async { + await CollectionFunc.collection(model.id!); - }, - ), - 24.wb, - GestureDetector( - child: Image.asset(R.ASSETS_ICONS_COLLECTION_SETTING_PNG,width: 44.w,height: 44.w,), - onTap: (){ + + refreshController.callRefresh(); }, + child:Image.asset( + R.ASSETS_ICONS_DELETE_PNG, + width: 44.w, + height: 44.w, + ) ), ], ), diff --git a/lib/ui/market/collection/my_collection.dart b/lib/ui/market/collection/my_collection.dart index db59fbbb..34b0b89b 100644 --- a/lib/ui/market/collection/my_collection.dart +++ b/lib/ui/market/collection/my_collection.dart @@ -54,8 +54,17 @@ class MyCollectionPageState extends State { @override Widget build(BuildContext context) { - final userProvider = Provider.of(context, listen: false); + return BeeScaffold( + leading: Navigator.canPop(context) + ? IconButton( + onPressed: () => Get.back(result: true), + icon: Icon( + CupertinoIcons.chevron_back, + color: Colors.black, + ), + ) + : SizedBox(), titleSpacing: 0, bgColor: Color(0xFFF9F9F9), bodyColor: Color(0xFFF9F9F9), @@ -74,7 +83,8 @@ class MyCollectionPageState extends State { child: _onload ? Container() : ListView( - children: [..._models.map((e) => CollectionListCard( model: e,)).toList()], + padding: EdgeInsets.symmetric(horizontal: 20.w), + children: [..._models.map((e) => CollectionListCard( model: e,refreshController: _refreshController,)).toList()], ), ), diff --git a/lib/ui/market/market_home_goods_card.dart b/lib/ui/market/market_home_goods_card.dart index 3b217882..4b786eb7 100644 --- a/lib/ui/market/market_home_goods_card.dart +++ b/lib/ui/market/market_home_goods_card.dart @@ -170,7 +170,10 @@ class MarketHomeGoodsCard extends StatelessWidget { ), ), TextSpan( - text: '9折', + text: (item.discountPrice??0)<(item.sellPrice??0) + ? _getDiscount(item.sellPrice ?? -1, + item.discountPrice ?? -1) + : '暂无折扣', style: TextStyle( color: ktextSubColor, fontSize: 20.sp, @@ -187,6 +190,13 @@ class MarketHomeGoodsCard extends StatelessWidget { ); } + _getDiscount(double sellPrice, double discountPrice) { + String count = ''; + count = ((discountPrice / sellPrice) * 10).toStringAsFixed(1); + + return count + '折'; + } + Widget _getIcon(int type){ if(type==1){ diff --git a/lib/ui/market/search/good_detail_page.dart b/lib/ui/market/search/good_detail_page.dart new file mode 100644 index 00000000..b7dc7cdc --- /dev/null +++ b/lib/ui/market/search/good_detail_page.dart @@ -0,0 +1,566 @@ +import 'package:aku_community/model/common/img_model.dart'; +import 'package:aku_community/model/good/good_detail_model.dart'; +import 'package:aku_community/provider/app_provider.dart'; +import 'package:aku_community/provider/user_provider.dart'; +import 'package:aku_community/ui/market/collection/collection_func.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_model.dart'; +import 'package:aku_community/widget/bee_back_button.dart'; +import 'package:aku_community/widget/home/home_sliver_app_bar.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'; + +class GoodDetailPage extends StatefulWidget { + final int goodId; + + GoodDetailPage({Key? key, required this.goodId}) : super(key: key); + + @override + _GoodDetailPageState createState() => _GoodDetailPageState(); +} + +class _GoodDetailPageState extends State { + late EasyRefreshController _refreshController; + bool _showList = true; + + late PageController _pageController; + int _currentIndex = 0; + late GoodDetailModel _goodDetail; + bool _onload = true; + late ScrollController _sliverListController; + + @override + void initState() { + super.initState(); + _pageController = PageController(); + _sliverListController = ScrollController(); + _refreshController = EasyRefreshController(); + } + + @override + void dispose() { + _refreshController.dispose(); + _pageController.dispose(); + _sliverListController.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: Row( + // children: [ + // ], + // ), + bottomNavi: _bottomButton(), + + body: Stack( + children: [ + EasyRefresh( + firstRefresh: true, + header: MaterialHeader(), + controller: _refreshController, + onRefresh: () async { + _goodDetail = await SearchFunc.getGoodDetail(widget.goodId); + if (_goodDetail != GoodDetailModel.fail()) { + _onload = false; + } + setState(() {}); + }, + child: _onload?SizedBox():_buildBody()), + Positioned( + top: (kToolbarHeight+16).w, + left: 24.w, + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + + Container( + padding: EdgeInsets.all(10.w), + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(52.w)), + color: Color(0x80000000)), + child: GestureDetector( + onTap: (){ + Get.back(); + }, + child: Image.asset(R.ASSETS_ICONS_ICON_BACK_PNG,width: 52.w,height: 52.w,), + ) + ) + ], + ), + ), + ], + ), + ); + } + + Widget _buildBody() { + return Column( + children: [ + _imageView(_goodDetail.goodsDetailImageVos??[]), + 20.hb, + _goodInfo(), + 20.hb, + _address(), + 20.hb, + _getDetailImage(), + ], + ); + } + + _goodInfo(){ + return Container( + padding: EdgeInsets.all(20.w), + margin: EdgeInsets.symmetric(horizontal:20.w ), + width: double.infinity, + height: 256.w, + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(24.w)), + color: Colors.white + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + 16.wb, + '¥'.text.color(Color(0xFFE52E2E)).size(28.sp).make(), + Text( + _goodDetail.discountPrice==null?'':(_goodDetail.discountPrice!).toStringAsFixed(2), + style: TextStyle(fontSize: 40.sp,color: Color(0xFFE52E2E)), + ), + Spacer(), + '已售:'.text.color(Color(0xFFBBBBBB)).size(24.sp).make(), + Text( + (_goodDetail.sellNum??0).toString(), + style: TextStyle(fontSize: 24.sp,color: Color(0xFFBBBBBB)), + ), + 16.wb, + ], + ), + 10.hb, + Container( + padding: EdgeInsets.symmetric(horizontal: 16.w), + height: 80.w, + width: double.infinity, + child: + Text( + (_goodDetail.skuName??''), + style: TextStyle(fontSize: 28.sp,color: ktextPrimary), + maxLines: 2, + overflow: TextOverflow.ellipsis, + ), + ), + + _getIcon(_goodDetail.kind??0), + Spacer(), + Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + 16.wb, + '原价:'.text.color(Color(0xFFBBBBBB)).size(24.sp).make(), + Text( + _goodDetail.sellPrice==null?'':(_goodDetail.sellPrice!).toStringAsFixed(2), + style: TextStyle(fontSize: 24.sp,color: Color(0xFFBBBBBB)), + ), + 50.wb, + + '折扣:'.text.color(Color(0xFFBBBBBB)).size(24.sp).make(), + Text( + (_goodDetail.discountPrice??0)<(_goodDetail.sellPrice??0) + ? _getDiscount(_goodDetail.sellPrice ?? -1, + _goodDetail.discountPrice ?? -1) + : '暂无折扣', + style: TextStyle(fontSize: 24.sp,color: Color(0xFFBBBBBB)), + ), + 16.wb, + ], + ), + + ], + ), + ); + } + + + _address(){ + return Container( + padding: EdgeInsets.all(20.w), + margin: EdgeInsets.symmetric(horizontal:20.w ), + width: double.infinity, + height: 184.w, + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(24.w)), + color: Colors.white + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + onTap: (){ + //跳转到地址界面,点击地址然后返回地址 + }, + child: Container( + color: Colors.white, + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + 16.wb, + '送至'.text.color(Color(0xFFBBBBBB)).size(28.sp).make(), + Image.asset(R.ASSETS_ICONS_SHOP_LOCATION_PNG,width: 48.w,height: 48.w,), + + Container( + width: 430.w, + child: Text( + 'uyerueiwoyruioweyrewiuuryriwuey13123123123123123r', + style: TextStyle(fontSize: 24.sp,color: ktextPrimary), + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + ), + + Spacer(), + Icon( + CupertinoIcons.chevron_forward, + size: 32.w, + color: Color(0xFF999999), + ), + + 16.wb, + ], + ), + ), + ), + 52.hb, + GestureDetector( + onTap: (){ + // + }, + child: Container( + color: Colors.white, + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + 16.wb, + '参数'.text.color(Color(0xFFBBBBBB)).size(28.sp).make(), + 48.wb, + Text( + '品牌、规格', + style: TextStyle(fontSize: 24.sp,color: ktextPrimary), + ), + Spacer(), + Icon( + CupertinoIcons.chevron_forward, + size: 32.w, + color: Color(0xFF999999), + ), + 16.wb, + ], + ), + ), + ), + + + + ], + ), + ); + } + + _getDetailImage(){ + return Container( + padding: EdgeInsets.all(20.w), + margin: EdgeInsets.symmetric(horizontal:20.w ), + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(24.w)), + color: Colors.white + ), + width: double.infinity, + child: Column( + children: [ + Row( + children: [ + 16.wb, + Container( + width: 8.w, + height: 30.w, + decoration: BoxDecoration( + color: Color(0xFFE52E2E), + borderRadius: BorderRadius.all(Radius.circular(4.w)), + ), + ), + 2.wb, + Text( + '商品详情', + style: TextStyle(fontSize: 28.sp,color: ktextPrimary), + ), + Spacer(), + ], + ), + + ..._goodDetail.goodsDetailImageVos!.map((e) => _image(e.url??'')) + ], + ), + ); + } + + _image(String url){ + return Container( + width: double.infinity, + child: GestureDetector( + onLongPress: () { + //保存图片 + }, + child: FadeInImage.assetNetwork( + placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + image: url, + fit: BoxFit.cover, + ), + ), + ); + } + + + + Widget _getIcon(int type){ + if(type==1){ + return Container( + margin: EdgeInsets.only(left: 15.w), + 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(); + } + + + + + _bottomButton() { + return Container( + width: double.infinity, + height: 100.w, + + decoration: BoxDecoration( + color: Colors.white, + boxShadow: [ + BoxShadow( + color: Color(0x4D000000), + offset: Offset(0.0, -1), //阴影xy轴偏移量 + blurRadius: 0, //阴影模糊程度 + spreadRadius: 0 //阴影扩散程度 + ) + ] + // border: Border(top:BorderSide( width: 2.w, + // color: kPrimaryColor,)) + ), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + 30.wb, + GestureDetector( + onTap: (){ + + }, + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image.asset(R.ASSETS_ICONS_ICON_GOOD_MY_PNG,width: 48.w,height: 48.w,), + Text( + '我的', + style: TextStyle(fontSize: 20.sp,color: ktextPrimary), + ), + ], + ), + ), + 30.wb, + GestureDetector( + onTap: (){ + //await CollectionFunc.collection(_goodDetail.id); + }, + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image.asset(R.ASSETS_ICONS_ICON_GOOD_FAVOR_PNG,width: 48.w,height: 48.w,), + Text( + '加入收藏', + style: TextStyle(fontSize: 20.sp,color: ktextPrimary), + ), + ], + ), + ), + 30.wb, + GestureDetector( + onTap: ()async{ + + }, + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image.asset(R.ASSETS_ICONS_ICON_GOOD_CAR_PNG,width: 48.w,height: 48.w,), + Text( + '购物车', + style: TextStyle(fontSize: 20.sp,color: ktextPrimary), + ), + ], + ), + ), + 30.wb, + Row( + children: [ + Container( + width: 210.w, + height: 84.w, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.horizontal(left: Radius.circular(84.w)), + border: Border.all(color: Color(0xFFE52E2E),width: 2.w) + // border: Border(top:BorderSide(color: Color(0xFFE52E2E),width: 2.w), + // left: BorderSide(color: Color(0xFFE52E2E),width: 2.w),bottom: BorderSide(color: Color(0xFFE52E2E),width: 2.w)) + ), + alignment: Alignment.center, + child:Text( + '加入购物车', + style: TextStyle(fontSize: 32.sp,color: Color(0xFFE52E2E)), + ), + ), + Container( + width: 210.w, + height: 84.w, + decoration: BoxDecoration( + borderRadius: BorderRadius.horizontal(right: Radius.circular(84.w)), + color:Color(0xFFE52E2E), + + ), + alignment: Alignment.center, + child:Text( + '立即购买', + style: TextStyle(fontSize: 32.sp,color: Colors.white), + ), + ) + ], + ) + ], + ), + + ); + } + + Widget _imageView(List imgList) { + return Stack( + children: [ + SizedBox( + width: double.infinity, + height: 725.w, + child: PageView.builder( + itemCount: imgList.length, + onPageChanged: (value) { + _pageController.jumpToPage(value); + _currentIndex = value; + setState(() {}); + }, + controller: _pageController, + itemBuilder: (context, index) { + return SizedBox( + width: double.infinity, + height: 725.w, + child: FadeInImage.assetNetwork( + fit: BoxFit.fill, + placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + image: imgList[index].url ?? ''), + ); + }), + ), + Positioned( + bottom: 24.w, + right: 5.w, + child: Container( + alignment: Alignment.center, + width: 69.w, + height: 39.w, + decoration: BoxDecoration( + color: Color(0x80000000), + borderRadius: BorderRadius.circular(40.w)), + child: '${_currentIndex + 1}/${imgList.length}' + .text + .size(24.sp) + .color(Colors.white) + .make(), + ), + ), + ], + ); + } + _getDiscount(double sellPrice, double discountPrice) { + String count = ''; + count = ((discountPrice / sellPrice) * 10).toStringAsFixed(1); + + return count + '折'; + } +} diff --git a/lib/ui/market/search/goods_list_card.dart b/lib/ui/market/search/goods_list_card.dart index 7b8f7346..0694739d 100644 --- a/lib/ui/market/search/goods_list_card.dart +++ b/lib/ui/market/search/goods_list_card.dart @@ -11,6 +11,8 @@ import 'package:aku_community/constants/api.dart'; import 'package:aku_community/utils/headers.dart'; +import 'good_detail_page.dart'; + class GoodsListCard extends StatefulWidget { final SearchGoodsModel model; final EasyRefreshController? refreshController; @@ -27,6 +29,9 @@ class GoodsListCardState extends State { @override Widget build(BuildContext context) { return GestureDetector( + onTap: (){ + Get.to(() => GoodDetailPage(goodId: widget.model.id!,)); + }, child: Container( height: 280.w, decoration: BoxDecoration( @@ -139,10 +144,7 @@ class GoodsListCardState extends State { ), ), TextSpan( - text: ((widget.model.discountPrice ?? - 1 / (widget.model.sellPrice ?? 1)) * - 10) < - 1 + text: (widget.model.discountPrice??0)<(widget.model.sellPrice??0) ? _getDiscount(widget.model.sellPrice ?? -1, widget.model.discountPrice ?? -1) : '暂无折扣', diff --git a/lib/ui/market/search/search_detail_page.dart b/lib/ui/market/search/search_detail_page.dart deleted file mode 100644 index a02c5b1d..00000000 --- a/lib/ui/market/search/search_detail_page.dart +++ /dev/null @@ -1,483 +0,0 @@ -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 ? kBalckSubColor : ktextPrimary, - fontSize: _orderType == OrderType.NORMAL ? 32.sp : 28.sp, - fontWeight: _orderType == OrderType.NORMAL - ?FontWeight.bold - : FontWeight.normal, - ), - ), - 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 ? kBalckSubColor : ktextPrimary, - fontSize: _orderType == OrderType.SALES ? 32.sp : 28.sp, - fontWeight: _orderType == OrderType.SALES - ?FontWeight.bold - : FontWeight.normal, - ), - ), - 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 - ? kBalckSubColor - : ktextPrimary, - fontSize: _orderType == OrderType.PRICE_HIGH || - _orderType == OrderType.PRICE_LOW - ? 32.sp - : 28.sp, - fontWeight: _orderType == OrderType.PRICE_HIGH || - _orderType == OrderType.PRICE_LOW - ?FontWeight.bold - : FontWeight.normal, - ), - ), - Icon( - priceIcon, - size: 32.w, - color: _orderType == OrderType.PRICE_HIGH || - _orderType == OrderType.PRICE_LOW - ? kBalckSubColor - : 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 index 0339b51a..fd5f1d1b 100644 --- a/lib/ui/market/search/search_func.dart +++ b/lib/ui/market/search/search_func.dart @@ -1,4 +1,5 @@ import 'package:aku_community/constants/api.dart'; +import 'package:aku_community/model/good/good_detail_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/models/search/search_goods_model.dart'; @@ -43,6 +44,16 @@ class SearchFunc { return model.tableList!.map((e) => SearchGoodsModel.fromJson(e)).toList(); } + ///查询商品详情 + static Future getGoodDetail(int shopId) async { + BaseModel model = await NetUtil().get( + API.market.findGoodsDetail, + params: {'shopId': shopId}, + ); + if (model.data == null) return GoodDetailModel.fail(); + return GoodDetailModel.fromJson(model.data); + } + diff --git a/lib/ui/market/search/search_goods_page.dart b/lib/ui/market/search/search_goods_page.dart index 5c0325fc..a20d9627 100644 --- a/lib/ui/market/search/search_goods_page.dart +++ b/lib/ui/market/search/search_goods_page.dart @@ -45,7 +45,8 @@ class SearchGoodsPage extends StatefulWidget { class SearchGoodsPageState extends State { TextEditingController _editingController = TextEditingController(); OrderType _orderType = OrderType.NORMAL; - IconData priceIcon = CupertinoIcons.chevron_up_chevron_down; + // IconData priceIcon = CupertinoIcons.chevron_up_chevron_down; + String priceIcon = R.ASSETS_ICONS_ICON_PRICE_NORMAL_PNG; EasyRefreshController _refreshController = EasyRefreshController(); EasyRefreshController _refreshController1 = EasyRefreshController(); List _searchHistory = []; @@ -82,7 +83,7 @@ class SearchGoodsPageState extends State { final normalTypeButton = MaterialButton( onPressed: () { _orderType = OrderType.NORMAL; - priceIcon = CupertinoIcons.chevron_up_chevron_down; + priceIcon = R.ASSETS_ICONS_ICON_PRICE_NORMAL_PNG; orderBySalesVolume = null; orderByPrice = null; _refreshController1.callRefresh(); @@ -107,7 +108,7 @@ class SearchGoodsPageState extends State { _orderType = OrderType.SALES; orderBySalesVolume = 2; orderByPrice = null; - priceIcon = CupertinoIcons.chevron_up_chevron_down; + priceIcon = R.ASSETS_ICONS_ICON_PRICE_NORMAL_PNG; _refreshController1.callRefresh(); setState(() {}); }, @@ -134,19 +135,19 @@ class SearchGoodsPageState extends State { _orderType = OrderType.PRICE_HIGH; orderByPrice = 1; orderBySalesVolume = null; - priceIcon = CupertinoIcons.chevron_up; + priceIcon = R.ASSETS_ICONS_ICON_PRICE_TOP_PNG; break; case OrderType.PRICE_HIGH: _orderType = OrderType.PRICE_LOW; orderByPrice = 2; orderBySalesVolume = null; - priceIcon = CupertinoIcons.chevron_down; + priceIcon = R.ASSETS_ICONS_ICON_PRICE_BOTTOM_PNG; break; case OrderType.PRICE_LOW: _orderType = OrderType.PRICE_HIGH; orderByPrice = 1; orderBySalesVolume = null; - priceIcon = CupertinoIcons.chevron_up; + priceIcon = R.ASSETS_ICONS_ICON_PRICE_TOP_PNG; break; } _refreshController1.callRefresh(); @@ -171,14 +172,15 @@ class SearchGoodsPageState extends State { : FontWeight.normal, ), ), - Icon( - priceIcon, - size: 32.w, - color: _orderType == OrderType.PRICE_HIGH || - _orderType == OrderType.PRICE_LOW - ? kBalckSubColor - : ktextPrimary, - ), + // Icon( + // priceIcon, + // size: 32.w, + // color: _orderType == OrderType.PRICE_HIGH || + // _orderType == OrderType.PRICE_LOW + // ? kBalckSubColor + // : ktextPrimary, + // ), + Image.asset(priceIcon,width: 32.w,height: 32.w,) ], ), height: 80.w, @@ -326,7 +328,6 @@ class SearchGoodsPageState extends State { ? Container( color: Color(0xFFF2F3F4), child: BeeListView( - path: API.market.search, controller: _refreshController, extraParams: {'searchName': ''}, @@ -413,9 +414,11 @@ class SearchGoodsPageState extends State { children: [ GestureDetector( child: Image.asset(R.ASSETS_ICONS_COLLECT_PNG,width: 84.w,height: 84.w,), - onTap: (){ - Get.to(() => MyCollectionPage()); - + onTap: ()async{ + var result = await Get.to(() => MyCollectionPage()); + if(result){ + _refreshController1.callRefresh(); + } }, ), 24.hb,