From 2266db00cf014c897bc9d078dc328ed4c3bd5117 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E8=90=8C?= <494089941@qq.com> Date: Wed, 20 Apr 2022 21:37:59 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=AF=E5=88=86=E5=95=86=E5=9F=8E=E6=A8=A1?= =?UTF-8?q?=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/constants/market_api.dart | 10 +++ .../market/integral_goods_list_model.dart | 33 ++++++++ .../market/integral_goods_list_model.g.dart | 17 ++++ lib/ui/community/community_func.dart | 12 +++ .../integral/integral_exchange_page.dart | 83 ++++++++++++++----- .../market/integral/integral_sku_model.dart | 80 ------------------ lib/ui/market/market_page.dart | 24 +++--- lib/ui/market/search/good_detail_page.dart | 1 - .../search/submit_order_page_normal.dart | 3 +- 9 files changed, 149 insertions(+), 114 deletions(-) create mode 100644 lib/models/market/integral_goods_list_model.dart create mode 100644 lib/models/market/integral_goods_list_model.g.dart delete mode 100644 lib/ui/market/integral/integral_sku_model.dart diff --git a/lib/constants/market_api.dart b/lib/constants/market_api.dart index 561f7c8e..14c78bc8 100644 --- a/lib/constants/market_api.dart +++ b/lib/constants/market_api.dart @@ -9,6 +9,7 @@ class _MarketApi { _ShopCart shopCart = _ShopCart(); _Address address = _Address(); _Order order = _Order(); + _IntegralGood integralGood = _IntegralGood(); } class _ShopCart { @@ -101,3 +102,12 @@ class _Order { ///我的订单 String get myOrder => '/app/user/shop/order/myOrder'; } + +class _IntegralGood { + ///查询积分商品列表 + String get list => '/app/user/shop/pointsGoods/list'; + + ///创建积分兑换积分商品订单 + String get createPointsOrder => + '/app/user/shop/pointsGoods/createPointsGoodsOrder'; +} diff --git a/lib/models/market/integral_goods_list_model.dart b/lib/models/market/integral_goods_list_model.dart new file mode 100644 index 00000000..22d16d30 --- /dev/null +++ b/lib/models/market/integral_goods_list_model.dart @@ -0,0 +1,33 @@ +import 'package:json_annotation/json_annotation.dart'; +import 'package:equatable/equatable.dart'; + +part 'integral_goods_list_model.g.dart'; + +@JsonSerializable() +class IntegralGoodsListModel extends Equatable { + final int id; + final String skuName; + final String mainPhoto; + final int points; + final int? saleNum; + + factory IntegralGoodsListModel.fromJson(Map json) => + _$IntegralGoodsListModelFromJson(json); + + const IntegralGoodsListModel({ + required this.id, + required this.skuName, + required this.mainPhoto, + required this.points, + this.saleNum, + }); + + @override + List get props => [ + id, + skuName, + mainPhoto, + points, + saleNum, + ]; +} diff --git a/lib/models/market/integral_goods_list_model.g.dart b/lib/models/market/integral_goods_list_model.g.dart new file mode 100644 index 00000000..f0a0ba01 --- /dev/null +++ b/lib/models/market/integral_goods_list_model.g.dart @@ -0,0 +1,17 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'integral_goods_list_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +IntegralGoodsListModel _$IntegralGoodsListModelFromJson( + Map json) => + IntegralGoodsListModel( + id: json['id'] as int, + skuName: json['skuName'] as String, + mainPhoto: json['mainPhoto'] as String, + points: json['points'] as int, + saleNum: json['saleNum'] as int?, + ); diff --git a/lib/ui/community/community_func.dart b/lib/ui/community/community_func.dart index 5e0827c8..9be46071 100644 --- a/lib/ui/community/community_func.dart +++ b/lib/ui/community/community_func.dart @@ -7,6 +7,7 @@ import 'package:aku_new_community/models/home/home_activity_model.dart'; import 'package:aku_new_community/models/home/home_announce_model.dart'; import 'package:aku_new_community/models/home/home_swiper_model.dart'; import 'package:aku_new_community/models/market/goods_popular_model.dart'; +import 'package:aku_new_community/models/market/integral_goods_list_model.dart'; import 'package:aku_new_community/models/market/market_all_category_model.dart'; import 'package:aku_new_community/models/market/market_category_model.dart'; import 'package:aku_new_community/models/market/market_statistics_model.dart'; @@ -106,6 +107,17 @@ class CommunityFunc { .toList(); } + ///查询积分商品 + static Future> getIntegralGoods(int num) async { + var baseList = await NetUtil().getList( + SAASAPI.market.integralGood.list, + params: {'pageNum': 1, 'size': num}, + ); + return baseList.rows + .map((e) => IntegralGoodsListModel.fromJson(e)) + .toList(); + } + ///获取所有商品的分类 static Future> getCategory() async { BaseModel model = await NetUtil().get( diff --git a/lib/ui/market/integral/integral_exchange_page.dart b/lib/ui/market/integral/integral_exchange_page.dart index 41ea33cf..e36d701b 100644 --- a/lib/ui/market/integral/integral_exchange_page.dart +++ b/lib/ui/market/integral/integral_exchange_page.dart @@ -1,11 +1,14 @@ +import 'package:aku_new_community/constants/saas_api.dart'; +import 'package:aku_new_community/models/market/integral_goods_list_model.dart'; +import 'package:aku_new_community/utils/network/net_util.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:velocity_x/velocity_x.dart'; import 'package:aku_new_community/gen/assets.gen.dart'; -import 'package:aku_new_community/ui/market/integral/integral_sku_model.dart'; import 'package:aku_new_community/ui/market/search/good_detail_page.dart'; import 'package:aku_new_community/widget/bee_scaffold.dart'; @@ -17,33 +20,74 @@ class IntegralExchangePage extends StatefulWidget { } class _IntegralExchangePageState extends State { - List _models = IntegralSkuModel.examples; + List _models = []; + int _pageNum = 1; + int _size = 10; + EasyRefreshController _easyRefreshController = EasyRefreshController(); + + @override + void dispose() { + _easyRefreshController.dispose(); + super.dispose(); + } @override Widget build(BuildContext context) { return BeeScaffold( title: '积分商城', body: SafeArea( - child: GridView.builder( - padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 24.w), - itemCount: _models.length, - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 2, - childAspectRatio: 332 / 480, - mainAxisSpacing: 16.w, - crossAxisSpacing: 24.w), - itemBuilder: (context, index) { - return _card(_models[index]); - })), + child: EasyRefresh( + firstRefresh: true, + header: MaterialHeader(), + footer: MaterialFooter(), + controller: _easyRefreshController, + onRefresh: () async { + _pageNum = 1; + var baseList = await NetUtil().getList( + SAASAPI.market.integralGood.list, + params: {'pageNum': _pageNum, 'size': _size}, + ); + _models = baseList.rows + .map((e) => IntegralGoodsListModel.fromJson(e)) + .toList(); + setState(() {}); + }, + onLoad: () async { + _pageNum++; + var baseList = await NetUtil().getList( + SAASAPI.market.integralGood.list, + params: {'pageNum': _pageNum, 'size': _size}, + ); + if (baseList.total > _models.length) { + _models.addAll(baseList.rows + .map((e) => IntegralGoodsListModel.fromJson(e)) + .toList()); + } else { + _easyRefreshController.finishLoad(noMore: true); + } + setState(() {}); + }, + child: GridView.builder( + padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 24.w), + itemCount: _models.length, + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + childAspectRatio: 332 / 480, + mainAxisSpacing: 16.w, + crossAxisSpacing: 24.w), + itemBuilder: (context, index) { + return _card(_models[index]); + }), + )), ); } - Widget _card(IntegralSkuModel model) { + Widget _card(IntegralGoodsListModel model) { return GestureDetector( onTap: () { Get.to(() => GoodDetailPage( - goodId: model.goodId, - integral: model.integral, + goodId: model.id, + integral: model.points, integralGood: true, )); }, @@ -51,7 +95,8 @@ class _IntegralExchangePageState extends State { children: [ Container( color: Color(0xFFF9F9F), - child: Image.network(model.imgPath, width: 332.w, height: 332.w)), + child: + Image.network(model.mainPhoto, width: 332.w, height: 332.w)), 16.w.heightBox, '${model.skuName}' .text @@ -65,9 +110,9 @@ class _IntegralExchangePageState extends State { children: [ Assets.icons.intergral.image(width: 24.w, height: 24.w), 4.w.widthBox, - '${model.integral}'.text.size(24.sp).color(Colors.red).make(), + '${model.points}'.text.size(24.sp).color(Colors.red).make(), Spacer(), - '已售${model.sold}份' + '已售${model.saleNum ?? 0}份' .text .size(24.sp) .color(Color(0xFFBDBDBD)) diff --git a/lib/ui/market/integral/integral_sku_model.dart b/lib/ui/market/integral/integral_sku_model.dart deleted file mode 100644 index 8309ce0b..00000000 --- a/lib/ui/market/integral/integral_sku_model.dart +++ /dev/null @@ -1,80 +0,0 @@ -class IntegralSkuModel { - final String imgPath; - final String skuName; - final int integral; - final int sold; - final int skuId; - final int goodId; - - static List get examples => [ - IntegralSkuModel( - imgPath: 'http://oss.jcook.com.cn/file5/1509704/1509704_0.jpg', - skuName: '3M 耳塞 降噪睡眠 弹性舒适1100耳塞一副', - integral: 1050, - skuId: 1509704, - goodId: 438052, - sold: 89), - IntegralSkuModel( - imgPath: 'http://oss.jcook.com.cn/file5/5059614/5059614_0.jpg', - skuName: '一品巷子 休闲零食 泡面搭档 卤蛋32g/个', - integral: 1060, - skuId: 5059614, - goodId: 451850, - sold: 156), - IntegralSkuModel( - imgPath: 'http://oss.jcook.com.cn/file5/1146553/1146553_0.jpg', - skuName: '齐心(Comix)美工刀/裁纸刀/壁纸刀工具 小号9mm 颜色随机', - integral: 1750, - skuId: 1146553, - goodId: 435913, - sold: 34), - IntegralSkuModel( - imgPath: - 'http://oss.jcook.com.cn/file5/100014750256/100014750256_0.jpg', - skuName: '公牛(BULL)118型开关插座布线盒 六孔插座暗盒墙插底盒2位暗盒H14(适用120mm面板)', - integral: 1910, - skuId: 100014750256, - goodId: 562798, - sold: 49), - IntegralSkuModel( - imgPath: 'http://oss.jcook.com.cn/file5/1033528/1033528_0.jpg', - skuName: '广博(GuangBo)0.5mm黑色中性笔 经典子弹头签字笔 水笔 12支装', - integral: 6250, - skuId: 1033528, - goodId: 435216, - sold: 298), - IntegralSkuModel( - imgPath: - 'http://oss.jcook.com.cn/file5/100017573108/100017573108_0.jpg', - skuName: '惠寻 100ml小白鞋清洁剂擦洗鞋清洗剂 1瓶', - integral: 6250, - skuId: 100017573108, - goodId: 572690, - sold: 74), - IntegralSkuModel( - imgPath: - 'http://oss.jcook.com.cn/file4/100009789209/100009789209_0.jpg', - skuName: '东园(TONGGARDEN)蚕豆 泰国进口 兰花豆盐焗味每日坚果炒货休闲零食非油炸', - integral: 6250, - skuId: 10009789209, - goodId: 535330, - sold: 330), - IntegralSkuModel( - imgPath: - 'http://oss.jcook.com.cn/file5/100010670794/100010670794_0.jpg', - skuName: '伊利 优酸乳 蓝莓味 250g*24盒/箱 乳饮料 聚会乐享 春节年货礼盒装早餐伴侣', - integral: 35680, - skuId: 100010670794, - goodId: 539334, - sold: 25), - ]; - - const IntegralSkuModel({ - required this.imgPath, - required this.skuName, - required this.integral, - required this.sold, - required this.skuId, - required this.goodId, - }); -} diff --git a/lib/ui/market/market_page.dart b/lib/ui/market/market_page.dart index 5bde1219..711a5933 100644 --- a/lib/ui/market/market_page.dart +++ b/lib/ui/market/market_page.dart @@ -7,6 +7,7 @@ import 'package:aku_new_community/constants/saas_api.dart'; import 'package:aku_new_community/gen/assets.gen.dart'; import 'package:aku_new_community/model/good/market_swiper_model.dart'; import 'package:aku_new_community/models/market/goods_popular_model.dart'; +import 'package:aku_new_community/models/market/integral_goods_list_model.dart'; import 'package:aku_new_community/models/market/market_all_category_model.dart'; import 'package:aku_new_community/models/market/market_category_model.dart'; import 'package:aku_new_community/models/market/market_statistics_model.dart'; @@ -14,7 +15,6 @@ import 'package:aku_new_community/models/market/order/goods_home_model.dart'; import 'package:aku_new_community/provider/app_provider.dart'; import 'package:aku_new_community/ui/community/community_func.dart'; import 'package:aku_new_community/ui/market/integral/integral_exchange_page.dart'; -import 'package:aku_new_community/ui/market/integral/integral_sku_model.dart'; import 'package:aku_new_community/ui/market/search/good_detail_page.dart'; import 'package:aku_new_community/ui/market/search/search_goods_page.dart'; import 'package:aku_new_community/ui/market/shop_car/shop_car_page.dart'; @@ -75,7 +75,7 @@ class _MarketPageState extends State List _goodsPopularModelList = []; - List get _integralModelList => IntegralSkuModel.examples; + List _integralModelList = []; int? orderBySalesVolume; int? orderByPrice; @@ -204,7 +204,7 @@ class _MarketPageState extends State print(_goodsClassificationList.length); _goodsPopularModelList = await CommunityFunc.getGoodsPopularModel(6); - + _integralModelList = await CommunityFunc.getIntegralGoods(6); setState(() {}); } @@ -321,9 +321,9 @@ class _MarketPageState extends State tabBarHeight + hotGoodHeight + ScreenUtil().statusBarHeight + - kToolbarHeight, - //积分商城高度 - // 172 * 2.w, + kToolbarHeight + + //积分商城高度 + 172 * 2.w, flexibleSpace: _flexibleSpaceBar(context), bottom: PreferredSize( preferredSize: Size.fromHeight(tabBarHeight), @@ -483,8 +483,8 @@ class _MarketPageState extends State _buttonTitle(), 20.hb, _recommend(), - // 20.hb, - // _integralMarket(), + 20.hb, + _integralMarket(), ], ), ], @@ -556,14 +556,14 @@ class _MarketPageState extends State separatorBuilder: (_, __) { return 24.wb; }, - itemCount: 4), + itemCount: _integralModelList.length), ), ], ), ); } - Widget _horizontalListCard(IntegralSkuModel model) { + Widget _horizontalListCard(IntegralGoodsListModel model) { return GestureDetector( onTap: () {}, child: SizedBox( @@ -571,7 +571,7 @@ class _MarketPageState extends State child: Column( children: [ Image.network( - model.imgPath, + model.mainPhoto, width: 148.w, height: 148.w, ), @@ -587,7 +587,7 @@ class _MarketPageState extends State children: [ Assets.icons.intergral.image(width: 24.w, height: 24.w), 4.wb, - '${model.integral}'.text.size(24.sp).color(Colors.red).make() + '${model.points}'.text.size(24.sp).color(Colors.red).make() ], ) ], diff --git a/lib/ui/market/search/good_detail_page.dart b/lib/ui/market/search/good_detail_page.dart index ce5c7b55..4b8bd85e 100644 --- a/lib/ui/market/search/good_detail_page.dart +++ b/lib/ui/market/search/good_detail_page.dart @@ -780,5 +780,4 @@ class _GoodDetailPageState extends State { return count + '折'; } - _getSpecifications() {} } diff --git a/lib/ui/market/search/submit_order_page_normal.dart b/lib/ui/market/search/submit_order_page_normal.dart index f037f56b..570a5da7 100644 --- a/lib/ui/market/search/submit_order_page_normal.dart +++ b/lib/ui/market/search/submit_order_page_normal.dart @@ -153,12 +153,11 @@ class _SubmitOrderNormalPageState extends State { } Function cancel = BotToast.showLoading(); BaseModel baseModel = await NetUtil() - .post(API.pay.jcookOrderCreateByIntegral, params: { + .post(SAASAPI.market.integralGood.createPointsOrder, params: { "addressId": _addressModel!.id!, "settlementGoodsDTOList": _goodsList.map((v) => v.toJson()).toList(), "payType": 10, //暂时写死 等待后续补充 - "payPrice": totalPrice, 'points': widget.integral, }); if (baseModel.success) {