Browse Source

砍价;

zyh
w-R 3 years ago
parent
commit
19bf43902c
  1. 2
      lib/main.dart
  2. 12
      lib/order/bargain_group_order.dart
  3. 2
      lib/order/order_history_page.dart
  4. 2
      lib/store/shopping/shopping_goods_details.dart
  5. 282
      lib/store/shopping/shopping_home/bargain_details.dart
  6. 2
      pubspec.lock

2
lib/main.dart

@ -359,7 +359,7 @@ Map<String, WidgetBuilder> routers = <String, WidgetBuilder>{
'/router/group_details': (context, {arguments}) =>
GroupDetails(arguments:arguments),
'/router/bargain_details': (context, {arguments}) =>
BargainDetails(),
BargainDetails(arguments:arguments),
'/router/group_page_details': (context, {arguments}) =>
GroupPageDetails(arguments:arguments),
'/router/photo_view_gallery_screen': (context, {arguments}) =>

12
lib/order/bargain_group_order.dart

@ -131,7 +131,6 @@ class _ExchangeHistoryList extends State<ExchangeHistoryList> {
List<ActivityOrderList> activityOrderList = [];
RefreshController _refreshController =
RefreshController(initialRefresh: false);
int type = 0;
@override
void initState() {
@ -302,7 +301,7 @@ class _ExchangeHistoryList extends State<ExchangeHistoryList> {
// orderInfo.sendStatus,
// orderInfo.isTakeOut)
// : "",
(type == 1)?(activityOrderList.howManyMore != 0 ? "还差${activityOrderList?.howManyMore ?? 0}人拼团成功" : "拼团成功")
(widget.type == 1)?(activityOrderList.howManyMore != 0 ? "还差${activityOrderList?.howManyMore ?? 0}人拼团成功" : "拼团成功")
:(activityOrderList.howManyMoney != 0 ? "还差¥${activityOrderList?.howManyMoney ?? 0}砍价成功" : "成功"),
style: TextStyle(
fontSize: 14.sp,
@ -443,12 +442,19 @@ class _ExchangeHistoryList extends State<ExchangeHistoryList> {
children: [
GestureDetector(
onTap: () {
if(widget.type == 1) {
Navigator.of(context)
.pushNamed('/router/group_details', arguments: {
"actRecordId": activityOrderList.actRecordId,
"actProduct":activityOrderList,
"limitNumber":activityOrderList.successNumber,
});
}else{
Navigator.of(context)
.popAndPushNamed('/router/bargain_details',arguments: {
"actRecordId": activityOrderList.actRecordId,
"limitNumber":activityOrderList.successNumber,
});
}
},
child: RoundButton(
height: 25.h,

2
lib/order/order_history_page.dart

@ -156,7 +156,7 @@ class _OrderHistoryList extends State<OrderHistoryList>
);
})
: NoDataView(
src: "assets/image/icon_empty.png",
src: "assets/image/ding_dan.png",
isShowBtn: false,
text: "目前暂无订单,快去下一单吧~",
fontSize: 16.sp,

2
lib/store/shopping/shopping_goods_details.dart

@ -898,7 +898,7 @@ class _ShoppingGoodsDetails extends State<ShoppingGoodsDetails> {
.popAndPushNamed('/router/bargain_details',arguments: {
// "actRecordId": activityDetails.actRecordAndJoinlDTOList[0]
// .actRecordJoinList[index].actRecordId,
"actProduct":activityDetails.actProduct,
// "actProduct":activityDetails.actProduct,
});
},
child: Container(

282
lib/store/shopping/shopping_home/bargain_details.dart

@ -1,6 +1,12 @@
import 'dart:async';
import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
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/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';
@ -8,8 +14,13 @@ import 'package:huixiang/view_widget/custom_image.dart';
import 'package:huixiang/view_widget/my_appbar.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:shared_preferences/shared_preferences.dart';
class BargainDetails extends StatefulWidget {
final Map<String, dynamic> arguments;
BargainDetails({this.arguments});
@override
State<StatefulWidget> createState() {
return _BargainDetails();
@ -17,22 +28,92 @@ class BargainDetails extends StatefulWidget {
}
class _BargainDetails extends State<BargainDetails> {
ApiService apiService;
@override
void initState() {
super.initState();
}
MinApiService minService;
String actRecordId;
ActivityActRecordDetails activityActRecordDetails;
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;
final SwiperController controller = SwiperController();
final RefreshController refreshController = RefreshController();
int limitNumber = 0;
@override
void dispose() {
super.dispose();
if (refreshController != null) refreshController.dispose();
isDispose = true;
if (_timer != null) {
_timer.cancel();
}
}
final RefreshController refreshController = RefreshController();
@override
void initState() {
super.initState();
actRecordId = widget.arguments["actRecordId"];
limitNumber = widget.arguments["limitNumber"];
startCountdownTimer();
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,
);
queryShowOneAct(actRecordId);
});
}
////
startCountdownTimer() {
if (_timer != null) return;
const oneSec = const Duration(seconds: 1);
var callback = ((timer) {
if (isDispose) return;
setState(() {
var tempDateTime =
DateTime.parse(activityActRecordDetails?.actRecord?.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);
}
///
queryShowOneAct(actRecordId) async {
BaseData<ActivityActRecordDetails> baseData =
await minService.showOneAct(actRecordId).catchError((error) {
refreshController.refreshFailed();
});
if (baseData != null && baseData.isSuccess) {
setState(() {
activityActRecordDetails = baseData.data;
});
refreshController.refreshCompleted();
} else {
refreshController.loadFailed();
}
}
@override
Widget build(BuildContext context) {
@ -122,23 +203,14 @@ class _BargainDetails extends State<BargainDetails> {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ClipRRect(
borderRadius: BorderRadius.circular(2),
child: Image.asset(
"assets/image/icon_story_td.png",
MImage(
activityActRecordDetails?.actProduct?.productImg ?? "",
width: 85,
height: 85,
fit: BoxFit.cover,
errorSrc: "assets/image/default_1.png",
fadeSrc: "assets/image/default_1.png",
),
),
// MImage(
// "",
// width: double.infinity,
// height: 166,
// fit: BoxFit.cover,
// errorSrc: "assets/image/default_1.png",
// fadeSrc: "assets/image/default_1.png",
// ),
SizedBox(
width: 10,
),
@ -150,7 +222,7 @@ class _BargainDetails extends State<BargainDetails> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"[生态小农]山林放养鸡蛋30枚/盒备份 2",
activityActRecordDetails?.actProduct?.productName ?? "",
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
@ -160,7 +232,9 @@ class _BargainDetails extends State<BargainDetails> {
),
),
Text(
"套盒装",
(activityActRecordDetails?.skuName != "")
? (activityActRecordDetails?.skuName ?? "")
: "x1",
style: TextStyle(
fontSize: 10.sp,
fontWeight: MyFontWeight.regular,
@ -179,7 +253,9 @@ class _BargainDetails extends State<BargainDetails> {
),
),
TextSpan(
text: "284.00",
text: activityActRecordDetails
?.actProduct?.productPrice ??
"",
style: TextStyle(
fontSize: 16.sp,
fontWeight: MyFontWeight.semi_bold,
@ -218,8 +294,9 @@ class _BargainDetails extends State<BargainDetails> {
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(margin: EdgeInsets.only(left: 10),child:
Stack(
Container(
margin: EdgeInsets.only(left: 10),
child: Stack(
alignment: Alignment.bottomLeft,
children: [
Container(
@ -241,20 +318,22 @@ class _BargainDetails extends State<BargainDetails> {
),
Align(
alignment: Alignment.bottomLeft,
child:
Container(height:8,child: Icon(
child: Container(
height: 8,
child: Icon(
Icons.arrow_drop_down,
color: Color(0xFF9476F7),
size: 18,
),),
),
),
),
],
),),
),
),
SizedBox(height: 10),
ClipRRect(
borderRadius: BorderRadius.circular(6.5),
child:
Stack(
child: Stack(
children: [
Container(
width: double.infinity,
@ -272,17 +351,21 @@ class _BargainDetails extends State<BargainDetails> {
)
],
)),
SizedBox(height: 3,),
SizedBox(
height: 3,
),
Row(
children: [
Expanded(child:Text(
Expanded(
child: Text(
"原价¥284.00",
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xFF8D8D8D),
),
),),
),
),
Text.rich(
TextSpan(
children: [
@ -302,15 +385,16 @@ class _BargainDetails extends State<BargainDetails> {
color: Color(0xFF9476F7),
),
),
],
),
),
],
),
SizedBox(height: 16),
Row(children: [
Expanded(child: GestureDetector(
Row(
children: [
Expanded(
child: GestureDetector(
child: Container(
alignment: Alignment.center,
width: double.infinity,
@ -362,7 +446,8 @@ class _BargainDetails extends State<BargainDetails> {
// ),
// )
// ),),
Expanded(child:GestureDetector(
Expanded(
child: GestureDetector(
child: Container(
alignment: Alignment.center,
width: double.infinity,
@ -388,9 +473,19 @@ class _BargainDetails extends State<BargainDetails> {
color: Color(0xFF858585),
),
),
)
),),
],),
)),
),
],
),
SizedBox(height: 11.h),
Text(
"剩余时间 ${((tempDay == 0) ? "" : (tempDay.toString() + ":")).toString()} ${tempHour.toString()} : ${tempM.toString()} : ${tempS.toString()}",
style: TextStyle(
fontSize: 10.sp,
fontWeight: MyFontWeight.medium,
color: Color(0xFF353535),
),
),
// Container(
// alignment: Alignment.center,
// width:double.infinity,
@ -639,30 +734,17 @@ class _BargainDetails extends State<BargainDetails> {
padding: EdgeInsets.zero,
scrollDirection: Axis.vertical,
physics: BouncingScrollPhysics(),
itemCount: 3,
itemCount: activityActRecordDetails?.actRecordJoinList != null
? activityActRecordDetails.actRecordJoinList.length
: 0,
itemBuilder: (context, position) {
return GestureDetector(
onTap: () {},
child: bargainFriendsItem(),
child: bargainFriendsItem(activityActRecordDetails, position),
);
},
),
// (coupons != null && coupons.length > 0)
// ? ListView.builder(
// padding: EdgeInsets.symmetric(vertical: 8.h),
// itemBuilder: (context, position) {
// return GestureDetector(
// onTap: () {
// Navigator.of(context).pushNamed(
// '/router/vip_details_page',
// arguments: {"id": coupons[position].id});
// },
// child: vipCardItem(coupons[position]),
// );
// },
// itemCount: coupons != null ? coupons.length : 0,
// )
// : NoDataView(
// NoDataView(
// isShowBtn: false,
// text: "暂无好友帮忙砍价~",
// fontSize: 16.sp,
@ -677,36 +759,37 @@ class _BargainDetails extends State<BargainDetails> {
);
}
Widget bargainFriendsItem() {
Widget bargainFriendsItem(
ActivityActRecordDetails activityActRecordDetails, index) {
return Container(
height: 36.h,
margin: EdgeInsets.only(bottom: 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
// MImage(
// "",
// width:34,
// height:34,
// fit: BoxFit.cover,
// isCircle: true,
// errorSrc: "assets/image/default_1.png",
// fadeSrc: "assets/image/default_1.png",
// ),
Image.asset(
"assets/image/icon_story_td.png",
MImage(
activityActRecordDetails.actRecordJoinList[index]?.memberAvatar ??
"",
width: 34,
height: 34,
fit: BoxFit.cover,
isCircle: true,
errorSrc: "assets/image/default_1.png",
fadeSrc: "assets/image/default_1.png",
),
SizedBox(
width: 4,
),
SizedBox(width: 4,),
Expanded(child:Column(
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"张三",
activityActRecordDetails
.actRecordJoinList[index]?.memberNickname ??
"",
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.medium,
@ -735,7 +818,17 @@ class _BargainDetails extends State<BargainDetails> {
),
),
TextSpan(
text: "23.00元",
text: activityActRecordDetails
.actRecordJoinList[index]?.actPrice ??
"0",
style: TextStyle(
fontSize: 11.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xFF9476F7),
),
),
TextSpan(
text: "",
style: TextStyle(
fontSize: 11.sp,
fontWeight: MyFontWeight.regular,
@ -746,8 +839,39 @@ class _BargainDetails extends State<BargainDetails> {
),
),
],
)
);
));
}
// static handleDate(String oldTime) {
// String nowTime =
// new DateTime.now().toString().split('.')[0].replaceAll('-', '/');
//
// int nowyear = int.parse(nowTime.split(" ")[0].split('/')[0]);
// int nowmonth = int.parse(nowTime.split(" ")[0].split('/')[1]);
// int nowday = int.parse(nowTime.split(" ")[0].split('/')[2]);
// int nowhour = int.parse(nowTime.split(" ")[1].split(':')[0]);
// int nowmin = int.parse(nowTime.split(" ")[1].split(':')[1]);
//
// int oldyear = int.parse(oldTime.split(" ")[0].split('/')[0]);
// int oldmonth = int.parse(oldTime.split(" ")[0].split('/')[1]);
// int oldday = int.parse(oldTime.split(" ")[0].split('/')[2]);
// int oldhour = int.parse(oldTime.split(" ")[1].split(':')[0]);
// int oldmin = int.parse(oldTime.split(" ")[1].split(':')[1]);
//
// var now = new DateTime(nowyear, nowmonth, nowday, nowhour, nowmin);
// var old = new DateTime(oldyear, oldmonth, oldday, oldhour, oldmin);
// var difference = now.difference(old);
//
// if (difference.inDays > 1) {
// return (difference.inDays).toString() + '天前';
// } else if (difference.inDays == 1) {
// return '昨天'.toString();
// } else if (difference.inHours >= 1 && difference.inHours < 24) {
// return (difference.inHours).toString() + '小时前';
// } else if (difference.inMinutes > 5 && difference.inMinutes < 60) {
// return (difference.inMinutes).toString() + '分钟前';
// } else if (difference.inMinutes <= 5) {
// return '刚刚';
// }
// }
}

2
pubspec.lock

@ -255,7 +255,7 @@ packages:
name: flutter_screenutil
url: "https://pub.flutter-io.cn"
source: hosted
version: "5.3.0"
version: "5.3.1"
flutter_smart_dialog:
dependency: "direct main"
description:

Loading…
Cancel
Save