积分商城模块

pull/1/head
张萌 3 years ago
parent 450b0a2e86
commit 2266db00cf

@ -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';
}

@ -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<String, dynamic> json) =>
_$IntegralGoodsListModelFromJson(json);
const IntegralGoodsListModel({
required this.id,
required this.skuName,
required this.mainPhoto,
required this.points,
this.saleNum,
});
@override
List<Object?> get props => [
id,
skuName,
mainPhoto,
points,
saleNum,
];
}

@ -0,0 +1,17 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'integral_goods_list_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
IntegralGoodsListModel _$IntegralGoodsListModelFromJson(
Map<String, dynamic> 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?,
);

@ -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<List<IntegralGoodsListModel>> 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<List<MarketAllCategoryModel>> getCategory() async {
BaseModel model = await NetUtil().get(

@ -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,13 +20,53 @@ class IntegralExchangePage extends StatefulWidget {
}
class _IntegralExchangePageState extends State<IntegralExchangePage> {
List<IntegralSkuModel> _models = IntegralSkuModel.examples;
List<IntegralGoodsListModel> _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: 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,
@ -34,16 +77,17 @@ class _IntegralExchangePageState extends State<IntegralExchangePage> {
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<IntegralExchangePage> {
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<IntegralExchangePage> {
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))

@ -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<IntegralSkuModel> 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: '广博GuangBo0.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,
});
}

@ -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<MarketPage>
List<GoodsPopularModel> _goodsPopularModelList = [];
List<IntegralSkuModel> get _integralModelList => IntegralSkuModel.examples;
List<IntegralGoodsListModel> _integralModelList = [];
int? orderBySalesVolume;
int? orderByPrice;
@ -204,7 +204,7 @@ class _MarketPageState extends State<MarketPage>
print(_goodsClassificationList.length);
_goodsPopularModelList = await CommunityFunc.getGoodsPopularModel(6);
_integralModelList = await CommunityFunc.getIntegralGoods(6);
setState(() {});
}
@ -321,9 +321,9 @@ class _MarketPageState extends State<MarketPage>
tabBarHeight +
hotGoodHeight +
ScreenUtil().statusBarHeight +
kToolbarHeight,
kToolbarHeight +
//
// 172 * 2.w,
172 * 2.w,
flexibleSpace: _flexibleSpaceBar(context),
bottom: PreferredSize(
preferredSize: Size.fromHeight(tabBarHeight),
@ -483,8 +483,8 @@ class _MarketPageState extends State<MarketPage>
_buttonTitle(),
20.hb,
_recommend(),
// 20.hb,
// _integralMarket(),
20.hb,
_integralMarket(),
],
),
],
@ -556,14 +556,14 @@ class _MarketPageState extends State<MarketPage>
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<MarketPage>
child: Column(
children: [
Image.network(
model.imgPath,
model.mainPhoto,
width: 148.w,
height: 148.w,
),
@ -587,7 +587,7 @@ class _MarketPageState extends State<MarketPage>
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()
],
)
],

@ -780,5 +780,4 @@ class _GoodDetailPageState extends State<GoodDetailPage> {
return count + '';
}
_getSpecifications() {}
}

@ -153,12 +153,11 @@ class _SubmitOrderNormalPageState extends State<SubmitOrderNormalPage> {
}
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) {

Loading…
Cancel
Save