|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
|
import 'package:flutter_easyloading/flutter_easyloading.dart'; |
|
|
|
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; |
|
|
|
|
import 'package:huixiang/generated/l10n.dart'; |
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
@ -9,24 +10,18 @@ import 'package:huixiang/view_widget/custom_image.dart';
|
|
|
|
|
import 'package:huixiang/view_widget/round_button.dart'; |
|
|
|
|
|
|
|
|
|
class ProductSku extends StatefulWidget { |
|
|
|
|
|
|
|
|
|
final MiNiDetail miNiDetail; |
|
|
|
|
final String productId; |
|
|
|
|
final Function(MiNiDetail miNiDetail, List<String> selectSkus, int count) addShopCar; |
|
|
|
|
final Function(MiNiDetail miNiDetail, List<String> selectSkus, int count) |
|
|
|
|
addShopCar; |
|
|
|
|
final Function(MiNiDetail miNiDetail, List<String> selectSkus) add; |
|
|
|
|
final Function(MiNiDetail miNiDetail, List<String> selectSkus) reduce; |
|
|
|
|
final ShoppingCart shopCarGoods; |
|
|
|
|
final int buttonType; |
|
|
|
|
|
|
|
|
|
ProductSku( |
|
|
|
|
this.miNiDetail, |
|
|
|
|
this.shopCarGoods, |
|
|
|
|
this.productId, |
|
|
|
|
this.addShopCar, |
|
|
|
|
this.add, |
|
|
|
|
this.reduce, |
|
|
|
|
{ this.buttonType} |
|
|
|
|
); |
|
|
|
|
ProductSku(this.miNiDetail, this.shopCarGoods, this.productId, |
|
|
|
|
this.addShopCar, this.add, this.reduce, |
|
|
|
|
{this.buttonType}); |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
State<StatefulWidget> createState() { |
|
|
|
@ -36,8 +31,9 @@ class ProductSku extends StatefulWidget {
|
|
|
|
|
|
|
|
|
|
class _ProductSku extends State<ProductSku> { |
|
|
|
|
List<String> selectSkus = []; |
|
|
|
|
int count = 1; |
|
|
|
|
int count = 1, realCount = 0; |
|
|
|
|
String selectedPrice = ""; |
|
|
|
|
bool _isTapEd = false; |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
void initState() { |
|
|
|
@ -63,10 +59,13 @@ class _ProductSku extends State<ProductSku> {
|
|
|
|
|
if (productSku == null) return; |
|
|
|
|
selectedPrice = productSku.skuPrice; |
|
|
|
|
String skuId = productSku.id; |
|
|
|
|
if (widget.shopCarGoods == null || widget.shopCarGoods.shoppingCartSkuItemList == null) return; |
|
|
|
|
int shopSkuIndex = widget.shopCarGoods.shoppingCartSkuItemList.indexWhere((element) => skuId == element.id); |
|
|
|
|
if (widget.shopCarGoods == null || |
|
|
|
|
widget.shopCarGoods.shoppingCartSkuItemList == null) return; |
|
|
|
|
int shopSkuIndex = widget.shopCarGoods.shoppingCartSkuItemList |
|
|
|
|
.indexWhere((element) => skuId == element.id); |
|
|
|
|
if (shopSkuIndex >= 0) { |
|
|
|
|
count = widget.shopCarGoods.shoppingCartSkuItemList[shopSkuIndex].buyNum; |
|
|
|
|
realCount = count; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -81,13 +80,13 @@ class _ProductSku extends State<ProductSku> {
|
|
|
|
|
return gg; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
Widget build(BuildContext context) { |
|
|
|
|
return WillPopScope( |
|
|
|
|
onWillPop: () async { |
|
|
|
|
debugPrint("ssssasdadsasdadasd"); |
|
|
|
|
SmartDialog.dismiss(); |
|
|
|
|
// debugPrint("ssssasdadsasdadasd"); |
|
|
|
|
// SmartDialog.dismiss(); |
|
|
|
|
Navigator.of(context).pop(); |
|
|
|
|
return true; |
|
|
|
|
}, |
|
|
|
|
child: StatefulBuilder(builder: (context1, state) { |
|
|
|
@ -124,7 +123,8 @@ class _ProductSku extends State<ProductSku> {
|
|
|
|
|
SizedBox( |
|
|
|
|
width: 10, |
|
|
|
|
), |
|
|
|
|
Expanded(child:Column( |
|
|
|
|
Expanded( |
|
|
|
|
child: Column( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start, |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
|
children: [ |
|
|
|
@ -141,7 +141,10 @@ class _ProductSku extends State<ProductSku> {
|
|
|
|
|
padding: EdgeInsets.only(top: 4, bottom: 7), |
|
|
|
|
child: Text( |
|
|
|
|
"已选: " + |
|
|
|
|
(selectSkus.map((e) => "$e").toList().toString()), |
|
|
|
|
(selectSkus |
|
|
|
|
.map((e) => "$e") |
|
|
|
|
.toList() |
|
|
|
|
.toString()), |
|
|
|
|
maxLines: 1, |
|
|
|
|
overflow: TextOverflow.ellipsis, |
|
|
|
|
style: TextStyle( |
|
|
|
@ -175,8 +178,8 @@ class _ProductSku extends State<ProductSku> {
|
|
|
|
|
)), |
|
|
|
|
InkWell( |
|
|
|
|
onTap: () { |
|
|
|
|
// Navigator.of(context).pop(); |
|
|
|
|
SmartDialog.dismiss(); |
|
|
|
|
Navigator.of(context).pop(); |
|
|
|
|
// SmartDialog.dismiss(); |
|
|
|
|
}, |
|
|
|
|
child: Image.asset( |
|
|
|
|
"assets/image/cancel.webp", |
|
|
|
@ -187,11 +190,14 @@ class _ProductSku extends State<ProductSku> {
|
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
if (widget.miNiDetail.attrList != null && widget.miNiDetail.attrList.length > 0) |
|
|
|
|
if (widget.miNiDetail.attrList != null && |
|
|
|
|
widget.miNiDetail.attrList.length > 0) |
|
|
|
|
SizedBox( |
|
|
|
|
height: 10, |
|
|
|
|
), |
|
|
|
|
if (widget.miNiDetail.attrList != null && widget.miNiDetail.attrList.length > 0 && widget.miNiDetail.attrList[0].attrName!="") |
|
|
|
|
if (widget.miNiDetail.attrList != null && |
|
|
|
|
widget.miNiDetail.attrList.length > 0 && |
|
|
|
|
widget.miNiDetail.attrList[0].attrName != "") |
|
|
|
|
Expanded( |
|
|
|
|
child: ListView.builder( |
|
|
|
|
itemCount: widget.miNiDetail.attrList.length, |
|
|
|
@ -231,12 +237,15 @@ class _ProductSku extends State<ProductSku> {
|
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
InkWell( |
|
|
|
|
onTap: () { |
|
|
|
|
if (count > 1) |
|
|
|
|
setState(() { |
|
|
|
|
onTap: () async { |
|
|
|
|
if(count == 1) |
|
|
|
|
return; |
|
|
|
|
_isTapEd = true; |
|
|
|
|
EasyLoading.show(status: S.current.zhengzaijiazai); |
|
|
|
|
await widget.reduce(widget.miNiDetail, selectSkus); |
|
|
|
|
count -= 1; |
|
|
|
|
}); |
|
|
|
|
widget.reduce(widget.miNiDetail, selectSkus); |
|
|
|
|
setState(() {}); |
|
|
|
|
EasyLoading.dismiss(); |
|
|
|
|
}, |
|
|
|
|
child: Image.asset( |
|
|
|
|
"assets/image/reduce.webp", |
|
|
|
@ -256,11 +265,17 @@ class _ProductSku extends State<ProductSku> {
|
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
InkWell( |
|
|
|
|
onTap: () { |
|
|
|
|
setState(() { |
|
|
|
|
onTap: () async { |
|
|
|
|
_isTapEd = true; |
|
|
|
|
EasyLoading.show(status: S.current.zhengzaijiazai); |
|
|
|
|
if (count == 1 && realCount == 0) |
|
|
|
|
await widget.addShopCar( |
|
|
|
|
widget.miNiDetail, selectSkus, 2); |
|
|
|
|
else |
|
|
|
|
await widget.add(widget.miNiDetail, selectSkus); |
|
|
|
|
count += 1; |
|
|
|
|
}); |
|
|
|
|
widget.add(widget.miNiDetail, selectSkus); |
|
|
|
|
setState(() {}); |
|
|
|
|
EasyLoading.dismiss(); |
|
|
|
|
}, |
|
|
|
|
child: Image.asset( |
|
|
|
|
"assets/image/add.webp", |
|
|
|
@ -284,8 +299,9 @@ class _ProductSku extends State<ProductSku> {
|
|
|
|
|
backgroup: Color(0xFF32A060), |
|
|
|
|
fontSize: 16.sp, |
|
|
|
|
callback: () { |
|
|
|
|
// Navigator.of(context).pop(); |
|
|
|
|
SmartDialog.dismiss(); |
|
|
|
|
Navigator.of(context).pop(); |
|
|
|
|
// SmartDialog.dismiss(); |
|
|
|
|
if (!_isTapEd) |
|
|
|
|
widget.addShopCar(widget.miNiDetail, selectSkus, 1); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
@ -300,18 +316,21 @@ class _ProductSku extends State<ProductSku> {
|
|
|
|
|
backgroup: Color(0xFF32A060), |
|
|
|
|
fontSize: 16.sp, |
|
|
|
|
callback: () { |
|
|
|
|
// Navigator.of(context).pop(); |
|
|
|
|
SmartDialog.dismiss(); |
|
|
|
|
Navigator.of(context).pop(); |
|
|
|
|
// SmartDialog.dismiss(); |
|
|
|
|
widget.addShopCar(widget.miNiDetail, selectSkus, count); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
|
|
|
|
|
///秒杀按钮 |
|
|
|
|
if (widget.buttonType == 2) |
|
|
|
|
Row( |
|
|
|
|
children: [ |
|
|
|
|
Expanded(child: GestureDetector( |
|
|
|
|
Expanded( |
|
|
|
|
child: GestureDetector( |
|
|
|
|
onTap: () { |
|
|
|
|
Navigator.of(context).pushReplacementNamed('/router/group_details'); |
|
|
|
|
Navigator.of(context) |
|
|
|
|
.pushReplacementNamed('/router/group_details'); |
|
|
|
|
}, |
|
|
|
|
child: Container( |
|
|
|
|
alignment: Alignment.center, |
|
|
|
@ -350,8 +369,8 @@ class _ProductSku extends State<ProductSku> {
|
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
Expanded(child: |
|
|
|
|
Text( |
|
|
|
|
Expanded( |
|
|
|
|
child: Text( |
|
|
|
|
"原价购买", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 12.sp, |
|
|
|
@ -362,10 +381,13 @@ class _ProductSku extends State<ProductSku> {
|
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
),), |
|
|
|
|
Expanded(child: GestureDetector( |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
Expanded( |
|
|
|
|
child: GestureDetector( |
|
|
|
|
onTap: () { |
|
|
|
|
Navigator.of(context).popAndPushNamed('/router/bargain_details'); |
|
|
|
|
Navigator.of(context) |
|
|
|
|
.popAndPushNamed('/router/bargain_details'); |
|
|
|
|
}, |
|
|
|
|
child: Container( |
|
|
|
|
alignment: Alignment.center, |
|
|
|
@ -408,29 +430,32 @@ class _ProductSku extends State<ProductSku> {
|
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
Expanded(child: |
|
|
|
|
Text( |
|
|
|
|
Expanded( |
|
|
|
|
child: Text( |
|
|
|
|
"我要砍价", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
|
color: Colors.white, |
|
|
|
|
), |
|
|
|
|
),), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
)),), |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
)), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
|
|
|
|
|
///砍价 |
|
|
|
|
if (widget.buttonType == 3) |
|
|
|
|
Row( |
|
|
|
|
children: [ |
|
|
|
|
Expanded(child:GestureDetector( |
|
|
|
|
Expanded( |
|
|
|
|
child: GestureDetector( |
|
|
|
|
onTap: () { |
|
|
|
|
Navigator.of(context).popAndPushNamed('/router/group_details'); |
|
|
|
|
Navigator.of(context) |
|
|
|
|
.popAndPushNamed('/router/group_details'); |
|
|
|
|
}, |
|
|
|
|
child: Container( |
|
|
|
|
alignment: Alignment.center, |
|
|
|
@ -469,8 +494,8 @@ class _ProductSku extends State<ProductSku> {
|
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
Expanded(child: |
|
|
|
|
Text( |
|
|
|
|
Expanded( |
|
|
|
|
child: Text( |
|
|
|
|
"原价购买", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 12.sp, |
|
|
|
@ -481,10 +506,13 @@ class _ProductSku extends State<ProductSku> {
|
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
),), |
|
|
|
|
Expanded(child:GestureDetector( |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
Expanded( |
|
|
|
|
child: GestureDetector( |
|
|
|
|
onTap: () { |
|
|
|
|
Navigator.of(context).popAndPushNamed('/router/bargain_details'); |
|
|
|
|
Navigator.of(context) |
|
|
|
|
.popAndPushNamed('/router/bargain_details'); |
|
|
|
|
}, |
|
|
|
|
child: Container( |
|
|
|
|
alignment: Alignment.center, |
|
|
|
@ -527,27 +555,32 @@ class _ProductSku extends State<ProductSku> {
|
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
Expanded(child: |
|
|
|
|
Text( |
|
|
|
|
Expanded( |
|
|
|
|
child: Text( |
|
|
|
|
"我要秒杀", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
|
color: Colors.white, |
|
|
|
|
), |
|
|
|
|
),), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
)),), |
|
|
|
|
)), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
|
|
|
|
|
///拼团按钮 |
|
|
|
|
if (widget.buttonType == 4) |
|
|
|
|
Row( |
|
|
|
|
children: [ |
|
|
|
|
Expanded(child: GestureDetector( |
|
|
|
|
Expanded( |
|
|
|
|
child: GestureDetector( |
|
|
|
|
onTap: () { |
|
|
|
|
Navigator.of(context).popAndPushNamed('/router/group_details'); |
|
|
|
|
Navigator.of(context) |
|
|
|
|
.popAndPushNamed('/router/group_details'); |
|
|
|
|
}, |
|
|
|
|
child: Container( |
|
|
|
|
alignment: Alignment.center, |
|
|
|
@ -586,8 +619,8 @@ class _ProductSku extends State<ProductSku> {
|
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
Expanded(child: |
|
|
|
|
Text( |
|
|
|
|
Expanded( |
|
|
|
|
child: Text( |
|
|
|
|
"单人购买", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 12.sp, |
|
|
|
@ -599,9 +632,11 @@ class _ProductSku extends State<ProductSku> {
|
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
)), |
|
|
|
|
Expanded(child:GestureDetector( |
|
|
|
|
Expanded( |
|
|
|
|
child: GestureDetector( |
|
|
|
|
onTap: () { |
|
|
|
|
Navigator.of(context).popAndPushNamed('/router/bargain_details'); |
|
|
|
|
Navigator.of(context) |
|
|
|
|
.popAndPushNamed('/router/bargain_details'); |
|
|
|
|
}, |
|
|
|
|
child: Container( |
|
|
|
|
alignment: Alignment.center, |
|
|
|
@ -644,18 +679,20 @@ class _ProductSku extends State<ProductSku> {
|
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
Expanded(child: |
|
|
|
|
Text( |
|
|
|
|
Expanded( |
|
|
|
|
child: Text( |
|
|
|
|
"我要开团", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
|
color: Colors.white, |
|
|
|
|
), |
|
|
|
|
),), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
)),), |
|
|
|
|
)), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
@ -669,7 +706,8 @@ class _ProductSku extends State<ProductSku> {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Widget attrItem(Function fc, AttrListBean attrListBean, position) { |
|
|
|
|
if (attrListBean.attrValueList != null && attrListBean.attrValueList.length > 0) |
|
|
|
|
if (attrListBean.attrValueList != null && |
|
|
|
|
attrListBean.attrValueList.length > 0) |
|
|
|
|
return Column( |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
|
children: [ |
|
|
|
@ -727,7 +765,8 @@ class _ProductSku extends State<ProductSku> {
|
|
|
|
|
return Wrap( |
|
|
|
|
runSpacing: 10.0, |
|
|
|
|
spacing: 10.0, |
|
|
|
|
children: arrays.take(arrays.length).map<Widget>((AttrValueListBean tag) { |
|
|
|
|
children: |
|
|
|
|
arrays.take(arrays.length).map<Widget>((AttrValueListBean tag) { |
|
|
|
|
return GestureDetector( |
|
|
|
|
onTap: () { |
|
|
|
|
fc(tag.attrValue); |
|
|
|
@ -763,5 +802,4 @@ class _ProductSku extends State<ProductSku> {
|
|
|
|
|
), |
|
|
|
|
)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|