Browse Source

Merge remote-tracking branch 'origin/new_revision_app' into new_revision_app

dart3_last
fmk 2 years ago
parent
commit
7b1d891879
  1. 3
      lib/mine/recharge_page.dart
  2. 19
      lib/retrofit/data/miNiDetail.dart
  3. 115
      lib/retrofit/data/shoppingCart.dart
  4. 4
      lib/settlement/settlement.dart
  5. 11
      lib/store/store_order.dart
  6. 919
      lib/store/store_view/product_meals_sku.dart
  7. 5
      lib/store/store_view/shop_car.dart
  8. 61
      lib/store/store_view/shop_goods.dart
  9. 334
      lib/store/store_view/shop_goods_car.dart
  10. 4
      lib/store/store_view/store_order_list.dart
  11. 2
      lib/view_widget/selector_store_dialog.dart

3
lib/mine/recharge_page.dart

@ -665,9 +665,6 @@ class _RechargePage extends State<RechargePage> {
// alignment: Alignment.center);
// return;
// }
BaseData<dynamic> baseData = await apiService.recharge({
"amount": 0,
"rechargeActId": rechargeA[selectIndex].id,

19
lib/retrofit/data/miNiDetail.dart

@ -472,6 +472,7 @@ class ProductInfoList {
List<SkuInfoList> _skuInfoList;
List<ProductAttrInfoList> _productAttrInfoList;
int _number;
int _count = 0;
ProductInfoList copyWith({ String productId,
String productName,
String productImg,
@ -493,7 +494,15 @@ class ProductInfoList {
bool get allSku => _allSku;
List<SkuInfoList> get skuInfoList => _skuInfoList;
List<ProductAttrInfoList> get productAttrInfoList => _productAttrInfoList;
int get number => _number;
int number;
int get count => _count;
set count(int value) {
_count = value;
}
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
@ -540,6 +549,7 @@ class ProductAttrInfoList {
String _attrId;
String _attrName;
List<AttrValueList> _attrValueList;
String _selectSku;
ProductAttrInfoList copyWith({ String attrId,
String attrName,
List<AttrValueList> attrValueList,
@ -551,6 +561,13 @@ class ProductAttrInfoList {
String get attrName => _attrName;
List<AttrValueList> get attrValueList => _attrValueList;
String get selectSku => _selectSku;
set selectSku(String value) {
_selectSku = value;
}
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['attrId'] = _attrId;

115
lib/retrofit/data/shoppingCart.dart

@ -77,6 +77,7 @@ class ShoppingCartSkuItemListBean {
String groupId;
String id;
List<PlatterListBean> platterList;
List<SetMealDataList> setMealDataList;
String productId;
String productName;
String skuId;
@ -98,6 +99,9 @@ class ShoppingCartSkuItemListBean {
shoppingCartSkuItemListBean.platterList = []..addAll(
(map['platterList'] as List ?? []).map((o) => PlatterListBean.fromJson(o))
);
shoppingCartSkuItemListBean.setMealDataList = []..addAll(
(map['setMealDataList'] as List ?? []).map((o) => SetMealDataList.fromJson(o))
);
shoppingCartSkuItemListBean.productId = map['productId'];
shoppingCartSkuItemListBean.skuId = map['skuId'];
shoppingCartSkuItemListBean.productName = map['productName'];
@ -117,6 +121,7 @@ class ShoppingCartSkuItemListBean {
"groupId": groupId,
"id": id,
"platterList": platterList,
"setMealDataList":setMealDataList,
"productId": productId,
"skuId": skuId,
"productName": productName,
@ -162,6 +167,116 @@ class PlatterListBean {
"skuId": skuId,
};
}
/// groupName : "锅底2选1"
/// productInfoList : [{"skuId":"1491652895857180672","skuName":"中辣","buyNumber":1,"productId":"1315903449707053056","sellPrice":48.0,"productName":"牛棒骨汤鸳鸯锅"}]
class SetMealDataList {
SetMealDataList({
String groupName,
List<ProductInfoList> productInfoList,}){
_groupName = groupName;
_productInfoList = productInfoList;
}
SetMealDataList.fromJson(dynamic json) {
_groupName = json['groupName'];
if (json['productInfoList'] != null) {
_productInfoList = [];
json['productInfoList'].forEach((v) {
_productInfoList.add(ProductInfoList.fromJson(v));
});
}
}
String _groupName;
List<ProductInfoList> _productInfoList;
SetMealDataList copyWith({ String groupName,
List<ProductInfoList> productInfoList,
}) => SetMealDataList( groupName: groupName ?? _groupName,
productInfoList: productInfoList ?? _productInfoList,
);
String get groupName => _groupName;
List<ProductInfoList> get productInfoList => _productInfoList;
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['groupName'] = _groupName;
if (_productInfoList != null) {
map['productInfoList'] = _productInfoList.map((v) => v.toJson()).toList();
}
return map;
}
}
/// skuId : "1491652895857180672"
/// skuName : "中辣"
/// buyNumber : 1
/// productId : "1315903449707053056"
/// sellPrice : 48.0
/// productName : "牛棒骨汤鸳鸯锅"
class ProductInfoList {
ProductInfoList({
String skuId,
String skuName,
int buyNumber,
String productId,
double sellPrice,
String productName,}){
_skuId = skuId;
_skuName = skuName;
_buyNumber = buyNumber;
_productId = productId;
_sellPrice = sellPrice;
_productName = productName;
}
ProductInfoList.fromJson(dynamic json) {
_skuId = json['skuId'];
_skuName = json['skuName'];
_buyNumber = json['buyNumber'];
_productId = json['productId'];
_sellPrice = json['sellPrice'];
_productName = json['productName'];
}
String _skuId;
String _skuName;
int _buyNumber;
String _productId;
double _sellPrice;
String _productName;
ProductInfoList copyWith({ String skuId,
String skuName,
int buyNumber,
String productId,
double sellPrice,
String productName,
}) => ProductInfoList( skuId: skuId ?? _skuId,
skuName: skuName ?? _skuName,
buyNumber: buyNumber ?? _buyNumber,
productId: productId ?? _productId,
sellPrice: sellPrice ?? _sellPrice,
productName: productName ?? _productName,
);
String get skuId => _skuId;
String get skuName => _skuName;
int get buyNumber => _buyNumber;
String get productId => _productId;
double get sellPrice => _sellPrice;
String get productName => _productName;
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['skuId'] = _skuId;
map['skuName'] = _skuName;
map['buyNumber'] = _buyNumber;
map['productId'] = _productId;
map['sellPrice'] = _sellPrice;
map['productName'] = _productName;
return map;
}
}
/// id : "1437254523520286720"
/// createTime : "2021-09-13 11:19:16"

4
lib/settlement/settlement.dart

@ -115,7 +115,7 @@ class _Settlement extends State<Settlement> {
token: minToken,
tenant: tenant,
storeId: storeId,
showLoading: true);
);
if (promotions != null && promotions != "" && tableId <= 0) {
queryOrderInfo(
address != null ? address.id : null,
@ -478,6 +478,7 @@ class _Settlement extends State<Settlement> {
print("error: $error");
});
if (baseData != null && baseData.isSuccess) {
EasyLoading.show(status: S.current.zhengzaijiazai);
placeOrder = true;
this.downOrder = DownOrder.fromJson(baseData.data);
querySettlement();
@ -642,6 +643,7 @@ class _Settlement extends State<Settlement> {
}
toOrderDetails(String orderId) {
EasyLoading.dismiss();
Navigator.of(context).pushReplacementNamed(
'/router/order_details',
arguments: {

11
lib/store/store_order.dart

@ -425,6 +425,7 @@ class _StoreOrderPage extends State<StoreOrderPage>
controller,
minToken,
tenant,
tableId,
_queryMiNiDetail, () {
queryShopCar().then((value) {
this.shopCarGoods = value;
@ -499,12 +500,12 @@ class _StoreOrderPage extends State<StoreOrderPage>
Spacer(),
GestureDetector(
onTap: () {
if(AppUtils.compareTime(storeInfo.openStartTime,DateFormat('HH:mm:ss').format(DateTime.now()))
&&(!AppUtils.compareTime(storeInfo.openEndTime,DateFormat('HH:mm:ss').format(DateTime.now())))){
// if(AppUtils.compareTime(storeInfo.openStartTime,DateFormat('HH:mm:ss').format(DateTime.now()))
// &&(!AppUtils.compareTime(storeInfo.openEndTime,DateFormat('HH:mm:ss').format(DateTime.now())))){
toDownOrder();
}
else
SmartDialog.showToast("营业时间:${storeInfo.openStartTime}-${storeInfo.openEndTime}", alignment: Alignment.center);
// }
// else
// SmartDialog.showToast("营业时间:${storeInfo.openStartTime}-${storeInfo.openEndTime}", alignment: Alignment.center);
},
child: RoundButton(
width: 103.w,

919
lib/store/store_view/product_meals_sku.dart

File diff suppressed because it is too large Load Diff

5
lib/store/store_view/shop_car.dart

@ -3,6 +3,7 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/data/shoppingCart.dart';
import 'package:huixiang/store/store_view/shop_goods.dart';
import 'package:huixiang/store/store_view/shop_goods_car.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/view_widget/round_button.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
@ -99,7 +100,7 @@ class _ShopCar extends State<ShopCar> {
top: 0,
left: 0,
right: 0,
bottom: 54,
bottom: 100.h,
child: Container(
padding: EdgeInsets.only(
left: 16,
@ -109,7 +110,7 @@ class _ShopCar extends State<ShopCar> {
itemCount: itemCount(),
physics: BouncingScrollPhysics(),
itemBuilder: (context, position) {
return ShopGoods(
return ShopGoodsCar(
(ShoppingCartSkuItemListBean cart) async {
widget.shopingCar =
await widget.shopCartAdd(cart);

61
lib/store/store_view/shop_goods.dart

@ -1,3 +1,4 @@
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/data/findMiNiGroupList.dart';
@ -7,15 +8,22 @@ import 'package:huixiang/utils/font_weight.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:huixiang/view_widget/round_button.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../retrofit/data/base_data.dart';
import '../../retrofit/data/miNiDetail.dart';
import '../../retrofit/min_api.dart';
class ShopGoods extends StatefulWidget {
final Function(String id, int count) queryMiNiDetail;
final Function(ShoppingCartSkuItemListBean shoppingCartSkuItemListBean) add;
final Function(ShoppingCartSkuItemListBean shoppingCartSkuItemListBean)
reduce;
final Function queryShoppingCart;
final ProductListBean productListBean;
final ShoppingCartSkuItemListBean shoppingCartSkuItemListBean;
final int count;
final int tableId;
final bool isShopCart;
ShopGoods(
@ -24,6 +32,8 @@ class ShopGoods extends StatefulWidget {
this.productListBean,
this.count = 0,
this.isShopCart = false,
this.tableId,
this.queryShoppingCart,
this.queryMiNiDetail,
this.shoppingCartSkuItemListBean,
});
@ -34,7 +44,45 @@ class ShopGoods extends StatefulWidget {
}
}
class _ShopGoods extends State<ShopGoods> {
int _jumpType = -1;
///
queryMiNiDetail(id) async {
MinApiService minService;
await SharedPreferences.getInstance().then((value) {
String minToken = value.getString("minToken");
String tenant = value.getString("tenant");
String storeId = value.getString("storeId");
minService = MinApiService(Dio(),
context: context,
token: minToken,
tenant: tenant,
storeId: storeId,);
});
BaseData<MiNiDetail> baseData =
await minService.miNiDetail(id).catchError((error) {
});
if (baseData != null && baseData.isSuccess) {
if(baseData.data.productSkuVOList[0].productSetMeals.length == 0){
_jumpType = 0;
widget.add(widget.shoppingCartSkuItemListBean);
}else{
_jumpType = 1;
await Navigator.of(context)
.pushNamed('/router/product_meals_sku', arguments: {
"id":widget.productListBean.id,
"storeId":widget.productListBean.storeId,
"tableId":widget.tableId
});
widget.queryShoppingCart();
}
} else {
// refreshController.refreshFailed();
}
}
@override
Widget build(BuildContext context) {
return Container(
@ -236,13 +284,19 @@ class _ShopGoods extends State<ShopGoods> {
if (widget.isShopCart ||
(widget.productListBean?.attrStyle ?? 0) == 0)
GestureDetector(
onTap: () {
onTap: () async{
if(_jumpType == -1)
queryMiNiDetail(widget.productListBean.id);
else if(_jumpType == 0)
widget.add(widget.shoppingCartSkuItemListBean);
Navigator.of(context)
else if(_jumpType == 1)
await Navigator.of(context)
.pushNamed('/router/product_meals_sku', arguments: {
"id":widget.productListBean.id,
"storeId":widget.productListBean.storeId
"storeId":widget.productListBean.storeId,
"tableId":widget.tableId
});
widget.queryShoppingCart();
},
child: Image.asset(
"assets/image/add.webp",
@ -271,4 +325,5 @@ class _ShopGoods extends State<ShopGoods> {
),
);
}
}

334
lib/store/store_view/shop_goods_car.dart

@ -0,0 +1,334 @@
import 'package:flutter/material.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/data/findMiNiGroupList.dart';
import 'package:huixiang/retrofit/data/shoppingCart.dart';
import 'package:huixiang/utils/flutter_utils.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:huixiang/view_widget/round_button.dart';
class ShopGoodsCar extends StatefulWidget {
final Function(String id, int count) queryMiNiDetail;
final Function(ShoppingCartSkuItemListBean shoppingCartSkuItemListBean) add;
final Function(ShoppingCartSkuItemListBean shoppingCartSkuItemListBean)
reduce;
final ProductListBean productListBean;
final ShoppingCartSkuItemListBean shoppingCartSkuItemListBean;
final int count;
final bool isShopCart;
ShopGoodsCar(
this.add,
this.reduce, {
this.productListBean,
this.count = 0,
this.isShopCart = false,
this.queryMiNiDetail,
this.shoppingCartSkuItemListBean,
});
@override
State<StatefulWidget> createState() {
return _ShopGoodsCar();
}
}
class _ShopGoodsCar extends State<ShopGoodsCar> {
@override
Widget build(BuildContext context) {
return Container(
color: Colors.white,
padding: EdgeInsets.only(
right: 16.w,
// bottom: 20.h,
),
child:Column(
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
children: [
SizedBox(width: 12.w),
MImage(
widget.productListBean != null
? widget.productListBean.imgPath
: (widget.shoppingCartSkuItemListBean != null
? widget.shoppingCartSkuItemListBean.skuImg
: ""),
width: 70.h,
height: 70.h,
radius: BorderRadius.circular(4),
fit: BoxFit.cover,
errorSrc: "assets/image/default_1.webp",
fadeSrc: "assets/image/default_1.webp",
),
SizedBox(
width: 10,
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: Text(
widget.productListBean != null
? widget.productListBean.productName
: widget.shoppingCartSkuItemListBean.productName,
overflow: TextOverflow.ellipsis,
maxLines: 2,
style: TextStyle(
color: Colors.black,
fontSize: 13.sp,
fontWeight: MyFontWeight.medium,
),
),
),
// Image.asset(
// "assets/image/green_leaf.webp",
// fit: BoxFit.cover,
// width: 12,
// height: 12,
// ),
// Text(
// "X300",
// style: TextStyle(
// color: Color(0xFF55BC51),
// fontSize: 10.sp,
// fontWeight: MyFontWeight.semi_bold,
// ),
// ),
],
),
SizedBox(
height: 2.h,
),
Row(
children: [
Expanded(
child: Text(
(widget.productListBean != null
? widget.productListBean.shortName
: ((widget.shoppingCartSkuItemListBean.skuName == "0") ? "": widget.shoppingCartSkuItemListBean.skuName ) ?? ""),
overflow: TextOverflow.ellipsis,
maxLines: 2,
style: TextStyle(
color: Color(0xFF4C4C4C),
fontSize: 10.sp,
fontWeight: MyFontWeight.regular,
),
),
),
SizedBox(
width: 10,
),
],
),
SizedBox(
height: 7.h,
),
Row(
children: [
Row(
children: [
Text(
"¥${AppUtils.calculateDouble(double.tryParse(widget.isShopCart ? widget.shoppingCartSkuItemListBean.skuPrice : widget.productListBean.price) ?? 0)}",
style: TextStyle(
color: Color(0xFFFF7A1A),
fontSize: 16.sp,
fontWeight: MyFontWeight.medium,
),
),
SizedBox(
width: 2.w,
),
// Container(
// width: 44.w,
// height: 18.h,
// decoration: BoxDecoration(
// color: Color(0xFFFF4500),
// borderRadius: BorderRadius.circular(2),
// ),
// alignment: Alignment.center,
// child: Text(
// "APP专享",
// style: TextStyle(
// color: Color(0xFFFFFFFF),
// fontSize: 10.sp,
// fontWeight: MyFontWeight.medium,
// ),
// ),
// ),
],
),
Spacer(),
if (!widget.isShopCart &&
(widget.productListBean?.attrStyle ?? 0) == 1)
Stack(
children: [
Container(
margin: EdgeInsets.only(right: 8, top: 4),
child: RoundButton(
width: 49.w,
text: S.of(context).xuanguige,
textColor: Colors.white,
fontWeight: MyFontWeight.medium,
radius: 3,
backgroup: Color(0xFF32A060),
fontSize: 11.sp,
padding: EdgeInsets.symmetric(vertical: 5.h),
callback: () {
widget.queryMiNiDetail(
widget.productListBean != null
? widget.productListBean.id
: widget.shoppingCartSkuItemListBean
.productId,
0);
},
),
),
Positioned(
right: 0,
child: Visibility(
visible: widget.count > 0,
child: RoundButton(
width: 17,
height: 17.h,
text: "${widget.count}",
textColor: Color(0xFF32A060),
fontWeight: MyFontWeight.regular,
backgroup: Colors.white,
fontSize: 12.sp,
radius: 100,
),
),
),
],
),
if (widget.isShopCart ||
(widget.productListBean?.attrStyle ?? 0) == 0)
InkWell(
onTap: () {
widget.reduce(widget.shoppingCartSkuItemListBean);
},
child: Image.asset(
"assets/image/reduce.webp",
width: 22,
height: 22.h,
),
),
if (widget.isShopCart ||
(widget.productListBean?.attrStyle ?? 0) == 0)
Container(
width: 30,
alignment: Alignment.center,
child: Text(
"${widget.count}",
style: TextStyle(
color: Colors.black,
fontSize: 14.sp,
fontWeight: MyFontWeight.medium,
),
),
),
if (widget.isShopCart ||
(widget.productListBean?.attrStyle ?? 0) == 0)
GestureDetector(
onTap: () {
widget.add(widget.shoppingCartSkuItemListBean);
},
child: Image.asset(
"assets/image/add.webp",
width: 22,
height: 22.h,
),
),
],
),
SizedBox(
height: 4.h,
),
Text(
"${AppUtils.calculateDouble(double.tryParse(widget.isShopCart ? widget.shoppingCartSkuItemListBean.skuPrice : widget.productListBean.applyPrice) ?? 0)}",
style: TextStyle(
color: Color(0xFFA29E9E),
fontSize: 12.sp,
decoration: TextDecoration.lineThrough,
fontWeight: MyFontWeight.regular,
),
),
],
),
),
],
),
if(widget.shoppingCartSkuItemListBean.setMealDataList.length != 0)
ListView.builder(
itemCount: widget.shoppingCartSkuItemListBean.setMealDataList.length,
scrollDirection: Axis.vertical,
physics: BouncingScrollPhysics(),
shrinkWrap: true,
padding: EdgeInsets.zero,
itemBuilder: (context, index) {
return shopCarMealsItem(widget.shoppingCartSkuItemListBean.setMealDataList[index]);
},
),
SizedBox(height:15.h,)
],
)
);
}
Widget shopCarMealsItem(SetMealDataList setMealDataList) {
return Container(
margin: EdgeInsets.symmetric(vertical:10.h,horizontal: 16.w),
child: Row(
children: [
Expanded(
flex: 3,
child: Text(
setMealDataList.productInfoList[0].productName,
overflow: TextOverflow.ellipsis,
maxLines: 1,
style: TextStyle(
color: Color(0xffA29E9E),
fontSize: 14.sp,
fontWeight: MyFontWeight.regular,
),
),
),
Expanded(flex: 2,
child: Text(
"${(setMealDataList.productInfoList[0].skuName == "") ? "默认": setMealDataList.productInfoList[0].skuName}",
overflow: TextOverflow.ellipsis,
maxLines: 1,
style: TextStyle(
color: Color(0xffA29E9E),
fontSize: 13.sp,
fontWeight: MyFontWeight.regular,
),
),
),
Expanded(
flex: 1,
child: Text(
"x1",
overflow: TextOverflow.ellipsis,
maxLines: 1,
style: TextStyle(
color: Color(0xffFF7A1A),
fontSize: 13.sp,
fontWeight: MyFontWeight.regular,
),
),
),
],
),
);
}
}

4
lib/store/store_view/store_order_list.dart

@ -21,6 +21,7 @@ class StoreOrderListPage extends StatefulWidget {
final ScrollController controller;
final String minToken;
final String tenant;
final int tableId;
final Function(String id, int count) queryMiNiDetail;
final Function queryShoppingCart;
@ -34,6 +35,7 @@ class StoreOrderListPage extends StatefulWidget {
this.controller,
this.minToken,
this.tenant,
this.tableId,
this.queryMiNiDetail,
this.queryShoppingCart,
);
@ -341,6 +343,8 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
productListBean: e,
count: count,
isShopCart: false,
tableId:widget.tableId,
queryShoppingCart:widget.queryShoppingCart,
queryMiNiDetail: widget.queryMiNiDetail,
shoppingCartSkuItemListBean: shoppingCartSkuItemListBean,
);

2
lib/view_widget/selector_store_dialog.dart

@ -117,7 +117,7 @@ class _SelectorStoreWidget extends State<SelectorStoreWidget> {
widget.stores[selectIndex].storeName,
);
} else {
Navigator.of(context).pushNamed(
Navigator.of(context).pushReplacementNamed(
'/router/store_order',
arguments: {
"id": widget.stores[selectIndex].id,

Loading…
Cancel
Save