|
|
|
@ -6,7 +6,10 @@ import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter_swiper/flutter_swiper.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/data/activity_actRecord_details.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/data/base_data.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/data/launch_join_act.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/data/store_info.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/min_api.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/retrofit_api.dart'; |
|
|
|
|
import 'package:huixiang/utils/font_weight.dart'; |
|
|
|
|
import 'package:huixiang/view_widget/classic_header.dart'; |
|
|
|
|
import 'package:huixiang/view_widget/custom_image.dart'; |
|
|
|
@ -41,6 +44,9 @@ class _BargainDetails extends State<BargainDetails> {
|
|
|
|
|
final RefreshController refreshController = RefreshController(); |
|
|
|
|
int limitNumber = 0; |
|
|
|
|
double bargainNum = 0; |
|
|
|
|
LaunchJoinAct launchJoinAct; |
|
|
|
|
StoreInfo storeInfo; |
|
|
|
|
String skuId; |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
void dispose() { |
|
|
|
@ -57,6 +63,8 @@ class _BargainDetails extends State<BargainDetails> {
|
|
|
|
|
super.initState(); |
|
|
|
|
actRecordId = widget.arguments["actRecordId"]; |
|
|
|
|
limitNumber = widget.arguments["limitNumber"]; |
|
|
|
|
storeInfo = widget.arguments["storeInfo"]; |
|
|
|
|
skuId = widget.arguments["skuId"]; |
|
|
|
|
startCountdownTimer(); |
|
|
|
|
SharedPreferences.getInstance().then((value) { |
|
|
|
|
String minToken = value.getString("minToken"); |
|
|
|
@ -120,6 +128,51 @@ class _BargainDetails extends State<BargainDetails> {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
///发起活动 |
|
|
|
|
queryLaunchAct() async { |
|
|
|
|
BaseData baseData = await minService.launchAct({ |
|
|
|
|
"actProductId": activityActRecordDetails.actRecord.actProductId, |
|
|
|
|
"actRecordId": 0, |
|
|
|
|
"actTemplateId": activityActRecordDetails.actRecord.actTemplateId, |
|
|
|
|
"actTimeId": activityActRecordDetails.actRecord.actTimeId, |
|
|
|
|
"addressId":"", |
|
|
|
|
"isDirectBuy":true, |
|
|
|
|
"getType": 1, |
|
|
|
|
"productId":activityActRecordDetails.actProduct.productId, |
|
|
|
|
"skuId": skuId, |
|
|
|
|
"skuPrice": activityActRecordDetails.actProduct.promotionPrice, |
|
|
|
|
"templateType": 3 |
|
|
|
|
}).catchError((error) { |
|
|
|
|
refreshController.refreshFailed(); |
|
|
|
|
}); |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
setState(() { |
|
|
|
|
launchJoinAct = baseData.data; |
|
|
|
|
toOrder(); |
|
|
|
|
refreshController.refreshCompleted(); |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
refreshController.refreshFailed(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
///直接购买去下单结算页面 |
|
|
|
|
toOrder() async { |
|
|
|
|
await Navigator.of(context).pushNamed( |
|
|
|
|
'/router/settlement', |
|
|
|
|
arguments: { |
|
|
|
|
"storeInfo": storeInfo, |
|
|
|
|
"pageType": 3, |
|
|
|
|
"isDirectBuy":true, |
|
|
|
|
"productId": activityActRecordDetails.actProduct.productId, |
|
|
|
|
"skuId":skuId, |
|
|
|
|
"buyNum": 1, |
|
|
|
|
"skuValue1":activityActRecordDetails.skuName, |
|
|
|
|
"orderId":launchJoinAct.orderId |
|
|
|
|
}, |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
Widget build(BuildContext context) { |
|
|
|
|
return Stack( |
|
|
|
@ -312,8 +365,11 @@ class _BargainDetails extends State<BargainDetails> {
|
|
|
|
|
borderRadius: BorderRadius.circular(4), |
|
|
|
|
color: Color(0xFF9476F7), |
|
|
|
|
), |
|
|
|
|
child:Text( |
|
|
|
|
(limitNumber != (activityActRecordDetails?.actRecord?.joinNum ?? 0)) ? "已砍${bargainNum.toStringAsFixed(2)}":"砍价成功", |
|
|
|
|
child: Text( |
|
|
|
|
(limitNumber != |
|
|
|
|
(activityActRecordDetails?.actRecord?.joinNum ?? 0)) |
|
|
|
|
? "已砍${bargainNum.toStringAsFixed(2)}" |
|
|
|
|
: "砍价成功", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 10.sp, |
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
@ -341,20 +397,34 @@ class _BargainDetails extends State<BargainDetails> {
|
|
|
|
|
child: Stack( |
|
|
|
|
children: [ |
|
|
|
|
Container( |
|
|
|
|
width:double.infinity, |
|
|
|
|
width: MediaQuery.of(context).size.width * 0.8, |
|
|
|
|
height: 8.h, |
|
|
|
|
color: Color(0xFFF5F5F5), |
|
|
|
|
), |
|
|
|
|
Container( |
|
|
|
|
width:(bargainNum/(double.tryParse(activityActRecordDetails?.actProduct?.productPrice ?? "0") - |
|
|
|
|
double.tryParse(activityActRecordDetails?.actProduct?.promotionPrice ?? "0")))*MediaQuery.of(context).size.width, |
|
|
|
|
height: 8.h, |
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
gradient: LinearGradient( |
|
|
|
|
begin: Alignment.centerLeft, |
|
|
|
|
end: Alignment.centerRight, |
|
|
|
|
colors: [Color(0xFFFEC401), Color(0xFF9274F7)])), |
|
|
|
|
) |
|
|
|
|
if (double.tryParse(activityActRecordDetails |
|
|
|
|
?.actProduct?.productPrice ?? |
|
|
|
|
"0") > |
|
|
|
|
0 && |
|
|
|
|
double.tryParse(activityActRecordDetails |
|
|
|
|
?.actProduct?.promotionPrice ?? |
|
|
|
|
"0") > |
|
|
|
|
0) |
|
|
|
|
Container( |
|
|
|
|
width: (bargainNum / |
|
|
|
|
(double.tryParse(activityActRecordDetails |
|
|
|
|
?.actProduct?.productPrice ?? |
|
|
|
|
"0") - |
|
|
|
|
double.tryParse(activityActRecordDetails |
|
|
|
|
?.actProduct?.promotionPrice ?? |
|
|
|
|
"0"))) * |
|
|
|
|
(MediaQuery.of(context).size.width * 0.8), |
|
|
|
|
height: 8.h, |
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
gradient: LinearGradient( |
|
|
|
|
begin: Alignment.centerLeft, |
|
|
|
|
end: Alignment.centerRight, |
|
|
|
|
colors: [Color(0xFFFEC401), Color(0xFF9274F7)])), |
|
|
|
|
) |
|
|
|
|
], |
|
|
|
|
)), |
|
|
|
|
SizedBox( |
|
|
|
@ -384,7 +454,9 @@ class _BargainDetails extends State<BargainDetails> {
|
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
TextSpan( |
|
|
|
|
text: activityActRecordDetails?.actProduct?.promotionPrice ?? "", |
|
|
|
|
text: activityActRecordDetails |
|
|
|
|
?.actProduct?.promotionPrice ?? |
|
|
|
|
"", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 14.sp, |
|
|
|
|
fontWeight: MyFontWeight.semi_bold, |
|
|
|
@ -397,154 +469,164 @@ class _BargainDetails extends State<BargainDetails> {
|
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
SizedBox(height: 16), |
|
|
|
|
Row( |
|
|
|
|
children: [ |
|
|
|
|
Expanded( |
|
|
|
|
child: GestureDetector( |
|
|
|
|
child: Container( |
|
|
|
|
alignment: Alignment.center, |
|
|
|
|
width: double.infinity, |
|
|
|
|
height: 54.h, |
|
|
|
|
margin: EdgeInsets.only(left: 6.w), |
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
borderRadius: BorderRadius.circular(27), |
|
|
|
|
border: Border.all( |
|
|
|
|
width: 1, |
|
|
|
|
color: Color(0xFF9476F7), |
|
|
|
|
style: BorderStyle.solid, |
|
|
|
|
if ((activityActRecordDetails?.actRecord?.mid ?? "") != |
|
|
|
|
(activityActRecordDetails?.actRecordJoinList != null |
|
|
|
|
? (activityActRecordDetails?.actRecordJoinList[0]?.mid ?? "") |
|
|
|
|
: "")) |
|
|
|
|
Row( |
|
|
|
|
children: [ |
|
|
|
|
Expanded( |
|
|
|
|
child: GestureDetector( |
|
|
|
|
child: Container( |
|
|
|
|
alignment: Alignment.center, |
|
|
|
|
width: double.infinity, |
|
|
|
|
height: 54.h, |
|
|
|
|
margin: EdgeInsets.only(left: 6.w), |
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
borderRadius: BorderRadius.circular(27), |
|
|
|
|
border: Border.all( |
|
|
|
|
width: 1, |
|
|
|
|
color: Color(0xFF9476F7), |
|
|
|
|
style: BorderStyle.solid, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
child: Text( |
|
|
|
|
"我也要砍", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 16.sp, |
|
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
|
color: Color(0xFF9476F7), |
|
|
|
|
child: Text( |
|
|
|
|
"我也要砍", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 16.sp, |
|
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
|
color: Color(0xFF9476F7), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
)), |
|
|
|
|
// Expanded(child:GestureDetector( |
|
|
|
|
// child: Container( |
|
|
|
|
// alignment: Alignment.center, |
|
|
|
|
// width:double.infinity, |
|
|
|
|
// height:54.h, |
|
|
|
|
// margin: EdgeInsets.only(left:6.w), |
|
|
|
|
// decoration: BoxDecoration( |
|
|
|
|
// color: Color(0xFF9476F7), |
|
|
|
|
// borderRadius: BorderRadius.circular(27), |
|
|
|
|
// boxShadow: [ |
|
|
|
|
// BoxShadow( |
|
|
|
|
// color: Colors.black.withAlpha(12), |
|
|
|
|
// offset: Offset(0, 3), |
|
|
|
|
// blurRadius: 14, |
|
|
|
|
// spreadRadius: 0, |
|
|
|
|
// ), |
|
|
|
|
// ], |
|
|
|
|
// ), |
|
|
|
|
// child: Text( |
|
|
|
|
// "帮他砍价", |
|
|
|
|
// style: TextStyle( |
|
|
|
|
// fontSize: 16.sp, |
|
|
|
|
// fontWeight: MyFontWeight.medium, |
|
|
|
|
// color: Colors.white, |
|
|
|
|
// ), |
|
|
|
|
// ), |
|
|
|
|
// ) |
|
|
|
|
// ),), |
|
|
|
|
Expanded( |
|
|
|
|
child: GestureDetector( |
|
|
|
|
child: Container( |
|
|
|
|
alignment: Alignment.center, |
|
|
|
|
width: double.infinity, |
|
|
|
|
height: 54.h, |
|
|
|
|
margin: EdgeInsets.only(left: 6.w), |
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
color: Color(0xFFE5E5E5), |
|
|
|
|
borderRadius: BorderRadius.circular(27), |
|
|
|
|
boxShadow: [ |
|
|
|
|
BoxShadow( |
|
|
|
|
color: Colors.black.withAlpha(12), |
|
|
|
|
offset: Offset(0, 3), |
|
|
|
|
blurRadius: 14, |
|
|
|
|
spreadRadius: 0, |
|
|
|
|
)), |
|
|
|
|
if (activityActRecordDetails?.isBargain ?? false) |
|
|
|
|
Expanded( |
|
|
|
|
child: GestureDetector( |
|
|
|
|
child: Container( |
|
|
|
|
alignment: Alignment.center, |
|
|
|
|
width: double.infinity, |
|
|
|
|
height: 54.h, |
|
|
|
|
margin: EdgeInsets.only(left: 6.w), |
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
color: Color(0xFF9476F7), |
|
|
|
|
borderRadius: BorderRadius.circular(27), |
|
|
|
|
boxShadow: [ |
|
|
|
|
BoxShadow( |
|
|
|
|
color: Colors.black.withAlpha(12), |
|
|
|
|
offset: Offset(0, 3), |
|
|
|
|
blurRadius: 14, |
|
|
|
|
spreadRadius: 0, |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
child: Text( |
|
|
|
|
"帮他砍价", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 16.sp, |
|
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
|
color: Colors.white, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
)), |
|
|
|
|
), |
|
|
|
|
child: Text( |
|
|
|
|
"已帮TA砍价", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 16.sp, |
|
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
|
color: Color(0xFF858585), |
|
|
|
|
), |
|
|
|
|
if (activityActRecordDetails?.isBargain ?? true) |
|
|
|
|
Expanded( |
|
|
|
|
child: GestureDetector( |
|
|
|
|
child: Container( |
|
|
|
|
alignment: Alignment.center, |
|
|
|
|
width: double.infinity, |
|
|
|
|
height: 54.h, |
|
|
|
|
margin: EdgeInsets.only(left: 6.w), |
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
color: Color(0xFFE5E5E5), |
|
|
|
|
borderRadius: BorderRadius.circular(27), |
|
|
|
|
boxShadow: [ |
|
|
|
|
BoxShadow( |
|
|
|
|
color: Colors.black.withAlpha(12), |
|
|
|
|
offset: Offset(0, 3), |
|
|
|
|
blurRadius: 14, |
|
|
|
|
spreadRadius: 0, |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
child: Text( |
|
|
|
|
"已帮TA砍价", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 16.sp, |
|
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
|
color: Color(0xFF858585), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
)), |
|
|
|
|
), |
|
|
|
|
)), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
if(limitNumber == (activityActRecordDetails?.actRecord?.joinNum ?? 0)) |
|
|
|
|
GestureDetector( |
|
|
|
|
child: Container( |
|
|
|
|
alignment: Alignment.center, |
|
|
|
|
width:double.infinity, |
|
|
|
|
height:54.h, |
|
|
|
|
margin: EdgeInsets.only(left:6.w), |
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
color: Color(0xFF9476F7), |
|
|
|
|
borderRadius: BorderRadius.circular(27), |
|
|
|
|
boxShadow: [ |
|
|
|
|
BoxShadow( |
|
|
|
|
color: Colors.black.withAlpha(12), |
|
|
|
|
offset: Offset(0, 3), |
|
|
|
|
blurRadius: 14, |
|
|
|
|
spreadRadius: 0, |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
child: Text( |
|
|
|
|
"立即购买", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 16.sp, |
|
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
|
color: Colors.white, |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
if (limitNumber == |
|
|
|
|
(activityActRecordDetails?.actRecord?.joinNum ?? 0)) |
|
|
|
|
GestureDetector( |
|
|
|
|
onTap: (){ |
|
|
|
|
queryLaunchAct(); |
|
|
|
|
}, |
|
|
|
|
child: Container( |
|
|
|
|
alignment: Alignment.center, |
|
|
|
|
width: double.infinity, |
|
|
|
|
height: 54.h, |
|
|
|
|
margin: EdgeInsets.only(left: 6.w), |
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
color: Color(0xFF9476F7), |
|
|
|
|
borderRadius: BorderRadius.circular(27), |
|
|
|
|
boxShadow: [ |
|
|
|
|
BoxShadow( |
|
|
|
|
color: Colors.black.withAlpha(12), |
|
|
|
|
offset: Offset(0, 3), |
|
|
|
|
blurRadius: 14, |
|
|
|
|
spreadRadius: 0, |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
child: Text( |
|
|
|
|
"立即购买", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 16.sp, |
|
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
|
color: Colors.white, |
|
|
|
|
), |
|
|
|
|
) |
|
|
|
|
), |
|
|
|
|
// GestureDetector( |
|
|
|
|
// child:Container( |
|
|
|
|
// width:double.infinity, |
|
|
|
|
// height:54.h, |
|
|
|
|
// margin: EdgeInsets.only(bottom: 28), |
|
|
|
|
// alignment: Alignment.center, |
|
|
|
|
// decoration: BoxDecoration( |
|
|
|
|
// color: Color(0xFF9476F7), |
|
|
|
|
// borderRadius: BorderRadius.circular(27)), |
|
|
|
|
// child: Row( |
|
|
|
|
// mainAxisAlignment: MainAxisAlignment.center, |
|
|
|
|
// crossAxisAlignment: CrossAxisAlignment.center, |
|
|
|
|
// children: [ |
|
|
|
|
// Image.asset( |
|
|
|
|
// "assets/image/wx.png", |
|
|
|
|
// width:24, |
|
|
|
|
// height:24, |
|
|
|
|
// fit: BoxFit.cover, |
|
|
|
|
// ), |
|
|
|
|
// SizedBox( |
|
|
|
|
// width:8, |
|
|
|
|
// ), |
|
|
|
|
// Text( |
|
|
|
|
// "邀请微信好友帮忙砍价", |
|
|
|
|
// style: TextStyle( |
|
|
|
|
// fontSize: 16.sp, |
|
|
|
|
// fontWeight: MyFontWeight.medium, |
|
|
|
|
// color: Colors.white, |
|
|
|
|
// ), |
|
|
|
|
// ) |
|
|
|
|
// ], |
|
|
|
|
// )) |
|
|
|
|
// ), |
|
|
|
|
), |
|
|
|
|
)), |
|
|
|
|
if (limitNumber != |
|
|
|
|
(activityActRecordDetails?.actRecord?.joinNum ?? 0)) |
|
|
|
|
GestureDetector( |
|
|
|
|
child: Container( |
|
|
|
|
width: double.infinity, |
|
|
|
|
height: 54.h, |
|
|
|
|
margin: EdgeInsets.only(bottom: 28), |
|
|
|
|
alignment: Alignment.center, |
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
color: Color(0xFF9476F7), |
|
|
|
|
borderRadius: BorderRadius.circular(27)), |
|
|
|
|
child: Row( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
|
|
|
children: [ |
|
|
|
|
Image.asset("assets/image/wx.png", |
|
|
|
|
width: 24, |
|
|
|
|
height: 24, |
|
|
|
|
fit: BoxFit.cover, |
|
|
|
|
color: Colors.white), |
|
|
|
|
SizedBox( |
|
|
|
|
width: 8, |
|
|
|
|
), |
|
|
|
|
Text( |
|
|
|
|
"邀请微信好友帮忙砍价", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 16.sp, |
|
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
|
color: Colors.white, |
|
|
|
|
), |
|
|
|
|
) |
|
|
|
|
], |
|
|
|
|
))), |
|
|
|
|
SizedBox(height: 11.h), |
|
|
|
|
Text( |
|
|
|
|
"剩余时间 ${((tempDay == 0) ? "" : (tempDay.toString() + ":")).toString()} ${tempHour.toString()} : ${tempM.toString()} : ${tempS.toString()}", |
|
|
|
@ -832,7 +914,8 @@ class _BargainDetails extends State<BargainDetails> {
|
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
Text( |
|
|
|
|
handleDate(activityActRecordDetails.actRecordJoinList[index].createTime), |
|
|
|
|
handleDate(activityActRecordDetails |
|
|
|
|
.actRecordJoinList[index].createTime), |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 10.sp, |
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
@ -878,8 +961,7 @@ class _BargainDetails extends State<BargainDetails> {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static handleDate(String oldTime) { |
|
|
|
|
String nowTime = |
|
|
|
|
new DateTime.now().toString().split('.')[0]; |
|
|
|
|
String nowTime = new DateTime.now().toString().split('.')[0]; |
|
|
|
|
|
|
|
|
|
int nowyear = int.parse(nowTime.split(" ")[0].split('-')[0]); |
|
|
|
|
int nowmonth = int.parse(nowTime.split(" ")[0].split('-')[1]); |
|
|
|
|