|
|
|
@ -75,9 +75,14 @@ class _ShoppingGoodsDetails extends State<ShoppingGoodsDetails> {
|
|
|
|
|
bool isDispose = false; |
|
|
|
|
Timer _timer; |
|
|
|
|
String testTime = "2021-12-30 10:00:00"; |
|
|
|
|
int tempDay = 0; |
|
|
|
|
int tempHour = 0; |
|
|
|
|
int tempM = 0; |
|
|
|
|
int tempS = 0; |
|
|
|
|
LaunchJoinAct launchJoinAct; |
|
|
|
|
int bargainType = 0; |
|
|
|
|
String indexP; |
|
|
|
|
int joinA = 0; |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
void dispose() { |
|
|
|
@ -238,88 +243,85 @@ class _ShoppingGoodsDetails extends State<ShoppingGoodsDetails> {
|
|
|
|
|
element.skuStock = sku.skuStock.toInt(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
refreshController.refreshCompleted(); |
|
|
|
|
} else { |
|
|
|
|
refreshController.refreshFailed(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
///发起活动 |
|
|
|
|
queryLaunchAct() async { |
|
|
|
|
if (minService == null) |
|
|
|
|
minService = MinApiService( |
|
|
|
|
Dio(), |
|
|
|
|
context: context, |
|
|
|
|
token: minToken, |
|
|
|
|
tenant: tenant, |
|
|
|
|
storeId: storeId, |
|
|
|
|
showLoading: false, |
|
|
|
|
); |
|
|
|
|
BaseData baseData = await minService.launchAct({ |
|
|
|
|
"actProductId": pageType == null |
|
|
|
|
? miNiDetail.productSkuVOList[0].id |
|
|
|
|
: activityDetails.actProduct.id, |
|
|
|
|
"actRecordId": 0, |
|
|
|
|
"actTemplateId": activityDetails.actProduct.templateId, |
|
|
|
|
"actTimeId": activityDetails.actProduct.timeId, |
|
|
|
|
"addressId": "", |
|
|
|
|
"isDirectBuy": (bargainType == 1 || bargainType == 2) ? false : true, |
|
|
|
|
"getType": 1, |
|
|
|
|
"productId": |
|
|
|
|
pageType == null ? productId : activityDetails.actProduct.productId, |
|
|
|
|
"skuId": skuId1, |
|
|
|
|
"skuPrice": skuPrice1, |
|
|
|
|
"templateType": pageType |
|
|
|
|
}).catchError((error) { |
|
|
|
|
refreshController.refreshFailed(); |
|
|
|
|
}); |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
setState(() { |
|
|
|
|
launchJoinAct = baseData.data; |
|
|
|
|
if (bargainType == 1) { |
|
|
|
|
toBargain(); |
|
|
|
|
} else { |
|
|
|
|
toOrder(); |
|
|
|
|
} |
|
|
|
|
goodsCountdownTimer(); |
|
|
|
|
refreshController.refreshCompleted(); |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
if((activityDetails?.actProduct?.productStock ?? 0) == 0) |
|
|
|
|
SmartDialog.showToast("活动商品售罄",alignment: Alignment.center); |
|
|
|
|
refreshController.refreshFailed(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
///参与活动 |
|
|
|
|
queryJoinAct() async { |
|
|
|
|
BaseData baseData = await minService.joinAct({ |
|
|
|
|
"actProductId": pageType == null |
|
|
|
|
? miNiDetail.productSkuVOList[0].id |
|
|
|
|
: activityDetails.actProduct.id, |
|
|
|
|
"actRecordId": indexP, |
|
|
|
|
"actTemplateId": activityDetails.actProduct.templateId, |
|
|
|
|
"actTimeId": activityDetails.actProduct.timeId, |
|
|
|
|
"addressId": "", |
|
|
|
|
"isDirectBuy": pageType == "3" ? false : true, |
|
|
|
|
"getType": 1, |
|
|
|
|
"productId": |
|
|
|
|
pageType == null ? productId : activityDetails.actProduct.productId, |
|
|
|
|
"skuId": skuId1, |
|
|
|
|
"skuPrice": skuPrice1, |
|
|
|
|
"templateType": pageType, |
|
|
|
|
}).catchError((error) { |
|
|
|
|
refreshController.refreshFailed(); |
|
|
|
|
}); |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
launchJoinAct = baseData.data; |
|
|
|
|
toOrder(); |
|
|
|
|
refreshController.refreshCompleted(); |
|
|
|
|
} else { |
|
|
|
|
SmartDialog.showToast(baseData.msg,alignment: Alignment.center); |
|
|
|
|
refreshController.refreshFailed(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
///发起活动 |
|
|
|
|
// queryLaunchAct() async { |
|
|
|
|
// if (minService == null) |
|
|
|
|
// minService = MinApiService( |
|
|
|
|
// Dio(), |
|
|
|
|
// context: context, |
|
|
|
|
// token: minToken, |
|
|
|
|
// tenant: tenant, |
|
|
|
|
// storeId: storeId, |
|
|
|
|
// showLoading: false, |
|
|
|
|
// ); |
|
|
|
|
// BaseData baseData = await minService.launchAct({ |
|
|
|
|
// "actProductId": pageType == null |
|
|
|
|
// ? miNiDetail.productSkuVOList[0].id |
|
|
|
|
// : activityDetails.actProduct.id, |
|
|
|
|
// "actRecordId": 0, |
|
|
|
|
// "actTemplateId": activityDetails.actProduct.templateId, |
|
|
|
|
// "actTimeId": activityDetails.actProduct.timeId, |
|
|
|
|
// "addressId": "", |
|
|
|
|
// "isDirectBuy": (bargainType == 1 || bargainType == 2) ? false : true, |
|
|
|
|
// "getType": 3, |
|
|
|
|
// "productId": |
|
|
|
|
// pageType == null ? productId : activityDetails.actProduct.productId, |
|
|
|
|
// "skuId": skuId1, |
|
|
|
|
// "skuPrice": skuPrice1, |
|
|
|
|
// "templateType": pageType |
|
|
|
|
// }).catchError((error) { |
|
|
|
|
// refreshController.refreshFailed(); |
|
|
|
|
// }); |
|
|
|
|
// if (baseData != null && baseData.isSuccess) { |
|
|
|
|
// setState(() { |
|
|
|
|
// launchJoinAct = baseData.data; |
|
|
|
|
// toBargain(); |
|
|
|
|
// refreshController.refreshCompleted(); |
|
|
|
|
// }); |
|
|
|
|
// } else { |
|
|
|
|
// if((activityDetails?.actProduct?.productStock ?? 0) == 0) |
|
|
|
|
// SmartDialog.showToast("活动商品售罄",alignment: Alignment.center); |
|
|
|
|
// refreshController.refreshFailed(); |
|
|
|
|
// } |
|
|
|
|
// } |
|
|
|
|
// |
|
|
|
|
// ///参与活动 |
|
|
|
|
// queryJoinAct() async { |
|
|
|
|
// BaseData baseData = await minService.joinAct({ |
|
|
|
|
// "actProductId": pageType == null |
|
|
|
|
// ? miNiDetail.productSkuVOList[0].id |
|
|
|
|
// : activityDetails.actProduct.id, |
|
|
|
|
// "actRecordId": indexP, |
|
|
|
|
// "actTemplateId": activityDetails.actProduct.templateId, |
|
|
|
|
// "actTimeId": activityDetails.actProduct.timeId, |
|
|
|
|
// "addressId": "", |
|
|
|
|
// "isDirectBuy": pageType == "3" ? false : true, |
|
|
|
|
// "getType": 1, |
|
|
|
|
// "productId": |
|
|
|
|
// pageType == null ? productId : activityDetails.actProduct.productId, |
|
|
|
|
// "skuId": skuId1, |
|
|
|
|
// "skuPrice": skuPrice1, |
|
|
|
|
// "templateType": pageType, |
|
|
|
|
// }).catchError((error) { |
|
|
|
|
// refreshController.refreshFailed(); |
|
|
|
|
// }); |
|
|
|
|
// if (baseData != null && baseData.isSuccess) { |
|
|
|
|
// launchJoinAct = baseData.data; |
|
|
|
|
// toOrder(); |
|
|
|
|
// refreshController.refreshCompleted(); |
|
|
|
|
// } else { |
|
|
|
|
// SmartDialog.showToast(baseData.msg,alignment: Alignment.center); |
|
|
|
|
// refreshController.refreshFailed(); |
|
|
|
|
// } |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
///选规格弹窗 |
|
|
|
|
showStoreSelector(MiNiDetail miNiDetail, String id, int count) async { |
|
|
|
@ -458,6 +460,31 @@ class _ShoppingGoodsDetails extends State<ShoppingGoodsDetails> {
|
|
|
|
|
_timer = Timer.periodic(oneSec, callback); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
///商品秒杀时间 |
|
|
|
|
goodsCountdownTimer() { |
|
|
|
|
if (_timer != null) return; |
|
|
|
|
const oneSec = const Duration(seconds: 1); |
|
|
|
|
var callback = ((timer) { |
|
|
|
|
if (isDispose) return; |
|
|
|
|
setState(() { |
|
|
|
|
var tempDateTime = |
|
|
|
|
DateTime.parse(activityDetails.endTime).difference(DateTime.now()); |
|
|
|
|
if (tempDateTime.inSeconds < 0) { |
|
|
|
|
tempDay = 0; |
|
|
|
|
tempHour = 0; |
|
|
|
|
tempM = 0; |
|
|
|
|
tempS = 0; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
tempDay = tempDateTime.inDays; |
|
|
|
|
tempHour = tempDateTime.inHours - (tempDateTime.inDays * 24); |
|
|
|
|
tempM = tempDateTime.inMinutes - (tempDateTime.inHours * 60); |
|
|
|
|
tempS = tempDateTime.inSeconds - (tempDateTime.inMinutes * 60); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
_timer = Timer.periodic(oneSec, callback); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
///去下单结算页面 |
|
|
|
|
toDownOrder() async { |
|
|
|
|
if (count1 == 0) { |
|
|
|
@ -507,9 +534,14 @@ class _ShoppingGoodsDetails extends State<ShoppingGoodsDetails> {
|
|
|
|
|
"skuId": skuId1, |
|
|
|
|
"buyNum": count1, |
|
|
|
|
"skuValue1": skuValue1, |
|
|
|
|
"orderId": launchJoinAct.orderId, |
|
|
|
|
// "orderId": launchJoinAct.orderId, |
|
|
|
|
"actProductId": actProductId, |
|
|
|
|
"actProductSkuId": skuId1, |
|
|
|
|
"activityDetails":activityDetails, |
|
|
|
|
"bargainType":bargainType, |
|
|
|
|
"skuPrice1":skuPrice1, |
|
|
|
|
"joinA":joinA, |
|
|
|
|
"indexP":indexP |
|
|
|
|
}, |
|
|
|
|
).then((value) { |
|
|
|
|
_onRefresh(); |
|
|
|
@ -786,11 +818,12 @@ class _ShoppingGoodsDetails extends State<ShoppingGoodsDetails> {
|
|
|
|
|
children: [ |
|
|
|
|
GestureDetector( |
|
|
|
|
onTap: () { |
|
|
|
|
joinA=4; |
|
|
|
|
if (count1 == 0) { |
|
|
|
|
SmartDialog.showToast("请先选择您要购买的商品!~"); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
queryLaunchAct(); |
|
|
|
|
toOrder(); |
|
|
|
|
}, |
|
|
|
|
child: Container( |
|
|
|
|
alignment: Alignment.center, |
|
|
|
@ -846,11 +879,12 @@ class _ShoppingGoodsDetails extends State<ShoppingGoodsDetails> {
|
|
|
|
|
), |
|
|
|
|
GestureDetector( |
|
|
|
|
onTap: () { |
|
|
|
|
joinA=5; |
|
|
|
|
if (count1 == 0) { |
|
|
|
|
SmartDialog.showToast("请先选择您要购买的商品!~"); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
queryLaunchAct(); |
|
|
|
|
toOrder(); |
|
|
|
|
}, |
|
|
|
|
child: Container( |
|
|
|
|
alignment: Alignment.center, |
|
|
|
@ -918,11 +952,12 @@ class _ShoppingGoodsDetails extends State<ShoppingGoodsDetails> {
|
|
|
|
|
GestureDetector( |
|
|
|
|
onTap: () { |
|
|
|
|
bargainType = 0; |
|
|
|
|
joinA=3; |
|
|
|
|
if (count1 == 0) { |
|
|
|
|
SmartDialog.showToast("请先选择您要购买的商品!~"); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
queryLaunchAct(); |
|
|
|
|
toOrder(); |
|
|
|
|
}, |
|
|
|
|
child: Container( |
|
|
|
|
alignment: Alignment.center, |
|
|
|
@ -983,7 +1018,7 @@ class _ShoppingGoodsDetails extends State<ShoppingGoodsDetails> {
|
|
|
|
|
SmartDialog.showToast("请先选择您要购买的商品!~"); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
queryLaunchAct(); |
|
|
|
|
toOrder(); |
|
|
|
|
}, |
|
|
|
|
child: Container( |
|
|
|
|
alignment: Alignment.center, |
|
|
|
@ -1050,11 +1085,12 @@ class _ShoppingGoodsDetails extends State<ShoppingGoodsDetails> {
|
|
|
|
|
children: [ |
|
|
|
|
GestureDetector( |
|
|
|
|
onTap: () { |
|
|
|
|
joinA = 2; |
|
|
|
|
if (count1 == 0) { |
|
|
|
|
SmartDialog.showToast("请先选择您要购买的商品!~"); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
queryLaunchAct(); |
|
|
|
|
toOrder(); |
|
|
|
|
}, |
|
|
|
|
child: Container( |
|
|
|
|
alignment: Alignment.center, |
|
|
|
@ -1111,11 +1147,12 @@ class _ShoppingGoodsDetails extends State<ShoppingGoodsDetails> {
|
|
|
|
|
GestureDetector( |
|
|
|
|
onTap: () { |
|
|
|
|
bargainType = 2; |
|
|
|
|
joinA = 1; |
|
|
|
|
if (count1 == 0) { |
|
|
|
|
SmartDialog.showToast("请先选择您要购买的商品!~"); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
queryLaunchAct(); |
|
|
|
|
toOrder(); |
|
|
|
|
}, |
|
|
|
|
child: Container( |
|
|
|
|
alignment: Alignment.center, |
|
|
|
@ -1396,7 +1433,7 @@ class _ShoppingGoodsDetails extends State<ShoppingGoodsDetails> {
|
|
|
|
|
color: Color(0xFF32A060), |
|
|
|
|
borderRadius: BorderRadius.circular(1)), |
|
|
|
|
child: Text( |
|
|
|
|
"5", |
|
|
|
|
tempDay.toString(), |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Colors.white, |
|
|
|
|
fontSize: 10.sp, |
|
|
|
@ -1428,7 +1465,7 @@ class _ShoppingGoodsDetails extends State<ShoppingGoodsDetails> {
|
|
|
|
|
color: Color(0xFF32A060), |
|
|
|
|
borderRadius: BorderRadius.circular(1)), |
|
|
|
|
child: Text( |
|
|
|
|
"5", |
|
|
|
|
tempHour.toString(), |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Colors.white, |
|
|
|
|
fontSize: 10.sp, |
|
|
|
@ -1459,7 +1496,7 @@ class _ShoppingGoodsDetails extends State<ShoppingGoodsDetails> {
|
|
|
|
|
color: Color(0xFF32A060), |
|
|
|
|
borderRadius: BorderRadius.circular(1)), |
|
|
|
|
child: Text( |
|
|
|
|
"5", |
|
|
|
|
tempM.toString(), |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Colors.white, |
|
|
|
|
fontSize: 10.sp, |
|
|
|
@ -1491,7 +1528,7 @@ class _ShoppingGoodsDetails extends State<ShoppingGoodsDetails> {
|
|
|
|
|
color: Color(0xFF32A060), |
|
|
|
|
borderRadius: BorderRadius.circular(1)), |
|
|
|
|
child: Text( |
|
|
|
|
"5", |
|
|
|
|
tempS.toString(), |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Colors.white, |
|
|
|
|
fontSize: 10.sp, |
|
|
|
@ -1944,12 +1981,13 @@ class _ShoppingGoodsDetails extends State<ShoppingGoodsDetails> {
|
|
|
|
|
), |
|
|
|
|
GestureDetector( |
|
|
|
|
onTap: () { |
|
|
|
|
joinA = 0; |
|
|
|
|
indexP = actRecordAndJoinlDTOList.actRecord.id; |
|
|
|
|
if (count1 == 0) { |
|
|
|
|
SmartDialog.showToast("请先选择您要购买的商品!~"); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
queryJoinAct(); |
|
|
|
|
toOrder(); |
|
|
|
|
}, |
|
|
|
|
child: Container( |
|
|
|
|
alignment: Alignment.center, |
|
|
|
|