对接购物车删除接口

hmxc
张萌 3 years ago
parent 9415b8e39a
commit 559fb691e7

@ -1,6 +1,7 @@
// import 'package:aku_community/base/base_style.dart';
import 'package:aku_community/base/base_style.dart';
import 'package:aku_community/constants/api.dart';
import 'package:aku_community/model/common/img_model.dart';
import 'package:aku_community/model/community/swiper_model.dart';
import 'package:aku_community/models/market/goods_classification.dart';
@ -9,37 +10,22 @@ import 'package:aku_community/models/market/order/goods_home_model.dart';
import 'package:aku_community/provider/app_provider.dart';
import 'package:aku_community/ui/community/community_func.dart';
import 'package:aku_community/ui/home/public_infomation/public_information_detail_page.dart';
import 'package:aku_community/ui/market/search/search_goods_page.dart';
import 'package:aku_community/ui/market/shop_car/shop_car_page.dart';
import 'package:aku_community/ui/market/widget/animated_home_background.dart';
import 'package:aku_community/ui/search/bee_search.dart';
import 'package:aku_community/utils/headers.dart';
import 'package:aku_community/utils/network/base_list_model.dart';
import 'package:aku_community/utils/network/net_util.dart';
import 'package:aku_community/widget/home/home_sliver_app_bar.dart';
import 'package:aku_community/widget/others/rectIndicator.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:bot_toast/bot_toast.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_swiper_null_safety/flutter_swiper_null_safety.dart';
import 'package:get/get.dart';
import 'package:waterfall_flow/waterfall_flow.dart';
import 'package:aku_community/constants/api.dart';
import 'package:aku_community/models/market/display_category_model.dart';
import 'package:aku_community/models/market/goods_item.dart';
import 'package:aku_community/models/market/market_category_model.dart';
import 'package:aku_community/ui/market/category/category_card.dart';
import 'package:aku_community/ui/market/category/category_page.dart';
import 'package:aku_community/ui/market/goods/goods_card.dart';
import 'package:aku_community/ui/market/order/my_order_page.dart';
import 'package:aku_community/ui/market/search/search_goods_page.dart';
import 'package:aku_community/utils/headers.dart';
import 'package:aku_community/utils/network/base_list_model.dart';
import 'package:aku_community/utils/network/net_util.dart';
import 'package:aku_community/widget/bee_scaffold.dart';
import 'package:provider/provider.dart';
import 'package:aku_community/provider/app_provider.dart';
import 'market_home_goods_card.dart';
// import 'package:aku_community/ui/market/goods/goods_detail_page.dart';
@ -88,11 +74,14 @@ class _MarketPageState extends State<MarketPage>
int? orderByPrice;
Future updateMarketInfo() async {
BaseListModel baseListModel =
await NetUtil().getList( API.market.findRecommendGoodsList,
params: {'pageNum': _pageNum, 'size': _size,
'orderBySalesVolume': orderBySalesVolume,'orderByPrice': orderByPrice,},
BaseListModel baseListModel = await NetUtil().getList(
API.market.findRecommendGoodsList,
params: {
'pageNum': _pageNum,
'size': _size,
'orderBySalesVolume': orderBySalesVolume,
'orderByPrice': orderByPrice,
},
);
if (baseListModel.tableList!.isNotEmpty) {
_goodsHomeModelList = (baseListModel.tableList as List)
@ -103,10 +92,14 @@ class _MarketPageState extends State<MarketPage>
}
Future loadMarketInfo() async {
BaseListModel baseListModel =
await NetUtil().getList( API.market.findRecommendGoodsList,
params: {'pageNum': _pageNum, 'size': _size,
'orderBySalesVolume': orderBySalesVolume,'orderByPrice': orderByPrice,},
BaseListModel baseListModel = await NetUtil().getList(
API.market.findRecommendGoodsList,
params: {
'pageNum': _pageNum,
'size': _size,
'orderBySalesVolume': orderBySalesVolume,
'orderByPrice': orderByPrice,
},
);
if (baseListModel.tableList!.isNotEmpty) {
_goodsHomeModelList = (baseListModel.tableList as List)
@ -120,17 +113,18 @@ class _MarketPageState extends State<MarketPage>
void initState() {
super.initState();
for (int i = 0; i < 10; i++) {
_goodsClassificationList.add(GoodsClassification(id: 0,name: '',imgUrls: null));
_goodsClassificationList
.add(GoodsClassification(id: 0, name: '', imgUrls: null));
}
for (int i = 0; i < 6; i++) {
_goodsPopularModelList.add(GoodsPopularModel(id: 0,skuName: '',mainPhoto: '',viewsNum: 0));
_goodsPopularModelList.add(
GoodsPopularModel(id: 0, skuName: '', mainPhoto: '', viewsNum: 0));
}
_refreshController = EasyRefreshController();
_sliverListController = ScrollController();
_tabController = TabController(
initialIndex: 0, length: 3, vsync: this);
_tabController = TabController(initialIndex: 0, length: 3, vsync: this);
///appbar refresh
Future.delayed(Duration(milliseconds: 0), () async {
await updateMarketInfo();
@ -149,7 +143,7 @@ class _MarketPageState extends State<MarketPage>
@override
Widget build(BuildContext context) {
// super.build(context);
super.build(context);
final mediaWidth = MediaQuery.of(context).size.width;
return Scaffold(
@ -171,16 +165,10 @@ class _MarketPageState extends State<MarketPage>
setState(() {});
},
child: _buildBody(context),
),
);
}
_refresh() async {
_pageNum = 1;
await updateMarketInfo();
@ -188,13 +176,13 @@ class _MarketPageState extends State<MarketPage>
_newTotal = await CommunityFunc.getNewProductsTodayNum();
_total = await CommunityFunc.getSkuTotal();
_brandTotal = await CommunityFunc.getSettledBrandsNum();
_goodsClassificationList = await CommunityFunc.getGoodsClassificationList(0);//0
_goodsClassificationList =
await CommunityFunc.getGoodsClassificationList(0); //0
//_goodsPopularModelList = await CommunityFunc.getGoodsPopularModel(6);
setState(() {});
}
Widget _buildBody(BuildContext context) {
final normalTypeButton = MaterialButton(
onPressed: () async {
@ -208,8 +196,7 @@ class _MarketPageState extends State<MarketPage>
child: Text(
'综合',
style: TextStyle(
color:
_orderType == OrderType.NORMAL ? kBalckSubColor : ktextPrimary,
color: _orderType == OrderType.NORMAL ? kBalckSubColor : ktextPrimary,
fontSize: _orderType == OrderType.NORMAL ? 32.sp : 28.sp,
fontWeight: _orderType == OrderType.NORMAL
? FontWeight.bold
@ -231,8 +218,7 @@ class _MarketPageState extends State<MarketPage>
child: Text(
'销量',
style: TextStyle(
color:
_orderType == OrderType.SALES ? kBalckSubColor : ktextPrimary,
color: _orderType == OrderType.SALES ? kBalckSubColor : ktextPrimary,
fontSize: _orderType == OrderType.SALES ? 32.sp : 28.sp,
fontWeight: _orderType == OrderType.SALES
? FontWeight.bold
@ -312,13 +298,19 @@ class _MarketPageState extends State<MarketPage>
expandedHeight: MessageHeight +
bannerHeight +
buttonsHeight +
searchHeight +tabBarHeight+ScreenUtil().statusBarHeight +kToolbarHeight+280.w,
searchHeight +
tabBarHeight +
ScreenUtil().statusBarHeight +
kToolbarHeight +
280.w,
flexibleSpace: _flexibleSpaceBar(context),
bottom: PreferredSize(
preferredSize: Size.fromHeight(tabBarHeight),
child: _goodsTitle( normalTypeButton, salesTypeButton, priceButton,)
)),
child: _goodsTitle(
normalTypeButton,
salesTypeButton,
priceButton,
))),
SliverPadding(
padding: EdgeInsets.all(10.w),
),
@ -326,14 +318,12 @@ class _MarketPageState extends State<MarketPage>
padding: EdgeInsets.only(left: 20.w, right: 20.w),
sliver: buildSliverGrid(),
),
],
);
}
SliverGrid buildSliverGrid() {
return SliverGrid(
// child: WaterfallFlow.builder(
// gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount(
// crossAxisCount: 2,
@ -357,7 +347,6 @@ class _MarketPageState extends State<MarketPage>
///Item
delegate: new SliverChildBuilderDelegate(
(BuildContext context, int index) {
///Item
return MarketHomeGoodsCard(item: _goodsHomeModelList[index]);
// return Container(
@ -366,6 +355,7 @@ class _MarketPageState extends State<MarketPage>
// color: Colors.blue,
// );
},
///Item
childCount: _goodsHomeModelList.length,
),
@ -376,10 +366,10 @@ class _MarketPageState extends State<MarketPage>
return <Widget>[
GestureDetector(
onTap: () {
//Get.to(() => BeeSearch());
Get.to(() => ShopCarPage()); //
},
child: Image.asset(R.ASSETS_ICONS_SHOP_CAR_PNG,
height: 40.w, width: 40.w),
child:
Image.asset(R.ASSETS_ICONS_SHOP_CAR_PNG, height: 40.w, width: 40.w),
),
Padding(
padding: EdgeInsets.only(left: 32.w, right: 32.w),
@ -409,9 +399,7 @@ class _MarketPageState extends State<MarketPage>
child: Flex(
direction: Axis.horizontal,
children: <Widget>[
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Row(crossAxisAlignment: CrossAxisAlignment.center, children: [
if (appProvider.location != null)
Padding(
padding: EdgeInsets.only(right: 5.w, top: 5.w),
@ -424,7 +412,9 @@ class _MarketPageState extends State<MarketPage>
),
),
Text(
appProvider.location?['city']==null?'':appProvider.location?['city'] as String? ?? '',
appProvider.location?['city'] == null
? ''
: appProvider.location?['city'] as String? ?? '',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 28.sp,
@ -449,7 +439,6 @@ class _MarketPageState extends State<MarketPage>
}
FlexibleSpaceBar _flexibleSpaceBar(context) {
return FlexibleSpaceBar(
collapseMode: CollapseMode.pin,
background: Container(
@ -478,7 +467,6 @@ class _MarketPageState extends State<MarketPage>
_buttonTitle(),
20.hb,
_recommend(),
],
),
],
@ -486,7 +474,6 @@ class _MarketPageState extends State<MarketPage>
);
}
geSearch() {
return Container(
margin: EdgeInsets.symmetric(horizontal: 24.w),
@ -522,9 +509,11 @@ class _MarketPageState extends State<MarketPage>
height: 76.w,
width: double.infinity,
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.horizontal(right: Radius.circular(12),left:Radius.circular(12), ),
borderRadius: BorderRadius.horizontal(
right: Radius.circular(12),
left: Radius.circular(12),
),
gradient: LinearGradient(
begin: FractionalOffset.centerRight,
end: FractionalOffset.centerLeft,
@ -544,31 +533,39 @@ class _MarketPageState extends State<MarketPage>
width: 694.w,
decoration: BoxDecoration(
color: Color(0xFFFDEEBF),
borderRadius: BorderRadius.horizontal(right: Radius.circular(12),left:Radius.circular(12) ),
borderRadius: BorderRadius.horizontal(
right: Radius.circular(12), left: Radius.circular(12)),
),
child: Container(
height: 50.w,
width: 682.w,
decoration: BoxDecoration(
//color: Color(0x99F5AF16),
borderRadius: BorderRadius.horizontal(right: Radius.circular(12),left:Radius.circular(12)),
borderRadius: BorderRadius.horizontal(
right: Radius.circular(12), left: Radius.circular(12)),
border: Border.all(width: 2.w, color: Color(0x99F5AF16)),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
80.wb,
Image.asset(R.ASSETS_ICONS_SHOP_LABA_PNG,width: 36.w,height: 34.w,),
Image.asset(
R.ASSETS_ICONS_SHOP_LABA_PNG,
width: 36.w,
height: 34.w,
),
20.wb,
Text('今日上新${_total}',style: TextStyle(color: Color(0xFFD0564B),fontSize: 24.sp,height: 1.05),),
],
Text(
'今日上新${_total}',
style: TextStyle(
color: Color(0xFFD0564B),
fontSize: 24.sp,
height: 1.05),
),
],
),
)
),
)),
Positioned(
left: 0,
top: 0,
@ -582,20 +579,23 @@ class _MarketPageState extends State<MarketPage>
end: FractionalOffset.centerRight,
colors: <Color>[Color(0xFFAD2222), Color(0xFFCD392B)],
),
borderRadius: BorderRadius.horizontal(right: Radius.circular(50),left: Radius.circular(24))
),
borderRadius: BorderRadius.horizontal(
right: Radius.circular(50), left: Radius.circular(24))),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('SKU总数${_newTotal}',style: TextStyle(color: Colors.white,fontSize: 24.sp),),
Text('入驻品牌数:${_brandTotal}',style: TextStyle(color: Colors.white,fontSize: 24.sp),)
Text(
'SKU总数${_newTotal}',
style: TextStyle(color: Colors.white, fontSize: 24.sp),
),
Text(
'入驻品牌数:${_brandTotal}',
style: TextStyle(color: Colors.white, fontSize: 24.sp),
)
],
),
)),
],
),
);
@ -652,12 +652,10 @@ class _MarketPageState extends State<MarketPage>
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(12.w)),
),
child:
FadeInImage.assetNetwork(
child: FadeInImage.assetNetwork(
placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
image: API.image(ImgModel.first(swiperModel.voResourcesImgList)),
fit: BoxFit.fill,
imageErrorBuilder: (context, error, stackTrace) {
return Image.asset(
R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
@ -668,7 +666,6 @@ class _MarketPageState extends State<MarketPage>
);
}
_buttonTitle() {
Container titles = Container(
alignment: Alignment.center,
@ -676,8 +673,7 @@ class _MarketPageState extends State<MarketPage>
color: Colors.white,
borderRadius: BorderRadius.circular(12.w),
),
child:
GridView.builder(
child: GridView.builder(
padding: EdgeInsets.zero,
physics: NeverScrollableScrollPhysics(),
gridDelegate:
@ -692,7 +688,6 @@ class _MarketPageState extends State<MarketPage>
itemCount: 10,
shrinkWrap: true,
),
);
return Container(
alignment: Alignment.center,
@ -703,10 +698,8 @@ class _MarketPageState extends State<MarketPage>
);
}
_buildTile(GoodsClassification item) {
return GestureDetector(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
@ -716,15 +709,18 @@ class _MarketPageState extends State<MarketPage>
height: 88.w,
image: API.image(ImgModel.first(item.imgUrls)),
imageErrorBuilder: (context, error, stackTrace) {
return Image.asset(R.ASSETS_IMAGES_PLACEHOLDER_WEBP,height: 88.w,
width: 88.w,);
return Image.asset(
R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
height: 88.w,
width: 88.w,
);
},
),
8.hb,
Text( (item.name??'').replaceAll('', ''),style: TextStyle(
fontSize: 28.sp,
color: ktextPrimary
),)
Text(
(item.name ?? '').replaceAll('', ''),
style: TextStyle(fontSize: 28.sp, color: ktextPrimary),
)
],
),
);
@ -735,13 +731,16 @@ class _MarketPageState extends State<MarketPage>
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(R.ASSETS_ICONS_TEST_KINGCION_PNG,height: 88.w,
width: 88.w,),
Image.asset(
R.ASSETS_ICONS_TEST_KINGCION_PNG,
height: 88.w,
width: 88.w,
),
8.hb,
Text( '全部分类',style: TextStyle(
fontSize: 28.sp,
color: ktextPrimary
),)
Text(
'全部分类',
style: TextStyle(fontSize: 28.sp, color: ktextPrimary),
)
],
),
);
@ -757,7 +756,6 @@ class _MarketPageState extends State<MarketPage>
);
}
_buttonTitleRow({onPressed}) {
return Expanded(
child: CupertinoButton(
@ -767,7 +765,11 @@ class _MarketPageState extends State<MarketPage>
Container(
width: 88.w,
height: 88.w,
child: Image.asset(R.ASSETS_IMAGES_PLACEHOLDER_WEBP,width: 88.w,height: 88.w,),
child: Image.asset(
R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
width: 88.w,
height: 88.w,
),
// FadeInImage.assetNetwork(
// placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
// image: Api.getImgUrl(kingCoin.url),)
@ -776,10 +778,7 @@ class _MarketPageState extends State<MarketPage>
margin: EdgeInsets.only(top: 6.w),
child: Text(
'数码产品',
style: TextStyle(
fontSize: 28.sp,
color: Color(0xFF333333)),
style: TextStyle(fontSize: 28.sp, color: Color(0xFF333333)),
),
)
],
@ -793,7 +792,6 @@ class _MarketPageState extends State<MarketPage>
);
}
_recommend() {
return Container(
height: 184.w,
@ -804,8 +802,7 @@ class _MarketPageState extends State<MarketPage>
color: Colors.white,
borderRadius: BorderRadius.circular(12.w),
),
child:
Column(
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
@ -835,12 +832,14 @@ class _MarketPageState extends State<MarketPage>
placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
image: _goodsPopularModelList[index].mainPhoto ?? '',
imageErrorBuilder: (context, error, stackTrace) {
return Image.asset(R.ASSETS_IMAGES_PLACEHOLDER_WEBP,height: 96.w,
width: 96.w,);
return Image.asset(
R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
height: 96.w,
width: 96.w,
);
},
),
),
],
);
},
@ -870,24 +869,20 @@ class _MarketPageState extends State<MarketPage>
// ],
// ).expand(),
],
)
);
));
}
_goodsTitle(Widget normalTypeButton,Widget salesTypeButton,Widget priceButton,){
_goodsTitle(
Widget normalTypeButton,
Widget salesTypeButton,
Widget priceButton,
) {
return Container(
height: 90.w,
alignment: Alignment.centerLeft,
color: Color(0xFFF9F9F9),
width: MediaQuery.of(context).size.width,
child:
Container(
child: Container(
alignment: Alignment.centerLeft,
height: 60.w,
child: Row(
@ -897,18 +892,10 @@ class _MarketPageState extends State<MarketPage>
priceButton,
],
),
),
);
}
@override
bool get wantKeepAlive => true;
}

@ -41,6 +41,14 @@ class _ShopCarPageState extends State<ShopCarPage> {
return num;
}
@override
void dispose() {
_controllers.forEach((element) {
element.dispose();
});
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
@ -102,26 +110,17 @@ class _ShopCarPageState extends State<ShopCarPage> {
_models = (base.data as List)
.map((e) => ShopCarListModel.fromJson(e))
.toList();
}
_models.add(ShopCarListModel(
id: 0,
skuName: '123',
mainPhoto: '',
status: 1,
shopStatus: 1,
sellPrice: 20.00,
discountPrice: 10,
unit: '',
kind: 1,
weight: 3,
num: 2));
_controllers.forEach((element) {
element.dispose();
});
_controllers.clear();
_models.forEach((element) {
_controllers.add(
TextEditingController(text: element.num.toString()));
});
}
if (mounted) {
setState(() {});
;
}
},
child: _models.isEmpty
@ -209,7 +208,15 @@ class _ShopCarPageState extends State<ShopCarPage> {
Future _settleEnd() async {}
Future _delete() async {}
Future _delete() async {
await NetUtil().post(
API.market.shopCarDelete,
params: {
'jcookGoodsIds': _selectIndex.map((e) => _models[e].id).toList()
},
showMessage: true,
);
}
Widget _goodCard(ShopCarListModel model, int index) {
var top = RichText(

Loading…
Cancel
Save