商场购物车 商品页面 下单页面 完成

hmxc
章文轩 3 years ago
parent 65a375b9a8
commit e937316f52

@ -99,7 +99,7 @@ class _User {
///
String get carList => '/user/myCar/list';
///
///
String get myAddressList => '/user/jcookAddress/myAddress';
///
@ -523,8 +523,6 @@ class _Market {
///jcook
String get shopCarList => '/user/jcookShoppingCat/myShoppingCart';
///jcook
String get shopCarAdd => '/user/jcookShoppingCat/insertShoppingCart';
///jcook 4
String get findAllCategoryInfo => '/user/jcookGoods/findAllCategoryInfo';
@ -685,6 +683,16 @@ class _Pay {
///-
String get sharePayOrderCodeCheck =>
'/user/alipay/meterReadingShareDetailsOrderCheckAlipay';
///app jcook(APP)
String get jcookOrderCreateOrder =>
'/user/alipay/jcookOrderCreateOrder';
///jcook
String get jcookOrderCheckAlipay =>
'/user/alipay/jcookOrderCheckAlipay';
}
class _House {

@ -1,4 +1,5 @@
class GoodDetailModel {
int? id;
List<GoodsDetailImageVos>? goodsDetailImageVos;
double? sellPrice;
double? discountPrice;
@ -12,7 +13,9 @@ class GoodDetailModel {
int? isCollection;
GoodDetailModel(
{this.goodsDetailImageVos,
{
this.id,
this.goodsDetailImageVos,
this.sellPrice,
this.discountPrice,
this.skuName,
@ -24,11 +27,12 @@ class GoodDetailModel {
this.goodsDetailSpecificationVoList,
this.isCollection});
factory GoodDetailModel.fail() => GoodDetailModel(goodsDetailImageVos: [],sellPrice: 0,discountPrice: 0,skuName: '',
factory GoodDetailModel.fail() => GoodDetailModel(id:null,goodsDetailImageVos: [],sellPrice: 0,discountPrice: 0,skuName: '',
sellNum: 0,kind: 0,defaultLocation: '',defaultAddressDetail: '',stockStatus: 0,goodsDetailSpecificationVoList: [],isCollection: 0
);
GoodDetailModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
if (json['goodsDetailImageVos'] != null) {
goodsDetailImageVos = [];
json['goodsDetailImageVos'].forEach((v) {
@ -59,6 +63,7 @@ class GoodDetailModel {
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
if (this.goodsDetailImageVos != null) {
data['goodsDetailImageVos'] =
this.goodsDetailImageVos!.map((v) => v.toJson()).toList();

@ -0,0 +1,125 @@
class CreateOrderModel {
DefaultAddressVo? defaultAddressVo;
List<MyShoppingCartVoList>? myShoppingCartVoList;
double? fee;
CreateOrderModel(
{this.defaultAddressVo, this.myShoppingCartVoList, this.fee});
factory CreateOrderModel.fail() => CreateOrderModel(defaultAddressVo: null,myShoppingCartVoList: [],fee: null
);
CreateOrderModel.fromJson(Map<String, dynamic> json) {
defaultAddressVo = json['defaultAddressVo'] != null
? new DefaultAddressVo.fromJson(json['defaultAddressVo'])
: null;
if (json['myShoppingCartVoList'] != null) {
myShoppingCartVoList = [];
json['myShoppingCartVoList'].forEach((v) {
myShoppingCartVoList!.add(new MyShoppingCartVoList.fromJson(v));
});
}else
myShoppingCartVoList = [];
fee = json['fee'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.defaultAddressVo != null) {
data['defaultAddressVo'] = this.defaultAddressVo!.toJson();
}
if (this.myShoppingCartVoList != null) {
data['myShoppingCartVoList'] =
this.myShoppingCartVoList!.map((v) => v.toJson()).toList();
}
data['fee'] = this.fee;
return data;
}
}
class DefaultAddressVo {
int? id;
String? name;
String? tel;
String? locationName;
String? addressDetail;
DefaultAddressVo(
{this.id, this.name, this.tel, this.locationName, this.addressDetail});
DefaultAddressVo.fromJson(Map<String, dynamic> json) {
id = json['id'];
name = json['name'];
tel = json['tel'];
locationName = json['locationName'];
addressDetail = json['addressDetail'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['name'] = this.name;
data['tel'] = this.tel;
data['locationName'] = this.locationName;
data['addressDetail'] = this.addressDetail;
return data;
}
}
class MyShoppingCartVoList {
int? id;
String? skuName;
String? mainPhoto;
int? status;
int? shopStatus;
double? sellPrice;
double? discountPrice;
String? unit;
int? kind;
double? weight;
int? num;
MyShoppingCartVoList(
{this.id,
this.skuName,
this.mainPhoto,
this.status,
this.shopStatus,
this.sellPrice,
this.discountPrice,
this.unit,
this.kind,
this.weight,
this.num});
MyShoppingCartVoList.fromJson(Map<String, dynamic> json) {
id = json['id'];
skuName = json['skuName'];
mainPhoto = json['mainPhoto'];
status = json['status'];
shopStatus = json['shopStatus'];
sellPrice = json['sellPrice'];
discountPrice = json['discountPrice'];
unit = json['unit'];
kind = json['kind'];
weight = json['weight'];
num = json['num'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
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['unit'] = this.unit;
data['kind'] = this.kind;
data['weight'] = this.weight;
data['num'] = this.num;
return data;
}
}

@ -5,34 +5,34 @@ part 'shop_car_list_model.g.dart';
@JsonSerializable()
class ShopCarListModel {
final int id;
final String skuName;
final String mainPhoto;
final int? id;
final String? skuName;
final String? mainPhoto;
//0.1.()
final int status;
final int? status;
//0.1.jcook
final int shopStatus;
final double sellPrice;
final double discountPrice;
final String unit;
final int? shopStatus;
final double? sellPrice;
final double? discountPrice;
final String? unit;
// 0= 1= 2= ,
final int kind;
final double weight;
final int num;
final int? kind;
final double? weight;
final int? num;
factory ShopCarListModel.fromJson(Map<String, dynamic> json) =>
_$ShopCarListModelFromJson(json);
GoodStatus get goodStatus => ShopCarFunc.getGoodsStatus(status, shopStatus);
GoodStatus get goodStatus => ShopCarFunc.getGoodsStatus(status??1, shopStatus??1);
const ShopCarListModel({
required this.id,
required this.skuName,
required this.mainPhoto,
required this.status,
required this.shopStatus,
required this.sellPrice,
required this.discountPrice,
required this.unit,
required this.kind,
required this.weight,
required this.num,
this.id,
this.skuName,
this.mainPhoto,
this.status,
this.shopStatus,
this.sellPrice,
this.discountPrice,
this.unit,
this.kind,
this.weight,
this.num,
});
}

@ -8,16 +8,16 @@ part of 'shop_car_list_model.dart';
ShopCarListModel _$ShopCarListModelFromJson(Map<String, dynamic> json) {
return ShopCarListModel(
id: json['id'] as int,
skuName: json['skuName'] as String,
mainPhoto: json['mainPhoto'] as String,
status: json['status'] as int,
shopStatus: json['shopStatus'] as int,
sellPrice: (json['sellPrice'] as num).toDouble(),
discountPrice: (json['discountPrice'] as num).toDouble(),
unit: json['unit'] as String,
kind: json['kind'] as int,
weight: (json['weight'] as num).toDouble(),
num: json['num'] as int,
id: json['id'] as int?,
skuName: json['skuName'] as String?,
mainPhoto: json['mainPhoto'] as String?,
status: json['status'] as int?,
shopStatus: json['shopStatus'] as int?,
sellPrice: (json['sellPrice'] as num?)?.toDouble(),
discountPrice: (json['discountPrice'] as num?)?.toDouble(),
unit: json['unit'] as String?,
kind: json['kind'] as int?,
weight: (json['weight'] as num?)?.toDouble(),
num: json['num'] as int?,
);
}

@ -2,6 +2,7 @@ import 'dart:ui';
import 'package:aku_community/model/user/adress_model.dart';
import 'package:aku_community/widget/bee_scaffold.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
@ -19,7 +20,8 @@ import '../user_func.dart';
import 'new_address_page.dart';
class AddressListPage extends StatefulWidget {
AddressListPage({Key? key}) : super(key: key);
final bool canBack;
AddressListPage({Key? key, required this.canBack}) : super(key: key);
@override
AddressListPageState createState() => AddressListPageState();
@ -30,106 +32,41 @@ class AddressListPageState extends State<AddressListPage>
EasyRefreshController _refreshController = EasyRefreshController();
bool _onload = true;
List<AddressModel> _addressModels = [];
AddressModel? _addressModel;
refresh() {
_refreshController.callRefresh();
}
_buildItem(CommunityTopicModel model) {
return MaterialButton(
padding: EdgeInsets.symmetric(horizontal: 53.w, vertical: 20.w),
onPressed: () {
Get.to(() => TopicDetailPage(model: model));
},
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Hero(
// tag: "${model.firstImg}_${model.id}",
tag: model.hashCode.toString(),
child: Container(
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.w),
color: Colors.black12,
),
child: Stack(
children: [
FadeInImage.assetNetwork(
placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
image: API.image(ImgModel.first(model.imgUrl)),
height: 160.w,
width: 250.w,
fit: BoxFit.cover,
),
Positioned(
bottom: 0,
left: 0,
right: 0,
child: ClipRRect(
borderRadius: BorderRadius.vertical(
bottom: Radius.circular(8.w),
),
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 5, sigmaY: 5),
child: ('#${model.summary}')
.text
.center
.size(28.sp)
.white
.make()
.material(color: Colors.black26),
),
),
),
],
),
),
),
12.wb,
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
(model.title ?? '')
.text
.maxLines(2)
.size(28.sp)
.bold
.overflow(TextOverflow.ellipsis)
.make(),
(model.content ?? '')
.text
.maxLines(1)
.size(22.sp)
.color(Color(0xFF666666))
.overflow(TextOverflow.ellipsis)
.make(),
21.hb,
[
Spacer(),
Image.asset(
R.ASSETS_ICONS_HOT_FIRE_PNG,
height: 24.w,
width: 24.w,
),
12.wb,
'${model.activityNum}'
.text
.maxLines(1)
.size(22.sp)
.overflow(TextOverflow.ellipsis)
.make()
].row(),
],
).box.make().expand(),
],
),
);
}
@override
Widget build(BuildContext context) {
super.build(context);
return BeeScaffold(
leading: Navigator.canPop(context)
? IconButton(
onPressed: () async {
if(_addressModels.isEmpty){
Get.back(result: null);
}else{
_addressModels.forEach((element) {
if(element.isDefault==1){
_addressModel = element;
}
});
if(_addressModel==null){
Get.back();
}else{
Get.back(result: _addressModel);
}
}
},
icon: Icon(
CupertinoIcons.chevron_back,
color: Colors.black,
),
)
: SizedBox(),
title: '我的收货地址',
bottomNavi: GestureDetector(
onTap: ()async{
@ -165,13 +102,8 @@ class AddressListPageState extends State<AddressListPage>
: ListView(
padding: EdgeInsets.all(20.w),
children: [
..._addressModels.map((e) => MyAddressItem(addressModel: e,refreshController: _refreshController,
..._addressModels.map((e) => MyAddressItem(addressModel: e,refreshController: _refreshController,canBack: widget.canBack,
)).toList(),
//
// ..._newItems.map((e) => ChatCard(
// model: e,
//
// )).toList()
],
),
),

@ -325,7 +325,7 @@ class _NewAddressPageState extends State<NewAddressPage> {
children: [
'设置为默认地址'.text.size(28.sp).color(ktextPrimary).make(),
5.hb,
'提醒:每次下单默认推荐使用该地址'.text.size(24.sp).color(Color(0xFFBBBBBB)).make(),
'提醒:每次下单默认推荐使用该地址'.text.size(24.sp).color(Color(0xFFBBBBBB)).make(),
],
),
Spacer(),

@ -23,11 +23,12 @@ import 'address/new_address_page.dart';
class MyAddressItem extends StatefulWidget {
final AddressModel addressModel;
final EasyRefreshController? refreshController;
final bool canBack;
Color _titleColor = Colors.black;
MyAddressItem({required this.addressModel,
this.refreshController})
this.refreshController, required this.canBack})
: assert(addressModel != null);
_MyAddressItemState createState() => _MyAddressItemState();
@ -35,158 +36,165 @@ this.refreshController})
class _MyAddressItemState extends State<MyAddressItem> {
@override
Widget build(BuildContext context) {
return Container(
clipBehavior: Clip.antiAlias,
margin: EdgeInsets.only(bottom:20.w),
padding: EdgeInsets.only(top: 22.w,bottom: 24.w,left: 24.w,right: 20.w),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(24.w)),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
children: [
GestureDetector(
onTap: () async{
bool? result = await Userfunc.setIsDefaultAddress(widget.addressModel.id!);
if(result!=null){
if(result) widget.refreshController!.callRefresh();
}
},
child: Container(
child: widget.addressModel.isDefault==1?
Image.asset(R.ASSETS_ICONS_ICON_ADDRESS_ISDEFAULT_PNG,width: 40.w,height: 40.w,):
Image.asset(R.ASSETS_ICONS_ICON_ADDRESS_NOT_PNG,width: 40.w,height: 40.w,),
return GestureDetector(
onTap: widget.canBack? (){
Get.back(result: widget.addressModel);
}:(){
},
child: Container(
clipBehavior: Clip.antiAlias,
margin: EdgeInsets.only(bottom:20.w),
padding: EdgeInsets.only(top: 22.w,bottom: 24.w,left: 24.w,right: 20.w),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(24.w)),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
children: [
GestureDetector(
onTap: () async{
bool? result = await Userfunc.setIsDefaultAddress(widget.addressModel.id!);
if(result!=null){
if(result) widget.refreshController!.callRefresh();
}
},
child: Container(
child: widget.addressModel.isDefault==1?
Image.asset(R.ASSETS_ICONS_ICON_ADDRESS_ISDEFAULT_PNG,width: 40.w,height: 40.w,):
Image.asset(R.ASSETS_ICONS_ICON_ADDRESS_NOT_PNG,width: 40.w,height: 40.w,),
),
),
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding:
EdgeInsets.symmetric(horizontal: 20.w, vertical:6.w),
child: SizedBox(
width: 520.w,
child: Text(
widget.addressModel.locationName??'',
style:TextStyle(fontSize: 24.sp,color: ktextPrimary),
maxLines: 1,
overflow: TextOverflow.ellipsis,
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding:
EdgeInsets.symmetric(horizontal: 20.w, vertical:6.w),
child: SizedBox(
width: 520.w,
child: Text(
widget.addressModel.locationName??'',
style:TextStyle(fontSize: 24.sp,color: ktextPrimary),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
),
),
Padding(
padding:
EdgeInsets.symmetric(horizontal: 20.w, vertical:6.w),
child: SizedBox(
width: 520.w,
child: Text(
( widget.addressModel.addressDetail??''),
style:TextStyle(fontSize: 32.sp,color: ktextPrimary),
maxLines: 1,
overflow: TextOverflow.ellipsis,
Padding(
padding:
EdgeInsets.symmetric(horizontal: 20.w, vertical:6.w),
child: SizedBox(
width: 520.w,
child: Text(
( widget.addressModel.addressDetail??''),
style:TextStyle(fontSize: 32.sp,color: ktextPrimary),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
),
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 20.w, vertical:6.w),
child: Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Text(
widget.addressModel.name??'',
style: TextStyle(fontSize: 24.sp,color: ktextPrimary)
),
30.wb,
Text(
widget.addressModel.tel??'',
style: TextStyle(fontSize: 24.sp,color: ktextPrimary)
),
],
Padding(
padding: EdgeInsets.symmetric(horizontal: 20.w, vertical:6.w),
child: Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Text(
widget.addressModel.name??'',
style: TextStyle(fontSize: 24.sp,color: ktextPrimary)
),
30.wb,
Text(
widget.addressModel.tel??'',
style: TextStyle(fontSize: 24.sp,color: ktextPrimary)
),
],
),
),
),
],
),
Spacer(),
GestureDetector(
onTap: () async{
bool? result = await Get.to(() => NewAddressPage(isFirstAdd:false,addressModel: widget.addressModel,
));
if(result!=null){
if(result) widget.refreshController!.callRefresh();
}
},
child: Container(
child: Image.asset(R.ASSETS_ICONS_ICON_ADDRESS_EDIT_PNG,width: 40.w,height: 40.w,),
],
),
)
],
),
20.hb,
Container(
height: 1,
color: Colors.grey[200],
),
20.hb,
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
10.wb,
Text(
widget.addressModel.isDefault == 0 ? "" : "默认地址",
style: TextStyle(fontSize: 28.sp,color: ktextSubColor),
),
Spacer(),
GestureDetector(
onTap: () async{
// bool? result = await Userfunc.deleteAddress(widget.addressModel.id!);
// if(result!=null){
// if(result) widget.refreshController!.callRefresh();
// }
bool? result =
await Get.dialog(CupertinoAlertDialog(
title: '您确定要删除该地址吗?'.text.isIntrinsic.size(30.sp).make(),
actions: [
CupertinoDialogAction(
child: '取消'.text.black.isIntrinsic.make(),
onPressed: () => Get.back(),
),
CupertinoDialogAction(
child: '确定'
.text
.color(Colors.orange)
.isIntrinsic
.make(),
onPressed: () => Get.back(result: true),
),
],
));
Spacer(),
GestureDetector(
onTap: () async{
if (result == true) {
bool? result = await Userfunc.deleteAddress(widget.addressModel.id!);
bool? result = await Get.to(() => NewAddressPage(isFirstAdd:false,addressModel: widget.addressModel,
));
if(result!=null){
if(result) widget.refreshController!.callRefresh();
}
};
},
child: Container(
width: 70.w,
height: 40.w,
child:Text(
"删除",
style: TextStyle(fontSize: 28.sp,color: ktextSubColor),
},
child: Container(
child: Image.asset(R.ASSETS_ICONS_ICON_ADDRESS_EDIT_PNG,width: 40.w,height: 40.w,),
),
)
],
),
20.hb,
Container(
height: 1,
color: Colors.grey[200],
),
20.hb,
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
10.wb,
Text(
widget.addressModel.isDefault == 0 ? "" : "默认地址",
style: TextStyle(fontSize: 28.sp,color: ktextSubColor),
),
Spacer(),
GestureDetector(
onTap: () async{
// bool? result = await Userfunc.deleteAddress(widget.addressModel.id!);
// if(result!=null){
// if(result) widget.refreshController!.callRefresh();
// }
bool? result =
await Get.dialog(CupertinoAlertDialog(
title: '您确定要删除该地址吗?'.text.isIntrinsic.size(30.sp).make(),
actions: [
CupertinoDialogAction(
child: '取消'.text.black.isIntrinsic.make(),
onPressed: () => Get.back(),
),
CupertinoDialogAction(
child: '确定'
.text
.color(Colors.orange)
.isIntrinsic
.make(),
onPressed: () => Get.back(result: true),
),
],
));
if (result == true) {
bool? result = await Userfunc.deleteAddress(widget.addressModel.id!);
if(result!=null){
if(result) widget.refreshController!.callRefresh();
}
};
},
child: Container(
width: 70.w,
height: 40.w,
child:Text(
"删除",
style: TextStyle(fontSize: 28.sp,color: ktextSubColor),
),
),
),
),
],
)
],
],
)
],
),
),
);
}

@ -598,7 +598,7 @@ class _PersonalIndexState extends State<PersonalIndex>
36.hb,
_function('我的访客', R.ASSETS_ICONS_ICON_MY_VISITOR_PNG, () => CarManagePage(),''),
36.hb,
_function('收货地址设置', R.ASSETS_ICONS_ICON_MY_LOCATION_PNG, () => AddressListPage(),''),
_function('收货地址设置', R.ASSETS_ICONS_ICON_MY_LOCATION_PNG, () => AddressListPage(canBack: false,),''),
//
// ApplicationView.custom(

@ -15,7 +15,7 @@ import 'package:bot_toast/bot_toast.dart';
class Userfunc {
///
///
static Future<List<AddressModel>> getMyAddress(
) async {
BaseModel model = await NetUtil().get(

@ -195,7 +195,7 @@ class _SharePayPageState extends State<SharePayPage> {
"ids": total.ids,
"payType": 1, //
"payPrice": total.payTotal.toDoubleStringAsFixed()
});
});
if (baseModel.status ?? false) {
bool result = await PayUtil()
.callAliPay(baseModel.message!, API.pay.sharePayOrderCodeCheck);

@ -111,6 +111,8 @@ class _SplashPageState extends State<SplashPage> {
@override
void initState() {
super.initState();
PowerLogger.start(
context,
debug: DeveloperUtil.dev,
@ -119,6 +121,7 @@ class _SplashPageState extends State<SplashPage> {
Future.delayed(Duration(milliseconds: 0), () async {
await _originOp();
var agreement = await HiveStore.appBox?.get('agreement') ?? false;
if (!agreement) {
var result = await _showLoginVerify();
@ -139,7 +142,8 @@ class _SplashPageState extends State<SplashPage> {
MainInitialize.initWechat();
MainInitialize.initWebSocket();
Get.offAll(() => TabNavigator());
});
}
);
}
@override

@ -3,6 +3,7 @@ import 'package:aku_community/constants/api.dart';
import 'package:aku_community/model/user/province_model.dart';
import 'package:aku_community/pages/property/property_page.dart';
import 'package:aku_community/pages/sign/sign_in_page.dart';
import 'package:aku_community/provider/app_provider.dart';
import 'package:aku_community/ui/community/community_views/community_page.dart';
import 'package:aku_community/ui/market/market_page.dart';
import 'package:aku_community/utils/hive_store.dart';
@ -17,6 +18,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:jpush_flutter/jpush_flutter.dart';
import 'package:provider/provider.dart';
import 'home/home_page.dart';
import 'personal/personal_page.dart';
@ -43,7 +45,9 @@ class _TabNavigatorState extends State<TabNavigator>
@override
void initState() {
super.initState();
final appProvider = Provider.of<AppProvider>(Get.context!);
Future.delayed(Duration(milliseconds: 0), () async {
await appProvider.getMyAddress();//
List<ProvinceModel> _province = [];
var agreement = await HiveStore.appBox?.get('cityList') ?? null;
if (agreement==null) {
@ -68,6 +72,7 @@ class _TabNavigatorState extends State<TabNavigator>
];
_tabController = TabController(length: _pages.length, vsync: this);
}
_buildBottomBar(

@ -6,6 +6,7 @@ import 'package:aku_community/constants/config.dart';
import 'package:aku_community/model/common/real_time_weather_model.dart';
import 'package:aku_community/model/community/hot_topic_model.dart';
import 'package:aku_community/model/message/message_center_model.dart';
import 'package:aku_community/model/user/adress_model.dart';
import 'package:aku_community/model/user/car_parking_model.dart';
import 'package:aku_community/models/user/passed_house_list_model.dart';
import 'package:aku_community/utils/hive_store.dart';
@ -294,6 +295,44 @@ class AppProvider extends ChangeNotifier {
notifyListeners();
}
List<AddressModel> _addressModels = [];
List<AddressModel> get addressModels => _addressModels;
AddressModel? _addressModel;
AddressModel? get addressModel => _addressModel;
///
///
Future getMyAddress() async {
BaseModel model = await NetUtil().get(
API.user.myAddressList,
);
if (model.data!.length == 0)
return [];
else{
_addressModels = (model.data as List)
.map((e) => AddressModel.fromJson(e))
.toList();
if (_addressModels.isEmpty) {
_addressModel = null;
} else {
_addressModels.forEach((element) {
if(element.isDefault==1){
_addressModel = element;
}
});
}
}
notifyListeners();
}

@ -112,7 +112,7 @@ class CollectionListCard extends StatelessWidget {
),
),
TextSpan(
text: '${model.sellPrice ?? 0}',
text: '${model.discountPrice ?? 0}',
style: TextStyle(
color: ktextSubColor,
fontSize: 20.sp,
@ -133,7 +133,7 @@ class CollectionListCard extends StatelessWidget {
),
),
TextSpan(
text: (model.discountPrice??0)<(model.sellPrice??0)
text: (model.discountPrice??0)>(model.sellPrice??0)
? _getDiscount(model.sellPrice ?? -1,
model.discountPrice ?? -1)
: '暂无折扣',
@ -187,7 +187,7 @@ class CollectionListCard extends StatelessWidget {
_getDiscount(double sellPrice, double discountPrice) {
String count = '';
count = ((discountPrice / sellPrice) * 10).toStringAsFixed(1);
count = ((sellPrice / discountPrice) * 10).toStringAsFixed(1);
return count + '';
}

@ -1,4 +1,5 @@
import 'package:aku_community/models/market/order/goods_home_model.dart';
import 'package:aku_community/ui/market/search/good_detail_page.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
@ -28,10 +29,9 @@ class MarketHomeGoodsCard extends StatelessWidget {
side: BorderSide(color: Color(0xFFC4C4C4))),
padding: EdgeInsets.zero,
onPressed: () {
// Get.to(
// () => GoodsDetailPage(id: item.id),
// preventDuplicates: false,
// )
Get.to(
() => GoodDetailPage(goodId: item.id!),
);
},
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@ -115,7 +115,7 @@ class MarketHomeGoodsCard extends StatelessWidget {
),
),
TextSpan(
text: '${item.discountPrice??''} ',
text: '${item.sellPrice??''} ',
style: TextStyle(
color: Colors.red,
fontWeight: FontWeight.bold,
@ -135,7 +135,7 @@ class MarketHomeGoodsCard extends StatelessWidget {
text: TextSpan(
children: [
TextSpan(
text: '原价:¥',
text: '原价:',
style: TextStyle(
color: ktextSubColor,
fontSize: 20.sp,
@ -143,7 +143,7 @@ class MarketHomeGoodsCard extends StatelessWidget {
),
),
TextSpan(
text: '${item.sellPrice??''}',
text: item.discountPrice==null?'':'¥${item.discountPrice??''}',
style: TextStyle(
color: ktextSubColor,
fontSize: 20.sp,
@ -170,7 +170,7 @@ class MarketHomeGoodsCard extends StatelessWidget {
),
),
TextSpan(
text: (item.discountPrice??0)<(item.sellPrice??0)
text: (item.discountPrice??0)>(item.sellPrice??0)
? _getDiscount(item.sellPrice ?? -1,
item.discountPrice ?? -1)
: '暂无折扣',
@ -192,7 +192,7 @@ class MarketHomeGoodsCard extends StatelessWidget {
_getDiscount(double sellPrice, double discountPrice) {
String count = '';
count = ((discountPrice / sellPrice) * 10).toStringAsFixed(1);
count = ((sellPrice / discountPrice) * 10).toStringAsFixed(1);
return count + '';
}

@ -27,10 +27,7 @@ import 'package:get/get.dart';
import 'package:provider/provider.dart';
import 'market_home_goods_card.dart';
// import 'package:aku_community/ui/market/goods/goods_detail_page.dart';
// import 'package:aku_community/widget/tab_bar/bee_tab_bar.dart';
import 'package:velocity_x/velocity_x.dart';
class MarketPage extends StatefulWidget {
MarketPage({Key? key}) : super(key: key);
@ -62,7 +59,7 @@ class _MarketPageState extends State<MarketPage>
List<SwiperModel> _swiperModels = [];
OrderType _orderType = OrderType.NORMAL;
IconData priceIcon = CupertinoIcons.chevron_up_chevron_down;
String priceIcon = R.ASSETS_ICONS_ICON_PRICE_NORMAL_PNG;
List<GoodsClassification> _goodsClassificationList = [];
@ -74,6 +71,7 @@ class _MarketPageState extends State<MarketPage>
int? orderByPrice;
Future updateMarketInfo() async {
_pageNum =1;
BaseListModel baseListModel = await NetUtil().getList(
API.market.findRecommendGoodsList,
params: {
@ -102,9 +100,9 @@ class _MarketPageState extends State<MarketPage>
},
);
if (baseListModel.tableList!.isNotEmpty) {
_goodsHomeModelList = (baseListModel.tableList as List)
_goodsHomeModelList.addAll((baseListModel.tableList as List)
.map((e) => GoodsHomeModel.fromJson(e))
.toList();
.toList());
}
_pageCount = baseListModel.pageCount!;
}
@ -114,7 +112,7 @@ class _MarketPageState extends State<MarketPage>
super.initState();
for (int i = 0; i < 10; i++) {
_goodsClassificationList
.add(GoodsClassification(id: 0, name: '', imgUrls: null));
.add(GoodsClassification(id: 0, name: '', imgUrls: []));
}
for (int i = 0; i < 6; i++) {
_goodsPopularModelList.add(
@ -127,7 +125,6 @@ class _MarketPageState extends State<MarketPage>
///appbar refresh
Future.delayed(Duration(milliseconds: 0), () async {
await updateMarketInfo();
await _refresh();
setState(() {});
});
@ -170,14 +167,17 @@ class _MarketPageState extends State<MarketPage>
}
_refresh() async {
_pageNum = 1;
await updateMarketInfo();
_swiperModels = await CommunityFunc.swiper();
_newTotal = await CommunityFunc.getNewProductsTodayNum();
_total = await CommunityFunc.getSkuTotal();
_brandTotal = await CommunityFunc.getSettledBrandsNum();
_goodsClassificationList =
await CommunityFunc.getGoodsClassificationList(0); //0
var list = await CommunityFunc.getGoodsClassificationList(0); //0
_goodsClassificationList.replaceRange(0, list.length, list);
//_goodsPopularModelList = await CommunityFunc.getGoodsPopularModel(6);
setState(() {});
@ -187,7 +187,7 @@ class _MarketPageState extends State<MarketPage>
final normalTypeButton = MaterialButton(
onPressed: () async {
_orderType = OrderType.NORMAL;
priceIcon = CupertinoIcons.chevron_up_chevron_down;
priceIcon = R.ASSETS_ICONS_ICON_PRICE_NORMAL_PNG;
orderBySalesVolume = null;
orderByPrice = null;
await updateMarketInfo();
@ -211,7 +211,7 @@ class _MarketPageState extends State<MarketPage>
_orderType = OrderType.SALES;
orderBySalesVolume = 2;
orderByPrice = null;
priceIcon = CupertinoIcons.chevron_up_chevron_down;
priceIcon = R.ASSETS_ICONS_ICON_PRICE_NORMAL_PNG;
await updateMarketInfo();
setState(() {});
},
@ -237,19 +237,19 @@ class _MarketPageState extends State<MarketPage>
_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;
}
await updateMarketInfo();
@ -274,14 +274,7 @@ class _MarketPageState extends State<MarketPage>
: FontWeight.normal,
),
),
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,

@ -0,0 +1,167 @@
/*
* ====================================================
* package :
* author : Created by nansi.
* time : 2019-07-17 09:41
* remark :
* ====================================================
*/
import 'package:aku_community/base/base_style.dart';
import 'package:aku_community/model/good/good_detail_model.dart';
import 'package:aku_community/model/user/province_model.dart';
import 'package:aku_community/utils/text_utils.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter/material.dart';
import 'package:aku_community/utils/headers.dart';
class GoodDetailBottomSheet extends StatefulWidget {
final GoodDetailModel goodDetail;
const GoodDetailBottomSheet({
Key? key,
required this.goodDetail,
});
@override
_GoodDetailBottomSheetState createState() => _GoodDetailBottomSheetState();
}
class _GoodDetailBottomSheetState extends State<GoodDetailBottomSheet>
with TickerProviderStateMixin {
late BuildContext _context;
late ScrollController _scrollController;
List<Attribute> attributes = [];
@override
void initState() {
super.initState();
_scrollController = ScrollController();
if (widget.goodDetail.goodsDetailSpecificationVoList != null) {
widget.goodDetail.goodsDetailSpecificationVoList!.forEach((element) {
if (element.attribute != null) {
attributes.addAll(element.attribute!);
}
});
}
}
@override
Widget build(BuildContext context) {
_context = context;
return GestureDetector(
onTap: () {},
child: _buildBody(context),
);
}
@override
void dispose() {
_scrollController.dispose();
super.dispose();
}
Container _buildBody(BuildContext context) {
return Container(
height: 1200.w,
padding: EdgeInsets.symmetric(horizontal: 15.w),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.vertical(top: Radius.circular(10.w))),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
_header(),
10.hb,
widget.goodDetail.goodsDetailSpecificationVoList != null
? _list()
: SizedBox()
],
),
);
}
Container _header() {
return Container(
margin: EdgeInsets.symmetric(vertical: 30.w),
child: Row(
children: <Widget>[
Spacer(),
Text(
"产品参数",
style: TextStyle(
fontSize: 32.sp,
fontWeight: FontWeight.w500,
color: ktextPrimary),
),
Spacer(),
GestureDetector(
onTap: () {
_dismiss();
},
child: Container(
padding: EdgeInsets.all(5.w),
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(20.w)),
color: Colors.white,
),
child: Icon(
Icons.close,
color: Colors.grey[500],
size: 40.w,
),
),
)
],
),
);
}
Expanded _list() {
return Expanded(
child: ListView.builder(
controller: _scrollController,
itemCount: attributes.length,
itemBuilder: (context, index) {
return _goodInfo(attributes[index]);
}),
);
}
_dismiss() {
Navigator.maybePop(_context);
}
_goodInfo(Attribute attribute) {
return Column(
children: [
Container(
width: double.infinity,
height: 86.w,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
44.wb,
Container(
child: Text(
attribute.name ?? '',
style: TextStyle(color: ktextPrimary, fontSize: 28.sp),
),
width: 250.w,
),
Text(
attribute.value ?? '',
style: TextStyle(color: ktextSubColor, fontSize: 28.sp),
),
],
),
),
Divider(
height: 1.w,
color: Color(0xFFD9D9D9),
indent: 44.w,
endIndent: 44.w,
)
],
);
}
}

@ -1,29 +1,26 @@
import 'package:aku_community/model/common/img_model.dart';
import 'package:aku_community/model/good/good_detail_model.dart';
import 'package:aku_community/model/user/adress_model.dart';
import 'package:aku_community/pages/personal/address/address_list_page.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:aku_community/ui/market/search/submit_order_page.dart';
import 'package:aku_community/ui/market/search/submit_order_page_normal.dart';
import 'package:aku_community/ui/market/shop_car/shop_car_page.dart';
import 'package:bot_toast/bot_toast.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 'good_detail_bottomSheet.dart';
class GoodDetailPage extends StatefulWidget {
final int goodId;
@ -39,16 +36,30 @@ class _GoodDetailPageState extends State<GoodDetailPage> {
late PageController _pageController;
int _currentIndex = 0;
late GoodDetailModel _goodDetail;
late GoodDetailModel? _goodDetail;
bool _onload = true;
late ScrollController _sliverListController;
AddressModel? _addressModel;
List _imageList = [];
@override
void initState() {
final appProvider = Provider.of<AppProvider>(Get.context!);
super.initState();
// Future.delayed(Duration(milliseconds: 0), () async {
// _imageList = await SearchFunc.getGoodDetailImage(widget.goodId);
// setState(() {
//
// });
// });
_pageController = PageController();
_sliverListController = ScrollController();
_refreshController = EasyRefreshController();
if(appProvider.addressModel!=null){
_addressModel = appProvider.addressModel!;
}else{
_addressModel = null;
}
}
@override
@ -61,7 +72,7 @@ class _GoodDetailPageState extends State<GoodDetailPage> {
@override
Widget build(BuildContext context) {
final userProvider = Provider.of<UserProvider>(context, listen: false);
return BeeScaffold(
titleSpacing: 0,
@ -71,7 +82,7 @@ class _GoodDetailPageState extends State<GoodDetailPage> {
// children: [
// ],
// ),
bottomNavi: _bottomButton(),
bottomNavi: _onload?SizedBox(): _bottomButton(),
body: Stack(
children: [
@ -81,12 +92,14 @@ class _GoodDetailPageState extends State<GoodDetailPage> {
controller: _refreshController,
onRefresh: () async {
_goodDetail = await SearchFunc.getGoodDetail(widget.goodId);
_imageList = await SearchFunc.getGoodDetailImage(widget.goodId);
if (_goodDetail != GoodDetailModel.fail()) {
_onload = false;
}
setState(() {});
},
child: _onload?SizedBox():_buildBody()),
child: _onload?SizedBox():_buildBody(context)),
Positioned(
top: (kToolbarHeight+16).w,
left: 24.w,
@ -115,14 +128,14 @@ class _GoodDetailPageState extends State<GoodDetailPage> {
);
}
Widget _buildBody() {
Widget _buildBody(BuildContext context) {
return Column(
children: [
_imageView(_goodDetail.goodsDetailImageVos??[]),
_imageView(_goodDetail!.goodsDetailImageVos??[]),
20.hb,
_goodInfo(),
20.hb,
_address(),
_address(context),
20.hb,
_getDetailImage(),
],
@ -148,13 +161,13 @@ class _GoodDetailPageState extends State<GoodDetailPage> {
16.wb,
'¥'.text.color(Color(0xFFE52E2E)).size(28.sp).make(),
Text(
_goodDetail.discountPrice==null?'':(_goodDetail.discountPrice!).toStringAsFixed(2),
_goodDetail!.sellPrice==null?'':(_goodDetail!.sellPrice!).toStringAsFixed(2),
style: TextStyle(fontSize: 40.sp,color: Color(0xFFE52E2E)),
),
Spacer(),
'已售:'.text.color(Color(0xFFBBBBBB)).size(24.sp).make(),
Text(
(_goodDetail.sellNum??0).toString(),
(_goodDetail!.sellNum??0).toString(),
style: TextStyle(fontSize: 24.sp,color: Color(0xFFBBBBBB)),
),
16.wb,
@ -167,14 +180,14 @@ class _GoodDetailPageState extends State<GoodDetailPage> {
width: double.infinity,
child:
Text(
(_goodDetail.skuName??''),
(_goodDetail!.skuName??''),
style: TextStyle(fontSize: 28.sp,color: ktextPrimary),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
),
_getIcon(_goodDetail.kind??0),
_getIcon(_goodDetail!.kind??0),
Spacer(),
Row(
crossAxisAlignment: CrossAxisAlignment.center,
@ -182,16 +195,16 @@ class _GoodDetailPageState extends State<GoodDetailPage> {
16.wb,
'原价:'.text.color(Color(0xFFBBBBBB)).size(24.sp).make(),
Text(
_goodDetail.sellPrice==null?'':(_goodDetail.sellPrice!).toStringAsFixed(2),
_goodDetail!.discountPrice==null?'':(_goodDetail!.discountPrice!).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)
(_goodDetail!.discountPrice??0)>(_goodDetail!.sellPrice??0)
? _getDiscount(_goodDetail!.sellPrice ?? -1,
_goodDetail!.discountPrice ?? -1)
: '暂无折扣',
style: TextStyle(fontSize: 24.sp,color: Color(0xFFBBBBBB)),
),
@ -205,7 +218,8 @@ class _GoodDetailPageState extends State<GoodDetailPage> {
}
_address(){
_address(BuildContext context){
return Container(
padding: EdgeInsets.all(20.w),
margin: EdgeInsets.symmetric(horizontal:20.w ),
@ -220,8 +234,15 @@ class _GoodDetailPageState extends State<GoodDetailPage> {
mainAxisAlignment: MainAxisAlignment.center,
children: [
GestureDetector(
onTap: (){
onTap: () async{
//
var result = await Get.to(()=>AddressListPage(canBack: true,));
if(result!=null){
_addressModel = result;
}
setState(() {
});
},
child: Container(
color: Colors.white,
@ -235,7 +256,8 @@ class _GoodDetailPageState extends State<GoodDetailPage> {
Container(
width: 430.w,
child: Text(
'uyerueiwoyruioweyrewiuuryriwuey13123123123123123r',
_addressModel==null?'请先选择地址':(_addressModel!.locationName??'')
+(_addressModel!.addressDetail??''),
style: TextStyle(fontSize: 24.sp,color: ktextPrimary),
maxLines: 1,
overflow: TextOverflow.ellipsis,
@ -257,7 +279,11 @@ class _GoodDetailPageState extends State<GoodDetailPage> {
52.hb,
GestureDetector(
onTap: (){
//
showModalBottomSheet(
context: context,
builder: (context) {
return GoodDetailBottomSheet(goodDetail:_goodDetail!);
});
},
child: Container(
color: Colors.white,
@ -320,14 +346,15 @@ class _GoodDetailPageState extends State<GoodDetailPage> {
Spacer(),
],
),
..._goodDetail.goodsDetailImageVos!.map((e) => _image(e.url??''))
10.hb,
..._imageList.map((e) => _image(_getRightUrl(e)??''))
],
),
);
}
_image(String url){
print(url);
return Container(
width: double.infinity,
child: GestureDetector(
@ -336,12 +363,17 @@ class _GoodDetailPageState extends State<GoodDetailPage> {
},
child: FadeInImage.assetNetwork(
placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
image: url,
image: 'https://'+url,
fit: BoxFit.cover,
),
),
);
}
/////img30.360buyimg.com/sku/jfs/t1/144443/40/4086/433571/5f22204bEd3a409dc/3090e34cf8c4187c.jpg
///
_getRightUrl(String url){
return url.substring(2);
}
@ -400,7 +432,7 @@ class _GoodDetailPageState extends State<GoodDetailPage> {
_bottomButton() {
return Container(
return Container(
width: double.infinity,
height: 100.w,
@ -420,33 +452,18 @@ class _GoodDetailPageState extends State<GoodDetailPage> {
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
30.wb,
40.wb,
GestureDetector(
onTap: (){
onTap: () async{
await CollectionFunc.collection(_goodDetail!.id!);
_refreshController.callRefresh();
},
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,),
Image.asset(_goodDetail!.isCollection==0? R.ASSETS_ICONS_ICON_GOOD_FAVOR_PNG:R.ASSETS_ICONS_SHOP_FAVORFILL_PNG,width: 48.w,height: 48.w,),
Text(
'加入收藏',
style: TextStyle(fontSize: 20.sp,color: ktextPrimary),
@ -454,9 +471,11 @@ class _GoodDetailPageState extends State<GoodDetailPage> {
],
),
),
30.wb,
40.wb,
GestureDetector(
onTap: ()async{
//
Get.to(()=> ShopCarPage());
},
child: Column(
@ -471,37 +490,48 @@ class _GoodDetailPageState extends State<GoodDetailPage> {
],
),
),
30.wb,
40.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)),
GestureDetector(
onTap: () async{
await SearchFunc.addGoodsCar(_goodDetail!.id!);
},
child: Container(
width: 230.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),
GestureDetector(
onTap: (){
Get.to(()=>SubmitOrderNormalPage(goodModel: _goodDetail!,));
},
child: Container(
width: 230.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),
),
alignment: Alignment.center,
child:Text(
'立即购买',
style: TextStyle(fontSize: 32.sp,color: Colors.white),
),
),
)
],
@ -559,8 +589,12 @@ class _GoodDetailPageState extends State<GoodDetailPage> {
}
_getDiscount(double sellPrice, double discountPrice) {
String count = '';
count = ((discountPrice / sellPrice) * 10).toStringAsFixed(1);
count = ((sellPrice / discountPrice) * 10).toStringAsFixed(1);
return count + '';
}
_getSpecifications(){
}
}

@ -123,7 +123,7 @@ class GoodsListCardState extends State<GoodsListCard> {
),
),
TextSpan(
text: '${widget.model.sellPrice ?? 0}',
text: '${widget.model.discountPrice ?? 0}',
style: TextStyle(
color: ktextSubColor,
fontSize: 20.sp,
@ -144,7 +144,7 @@ class GoodsListCardState extends State<GoodsListCard> {
),
),
TextSpan(
text: (widget.model.discountPrice??0)<(widget.model.sellPrice??0)
text: (widget.model.discountPrice??0)>(widget.model.sellPrice??0)
? _getDiscount(widget.model.sellPrice ?? -1,
widget.model.discountPrice ?? -1)
: '暂无折扣',
@ -193,7 +193,7 @@ class GoodsListCardState extends State<GoodsListCard> {
_getDiscount(double sellPrice, double discountPrice) {
String count = '';
count = ((discountPrice / sellPrice) * 10).toStringAsFixed(1);
count = ((sellPrice / discountPrice) * 10).toStringAsFixed(1);
return count + '';
}

@ -54,6 +54,29 @@ class SearchFunc {
return GoodDetailModel.fromJson(model.data);
}
///
static Future<List> getGoodDetailImage(int shopId) async {
BaseModel model = await NetUtil().get(
API.market.findGoodsDetailBigInfo,
params: {'shopId': shopId},
);
if (model.data == null) return [];
return model.data!.map((e) => e as String).toList();
}
///
static Future<String> addGoodsCar(int jcookGoodsId) async {
BaseModel model = await NetUtil().post(
API.market.insertShoppingCart,
params: {'jcookGoodsId': jcookGoodsId},
showMessage: true
);
if (model.message == null) return '';
return model.message as String;
}

@ -1,8 +1,10 @@
import 'dart:math';
import 'package:aku_community/model/common/img_model.dart';
import 'package:aku_community/models/market/goods_popular_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/community/community_func.dart';
import 'package:aku_community/ui/market/collection/my_collection.dart';
@ -26,6 +28,7 @@ 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 'good_detail_page.dart';
import 'goods_list_card.dart';
enum OrderType {
@ -59,8 +62,9 @@ class SearchGoodsPageState extends State<SearchGoodsPage> {
int? brandId;
double? minPrice;
double? maxPrice;
late List<SearchGoodsModel> _models;
List<SearchGoodsModel> _models = [];
ScrollController _scrollController= new ScrollController();
List<GoodsPopularModel> goodsPopularModels = [];
@override
void initState() {
@ -327,35 +331,56 @@ class SearchGoodsPageState extends State<SearchGoodsPage> {
_showList
? Container(
color: Color(0xFFF2F3F4),
child: BeeListView(
path: API.market.search,
child: EasyRefresh(
firstRefresh: true,
header: MaterialHeader(),
footer: MaterialFooter(),
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,
// ),
onRefresh: () async {
goodsPopularModels = await CommunityFunc.getGoodsPopularModel(20);
setState(() {});
},
child: goodsPopularModels.isEmpty
? Container()
: ListView.separated(
padding: EdgeInsets.symmetric(vertical: 16.w, horizontal: 32.w),
itemBuilder: (context, index) {
final item = items[index];
return _hotGoodsCard(
item, index); //GoodsCard(item: item);
return _hotGoodsCard(goodsPopularModels[index], index);
},
separatorBuilder: (_, __) {
return 32.w.heightBox;
return 16.w.heightBox;
},
itemCount: items.length,
);
},
itemCount: goodsPopularModels.length),
),
// 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(),
],
@ -416,6 +441,7 @@ class SearchGoodsPageState extends State<SearchGoodsPage> {
child: Image.asset(R.ASSETS_ICONS_COLLECT_PNG,width: 84.w,height: 84.w,),
onTap: ()async{
var result = await Get.to(() => MyCollectionPage());
if(result!=null)
if(result){
_refreshController1.callRefresh();
}
@ -461,106 +487,116 @@ class SearchGoodsPageState extends State<SearchGoodsPage> {
setState(() {});
}
_hotGoodsCard(GoodsItem goodsItem, int index) {
return Row(
children: [
Stack(
_hotGoodsCard(GoodsPopularModel goodsItem, int index) {
return GestureDetector(
onTap: (){
Get.to(
() => GoodDetailPage(goodId: goodsItem.id!),
);
},
child: Container(
color: Colors.transparent,
child: Row(
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,
Stack(
children: [
Material(
color: Color(0xFFF5F5F5),
borderRadius: BorderRadius.circular(16.w),
clipBehavior: Clip.antiAlias,
child: FadeInImage.assetNetwork(
placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
image: goodsItem.mainPhoto??'',
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>[
Color(0xFFE52E2E),
Color(0xFFF58123),
]
: index == 1
imageErrorBuilder: (context, error, stackTrace) {
return Image.asset(
R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
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>[
Color(0xFFE52E2E),
Color(0xFFF58123),
Color(0xFFF5AF16),
]
: index == 2
: index == 1
? <Color>[
Color(0xFFF5AF16),
Color(0xFFF58123),
Color(0xFFF5AF16),
]
: <Color>[
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),
),
: index == 2
? <Color>[
Color(0xFFF5AF16),
Color(0xFFF5AF16),
]
: <Color>[
Color(0xFFBBBBBB),
Color(0xFFBBBBBB),
],
),
),
child: Text(
'${index + 1}',
style: TextStyle(
color: Colors.white,
fontSize: 24.sp,
),
),
)),
],
),
8.hb,
Row(
32.wb,
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'人气值',
style: TextStyle(color: ktextSubColor, fontSize: 24.sp),
),
10.wb,
Text(
'99251',
style: TextStyle(color: Color(0xFFBBBBBB), fontSize: 24.sp),
SizedBox(
width: 500.w,
child: Text(
goodsItem.skuName??'',
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(
goodsItem.viewsNum==null?'0':goodsItem.viewsNum.toString(),
style: TextStyle(color: Color(0xFFBBBBBB), fontSize: 24.sp),
),
],
)
],
)
],
)
],
),
),
);
}

@ -0,0 +1,20 @@
class SettlementGoodsDTO {
int? jcookGoodsId;
int? num;
SettlementGoodsDTO(
{this.jcookGoodsId, this.num,});
SettlementGoodsDTO.fromJson(Map<String, dynamic> json) {
jcookGoodsId = json['jcookGoodsId'];
num = json['num'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['jcookGoodsId'] = this.jcookGoodsId;
data['num'] = this.num;
return data;
}
}

@ -0,0 +1,773 @@
import 'package:aku_community/base/base_style.dart';
import 'package:aku_community/const/resource.dart';
import 'package:aku_community/constants/api.dart';
import 'package:aku_community/model/order/create_order_model.dart';
import 'package:aku_community/model/user/adress_model.dart';
import 'package:aku_community/models/market/shop_car/shop_car_list_model.dart';
import 'package:aku_community/pages/life_pay/pay_finish_page.dart';
import 'package:aku_community/pages/life_pay/pay_util.dart';
import 'package:aku_community/pages/personal/address/address_list_page.dart';
import 'package:aku_community/provider/app_provider.dart';
import 'package:aku_community/ui/market/search/settlementGoodsDTO.dart';
import 'package:aku_community/ui/market/shop_car/shop_car_func.dart';
import 'package:aku_community/utils/network/base_model.dart';
import 'package:aku_community/utils/network/net_util.dart';
import 'package:aku_community/widget/bee_scaffold.dart';
import 'package:velocity_x/velocity_x.dart';
import 'package:aku_community/widget/buttons/end_button.dart';
import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:aku_community/base/base_style.dart';
import 'package:aku_community/utils/headers.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:provider/provider.dart';
class SubmitOrderPage extends StatefulWidget {
final List<ShopCarListModel> models;
SubmitOrderPage({Key? key, required this.models}) : super(key: key);
@override
_SubmitOrderPageState createState() => _SubmitOrderPageState();
}
class _SubmitOrderPageState extends State<SubmitOrderPage> {
List<TextEditingController> _controllers = [];
List<SettlementGoodsDTO> _goodsList = [];
AddressModel? _addressModel;
CreateOrderModel? _createOrderModel;
double _allPrice = 0;
@override
void initState() {
super.initState();
final appProvider = Provider.of<AppProvider>(Get.context!);
_controllers.forEach((element) {
element.dispose();
});
_controllers.clear();
widget.models.forEach((element) {
_controllers.add(
TextEditingController(text: element.num.toString()));
_goodsList.add(SettlementGoodsDTO(jcookGoodsId: element.id,num: element.num));
});
if(appProvider.addressModel!=null){
_addressModel = appProvider.addressModel!;
createOrder(_addressModel!.id!,_goodsList);
}else{
_addressModel = null;
}
}
@override
void dispose() {
super.dispose();
}
Future<bool> createOrder(int addressId,List<SettlementGoodsDTO> goodsList) async {
BaseModel model = await NetUtil().post(
API.market.shopCarSettlement,
params: {'addressId': addressId,'settlementGoodsDTOList':goodsList.map((v) => v.toJson()).toList()},
);
if (model.data == null){
_createOrderModel = null;
setState(() {
});
return false;
}else{
_createOrderModel = CreateOrderModel.fromJson(model.data);
setState(() {
});
return true;
}
}
@override
Widget build(BuildContext context) {
return BeeScaffold(
title: '确认订单'.text.size(32.sp).black.bold.make(),
titleSpacing: 0,
body: ListView(
children: [
20.hb,
_address(context),
20.hb,
...widget.models.mapIndexed((currentValue, index) => _goodCard(currentValue,index)),
20.hb,
_priceView(),
20.hb,
_payWay(),
20.hb,
],
),
bottomNavi: Container(
width: double.infinity,
height: 120.w,
color: Colors.white,
child: Row(
children: [
Spacer(),
EndButton(
onPressed: () async {
if(_addressModel==null){
BotToast.showText(text: '请先选择地址');
}
Function cancel = BotToast.showLoading();
BaseModel baseModel =
await NetUtil().post(API.pay.jcookOrderCreateOrder, params: {
"addressId": _addressModel!.id!,
"settlementGoodsDTOList": _goodsList.map((v) => v.toJson()).toList(),
"payType": 1, //
"payPrice": _allPrice
});
if (baseModel.status ?? false) {
bool result = await PayUtil()
.callAliPay(baseModel.message!, API.pay.sharePayOrderCodeCheck);
if (result) {
Get.off(() => PayFinishPage());
}
}
cancel();
},
text: '提交订单'
.text
.size(32.sp)
.color(Colors.white)
.make()),
10.widthBox,
],
),
),
);
}
_address(BuildContext context){
return Container(
padding: EdgeInsets.only(left: 16.w,right: 16.w,top: 20.w,bottom: 20.w),
margin: EdgeInsets.symmetric(horizontal:20.w ),
width: double.infinity,
height: 182.w,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(24.w)),
color: Colors.white
),
child:
GestureDetector(
onTap: () async{
//
var result = await Get.to(()=>AddressListPage(canBack: true,));
if(result!=null){
_addressModel = result;
createOrder(_addressModel!.id!,_goodsList);
}else{
_addressModel =null;
}
setState(() {
});
},
child: Container(
color: Colors.white,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Image.asset(R.ASSETS_ICONS_ICON_GOOD_LOCATION_PNG,width: 60.w,height: 60.w,),
_addressModel!=null?Column(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding:
EdgeInsets.symmetric(horizontal: 20.w, vertical:6.w),
child: SizedBox(
width: 518.w,
child: Text(
_addressModel!.locationName??'',
style:TextStyle(fontSize: 24.sp,color: ktextPrimary),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
),
Padding(
padding:
EdgeInsets.symmetric(horizontal: 20.w, vertical:6.w),
child: SizedBox(
width: 518.w,
child: Text(
( _addressModel!.addressDetail??''),
style:TextStyle(fontSize: 32.sp,color: ktextPrimary),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 20.w, vertical:6.w),
child: Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Text(
_addressModel!.name??'',
style: TextStyle(fontSize: 24.sp,color: ktextPrimary)
),
30.wb,
Text(
_addressModel!.tel??'',
style: TextStyle(fontSize: 24.sp,color: ktextPrimary)
),
],
),
),
],
),
],
):Center(
child: Text(
'请先选择地址',
style:TextStyle(fontSize: 32.sp,color: ktextPrimary),
maxLines: 1,
overflow: TextOverflow.ellipsis,
)
),
Spacer(),
Icon(
CupertinoIcons.chevron_forward,
size: 40.w,
color: Color(0xFF999999),
),
],
),
),
),
);
}
_priceView(){
double allPrice = 0;
int allNum = 0;
double fee = 0;
if(_createOrderModel!=null){
fee =_createOrderModel!.fee??0;
}
_controllers.forEachIndexed((index, element) {
int num = int.parse(_controllers[index].text);
print(num);
allNum += num;
allPrice += ((widget.models[index].sellPrice??0) * num);
print(allPrice);
});
_allPrice = allPrice+fee;
return Container(
padding: EdgeInsets.only(left: 16.w,right: 16.w,top: 20.w,bottom: 20.w),
margin: EdgeInsets.symmetric(horizontal:20.w ),
width: double.infinity,
height: 200.w,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(24.w)),
color: Colors.white
),
child: Column(
children: [
Row(
children: [
Spacer(),
'${allNum}'
.text
.size(28.sp)
.color(Color(0xFFBBBBBB))
.make(),
5.wb,
'商品金额:'
.text
.size(28.sp)
.color(Color(0xFF333333))
.make(),
'¥${(_allPrice).toStringAsFixed(2)}'
.text
.size(28.sp)
.color(Color(0xFF333333))
.make(),
16.wb,
],
),
16.hb,
_createOrderModel!=null? Row(
children: [
Spacer(),
'运费:'
.text
.size(28.sp)
.color(Color(0xFF333333))
.make(),
( '¥${_createOrderModel!.fee}')
.text
.size(28.sp)
.color(Color(0xFF333333))
.make(),
16.wb,
],
):SizedBox(),
16.hb,
// Row(
// children: [
// Spacer(),
// '(小提示:京东自营商品加入购物车后一起下单,运费会更划算)'
// .text
// .size(18.sp)
// .color(Color(0xFFBBBBBB))
// .make(),
// ],
// ),
//16.hb,
Row(
children: [
Spacer(),
'应付金额:'
.text
.size(32.sp)
.color(Color(0xFF333333)).bold
.make(),
'¥${_allPrice+fee}'
.text
.size(32.sp)
.color(Color(0xFFE52E2E)).bold
.make(),
16.wb,
],
)
],
),
);
}
_payWay(){
return Container(
padding: EdgeInsets.only(left: 16.w,right: 16.w,top: 20.w,bottom: 20.w),
margin: EdgeInsets.symmetric(horizontal:20.w ),
width: double.infinity,
height: 72.w,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(24.w)),
color: Colors.white
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
'支付方式'
.text
.size(28.sp)
.color(Color(0xFF333333))
.make(),
Spacer(),
Image.asset(R.ASSETS_ICONS_ALIPAY_ROUND_PNG,width: 40.w,height: 40.w,),
16.wb,
'支付宝'
.text
.size(28.sp)
.color(Color(0xFF333333))
.make(),
],
),
);
}
Widget _goodCard(ShopCarListModel model, int index) {
var top = RichText(
text: TextSpan(children: [
WidgetSpan(
child: _getKindWd(model.kind??0),
),
TextSpan(
text: model.skuName,
style: TextStyle(fontSize: 28.sp, color: ktextPrimary)),
]),
maxLines: 2,
overflow: TextOverflow.ellipsis,
);
var mid = Container(
padding: EdgeInsets.symmetric(horizontal: 8.w, vertical: 10.w),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4.w), color: Color(0xFFF2F3F4)),
child: '规格:${model.weight}kg/${model.unit}'
.text
.size(24.sp)
.color(Color(0xFFBBBBBB))
.make(),
);
var bottom =
Column(
children: [
Row(
children: [
92.wb,
'购买数量'
.text
.size(28.sp)
.color(Color(0xFF333333))
.make(),
Spacer(),
_getBottomSuffix(model.goodStatus, model.id!, index)
],
),
48.hb,
Row(
children: [
92.wb,
'配送方式'
.text
.size(28.sp)
.color(Color(0xFF333333))
.make(),
Spacer(),
'快递配送'
.text
.size(28.sp)
.color(Color(0xFFBBBBBB))
.make(),
10.wb,
],
),
],
);
int num = int.parse(_controllers[index].text);
double sellPrice = model.sellPrice??0;
var price =
Row(
children: [
Spacer(),
'${_controllers[index].text}'
.text
.size(28.sp)
.color(Color(0xFFBBBBBB))
.make(),
5.wb,
'商品金额:'
.text
.size(28.sp)
.color(Color(0xFF333333))
.make(),
'¥${(num * sellPrice).toStringAsFixed(2)}'
.text
.size(28.sp)
.color(Color(0xFF333333))
.make(),
16.wb,
],
);
return Container(
alignment: Alignment.center,
height: 500.w,
margin: EdgeInsets.symmetric(horizontal: 20.w),
padding: EdgeInsets.all(16.w),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16.w),
),
child: Column(
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Container(
// width: 188.w,
// height: 188.w,
// clipBehavior: Clip.antiAlias,
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(16.w),
// image: DecorationImage(
// fit: BoxFit.scaleDown,
// image: NetworkImage(model.mainPhoto??''))),
// child: _getGoodsStatusImg(model.goodStatus),
// ),
Stack(
children: [
Container(
width: 188.w,
height: 188.w,
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16.w),
),
child: FadeInImage.assetNetwork(
placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
image: model.mainPhoto??'',
height: 188.w,
width: 188.w,
),
),
Positioned(
child: Container(
height: 188.w,
width: 188.w,
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16.w),
),
child: _getGoodsStatusImg(model.goodStatus) ??
SizedBox()))
],
),
20.wb,
Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Container(child: top,width:sellPrice>9999?300.w:320.w,alignment: Alignment.topCenter,),
10.hb,
mid,
//Spacer(),
10.hb,
],
),
),
Spacer(),
Container(
child:Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
8.hb,
'¥'
.richText
.withTextSpanChildren([
sellPrice.toStringAsFixed(2)
.textSpan
.size(28.sp)
.color(ktextPrimary)
.make(),
])
.color(ktextPrimary)
.size(28.sp)
.make(),
'x ${_controllers[index].text}'
.text
.size(24.sp)
.color(Color(0xFFBBBBBB))
.make(),
],
),
)
],
),
bottom,
Spacer(),
price,
30.hb,
],
),
);
}
String _getPointBehind(double num) {
var str = (num - num.toInt().toDouble()).toStringAsFixed(2);
return str.substring(str.length - 2);
}
Widget _getKindWd(int kind) {
switch (kind) {
case 1:
return Container(
// width: 90.w,
// height: 26.w,
padding: EdgeInsets.symmetric(horizontal: 6.w, vertical: 2.w),
margin: EdgeInsets.only(right: 10.w),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4.w),
gradient: LinearGradient(
begin: Alignment.centerLeft,
end: Alignment.centerRight,
colors: [Color(0xFFEC5329), Color(0xFFF58123)])),
child: '京东自营'.text.size(18.sp).color(Colors.white).make());
case 2:
return Container(
width: 90.w,
height: 26.w,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.centerLeft,
end: Alignment.centerRight,
colors: [Color(0xFFEC5329), Color(0xFFF58123)])),
child: '京东POP'.text.size(18.sp).color(Colors.white).make());
default:
return SizedBox();
}
}
Widget? _getGoodsStatusImg(GoodStatus status) {
switch (status) {
case GoodStatus.unSell:
return Container(
width: double.infinity,
height: double.infinity,
color: Color(0xFF000000).withOpacity(0.5),
alignment: Alignment.center,
child: Text(
'已下架',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 28.sp,
color: Colors.white),
),
);
case GoodStatus.onSell:
return null;
}
}
Widget _getBottomSuffix(GoodStatus status, int id, int index) {
switch (status) {
case GoodStatus.onSell:
return Container(
width: 108.w + 64.w,
height: 40.w,
child: Row(
children: [
GestureDetector(
onTap: () async {
int num = int.parse(_controllers[index].text);
if(num>1){
var result = await changeNum(id, num - 1);
if (result) {
_controllers[index].text = (num - 1).toString();
_goodsList[index].num = num - 1;
createOrder(_addressModel!.id!,_goodsList);
}
}
setState(() {});
},
child: Padding(
padding: EdgeInsets.only(right: 12.w),
child: Icon(
CupertinoIcons.minus,
size: 30.w,
),
),
),
Container(
width: 84.w,
height: 40.w,
decoration: BoxDecoration(
color: Color(0xFFF2F2F2),
borderRadius: BorderRadius.circular(4.w)),
child: TextField(
readOnly:true,
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
onChanged: (text) async {
var result = await changeNum(id, int.parse(text));
if (!result) {
// _controllers[index].text=
}
setState(() {});
},
controller: _controllers[index],
textAlign: TextAlign.center,
decoration: InputDecoration(
border: InputBorder.none,
isDense: true,
contentPadding: EdgeInsets.zero,
),
),
),
GestureDetector(
onTap: () async {
int num = int.parse(_controllers[index].text);
if(num<10){
var result = await changeNum(
id, int.parse(_controllers[index].text) + 1);
if (result) {
_controllers[index].text =
(int.parse(_controllers[index].text) + 1).toString();
_goodsList[index].num = num + 1;
createOrder(_addressModel!.id!,_goodsList);
}
setState(() {});
}
},
child: Padding(
padding: EdgeInsets.only(left: 12.w),
child: Icon(
CupertinoIcons.plus,
size: 30.w,
),
),
)
],
),
);
case GoodStatus.unSell:
return '商品已下架'.text.size(24.sp).color(Color(0x80000000)).make();
}
}
Widget _emptyWidget() {
return Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Image.asset(
R.ASSETS_IMAGES_SHOP_CAR_EMPTY_PNG,
width: 400.w,
height: 400.w,
),
'暂时没有加购商品'.text.size(28.sp).color(Color(0xFFBBBBBB)).make()
],
),
);
}
Future<bool> changeNum(int jcookGoodsId, int num) async {
var cancel = BotToast.showLoading();
var base = await NetUtil().post(API.market.shopCarChangeNum,
params: {'jcookGoodsId': jcookGoodsId, 'num': num});
if (!(base.status ?? false)) {
BotToast.showText(text: base.message ?? '');
}
cancel();
return base.status ?? false;
}
}

@ -0,0 +1,689 @@
import 'package:aku_community/base/base_style.dart';
import 'package:aku_community/const/resource.dart';
import 'package:aku_community/constants/api.dart';
import 'package:aku_community/model/good/good_detail_model.dart';
import 'package:aku_community/model/order/create_order_model.dart';
import 'package:aku_community/model/user/adress_model.dart';
import 'package:aku_community/models/market/shop_car/shop_car_list_model.dart';
import 'package:aku_community/pages/life_pay/pay_finish_page.dart';
import 'package:aku_community/pages/life_pay/pay_util.dart';
import 'package:aku_community/pages/personal/address/address_list_page.dart';
import 'package:aku_community/provider/app_provider.dart';
import 'package:aku_community/ui/market/search/settlementGoodsDTO.dart';
import 'package:aku_community/ui/market/shop_car/shop_car_func.dart';
import 'package:aku_community/utils/network/base_model.dart';
import 'package:aku_community/utils/network/net_util.dart';
import 'package:aku_community/widget/bee_scaffold.dart';
import 'package:velocity_x/velocity_x.dart';
import 'package:aku_community/widget/buttons/end_button.dart';
import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:aku_community/base/base_style.dart';
import 'package:aku_community/utils/headers.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:provider/provider.dart';
class SubmitOrderNormalPage extends StatefulWidget {
final GoodDetailModel goodModel;
SubmitOrderNormalPage({Key? key, required this.goodModel}) : super(key: key);
@override
_SubmitOrderNormalPageState createState() => _SubmitOrderNormalPageState();
}
class _SubmitOrderNormalPageState extends State<SubmitOrderNormalPage> {
late TextEditingController _controllers;
List<SettlementGoodsDTO> _goodsList = [];
AddressModel? _addressModel;
CreateOrderModel? _createOrderModel;
double _allPrice = 0;
@override
void initState() {
super.initState();
final appProvider = Provider.of<AppProvider>(Get.context!);
_controllers = TextEditingController(text: '1');
_goodsList
.add(SettlementGoodsDTO(jcookGoodsId: widget.goodModel.id, num: 1));
if (appProvider.addressModel != null) {
_addressModel = appProvider.addressModel!;
createOrder(_addressModel!.id!, _goodsList);
} else {
_addressModel = null;
}
}
@override
void dispose() {
_controllers.dispose();
super.dispose();
}
Future<bool> createOrder(
int addressId, List<SettlementGoodsDTO> goodsList) async {
BaseModel model = await NetUtil().post(
API.market.shopCarSettlement,
params: {
'addressId': addressId,
'settlementGoodsDTOList': goodsList.map((v) => v.toJson()).toList()
},
);
if (model.data == null) {
_createOrderModel = null;
setState(() {});
return false;
} else {
_createOrderModel = CreateOrderModel.fromJson(model.data);
setState(() {});
return true;
}
}
@override
Widget build(BuildContext context) {
return BeeScaffold(
title: '确认订单'.text.size(32.sp).black.bold.make(),
titleSpacing: 0,
body: ListView(
children: [
20.hb,
_address(context),
20.hb,
_goodCard(widget.goodModel),
20.hb,
_priceView(),
20.hb,
_payWay(),
20.hb,
],
),
bottomNavi: Container(
width: double.infinity,
height: 120.w,
color: Colors.white,
child: Row(
children: [
Spacer(),
EndButton(
onPressed: () async {
if (_addressModel == null) {
BotToast.showText(text: '请先选择地址');
}
Function cancel = BotToast.showLoading();
BaseModel baseModel = await NetUtil()
.post(API.pay.jcookOrderCreateOrder, params: {
"addressId": _addressModel!.id!,
"settlementGoodsDTOList":
_goodsList.map((v) => v.toJson()).toList(),
"payType": 1, //
"payPrice": _allPrice
});
if (baseModel.status ?? false) {
bool result = await PayUtil().callAliPay(
baseModel.message!, API.pay.sharePayOrderCodeCheck);
if (result) {
Get.off(() => PayFinishPage());
}
}
cancel();
},
text: '提交订单'.text.size(32.sp).color(Colors.white).make()),
10.widthBox,
],
),
),
);
}
_address(BuildContext context) {
return Container(
padding:
EdgeInsets.only(left: 16.w, right: 16.w, top: 20.w, bottom: 20.w),
margin: EdgeInsets.symmetric(horizontal: 20.w),
width: double.infinity,
height: 182.w,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(24.w)),
color: Colors.white),
child: GestureDetector(
onTap: () async {
//
var result = await Get.to(() => AddressListPage(
canBack: true,
));
if (result != null) {
_addressModel = result;
createOrder(_addressModel!.id!, _goodsList);
} else {
_addressModel = null;
}
setState(() {});
},
child: Container(
color: Colors.white,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Image.asset(
R.ASSETS_ICONS_ICON_GOOD_LOCATION_PNG,
width: 60.w,
height: 60.w,
),
_addressModel != null
? Column(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.symmetric(
horizontal: 20.w, vertical: 6.w),
child: SizedBox(
width: 518.w,
child: Text(
_addressModel!.locationName ?? '',
style: TextStyle(
fontSize: 24.sp, color: ktextPrimary),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
),
Padding(
padding: EdgeInsets.symmetric(
horizontal: 20.w, vertical: 6.w),
child: SizedBox(
width: 518.w,
child: Text(
(_addressModel!.addressDetail ?? ''),
style: TextStyle(
fontSize: 32.sp, color: ktextPrimary),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
),
Padding(
padding: EdgeInsets.symmetric(
horizontal: 20.w, vertical: 6.w),
child: Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Text(_addressModel!.name ?? '',
style: TextStyle(
fontSize: 24.sp,
color: ktextPrimary)),
30.wb,
Text(_addressModel!.tel ?? '',
style: TextStyle(
fontSize: 24.sp,
color: ktextPrimary)),
],
),
),
],
),
],
)
: Center(
child: Text(
'请先选择地址',
style: TextStyle(fontSize: 32.sp, color: ktextPrimary),
maxLines: 1,
overflow: TextOverflow.ellipsis,
)),
Spacer(),
Icon(
CupertinoIcons.chevron_forward,
size: 40.w,
color: Color(0xFF999999),
),
],
),
),
),
);
}
_priceView() {
double allPrice = 0;
int allNum = 0;
double fee = 0;
if (_createOrderModel != null) {
fee = _createOrderModel!.fee ?? 0;
}
int num = int.parse(_controllers.text);
print(num);
allNum += num;
allPrice += (widget.goodModel.sellPrice! * num);
_allPrice = allPrice + fee;
return Container(
padding:
EdgeInsets.only(left: 16.w, right: 16.w, top: 20.w, bottom: 20.w),
margin: EdgeInsets.symmetric(horizontal: 20.w),
width: double.infinity,
height: 200.w,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(24.w)),
color: Colors.white),
child: Column(
children: [
Row(
children: [
Spacer(),
'${allNum}'.text.size(28.sp).color(Color(0xFFBBBBBB)).make(),
5.wb,
'商品金额:'.text.size(28.sp).color(Color(0xFF333333)).make(),
'¥${(allPrice).toStringAsFixed(2)}'
.text
.size(28.sp)
.color(Color(0xFF333333))
.make(),
16.wb,
],
),
16.hb,
_createOrderModel != null
? Row(
children: [
Spacer(),
'运费:'.text.size(28.sp).color(Color(0xFF333333)).make(),
('¥${_createOrderModel!.fee}')
.text
.size(28.sp)
.color(Color(0xFF333333))
.make(),
16.wb,
],
)
: SizedBox(),
16.hb,
// Row(
// children: [
// Spacer(),
// '(小提示:京东自营商品加入购物车后一起下单,运费会更划算)'
// .text
// .size(18.sp)
// .color(Color(0xFFBBBBBB))
// .make(),
// ],
// ),
//16.hb,
Row(
children: [
Spacer(),
'应付金额:'.text.size(32.sp).color(Color(0xFF333333)).bold.make(),
'¥${allPrice + fee}'
.text
.size(32.sp)
.color(Color(0xFFE52E2E))
.bold
.make(),
16.wb,
],
)
],
),
);
}
_payWay() {
return Container(
padding:
EdgeInsets.only(left: 16.w, right: 16.w, top: 20.w, bottom: 20.w),
margin: EdgeInsets.symmetric(horizontal: 20.w),
width: double.infinity,
height: 72.w,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(24.w)),
color: Colors.white),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
'支付方式'.text.size(28.sp).color(Color(0xFF333333)).make(),
Spacer(),
Image.asset(
R.ASSETS_ICONS_ALIPAY_ROUND_PNG,
width: 40.w,
height: 40.w,
),
16.wb,
'支付宝'.text.size(28.sp).color(Color(0xFF333333)).make(),
],
),
);
}
Widget _goodCard(GoodDetailModel model) {
var top = RichText(
text: TextSpan(children: [
WidgetSpan(
child: _getKindWd(model.kind ?? 0),
),
TextSpan(
text: model.skuName,
style: TextStyle(fontSize: 28.sp, color: ktextPrimary)),
]),
maxLines: 2,
overflow: TextOverflow.ellipsis,
);
var mid = Container(
padding: EdgeInsets.symmetric(horizontal: 8.w, vertical: 10.w),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4.w), color: Color(0xFFF2F3F4)),
child: '规格:'.text.size(24.sp).color(Color(0xFFBBBBBB)).make(),
);
var bottom = Column(
children: [
Row(
children: [
92.wb,
'购买数量'.text.size(28.sp).color(Color(0xFF333333)).make(),
Spacer(),
_getBottomSuffix(GoodStatus.onSell, model.id!)
],
),
48.hb,
Row(
children: [
92.wb,
'配送方式'.text.size(28.sp).color(Color(0xFF333333)).make(),
Spacer(),
'快递配送'.text.size(28.sp).color(Color(0xFFBBBBBB)).make(),
10.wb,
],
),
],
);
int num = int.parse(_controllers.text);
var price = Row(
children: [
Spacer(),
'${_controllers.text}'
.text
.size(28.sp)
.color(Color(0xFFBBBBBB))
.make(),
5.wb,
'商品金额:'.text.size(28.sp).color(Color(0xFF333333)).make(),
'¥${(num * model.sellPrice!).toStringAsFixed(2)}'
.text
.size(28.sp)
.color(Color(0xFF333333))
.make(),
16.wb,
],
);
return Container(
alignment: Alignment.center,
height: 500.w,
margin: EdgeInsets.symmetric(horizontal: 20.w),
padding: EdgeInsets.all(16.w),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16.w),
),
child: Column(
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Stack(
children: [
Container(
width: 188.w,
height: 188.w,
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16.w),
),
child: FadeInImage.assetNetwork(
placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
image: model.goodsDetailImageVos![0].url ?? '',
height: 188.w,
width: 188.w,
),
),
Positioned(
child: Container(
height: 188.w,
width: 188.w,
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16.w),
),
child: _getGoodsStatusImg(GoodStatus.unSell) ??
SizedBox()))
],
),
20.wb,
Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Container(
child: top,
width: model.sellPrice! > 9999 ? 300.w : 320.w,
alignment: Alignment.topCenter,
),
10.hb,
mid,
//Spacer(),
10.hb,
],
),
),
Spacer(),
Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
8.hb,
'¥'
.richText
.withTextSpanChildren([
model.sellPrice!
.toStringAsFixed(2)
.textSpan
.size(28.sp)
.color(ktextPrimary)
.make(),
])
.color(ktextPrimary)
.size(28.sp)
.make(),
'x ${_controllers.text}'
.text
.size(24.sp)
.color(Color(0xFFBBBBBB))
.make(),
],
),
)
],
),
bottom,
Spacer(),
price,
30.hb,
],
),
);
}
String _getPointBehind(double num) {
var str = (num - num.toInt().toDouble()).toStringAsFixed(2);
return str.substring(str.length - 2);
}
Widget _getKindWd(int kind) {
switch (kind) {
case 1:
return Container(
// width: 90.w,
// height: 26.w,
padding: EdgeInsets.symmetric(horizontal: 6.w, vertical: 2.w),
margin: EdgeInsets.only(right: 10.w),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4.w),
gradient: LinearGradient(
begin: Alignment.centerLeft,
end: Alignment.centerRight,
colors: [Color(0xFFEC5329), Color(0xFFF58123)])),
child: '京东自营'.text.size(18.sp).color(Colors.white).make());
case 2:
return Container(
width: 90.w,
height: 26.w,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.centerLeft,
end: Alignment.centerRight,
colors: [Color(0xFFEC5329), Color(0xFFF58123)])),
child: '京东POP'.text.size(18.sp).color(Colors.white).make());
default:
return SizedBox();
}
}
Widget? _getGoodsStatusImg(GoodStatus status) {
switch (status) {
case GoodStatus.unSell:
return Container(
width: double.infinity,
height: double.infinity,
color: Color(0xFF000000).withOpacity(0.5),
alignment: Alignment.center,
child: Text(
'已下架',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 28.sp,
color: Colors.white),
),
);
case GoodStatus.onSell:
return null;
}
}
Widget _getBottomSuffix(GoodStatus status, int id) {
switch (status) {
case GoodStatus.onSell:
return Container(
width: 108.w + 64.w,
height: 40.w,
child: Row(
children: [
GestureDetector(
onTap: () async {
int num = int.parse(_controllers.text);
if (num > 1) {
_controllers.text = (num - 1).toString();
_goodsList[0].num = num - 1;
createOrder(_addressModel!.id!, _goodsList);
}
setState(() {});
},
child: Padding(
padding: EdgeInsets.only(right: 12.w),
child: Icon(
CupertinoIcons.minus,
size: 30.w,
),
),
),
Container(
width: 84.w,
height: 40.w,
decoration: BoxDecoration(
color: Color(0xFFF2F2F2),
borderRadius: BorderRadius.circular(4.w)),
child: TextField(
readOnly: true,
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
onChanged: (text) async {
var result = await changeNum(id, int.parse(text));
if (!result) {
// _controllers[index].text=
}
setState(() {});
},
controller: _controllers,
textAlign: TextAlign.center,
decoration: InputDecoration(
border: InputBorder.none,
isDense: true,
contentPadding: EdgeInsets.zero,
),
),
),
GestureDetector(
onTap: () async {
int num = int.parse(_controllers.text);
if (num < 10) {
_controllers.text =
(int.parse(_controllers.text) + 1).toString();
_goodsList[0].num = num + 1;
createOrder(_addressModel!.id!, _goodsList);
setState(() {});
}
},
child: Padding(
padding: EdgeInsets.only(left: 12.w),
child: Icon(
CupertinoIcons.plus,
size: 30.w,
),
),
)
],
),
);
case GoodStatus.unSell:
return '商品已下架'.text.size(24.sp).color(Color(0x80000000)).make();
}
}
Widget _emptyWidget() {
return Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Image.asset(
R.ASSETS_IMAGES_SHOP_CAR_EMPTY_PNG,
width: 400.w,
height: 400.w,
),
'暂时没有加购商品'.text.size(28.sp).color(Color(0xFFBBBBBB)).make()
],
),
);
}
Future<bool> changeNum(int jcookGoodsId, int num) async {
var cancel = BotToast.showLoading();
var base = await NetUtil().post(API.market.shopCarChangeNum,
params: {'jcookGoodsId': jcookGoodsId, 'num': num});
if (!(base.status ?? false)) {
BotToast.showText(text: base.message ?? '');
}
cancel();
return base.status ?? false;
}
}

@ -1,3 +1,7 @@
import 'package:aku_community/constants/api.dart';
import 'package:aku_community/utils/network/base_model.dart';
import 'package:aku_community/utils/network/net_util.dart';
class ShopCarFunc {
static GoodStatus getGoodsStatus(int jcook, int bee) {
if (jcook == 0) {

@ -2,8 +2,11 @@ import 'package:aku_community/base/base_style.dart';
import 'package:aku_community/const/resource.dart';
import 'package:aku_community/constants/api.dart';
import 'package:aku_community/models/market/shop_car/shop_car_list_model.dart';
import 'package:aku_community/ui/market/search/submit_order_page.dart';
import 'package:aku_community/ui/market/shop_car/shop_car_func.dart';
import 'package:aku_community/utils/network/base_model.dart';
import 'package:aku_community/utils/network/net_util.dart';
import 'package:aku_community/widget/bee_scaffold.dart';
import 'package:aku_community/widget/buttons/bee_check_radio.dart';
import 'package:aku_community/widget/buttons/end_button.dart';
import 'package:bot_toast/bot_toast.dart';
@ -14,6 +17,8 @@ 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_community/utils/headers.dart';
class ShopCarPage extends StatefulWidget {
const ShopCarPage({Key? key}) : super(key: key);
@ -26,6 +31,8 @@ class _ShopCarPageState extends State<ShopCarPage> {
bool _editStatus = false;
List<TextEditingController> _controllers = [];
List<ShopCarListModel> _models = [];
List<ShopCarListModel> _chooseModels = [];
EasyRefreshController _refreshController=EasyRefreshController();
//model
List<int> _selectIndex = [];
@ -35,63 +42,51 @@ class _ShopCarPageState extends State<ShopCarPage> {
double get total {
var num = 0.0;
if(_selectIndex.isEmpty) return 0.0;
_selectIndex.forEach((element) {
num += _models[element].sellPrice;
double sellPrice = _models[element].sellPrice??0;
int number = _models[element].num??0;
num += (sellPrice * number) ;
});
return num;
}
@override
void dispose() {
_controllers.forEach((element) {
element.dispose();
});
_refreshController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
automaticallyImplyLeading: false,
backgroundColor: Color(0xFFF9F9F9),
titleSpacing: 0,
title: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
GestureDetector(
onTap: () {
Get.back();
},
child: Material(
child: Align(
alignment: Alignment.centerLeft,
child: Icon(
CupertinoIcons.back,
size: 48.w,
),
),
),
),
'购物车'.text.size(32.sp).black.bold.make(),
],
),
actions: [
TextButton(
onPressed: () {
_editStatus = !_editStatus;
},
child: (_editStatus ? '完成' : '管理')
.text
.size(32.sp)
.black
.bold
.make())
],
),
return BeeScaffold(
title: '购物车'.text.size(32.sp).black.bold.make(),
titleSpacing: 0,
actions: [
TextButton(
onPressed: () {
_editStatus = !_editStatus;
setState(() {
});
},
child: (_editStatus ? '完成' : '管理')
.text
.size(32.sp)
.black
.bold
.make())
],
body: SafeArea(
child: Column(
children: [
10.hb,
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
@ -99,10 +94,11 @@ class _ShopCarPageState extends State<ShopCarPage> {
'${_models.length}件商品'.text.size(28.sp).black.make(),
],
),
16.heightBox,
10.hb,
Expanded(
child: EasyRefresh(
firstRefresh: true,
controller: _refreshController,
header: MaterialHeader(),
onRefresh: () async {
var base = await NetUtil().get(API.market.shopCarList);
@ -117,8 +113,10 @@ class _ShopCarPageState extends State<ShopCarPage> {
_models.forEach((element) {
_controllers.add(
TextEditingController(text: element.num.toString()));
});
}
);
}
print(_models.length);
if (mounted) {
setState(() {});
}
@ -135,42 +133,57 @@ class _ShopCarPageState extends State<ShopCarPage> {
],
),
),
bottomNavigationBar: Container(
bottomNavi: Container(
width: double.infinity,
height: 100.w,
color: Colors.white,
child: Row(
children: [
10.widthBox,
20.widthBox,
GestureDetector(
onTap: () {
if (_allSelect) {
_selectIndex.clear();
_chooseModels.clear();
} else {
_selectIndex.clear();
_chooseModels.clear();
_chooseModels.addAll(_models);
_selectIndex
.addAll(List.generate(_models.length, (index) => index));
}
setState(() {});
},
child: Container(
width: 44.w,
height: 44.w,
width: 120.w,
height: 60.w,
color: Colors.transparent,
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(22.w),
border: Border.all(color: Color(0xFFBBBBBB))),
child: AnimatedOpacity(
duration: Duration(milliseconds: 500),
opacity: _allSelect ? 1 : 0,
child: Container(
width: 24.w,
height: 24.w,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12.w),
color: Color(0xFFE52E2E),
child: Row(
children: [
Container(
width: 44.w,
height: 44.w,
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(22.w),
border: Border.all(color: Color(0xFFBBBBBB))),
child: AnimatedOpacity(
duration: Duration(milliseconds: 500),
opacity: _allSelect ? 1 : 0,
child: Container(
width: 24.w,
height: 24.w,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12.w),
color: Color(0xFFE52E2E),
),
),
),
),
),
5.widthBox,
'全选'.text.size(28.sp).color(ktextPrimary).make(),
],
),
),
),
@ -193,7 +206,7 @@ class _ShopCarPageState extends State<ShopCarPage> {
),
20.widthBox,
EndButton(
onPressed: _editStatus ? _delete : _settleEnd,
onPressed: _editStatus ? _delete: _settleEnd,
text: (_editStatus ? '删除' : '结算')
.text
.size(32.sp)
@ -206,23 +219,61 @@ class _ShopCarPageState extends State<ShopCarPage> {
);
}
Future _settleEnd() async {}
Future _settleEnd() async {
if(_chooseModels.isEmpty){
BotToast.showText(text: '请先选择商品');
}else
Get.to(()=>SubmitOrderPage(models: _chooseModels,));
}
Future _delete() async {
await NetUtil().post(
API.market.shopCarDelete,
params: {
'jcookGoodsIds': _selectIndex.map((e) => _models[e].id).toList()
},
showMessage: true,
);
if(_selectIndex.isNotEmpty){
bool? result =
await Get.dialog(CupertinoAlertDialog(
title: '您确定要删除该商品吗?'.text.isIntrinsic.size(30.sp).make(),
actions: [
CupertinoDialogAction(
child: '取消'.text.black.isIntrinsic.make(),
onPressed: () => Get.back(),
),
CupertinoDialogAction(
child: '确定'
.text
.color(Colors.orange)
.isIntrinsic
.make(),
onPressed: () => Get.back(result: true),
),
],
));
if (result == true) {
BaseModel model = await NetUtil().post(
API.market.shopCarDelete,
params: {
'jcookGoodsIds': _selectIndex.map((e) => _models[e].id).toList()
},
showMessage: true,
);
if(model.status!=null){
if(model.status!){
_selectIndex.clear();
_refreshController.callRefresh();
}
}
};
}else{
BotToast.showText(text: '请先选择商品');
}
}
Widget _goodCard(ShopCarListModel model, int index) {
var top = RichText(
text: TextSpan(children: [
WidgetSpan(
child: _getKindWd(model.kind),
child: _getKindWd(model.kind??0),
),
TextSpan(
text: model.skuName,
@ -241,19 +292,20 @@ class _ShopCarPageState extends State<ShopCarPage> {
.color(Color(0xFFBBBBBB))
.make(),
);
double sellPrice = model.sellPrice??0;
var bottom = Row(
children: [
'¥'
.richText
.withTextSpanChildren([
model.sellPrice
sellPrice
.toInt()
.toString()
.textSpan
.size(40.sp)
.color(Color(0xFFE52E2E))
.make(),
'.${_getPointBehind(model.sellPrice)}'
'.${_getPointBehind(sellPrice)}'
.textSpan
.size(28.sp)
.color(Color(0xFFE52E2E))
@ -263,13 +315,13 @@ class _ShopCarPageState extends State<ShopCarPage> {
.size(28.sp)
.make(),
Spacer(),
_getBottomSuffix(model.goodStatus, model.id, index)
_getBottomSuffix(model.goodStatus, model.id!, index)
],
);
return Container(
alignment: Alignment.center,
height: 260.w,
margin: EdgeInsets.symmetric(horizontal: 20.w),
margin: EdgeInsets.only(left: 20.w,right: 20.w,bottom: 20.w),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16.w),
@ -279,42 +331,68 @@ class _ShopCarPageState extends State<ShopCarPage> {
children: [
GestureDetector(
onTap: () {
if (_selectIndex.contains(model.id)) {
if (_selectIndex.contains(index)) {
_selectIndex.remove(index);
_chooseModels.remove(model);
} else {
_selectIndex.add(index);
_chooseModels.add(model);
}
setState(() {});
},
child: Container(
padding: EdgeInsets.symmetric(horizontal: 16.w),
color: Colors.transparent,
height: double.infinity,
alignment: Alignment.center,
child: BeeCheckRadio(
value: model.id,
groupValue: _selectIndex,
backColor: Colors.white,
indent: Container(
width: 24.w,
height: 24.w,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12.w),
color: Color(0xFFE52E2E),
child: Container(
padding: EdgeInsets.symmetric(horizontal: 16.w),
height: double.infinity,
alignment: Alignment.center,
child: BeeCheckRadio(
value: index,
groupValue: _selectIndex,
backColor: Colors.white,
indent: Container(
width: 24.w,
height: 24.w,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12.w),
color: Color(0xFFE52E2E),
),
),
),
),
),
),
Container(
width: 220.w,
height: 220.w,
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16.w),
image: DecorationImage(
fit: BoxFit.scaleDown,
image: NetworkImage(API.image(model.mainPhoto)))),
child: _getGoodsStatusImg(model.goodStatus),
// Container(
// width: 220.w,
// height: 220.w,
// clipBehavior: Clip.antiAlias,
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(16.w),
// image: DecorationImage(
// fit: BoxFit.scaleDown,
// image: NetworkImage(model.mainPhoto??''))),
// child: _getGoodsStatusImg(model.goodStatus),
// ),
Stack(
children: [
Container(
width: 220.w,
height: 220.w,
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16.w),
),
child: FadeInImage.assetNetwork(
placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
image: model.mainPhoto??'',
height: 220.w,
width: 220.w,
),
),
Positioned(child: _getGoodsStatusImg(GoodStatus.onSell)??SizedBox())
],
),
16.widthBox,
Column(
@ -372,7 +450,7 @@ class _ShopCarPageState extends State<ShopCarPage> {
Widget? _getGoodsStatusImg(GoodStatus status) {
switch (status) {
case GoodStatus.onSell:
case GoodStatus.unSell:
return Container(
width: double.infinity,
height: double.infinity,
@ -386,7 +464,7 @@ class _ShopCarPageState extends State<ShopCarPage> {
color: Colors.white),
),
);
case GoodStatus.unSell:
case GoodStatus.onSell:
return null;
}
}
@ -402,10 +480,13 @@ class _ShopCarPageState extends State<ShopCarPage> {
GestureDetector(
onTap: () async {
int num = int.parse(_controllers[index].text);
var result = await changeNum(id, num - 1);
if (result) {
_controllers[index].text = (num - 1).toString();
if(num>1){
var result = await changeNum(id, num - 1);
if (result) {
_controllers[index].text = (num - 1).toString();
}
}
setState(() {});
},
child: Padding(
@ -423,11 +504,13 @@ class _ShopCarPageState extends State<ShopCarPage> {
color: Color(0xFFF2F2F2),
borderRadius: BorderRadius.circular(4.w)),
child: TextField(
readOnly: true,
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
onChanged: (text) async {
var result = await changeNum(id, int.parse(text));
if (!result) {
// _controllers[index].text=
}
setState(() {});
@ -443,13 +526,18 @@ class _ShopCarPageState extends State<ShopCarPage> {
),
GestureDetector(
onTap: () async {
var result = await changeNum(
id, int.parse(_controllers[index].text) + 1);
if (result) {
_controllers[index].text =
(int.parse(_controllers[index].text) + 1).toString();
int num = int.parse(_controllers[index].text);
if(num<10){
var result = await changeNum(
id, int.parse(_controllers[index].text) + 1);
if (result) {
_controllers[index].text =
(int.parse(_controllers[index].text) + 1).toString();
}
setState(() {});
}
setState(() {});
},
child: Padding(
padding: EdgeInsets.only(left: 12.w),

@ -42,9 +42,9 @@ class HomeSliverAppBarState extends State<HomeSliverAppBar> {
titleSpacing: 3,
actions: widget.actions,
title: widget.title,
floating: true,
floating: false,
pinned: true,
snap: true,
snap: false,
elevation: 0,
backgroundColor: _displayColor,
flexibleSpace: widget.flexibleSpace,

Loading…
Cancel
Save