diff --git a/lib/main.dart b/lib/main.dart index 8a1626e8..e7d49859 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -359,7 +359,7 @@ Map routers = { '/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}) => diff --git a/lib/order/bargain_group_order.dart b/lib/order/bargain_group_order.dart index 7230f558..4270e097 100644 --- a/lib/order/bargain_group_order.dart +++ b/lib/order/bargain_group_order.dart @@ -131,7 +131,6 @@ class _ExchangeHistoryList extends State { List activityOrderList = []; RefreshController _refreshController = RefreshController(initialRefresh: false); - int type = 0; @override void initState() { @@ -302,7 +301,7 @@ class _ExchangeHistoryList extends State { // 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 { 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, diff --git a/lib/order/order_history_page.dart b/lib/order/order_history_page.dart index 4baa270a..1eafe3b5 100644 --- a/lib/order/order_history_page.dart +++ b/lib/order/order_history_page.dart @@ -156,7 +156,7 @@ class _OrderHistoryList extends State ); }) : NoDataView( - src: "assets/image/icon_empty.png", + src: "assets/image/ding_dan.png", isShowBtn: false, text: "目前暂无订单,快去下一单吧~", fontSize: 16.sp, diff --git a/lib/store/shopping/shopping_goods_details.dart b/lib/store/shopping/shopping_goods_details.dart index 160fe3f1..27b5150d 100644 --- a/lib/store/shopping/shopping_goods_details.dart +++ b/lib/store/shopping/shopping_goods_details.dart @@ -898,7 +898,7 @@ class _ShoppingGoodsDetails extends State { .popAndPushNamed('/router/bargain_details',arguments: { // "actRecordId": activityDetails.actRecordAndJoinlDTOList[0] // .actRecordJoinList[index].actRecordId, - "actProduct":activityDetails.actProduct, + // "actProduct":activityDetails.actProduct, }); }, child: Container( diff --git a/lib/store/shopping/shopping_home/bargain_details.dart b/lib/store/shopping/shopping_home/bargain_details.dart index b5d04bdb..33ce1141 100644 --- a/lib/store/shopping/shopping_home/bargain_details.dart +++ b/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 arguments; + + BargainDetails({this.arguments}); + @override State createState() { return _BargainDetails(); @@ -17,22 +28,92 @@ class BargainDetails extends StatefulWidget { } class _BargainDetails extends State { - 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 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,76 +203,71 @@ class _BargainDetails extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ - ClipRRect( - borderRadius: BorderRadius.circular(2), - child: Image.asset( - "assets/image/icon_story_td.png", - width: 85, - height: 85, - fit: BoxFit.cover, - ), + 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, ), Expanded( child: Container( - height: 85, - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "[生态小农]山林放养鸡蛋30枚/盒备份 2", - maxLines: 2, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 14.sp, - fontWeight: MyFontWeight.medium, - color: Color(0xFF353535), - ), - ), - Text( - "套盒装", - style: TextStyle( - fontSize: 10.sp, - fontWeight: MyFontWeight.regular, - color: Color(0xFF727272), + height: 85, + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + activityActRecordDetails?.actProduct?.productName ?? "", + maxLines: 2, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 14.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF353535), + ), + ), + Text( + (activityActRecordDetails?.skuName != "") + ? (activityActRecordDetails?.skuName ?? "") + : "x1", + style: TextStyle( + fontSize: 10.sp, + fontWeight: MyFontWeight.regular, + color: Color(0xFF727272), + ), + ), + Text.rich( + TextSpan( + children: [ + TextSpan( + text: "¥", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.semi_bold, + color: Color(0xFF9476F7), + ), ), - ), - Text.rich( TextSpan( - children: [ - TextSpan( - text: "¥", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.semi_bold, - color: Color(0xFF9476F7), - ), - ), - TextSpan( - text: "284.00", - style: TextStyle( - fontSize: 16.sp, - fontWeight: MyFontWeight.semi_bold, - color: Color(0xFF9476F7), - ), - ), - ], + text: activityActRecordDetails + ?.actProduct?.productPrice ?? + "", + style: TextStyle( + fontSize: 16.sp, + fontWeight: MyFontWeight.semi_bold, + color: Color(0xFF9476F7), + ), ), - ), - ], + ], + ), ), - )) + ], + ), + )) ], ), ); @@ -218,46 +294,49 @@ class _BargainDetails extends State { mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ - Container(margin: EdgeInsets.only(left: 10),child: - Stack( - alignment: Alignment.bottomLeft, - children: [ - Container( - alignment: Alignment.center, - width:67, - height:23.h, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(4), - color: Color(0xFF9476F7), + Container( + margin: EdgeInsets.only(left: 10), + child: Stack( + alignment: Alignment.bottomLeft, + children: [ + Container( + alignment: Alignment.center, + width: 67, + height: 23.h, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(4), + color: Color(0xFF9476F7), + ), + child: Text( + "砍价成功", + style: TextStyle( + fontSize: 10.sp, + fontWeight: MyFontWeight.regular, + color: Colors.white, + ), + ), ), - child: Text( - "砍价成功", - style: TextStyle( - fontSize: 10.sp, - fontWeight: MyFontWeight.regular, - color: Colors.white, + Align( + alignment: Alignment.bottomLeft, + child: Container( + height: 8, + child: Icon( + Icons.arrow_drop_down, + color: Color(0xFF9476F7), + size: 18, + ), ), ), - ), - Align( - alignment: Alignment.bottomLeft, - child: - Container(height:8,child: Icon( - Icons.arrow_drop_down, - color: Color(0xFF9476F7), - size: 18, - ),), - ), - ], - ),), - SizedBox(height:10), + ], + ), + ), + SizedBox(height: 10), ClipRRect( borderRadius: BorderRadius.circular(6.5), - child: - Stack( + child: Stack( children: [ Container( - width:double.infinity, + width: double.infinity, height: 8.h, color: Color(0xFFF5F5F5), ), @@ -272,24 +351,28 @@ class _BargainDetails extends State { ) ], )), - SizedBox(height: 3,), + SizedBox( + height: 3, + ), Row( children: [ - Expanded(child:Text( - "原价¥284.00", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: Color(0xFF8D8D8D), + Expanded( + child: Text( + "原价¥284.00", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: Color(0xFF8D8D8D), + ), ), - ),), + ), Text.rich( TextSpan( children: [ TextSpan( text: "最低价¥", style: TextStyle( - fontSize:9.sp, + fontSize: 9.sp, fontWeight: MyFontWeight.regular, color: Color(0xFF9476F7), ), @@ -302,72 +385,74 @@ class _BargainDetails extends State { color: Color(0xFF9476F7), ), ), - ], ), ), ], ), - 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, + 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, + ), ), - ), - 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( + )), + // 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), + width: double.infinity, + height: 54.h, + margin: EdgeInsets.only(left: 6.w), decoration: BoxDecoration( color: Color(0xFFE5E5E5), borderRadius: BorderRadius.circular(27), @@ -380,7 +465,7 @@ class _BargainDetails extends State { ), ], ), - child: Text( + child: Text( "已帮TA砍价", style: TextStyle( fontSize: 16.sp, @@ -388,9 +473,19 @@ class _BargainDetails extends State { 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, @@ -481,7 +576,7 @@ class _BargainDetails extends State { Text( "砍价规则", style: TextStyle( - fontSize:15.sp, + fontSize: 15.sp, fontWeight: MyFontWeight.semi_bold, color: Colors.black, ), @@ -518,7 +613,7 @@ class _BargainDetails extends State { "1.选择自己喜欢的商品,邀请好友砍价,每次砍价金额以页面显示为主,邀请的越多,砍价成功的几率越高。", style: TextStyle( color: Color(0xFF4C4C4C), - fontSize:12.sp, + fontSize: 12.sp, height: 1.5, fontWeight: MyFontWeight.medium, ), @@ -527,7 +622,7 @@ class _BargainDetails extends State { "2.砍价成功后,点击立即购买,将以最终价格进行结算。", style: TextStyle( color: Color(0xFF4C4C4C), - fontSize:12.sp, + fontSize: 12.sp, height: 1.5, fontWeight: MyFontWeight.medium, ), @@ -536,7 +631,7 @@ class _BargainDetails extends State { "3.砍价商品不享受平台活动,优惠券以及会员折扣。", style: TextStyle( color: Color(0xFF4C4C4C), - fontSize:12.sp, + fontSize: 12.sp, height: 1.5, fontWeight: MyFontWeight.medium, ), @@ -598,7 +693,7 @@ class _BargainDetails extends State { Text( "好友砍价榜", style: TextStyle( - fontSize:15.sp, + fontSize: 15.sp, fontWeight: MyFontWeight.semi_bold, color: Colors.black, ), @@ -629,7 +724,7 @@ class _BargainDetails extends State { ], ), SizedBox( - height:20, + height: 20, ), Container( alignment: Alignment.center, @@ -639,30 +734,17 @@ class _BargainDetails extends State { 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, @@ -670,45 +752,46 @@ class _BargainDetails extends State { // ), ), SizedBox( - height:20, + height: 20, ), ], ), ); } - Widget bargainFriendsItem() { + Widget bargainFriendsItem( + ActivityActRecordDetails activityActRecordDetails, index) { return Container( - height: 36.h, - margin: EdgeInsets.only(bottom:10), - child:Row( + 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,), - Expanded(child:Column( + SizedBox( + width: 4, + ), + Expanded( + child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - "张三", + activityActRecordDetails + .actRecordJoinList[index]?.memberNickname ?? + "", style: TextStyle( - fontSize:12.sp, + fontSize: 12.sp, fontWeight: MyFontWeight.medium, color: Color(0xFF353535), ), @@ -716,7 +799,7 @@ class _BargainDetails extends State { Text( "3分钟前", style: TextStyle( - fontSize:10.sp, + fontSize: 10.sp, fontWeight: MyFontWeight.regular, color: Color(0xFFACACAC), ), @@ -735,9 +818,19 @@ class _BargainDetails extends State { ), ), 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, + fontSize: 11.sp, fontWeight: MyFontWeight.regular, color: Color(0xFF9476F7), ), @@ -746,8 +839,39 @@ class _BargainDetails extends State { ), ), ], - ) - ); + )); } + // 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 '刚刚'; + // } + // } } diff --git a/pubspec.lock b/pubspec.lock index 21e6e453..bbd80ec0 100644 --- a/pubspec.lock +++ b/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: