Browse Source

safety

master
fmk 3 years ago
parent
commit
f27b1aca3c
  1. 32
      lib/retrofit/data/miNiDetail.dart
  2. 7
      lib/retrofit/min_api.dart
  3. 33
      lib/retrofit/min_api.g.dart
  4. 17
      lib/store/store_order.dart
  5. 92
      lib/store/store_view/product_sku.dart
  6. 2
      lib/store/store_view/shop_car.dart
  7. 278
      lib/store/store_view/store_order_list.dart

32
lib/retrofit/data/miNiDetail.dart

@ -83,7 +83,7 @@ class MiNiDetail {
dynamic namePinyin;
dynamic nameInitials;
static MiNiDetail fromMap(Map<String, dynamic> map) {
static MiNiDetail fromJson(Map<String, dynamic> map) {
if (map == null) return null;
MiNiDetail miNiDetailBean = MiNiDetail();
miNiDetailBean.id = map['id'];
@ -115,15 +115,15 @@ class MiNiDetail {
miNiDetailBean.isDelete = map['isDelete'];
miNiDetailBean.printerFlag = map['printerFlag'];
miNiDetailBean.materialId = map['materialId'];
miNiDetailBean.imgs = List()..addAll(
miNiDetailBean.imgs = []..addAll(
(map['imgs'] as List ?? []).map((o) => o.toString())
);
miNiDetailBean.storeDTO = StoreDTOBean.fromMap(map['storeDTO']);
miNiDetailBean.attrList = List()..addAll(
(map['attrList'] as List ?? []).map((o) => AttrListBean.fromMap(o))
miNiDetailBean.storeDTO = StoreDTOBean.fromJson(map['storeDTO']);
miNiDetailBean.attrList = []..addAll(
(map['attrList'] as List ?? []).map((o) => AttrListBean.fromJson(o))
);
miNiDetailBean.productSkuVOList = List()..addAll(
(map['productSkuVOList'] as List ?? []).map((o) => ProductSkuVOListBean.fromMap(o))
miNiDetailBean.productSkuVOList = []..addAll(
(map['productSkuVOList'] as List ?? []).map((o) => ProductSkuVOListBean.fromJson(o))
);
miNiDetailBean.shipAddress = map['shipAddress'];
miNiDetailBean.buyCount = map['buyCount'];
@ -232,7 +232,7 @@ class ProductSkuVOListBean {
List<SkuAttrListBean> skuAttrList;
dynamic setMealDTOList;
static ProductSkuVOListBean fromMap(Map<String, dynamic> map) {
static ProductSkuVOListBean fromJson(Map<String, dynamic> map) {
if (map == null) return null;
ProductSkuVOListBean productSkuVOListBean = ProductSkuVOListBean();
productSkuVOListBean.id = map['id'];
@ -257,8 +257,8 @@ class ProductSkuVOListBean {
productSkuVOListBean.material = map['material'];
productSkuVOListBean.version = map['version'];
productSkuVOListBean.skuAttrCodeDTOList = map['skuAttrCodeDTOList'];
productSkuVOListBean.skuAttrList = List()..addAll(
(map['skuAttrList'] as List ?? []).map((o) => SkuAttrListBean.fromMap(o))
productSkuVOListBean.skuAttrList = []..addAll(
(map['skuAttrList'] as List ?? []).map((o) => SkuAttrListBean.fromJson(o))
);
productSkuVOListBean.setMealDTOList = map['setMealDTOList'];
return productSkuVOListBean;
@ -315,7 +315,7 @@ class SkuAttrListBean {
dynamic sortOrder;
int isDelete;
static SkuAttrListBean fromMap(Map<String, dynamic> map) {
static SkuAttrListBean fromJson(Map<String, dynamic> map) {
if (map == null) return null;
SkuAttrListBean skuAttrListBean = SkuAttrListBean();
skuAttrListBean.id = map['id'];
@ -364,7 +364,7 @@ class AttrListBean {
String id;
List<AttrValueListBean> attrValueList;
static AttrListBean fromMap(Map<String, dynamic> map) {
static AttrListBean fromJson(Map<String, dynamic> map) {
if (map == null) return null;
AttrListBean attrListBean = AttrListBean();
attrListBean.productId = map['productId'];
@ -374,8 +374,8 @@ class AttrListBean {
attrListBean.isDelete = map['isDelete'];
attrListBean.attrCode = map['attrCode'];
attrListBean.id = map['id'];
attrListBean.attrValueList = List()..addAll(
(map['attrValueList'] as List ?? []).map((o) => AttrValueListBean.fromMap(o))
attrListBean.attrValueList = []..addAll(
(map['attrValueList'] as List ?? []).map((o) => AttrValueListBean.fromJson(o))
);
return attrListBean;
}
@ -410,7 +410,7 @@ class AttrValueListBean {
dynamic attrValueCode;
bool isSelected;
static AttrValueListBean fromMap(Map<String, dynamic> map) {
static AttrValueListBean fromJson(Map<String, dynamic> map) {
if (map == null) return null;
AttrValueListBean attrValueListBean = AttrValueListBean();
attrValueListBean.id = map['id'];
@ -449,7 +449,7 @@ class StoreDTOBean {
int productCount;
int soldNum;
static StoreDTOBean fromMap(Map<String, dynamic> map) {
static StoreDTOBean fromJson(Map<String, dynamic> map) {
if (map == null) return null;
StoreDTOBean storeDTOBean = StoreDTOBean();
storeDTOBean.id = map['id'];

7
lib/retrofit/min_api.dart

@ -71,14 +71,17 @@ abstract class MinApiService {
EasyLoading.dismiss();
}
debugPrint("code = ${response.statusCode}");
p(jsonEncode(response.data));
// p(jsonEncode(response.data));
debugPrint(jsonEncode(response.data), wrapWidth: response.data.toString().length);
Map map = response.data;
if (map["code"] != 0) {
EasyLoading.dismiss();
}
if (map["code"] == 40005 || map["code"] == 40001) {
if (!LoginTipsDialog().isShow) {
print("show: ${LoginTipsDialog().isShow}");
// print("show: ${LoginTipsDialog().isShow}");
LoginTipsDialog().show(context);
}
} else if (map["code"] != 0 && response.request.baseUrl == baseUrl) {

33
lib/retrofit/min_api.g.dart

@ -17,22 +17,18 @@ class _MinApiService implements MinApiService {
String baseUrl;
@override
Future<BaseData<List<FindMiNiGroupList>>> findMiNiGroupList(
param, header) async {
Future<BaseData<List<FindMiNiGroupList>>> findMiNiGroupList(param) async {
ArgumentError.checkNotNull(param, 'param');
ArgumentError.checkNotNull(header, 'header');
const _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _data = <String, dynamic>{};
_data.addAll(param ?? <String, dynamic>{});
final _header= <String, dynamic>{};
_header.addAll(header ?? <String,dynamic>{});
final _result = await _dio.request<Map<String, dynamic>>(
'product/findMiNiGroupList',
queryParameters: queryParameters,
options: RequestOptions(
method: 'POST',
headers: _header,
headers: <String, dynamic>{},
extra: _extra,
baseUrl: baseUrl),
data: _data);
@ -62,7 +58,30 @@ class _MinApiService implements MinApiService {
data: _data);
final value = BaseData<MiNiDetail>.fromJson(
_result.data,
(json) => MiNiDetail.fromMap(json),
(json) => MiNiDetail.fromJson(json),
);
return value;
}
@override
Future<BaseData<FindMiNiGroupList>> shoppingCart(param, header) async {
ArgumentError.checkNotNull(param, 'param');
ArgumentError.checkNotNull(header, 'header');
const _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _data = <String, dynamic>{};
_data.addAll(param ?? <String, dynamic>{});
final _result = await _dio.request<Map<String, dynamic>>('shoppingcart',
queryParameters: queryParameters,
options: RequestOptions(
method: 'POST',
headers: <String, dynamic>{},
extra: _extra,
baseUrl: baseUrl),
data: _data);
final value = BaseData<FindMiNiGroupList>.fromJson(
_result.data,
(json) => FindMiNiGroupList.fromJson(json),
);
return value;
}

17
lib/store/store_order.dart

@ -176,12 +176,6 @@ class _StoreOrderPage extends State<StoreOrderPage>
Positioned(
child: Column(
children: [
// Image.asset(
// "assets/image/share_image_bg.png",
// fit: BoxFit.cover,
// width: MediaQuery.of(context).size.width,
// height: 180.h,
// ),
buildSwiper(),
Expanded(
child: Container(
@ -278,6 +272,7 @@ class _StoreOrderPage extends State<StoreOrderPage>
),
),
),
),
Positioned(
bottom: 0,
left: 0,
@ -363,7 +358,7 @@ class _StoreOrderPage extends State<StoreOrderPage>
),
],
),
)
),
],
);
}
@ -400,7 +395,8 @@ class _StoreOrderPage extends State<StoreOrderPage>
},
itemCount: (storeInfo != null && storeInfo.bannerList != null)
? storeInfo.bannerList.length
: 1),
: 1,
),
);
}
@ -412,9 +408,7 @@ class _StoreOrderPage extends State<StoreOrderPage>
context: context,
backgroundColor: Colors.transparent,
builder: (context) {
return StatefulBuilder(builder: (context1, state) {
return ShopCar(productLists);
});
},
);
}
@ -454,7 +448,8 @@ class _Title extends State<Title> {
if (alphaProgress <= 1) {
alphatemp = 1;
} else if (alphaProgress <= alphaHeight) {
alphatemp = (((alphaHeight - alphaProgress) / alphaHeight) > 0.5) ? 1 : 0;
alphatemp =
(((alphaHeight - alphaProgress) / alphaHeight) > 0.5) ? 1 : 0;
} else {
alphatemp = 0;
}

92
lib/store/store_view/product_sku.dart

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:huixiang/retrofit/data/miNiDetail.dart';
@ -23,9 +24,16 @@ class _ProductSku extends State<ProductSku> {
@override
Widget build(BuildContext context) {
String selectSku = "";
int selectCount = 1;
return StatefulBuilder(builder: (context1, state) {
return Container(
alignment: Alignment.topCenter,
padding: EdgeInsets.only(top: 16, left: 16, right: 16),
padding: EdgeInsets.only(
top: 16,
left: 16,
right: 16,
),
width: double.infinity,
decoration: BoxDecoration(
color: Color(0xFFFAFAFA),
@ -67,7 +75,7 @@ class _ProductSku extends State<ProductSku> {
Padding(
padding: EdgeInsets.only(top: 4, bottom: 7),
child: Text(
"已选:正常冰",
"已选:" + selectSku,
style: TextStyle(
color: Color(0xFF727272),
fontSize: 11.sp,
@ -121,19 +129,26 @@ class _ProductSku extends State<ProductSku> {
itemBuilder: (context, position) {
return attrItem(
() {
setState(() {
state(() {
for (var i = 0;
i <
widget.miNiDetail.attrList[position].attrValueList
.length;
widget.miNiDetail.attrList[position]
.attrValueList.length;
i++) {
if (tempClickIndex == i)
widget.miNiDetail.attrList[position].attrValueList[i]
.isSelected = true;
widget.miNiDetail.attrList[position]
.attrValueList[i].isSelected = true;
else
widget.miNiDetail.attrList[position].attrValueList[i]
.isSelected = false;
widget.miNiDetail.attrList[position]
.attrValueList[i].isSelected = false;
}
selectSku = "";
widget.miNiDetail.attrList.forEach((e0) {
e0.attrValueList.forEach((e1) {
if (e1.isSelected ?? false)
selectSku += e1.attrValue + " ";
});
});
});
},
widget.miNiDetail.attrList[position],
@ -158,7 +173,11 @@ class _ProductSku extends State<ProductSku> {
),
),
InkWell(
onTap: () {},
onTap: () {
state(() {
if (selectCount > 1) selectCount--;
});
},
child: Image.asset(
"assets/image/reduce.png",
width: 22,
@ -168,7 +187,7 @@ class _ProductSku extends State<ProductSku> {
Padding(
padding: EdgeInsets.only(left: 8, right: 8),
child: Text(
"1",
selectCount.toString(),
style: TextStyle(
color: Colors.black,
fontSize: 14.sp,
@ -177,7 +196,11 @@ class _ProductSku extends State<ProductSku> {
),
),
InkWell(
onTap: () {},
onTap: () {
state(() {
selectCount++;
});
},
child: Image.asset(
"assets/image/add.png",
width: 22,
@ -189,7 +212,19 @@ class _ProductSku extends State<ProductSku> {
SizedBox(
height: 24,
),
RoundButton(
GestureDetector(
onTap: () {
bool flag = false;
widget.miNiDetail.productSkuVOList.forEach((element) {
if (selectSku.trim() == element.skuNameStr) {
Navigator.of(context).pop();
flag = true;
}
});
if (!flag)
SmartDialog.showToast("请选择規格!", alignment: Alignment.center);
},
child: RoundButton(
width: double.infinity,
height: 54.h,
text: "加入购物车",
@ -199,14 +234,38 @@ class _ProductSku extends State<ProductSku> {
backgroup: Color(0xFF32A060),
fontSize: 16.sp,
// padding: EdgeInsets.symmetric(vertical: 5.h),
callback: () { },
),
),
SizedBox(
height: 21.h,
),
],
),
);
});
}
Widget attrItem(Function fc, AttrListBean attrListBean) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.only(top: 24, bottom: 16),
child: Text(
attrListBean.attrName,
style: TextStyle(
color: Colors.black,
fontSize: 14.sp,
fontWeight: MyFontWeight.regular,
),
),
),
sweetnessStore(fc, attrListBean.attrValueList),
],
);
}
Widget sweetnessStore(Function fc, List<testModel> arrays) {
Widget sweetnessStore(Function fc, List<AttrValueListBean> arrays) {
return GridView.builder(
itemCount: arrays.length,
shrinkWrap: true,
@ -227,7 +286,8 @@ class _ProductSku extends State<ProductSku> {
tempClickIndex = index;
fc();
},
child: sweetnessItem(arrays[index].name, arrays[index].isSelected),
child: sweetnessItem(
arrays[index].attrValue, arrays[index].isSelected ?? false),
);
},
);

2
lib/store/store_view/shop_car.dart

@ -22,6 +22,7 @@ class ShopCar extends StatefulWidget {
class _ShopCar extends State<ShopCar> {
@override
Widget build(BuildContext context) {
return StatefulBuilder(builder: (context1, state) {
return Container(
alignment: Alignment.topCenter,
width: double.infinity,
@ -174,6 +175,7 @@ class _ShopCar extends State<ShopCar> {
],
),
);
});
}
}

278
lib/store/store_view/store_order_list.dart

@ -35,6 +35,7 @@ class StoreOrderListPage extends StatefulWidget {
class _StoreOrderListPage extends State<StoreOrderListPage> {
int isSelected = 0;
int tempClickIndex = 0;
ApiService apiService;
MinApiService minService;
List<FindMiNiGroupList> appletProducts;
@ -403,288 +404,13 @@ class _StoreOrderListPage extends State<StoreOrderListPage> {
///
showStoreSelector(MiNiDetail miNiDetail) {
String selectSku = "";
int selectCount = 1;
showModalBottomSheet(
context: context,
backgroundColor: Colors.transparent,
builder: (context) {
return StatefulBuilder(builder: (context1, state) {
return Container(
alignment: Alignment.topCenter,
padding: EdgeInsets.only(top: 16, left: 16, right: 16),
width: double.infinity,
decoration: BoxDecoration(
color: Color(0xFFFAFAFA),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8),
topRight: Radius.circular(8),
),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
MImage(
miNiDetail.imgs[0],
width: 70,
height: 70,
fit: BoxFit.cover,
errorSrc: "assets/image/default_1.png",
fadeSrc: "assets/image/default_1.png",
),
SizedBox(width: 10),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
miNiDetail.productName,
style: TextStyle(
color: Colors.black,
fontSize: 16.sp,
fontWeight: MyFontWeight.medium,
),
),
Padding(
padding: EdgeInsets.only(top: 4, bottom: 7),
child: Text(
"已选:" + selectSku,
style: TextStyle(
color: Color(0xFF727272),
fontSize: 11.sp,
fontWeight: MyFontWeight.regular,
),
),
),
Row(
children: [
Text(
S.of(context).huiyuanjia,
style: TextStyle(
color: Color(0xFFFF7A1A),
fontSize: 13.sp,
fontWeight: MyFontWeight.medium,
),
),
Text(
miNiDetail.price,
style: TextStyle(
color: Color(0xFFFF7A1A),
fontSize: 14.sp,
fontWeight: MyFontWeight.medium,
),
)
],
),
],
),
Spacer(),
InkWell(
onTap: () {
Navigator.of(context).pop();
},
child: Image.asset(
"assets/image/icon_order_cancel.png",
width: 22,
height: 22,
),
),
],
),
SizedBox(
height: 23,
),
Expanded(
child: ListView.builder(
itemCount: miNiDetail.attrList.length,
scrollDirection: Axis.vertical,
physics: BouncingScrollPhysics(),
itemBuilder: (context, position) {
return attrItem(() {
state(() {
for (var i = 0;
i <
miNiDetail
.attrList[position].attrValueList.length;
i++) {
if (tempClickIndex == i)
miNiDetail.attrList[position].attrValueList[i]
.isSelected = true;
else
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]);
},
)),
SizedBox(
height: 24,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child: Text(
"数量",
style: TextStyle(
color: Colors.black,
fontSize: 14.sp,
fontWeight: MyFontWeight.regular,
),
)),
InkWell(
onTap: () {
state(() {
if (selectCount > 1) selectCount--;
});
},
child: Image.asset(
"assets/image/reduce.png",
width: 22,
height: 22,
),
),
Padding(
padding: EdgeInsets.only(left: 8, right: 8),
child: Text(
selectCount.toString(),
style: TextStyle(
color: Colors.black,
fontSize: 14.sp,
fontWeight: MyFontWeight.medium,
),
),
),
InkWell(
onTap: () {
state(() {
selectCount++;
});
},
child: Image.asset(
"assets/image/add.png",
width: 22,
height: 22,
),
),
],
),
SizedBox(
height: 24,
),
GestureDetector(
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(
width: double.infinity,
height: 54.h,
text: "加入购物车",
textColor: Colors.white,
fontWeight: MyFontWeight.semi_bold,
radius: 27,
backgroup: Color(0xFF32A060),
fontSize: 16.sp,
// padding: EdgeInsets.symmetric(vertical: 5.h),
),
),
SizedBox(
height: 21.h,
),
],
),
);
});
return ProductSku(miNiDetail);
},
);
}
Widget attrItem(Function fc, AttrListBean attrListBean) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.only(top: 24, bottom: 16),
child: Text(
attrListBean.attrName,
style: TextStyle(
color: Colors.black,
fontSize: 14.sp,
fontWeight: MyFontWeight.regular,
),
)),
sweetnessStore(fc, attrListBean.attrValueList),
],
);
}
Widget sweetnessStore(Function fc, List<AttrValueListBean> arrays) {
return GridView.builder(
itemCount: arrays.length,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
//Widget数量
crossAxisCount: 4,
//Widget之间间距
crossAxisSpacing: 6.w,
//Widget之间间距
mainAxisSpacing: 12.w,
//Widget之间间距
childAspectRatio: 3 / 1),
itemBuilder: (contetx, index) {
return GestureDetector(
onTap: () {
tempClickIndex = index;
fc();
},
child: sweetnessItem(
arrays[index].attrValue, arrays[index].isSelected ?? false),
);
},
);
}
Widget sweetnessItem(String name, bool isCheck) {
return Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
RoundButton(
width: 68.w,
height: 29.h,
text: name,
textColor: !isCheck ? Color(0xFF727272) : Colors.white,
fontWeight: MyFontWeight.regular,
radius: 4,
backgroup: !isCheck ? Color(0xFFE5E5E5) : Color(0xFF32A060),
fontSize: 12.sp,
),
],
),
);
}
}

Loading…
Cancel
Save