Browse Source

更改

master
w-R 3 years ago
parent
commit
38f9b67153
  1. 146
      lib/retrofit/data/shoppingCart.dart
  2. 5
      lib/retrofit/min_api.dart
  3. 29
      lib/store/store_order.dart
  4. 183
      lib/store/store_view/store_order_list.dart

146
lib/retrofit/data/shoppingCart.dart

@ -0,0 +1,146 @@
/// cartSum : 0
/// numberOfPeople : 0
/// selected : 0
/// shoppingCartSkuItemList : [{"buyNum":0,"createTime":"","groupId":0,"id":0,"platterList":[{"deleted":true,"id":0,"productId":0,"required":true,"skuId":0}],"productId":0,"productName":"","selected":0,"skuImg":"","skuName":"","skuPrice":0,"skuStock":0,"storeId":0,"tableId":0}]
/// storeId : 0
/// storeName : ""
/// tableId : 0
class ShoppingCart {
int cartSum;
int numberOfPeople;
int selected;
List<ShoppingCartSkuItemListBean> shoppingCartSkuItemList;
int storeId;
String storeName;
int tableId;
static ShoppingCart fromMap(Map<String, dynamic> map) {
if (map == null) return null;
ShoppingCart shoppingCartBean = ShoppingCart();
shoppingCartBean.cartSum = map['cartSum'];
shoppingCartBean.numberOfPeople = map['numberOfPeople'];
shoppingCartBean.selected = map['selected'];
shoppingCartBean.shoppingCartSkuItemList = List()..addAll(
(map['shoppingCartSkuItemList'] as List ?? []).map((o) => ShoppingCartSkuItemListBean.fromMap(o))
);
shoppingCartBean.storeId = map['storeId'];
shoppingCartBean.storeName = map['storeName'];
shoppingCartBean.tableId = map['tableId'];
return shoppingCartBean;
}
Map toJson() => {
"cartSum": cartSum,
"numberOfPeople": numberOfPeople,
"selected": selected,
"shoppingCartSkuItemList": shoppingCartSkuItemList,
"storeId": storeId,
"storeName": storeName,
"tableId": tableId,
};
}
/// buyNum : 0
/// createTime : ""
/// groupId : 0
/// id : 0
/// platterList : [{"deleted":true,"id":0,"productId":0,"required":true,"skuId":0}]
/// productId : 0
/// productName : ""
/// selected : 0
/// skuImg : ""
/// skuName : ""
/// skuPrice : 0
/// skuStock : 0
/// storeId : 0
/// tableId : 0
class ShoppingCartSkuItemListBean {
int buyNum;
String createTime;
int groupId;
int id;
List<PlatterListBean> platterList;
int productId;
String productName;
int selected;
String skuImg;
String skuName;
int skuPrice;
int skuStock;
int storeId;
int tableId;
static ShoppingCartSkuItemListBean fromMap(Map<String, dynamic> map) {
if (map == null) return null;
ShoppingCartSkuItemListBean shoppingCartSkuItemListBean = ShoppingCartSkuItemListBean();
shoppingCartSkuItemListBean.buyNum = map['buyNum'];
shoppingCartSkuItemListBean.createTime = map['createTime'];
shoppingCartSkuItemListBean.groupId = map['groupId'];
shoppingCartSkuItemListBean.id = map['id'];
shoppingCartSkuItemListBean.platterList = List()..addAll(
(map['platterList'] as List ?? []).map((o) => PlatterListBean.fromMap(o))
);
shoppingCartSkuItemListBean.productId = map['productId'];
shoppingCartSkuItemListBean.productName = map['productName'];
shoppingCartSkuItemListBean.selected = map['selected'];
shoppingCartSkuItemListBean.skuImg = map['skuImg'];
shoppingCartSkuItemListBean.skuName = map['skuName'];
shoppingCartSkuItemListBean.skuPrice = map['skuPrice'];
shoppingCartSkuItemListBean.skuStock = map['skuStock'];
shoppingCartSkuItemListBean.storeId = map['storeId'];
shoppingCartSkuItemListBean.tableId = map['tableId'];
return shoppingCartSkuItemListBean;
}
Map toJson() => {
"buyNum": buyNum,
"createTime": createTime,
"groupId": groupId,
"id": id,
"platterList": platterList,
"productId": productId,
"productName": productName,
"selected": selected,
"skuImg": skuImg,
"skuName": skuName,
"skuPrice": skuPrice,
"skuStock": skuStock,
"storeId": storeId,
"tableId": tableId,
};
}
/// deleted : true
/// id : 0
/// productId : 0
/// required : true
/// skuId : 0
class PlatterListBean {
bool deleted;
int id;
int productId;
bool required;
int skuId;
static PlatterListBean fromMap(Map<String, dynamic> map) {
if (map == null) return null;
PlatterListBean platterListBean = PlatterListBean();
platterListBean.deleted = map['deleted'];
platterListBean.id = map['id'];
platterListBean.productId = map['productId'];
platterListBean.required = map['required'];
platterListBean.skuId = map['skuId'];
return platterListBean;
}
Map toJson() => {
"deleted": deleted,
"id": id,
"productId": productId,
"required": required,
"skuId": skuId,
};
}

5
lib/retrofit/min_api.dart

@ -122,6 +122,11 @@ abstract class MinApiService {
@GET("/product/queryMiNiProductDetail?id={id}") @GET("/product/queryMiNiProductDetail?id={id}")
Future<BaseData<MiNiDetail>> miNiDetail(@Path("id") String id); Future<BaseData<MiNiDetail>> miNiDetail(@Path("id") String id);
///
@POST("shoppingcart")
Future<BaseData<FindMiNiGroupList>> shoppingCart(
@Body() Map<String, dynamic> param,Map<String, dynamic> header);
} }

29
lib/store/store_order.dart

@ -45,6 +45,8 @@ class _StoreOrderPage extends State<StoreOrderPage>
List<Activity> activitys; List<Activity> activitys;
RefreshController refreshController; RefreshController refreshController;
List<Widget> _widgetOptions; List<Widget> _widgetOptions;
int allCount = 0;
double allPrice = 0;
ScrollController controller = ScrollController(); ScrollController controller = ScrollController();
@ -59,13 +61,13 @@ class _StoreOrderPage extends State<StoreOrderPage>
); );
_widgetOptions = [ _widgetOptions = [
StoreOrderListPage( StoreOrderListPage(widget.arguments, activitys, storeInfo, controller,
widget.arguments, (ac, ap) {
activitys, setState(() {
storeInfo, allCount = ac;
controller, allPrice = ap;
), });
}),
///, ///,
StoreActivity( StoreActivity(
@ -116,7 +118,8 @@ class _StoreOrderPage extends State<StoreOrderPage>
child: DefaultTabController( child: DefaultTabController(
length: 2, length: 2,
child: SmartRefresher( child: SmartRefresher(
controller: refreshController = RefreshController(initialRefresh: false), controller: refreshController =
RefreshController(initialRefresh: false),
enablePullDown: true, enablePullDown: true,
enablePullUp: false, enablePullUp: false,
header: MyHeader(), header: MyHeader(),
@ -131,7 +134,8 @@ class _StoreOrderPage extends State<StoreOrderPage>
(BuildContext context, bool innerBoxIsScrolled) { (BuildContext context, bool innerBoxIsScrolled) {
return [ return [
SliverOverlapAbsorber( SliverOverlapAbsorber(
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context), handle: NestedScrollView.sliverOverlapAbsorberHandleFor(
context),
sliver: SliverAppBar( sliver: SliverAppBar(
expandedHeight: (storeInfo != null && expandedHeight: (storeInfo != null &&
storeInfo.couponVOList != null) storeInfo.couponVOList != null)
@ -297,7 +301,7 @@ class _StoreOrderPage extends State<StoreOrderPage>
), ),
), ),
Text( Text(
"19.00", "" + allPrice.toString(),
style: TextStyle( style: TextStyle(
fontSize: 20.sp, fontSize: 20.sp,
fontWeight: MyFontWeight.medium, fontWeight: MyFontWeight.medium,
@ -348,7 +352,7 @@ class _StoreOrderPage extends State<StoreOrderPage>
child: RoundButton( child: RoundButton(
width: 17, width: 17,
height: 17, height: 17,
text: "1", text: allCount.toString(),
textColor: Colors.white, textColor: Colors.white,
fontWeight: MyFontWeight.regular, fontWeight: MyFontWeight.regular,
backgroup: Color(0xFF32A060), backgroup: Color(0xFF32A060),
@ -469,7 +473,8 @@ class _StoreOrderPage extends State<StoreOrderPage>
// return shoppGoodsItem(); // return shoppGoodsItem();
return GestureDetector( return GestureDetector(
onTap: () {}, onTap: () {},
child: shoppGoodsItem(productLists[position], position), child:
shoppGoodsItem(productLists[position], position),
); );
}, },
), ),

183
lib/store/store_view/store_order_list.dart

@ -1,12 +1,10 @@
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/data/activity.dart'; import 'package:huixiang/retrofit/data/activity.dart';
import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/base_data.dart';
import 'package:huixiang/retrofit/data/findMiNiGroupList.dart'; import 'package:huixiang/retrofit/data/findMiNiGroupList.dart';
import 'package:huixiang/retrofit/data/findMiNiGroupList.dart';
import 'package:huixiang/retrofit/data/findMiNiGroupList.dart';
import 'package:huixiang/retrofit/data/findMiNiGroupList.dart';
import 'package:huixiang/retrofit/data/miNiDetail.dart'; import 'package:huixiang/retrofit/data/miNiDetail.dart';
import 'package:huixiang/retrofit/data/store_info.dart'; import 'package:huixiang/retrofit/data/store_info.dart';
import 'package:huixiang/retrofit/min_api.dart'; import 'package:huixiang/retrofit/min_api.dart';
@ -22,13 +20,10 @@ class StoreOrderListPage extends StatefulWidget {
final List<Activity> activitys; final List<Activity> activitys;
final StoreInfo storeInfo; final StoreInfo storeInfo;
final ScrollController controller; final ScrollController controller;
final Function(int allCount, double allPrice) fc;
StoreOrderListPage( StoreOrderListPage(
this.arguments, this.arguments, this.activitys, this.storeInfo, this.controller, this.fc);
this.activitys,
this.storeInfo,
this.controller,
);
@override @override
State<StatefulWidget> createState() { State<StatefulWidget> createState() {
@ -36,24 +31,7 @@ class StoreOrderListPage extends StatefulWidget {
} }
} }
class testModel {
String name;
bool isSelected;
testModel(String name) {
this.name = name;
this.isSelected = false;
}
}
class _StoreOrderListPage extends State<StoreOrderListPage> { class _StoreOrderListPage extends State<StoreOrderListPage> {
List<testModel> temperatureStoreList = [
testModel("正常冰"),
testModel("少冰"),
testModel("多冰"),
testModel("去冰")
];
List<testModel> sweetnessStoreList = [testModel("正常糖"), testModel("5分糖")];
int isSelected = 0; int isSelected = 0;
int isChoice = 0; int isChoice = 0;
int tempClickIndex = 0; int tempClickIndex = 0;
@ -127,6 +105,18 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
} }
} }
///
addsShoppingCart() async {
BaseData baseDate = await apiService.creditOrder({
"parentId": widget.arguments["parentId"],
"skuImg": widget.arguments["skuImg"],
"skuNameStr": widget.arguments["skuNameStr"],
"skuPrice": widget.arguments["skuPrice"],
"skuStock": widget.arguments["skuStock"],
});
if (baseDate != null && baseDate.isSuccess) {}
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(
@ -157,7 +147,7 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
// controller: widget.controller, // controller: widget.controller,
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
itemBuilder: (context, position) { itemBuilder: (context, position) {
return goodsItem(productListBeans[position], position); return goodsItem(position);
}, },
), ),
), ),
@ -204,7 +194,7 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
); );
} }
Widget goodsItem(ProductListBean productListBean, position) { Widget goodsItem(position) {
return Container( return Container(
color: Colors.white, color: Colors.white,
padding: EdgeInsets.only(right: 16.w, bottom: 10.h, top: 10.h), padding: EdgeInsets.only(right: 16.w, bottom: 10.h, top: 10.h),
@ -214,7 +204,9 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
children: [ children: [
SizedBox(width: 12.w), SizedBox(width: 12.w),
MImage( MImage(
productListBean != null ? productListBean.imgPath : "", productListBeans[position] != null
? productListBeans[position].imgPath
: "",
width: 70, width: 70,
height: 70, height: 70,
fit: BoxFit.cover, fit: BoxFit.cover,
@ -227,7 +219,7 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( Text(
productListBean.productName, productListBeans[position].productName,
style: TextStyle( style: TextStyle(
color: Colors.black, color: Colors.black,
fontSize: 13.sp, fontSize: 13.sp,
@ -239,7 +231,7 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
children: [ children: [
Expanded( Expanded(
child: Text( child: Text(
productListBean.shortName, productListBeans[position].shortName,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
maxLines: 2, maxLines: 2,
style: TextStyle( style: TextStyle(
@ -269,7 +261,7 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
), ),
), ),
Text( Text(
productListBean.price, productListBeans[position].price,
style: TextStyle( style: TextStyle(
color: Color(0xFFFF7A1A), color: Color(0xFFFF7A1A),
fontSize: 11.sp, fontSize: 11.sp,
@ -290,7 +282,7 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
), ),
SizedBox(width: 10), SizedBox(width: 10),
Text( Text(
productListBean.applyPrice, productListBeans[position].applyPrice,
style: TextStyle( style: TextStyle(
color: Color(0xFFA29E9E), color: Color(0xFFA29E9E),
fontSize: 10.sp, fontSize: 10.sp,
@ -302,11 +294,10 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
], ],
), ),
Spacer(), Spacer(),
true productListBeans[position].attrStyle == 1
? GestureDetector( ? GestureDetector(
onTap: () { onTap: () {
// showStoreSelector(productListBean); queryMiNiDetail(productListBeans[position].id);
queryMiNiDetail(productListBean.id);
}, },
child: RoundButton( child: RoundButton(
width: 49.w, width: 49.w,
@ -320,18 +311,33 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
), ),
) )
: InkWell( : InkWell(
onTap: () {}, onTap: () {
setState(() {
{
if (productListBeans[position].buyNum > 0)
productListBeans[position].buyNum--;
int allCount = 0;
double allPrice = 0;
productListBeans.forEach((element) {
allCount += element.buyNum;
allPrice += double.parse(element.price) *
element.buyNum;
});
widget.fc(allCount, allPrice);
}
});
},
child: Image.asset( child: Image.asset(
"assets/image/reduce.png", "assets/image/reduce.png",
width: 22, width: 22,
height: 22, height: 22,
), ),
), ),
if (false) if (productListBeans[position].attrStyle == 0)
Padding( Padding(
padding: EdgeInsets.only(left: 8, right: 8), padding: EdgeInsets.only(left: 8, right: 8),
child: Text( child: Text(
productListBean.buyNum.toString(), productListBeans[position].buyNum.toString(),
style: TextStyle( style: TextStyle(
color: Colors.black, color: Colors.black,
fontSize: 14.sp, fontSize: 14.sp,
@ -339,9 +345,23 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
), ),
), ),
), ),
if (false) if (productListBeans[position].attrStyle == 0)
InkWell( InkWell(
onTap: () {}, onTap: () {
setState(() {
{
productListBeans[position].buyNum++;
int allCount = 0;
double allPrice = 0;
productListBeans.forEach((element) {
allCount += element.buyNum;
allPrice += double.parse(element.price) *
element.buyNum;
});
widget.fc(allCount, allPrice);
}
});
},
child: Image.asset( child: Image.asset(
"assets/image/add.png", "assets/image/add.png",
width: 22, width: 22,
@ -364,6 +384,8 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
/// ///
showStoreSelector(MiNiDetail miNiDetail) { showStoreSelector(MiNiDetail miNiDetail) {
String selectSku = "";
int selectCount = 1;
showModalBottomSheet( showModalBottomSheet(
context: context, context: context,
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
@ -411,7 +433,7 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
Padding( Padding(
padding: EdgeInsets.only(top: 4, bottom: 7), padding: EdgeInsets.only(top: 4, bottom: 7),
child: Text( child: Text(
"已选:正常冰", "已选:" + selectSku,
style: TextStyle( style: TextStyle(
color: Color(0xFF727272), color: Color(0xFF727272),
fontSize: 11.sp, fontSize: 11.sp,
@ -457,19 +479,33 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
SizedBox( SizedBox(
height: 23, height: 23,
), ),
Expanded(child: ListView.builder( Expanded(
child: ListView.builder(
itemCount: miNiDetail.attrList.length, itemCount: miNiDetail.attrList.length,
scrollDirection: Axis.vertical, scrollDirection: Axis.vertical,
physics: BouncingScrollPhysics(), physics: BouncingScrollPhysics(),
itemBuilder: (context, position) { itemBuilder: (context, position) {
return attrItem(() { return attrItem(() {
state(() { state(() {
for (var i = 0; i < miNiDetail.attrList[position].attrValueList.length; i++) { for (var i = 0;
i <
miNiDetail
.attrList[position].attrValueList.length;
i++) {
if (tempClickIndex == i) if (tempClickIndex == i)
miNiDetail.attrList[position].attrValueList[i].isSelected = true; miNiDetail.attrList[position].attrValueList[i]
.isSelected = true;
else else
miNiDetail.attrList[position].attrValueList[i].isSelected = false; miNiDetail.attrList[position].attrValueList[i]
.isSelected = false;
} }
selectSku = "";
miNiDetail.attrList.forEach((e0) {
e0.attrValueList.forEach((e1) {
if (e1.isSelected ?? false)
selectSku += e1.attrValue + " ";
});
});
}); });
}, miNiDetail.attrList[position]); }, miNiDetail.attrList[position]);
}, },
@ -490,7 +526,11 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
), ),
)), )),
InkWell( InkWell(
onTap: () {}, onTap: () {
state(() {
if (selectCount > 1) selectCount--;
});
},
child: Image.asset( child: Image.asset(
"assets/image/reduce.png", "assets/image/reduce.png",
width: 22, width: 22,
@ -500,7 +540,7 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
Padding( Padding(
padding: EdgeInsets.only(left: 8, right: 8), padding: EdgeInsets.only(left: 8, right: 8),
child: Text( child: Text(
"1", selectCount.toString(),
style: TextStyle( style: TextStyle(
color: Colors.black, color: Colors.black,
fontSize: 14.sp, fontSize: 14.sp,
@ -509,7 +549,11 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
), ),
), ),
InkWell( InkWell(
onTap: () {}, onTap: () {
state(() {
selectCount++;
});
},
child: Image.asset( child: Image.asset(
"assets/image/add.png", "assets/image/add.png",
width: 22, width: 22,
@ -522,7 +566,18 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
height: 24, height: 24,
), ),
GestureDetector( GestureDetector(
onTap: (){}, onTap: () {
bool flag = false;
miNiDetail.productSkuVOList.forEach((element) {
if (selectSku.trim() == element.skuNameStr) {
Navigator.of(context).pop();
flag = true;
}
});
if (!flag)
SmartDialog.showToast("请选择規格!",
alignment: Alignment.center);
},
child: RoundButton( child: RoundButton(
width: double.infinity, width: double.infinity,
height: 54.h, height: 54.h,
@ -535,6 +590,9 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
// padding: EdgeInsets.symmetric(vertical: 5.h), // padding: EdgeInsets.symmetric(vertical: 5.h),
), ),
), ),
SizedBox(
height: 21.h,
),
], ],
), ),
); );
@ -543,21 +601,20 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
); );
} }
Widget attrItem(Function fc,AttrListBean attrListBean){ Widget attrItem(Function fc, AttrListBean attrListBean) {
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( Padding(
attrListBean.attrName, padding: EdgeInsets.only(top: 24, bottom: 16),
style: TextStyle( child: Text(
color: Colors.black, attrListBean.attrName,
fontSize: 14.sp, style: TextStyle(
fontWeight: MyFontWeight.regular, color: Colors.black,
), fontSize: 14.sp,
), fontWeight: MyFontWeight.regular,
SizedBox( ),
height: 15, )),
),
sweetnessStore(fc, attrListBean.attrValueList), sweetnessStore(fc, attrListBean.attrValueList),
], ],
); );
@ -583,7 +640,8 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
tempClickIndex = index; tempClickIndex = index;
fc(); fc();
}, },
child: sweetnessItem(arrays[index].attrValue, arrays[index].isSelected??false), child: sweetnessItem(
arrays[index].attrValue, arrays[index].isSelected ?? false),
); );
}, },
); );
@ -609,5 +667,4 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
), ),
); );
} }
} }

Loading…
Cancel
Save