From fc50c4d4766f4d92058d8ff95d72a20bc13f5985 Mon Sep 17 00:00:00 2001 From: w-R <953969641@qq.com> Date: Fri, 25 Feb 2022 10:30:23 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E8=B4=AD=E4=B9=B0=E6=9B=B4?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/community/community_details.dart | 2 +- .../data/activity_actRecord_details.dart | 60 ++- lib/retrofit/retrofit_api.dart | 1 - lib/settlement/settlement.dart | 55 ++- .../settlement_order_commodity.dart | 136 +++--- .../shopping/shopping_goods_details.dart | 116 +++-- .../shopping_home/bargain_details.dart | 396 +++++++++++------- 7 files changed, 473 insertions(+), 293 deletions(-) diff --git a/lib/community/community_details.dart b/lib/community/community_details.dart index 391b8702..c9c4a42b 100644 --- a/lib/community/community_details.dart +++ b/lib/community/community_details.dart @@ -127,7 +127,7 @@ class _CommunityDetails extends State with WidgetsBindingObser exitFull: () { setState(() {}); }, - userId:widget.arguments !=null ? widget.arguments["userId"] :widget.arguments["mid"], + userId:widget.arguments !=null ? widget.arguments["userId"] ??widget.arguments["mid"]:"", itemCount: 3, isDetails: true, heightFun: (height) { diff --git a/lib/retrofit/data/activity_actRecord_details.dart b/lib/retrofit/data/activity_actRecord_details.dart index 367a2cc2..4b2479a2 100644 --- a/lib/retrofit/data/activity_actRecord_details.dart +++ b/lib/retrofit/data/activity_actRecord_details.dart @@ -1,18 +1,21 @@ -/// actRecord : {"id":"1494198857058222080","createTime":"2022-02-17 14:35:43","createUser":"1478548720785031168","updateTime":"2022-02-17 14:35:43","updateUser":"1478548720785031168","storeId":"1460885296764682240","type":3,"actTemplateId":"1490572026815971328","actTimeId":"1490572027034075136","actProductId":"1494198261018263552","mid":"1478548720785031168","joinNum":1,"startTime":"2022-02-17 14:35:43","endTime":"2022-02-17 16:35:43","state":2,"isDelete":0} -/// actRecordJoinList : [{"id":"1494198857217605632","createTime":"2022-02-17 14:35:43","createUser":"1478548720785031168","updateTime":"2022-02-17 14:35:43","updateUser":"1478548720785031168","storeId":"1460885296764682240","type":3,"actTemplateId":"1490572026815971328","actTimeId":"1490572027034075136","actRecordId":"1494198857058222080","mid":"1478548720785031168","orderId":null,"isLeader":true,"memberAvatar":"","memberNickname":"","productId":"1494198261018263552","actPrice":"57.81","state":true,"isDelete":0}] +/// actRecord : {"id":"1496692045555695616","createTime":"2022-02-24 11:42:46","createUser":"1496056013827080192","updateTime":"2022-02-24 11:42:46","updateUser":"1496056013827080192","storeId":"1460885296764682240","type":3,"actTemplateId":"1490572026815971328","actTimeId":"1490572027034075136","actProductId":"1494198261018263552","mid":"1496056013827080192","isDirectBuy":false,"joinNum":1,"startTime":"2022-02-24 11:42:46","endTime":"2022-02-24 13:42:46","state":4,"isDelete":0} +/// actRecordJoinList : [{"id":"1496692045677330432","createTime":"2022-02-24 11:42:46","createUser":"1496056013827080192","updateTime":"2022-02-24 11:42:46","updateUser":"1496056013827080192","storeId":"1460885296764682240","type":3,"actTemplateId":"1490572026815971328","actTimeId":"1490572027034075136","actRecordId":"1496692045555695616","mid":"1496056013827080192","orderId":null,"isLeader":true,"memberAvatar":"","memberNickname":"","productId":"1494198261018263552","actPrice":"54.45","state":true,"isDelete":0}] /// actProduct : {"id":"1494198261018263552","createTime":"2022-02-17 14:33:21","createUser":"1364043181062094848","updateTime":"2022-02-17 14:33:21","updateUser":"1364043181062094848","storeId":"1460885296764682240","templateId":"1490572026815971328","timeId":"1490572027034075136","productId":"1461246266586431488","productName":"野生羊肚菌","productImg":"https://pos.upload.gznl.top/1179/2021/11/298d1e1c-2a5f-4b9d-95a7-87b3f88a9cd1.jpg","productPrice":"150.00","promotionPrice":"11.00","productStock":200,"sellCount":0,"skuJson":[{"skuId":"1461246266661928960","skuPrice":11,"skuStock":100},{"skuId":"1461246266687094784","skuPrice":100,"skuStock":100}],"isDelete":0} -/// skuName : "50g/袋" +/// skuName : null +/// isBargain : true class ActivityActRecordDetails { ActivityActRecordDetails({ ActRecord actRecord, List actRecordJoinList, ActProduct actProduct, - String skuName,}){ + dynamic skuName, + bool isBargain,}){ _actRecord = actRecord; _actRecordJoinList = actRecordJoinList; _actProduct = actProduct; _skuName = skuName; + _isBargain = isBargain; } ActivityActRecordDetails.fromJson(dynamic json) { @@ -25,16 +28,19 @@ class ActivityActRecordDetails { } _actProduct = json['actProduct'] != null ? ActProduct.fromJson(json['actProduct']) : null; _skuName = json['skuName']; + _isBargain = json['isBargain']; } ActRecord _actRecord; List _actRecordJoinList; ActProduct _actProduct; - String _skuName; + dynamic _skuName; + bool _isBargain; ActRecord get actRecord => _actRecord; List get actRecordJoinList => _actRecordJoinList; ActProduct get actProduct => _actProduct; - String get skuName => _skuName; + dynamic get skuName => _skuName; + bool get isBargain => _isBargain; Map toJson() { final map = {}; @@ -48,6 +54,7 @@ class ActivityActRecordDetails { map['actProduct'] = _actProduct.toJson(); } map['skuName'] = _skuName; + map['isBargain'] = _isBargain; return map; } @@ -232,23 +239,23 @@ class SkuJson { } -/// id : "1494198857217605632" -/// createTime : "2022-02-17 14:35:43" -/// createUser : "1478548720785031168" -/// updateTime : "2022-02-17 14:35:43" -/// updateUser : "1478548720785031168" +/// id : "1496692045677330432" +/// createTime : "2022-02-24 11:42:46" +/// createUser : "1496056013827080192" +/// updateTime : "2022-02-24 11:42:46" +/// updateUser : "1496056013827080192" /// storeId : "1460885296764682240" /// type : 3 /// actTemplateId : "1490572026815971328" /// actTimeId : "1490572027034075136" -/// actRecordId : "1494198857058222080" -/// mid : "1478548720785031168" +/// actRecordId : "1496692045555695616" +/// mid : "1496056013827080192" /// orderId : null /// isLeader : true /// memberAvatar : "" /// memberNickname : "" /// productId : "1494198261018263552" -/// actPrice : "57.81" +/// actPrice : "54.45" /// state : true /// isDelete : 0 @@ -381,21 +388,22 @@ class ActRecordJoinList { } -/// id : "1494198857058222080" -/// createTime : "2022-02-17 14:35:43" -/// createUser : "1478548720785031168" -/// updateTime : "2022-02-17 14:35:43" -/// updateUser : "1478548720785031168" +/// id : "1496692045555695616" +/// createTime : "2022-02-24 11:42:46" +/// createUser : "1496056013827080192" +/// updateTime : "2022-02-24 11:42:46" +/// updateUser : "1496056013827080192" /// storeId : "1460885296764682240" /// type : 3 /// actTemplateId : "1490572026815971328" /// actTimeId : "1490572027034075136" /// actProductId : "1494198261018263552" -/// mid : "1478548720785031168" +/// mid : "1496056013827080192" +/// isDirectBuy : false /// joinNum : 1 -/// startTime : "2022-02-17 14:35:43" -/// endTime : "2022-02-17 16:35:43" -/// state : 2 +/// startTime : "2022-02-24 11:42:46" +/// endTime : "2022-02-24 13:42:46" +/// state : 4 /// isDelete : 0 class ActRecord { @@ -411,6 +419,7 @@ class ActRecord { String actTimeId, String actProductId, String mid, + bool isDirectBuy, int joinNum, String startTime, String endTime, @@ -427,6 +436,7 @@ class ActRecord { _actTimeId = actTimeId; _actProductId = actProductId; _mid = mid; + _isDirectBuy = isDirectBuy; _joinNum = joinNum; _startTime = startTime; _endTime = endTime; @@ -446,6 +456,7 @@ class ActRecord { _actTimeId = json['actTimeId']; _actProductId = json['actProductId']; _mid = json['mid']; + _isDirectBuy = json['isDirectBuy']; _joinNum = json['joinNum']; _startTime = json['startTime']; _endTime = json['endTime']; @@ -463,6 +474,7 @@ class ActRecord { String _actTimeId; String _actProductId; String _mid; + bool _isDirectBuy; int _joinNum; String _startTime; String _endTime; @@ -480,6 +492,7 @@ class ActRecord { String get actTimeId => _actTimeId; String get actProductId => _actProductId; String get mid => _mid; + bool get isDirectBuy => _isDirectBuy; int get joinNum => _joinNum; String get startTime => _startTime; String get endTime => _endTime; @@ -499,6 +512,7 @@ class ActRecord { map['actTimeId'] = _actTimeId; map['actProductId'] = _actProductId; map['mid'] = _mid; + map['isDirectBuy'] = _isDirectBuy; map['joinNum'] = _joinNum; map['startTime'] = _startTime; map['endTime'] = _endTime; diff --git a/lib/retrofit/retrofit_api.dart b/lib/retrofit/retrofit_api.dart index 1ec5234e..ea00a142 100644 --- a/lib/retrofit/retrofit_api.dart +++ b/lib/retrofit/retrofit_api.dart @@ -19,7 +19,6 @@ import 'package:huixiang/view_widget/login_tips_dialog.dart'; import 'package:retrofit/retrofit.dart'; import 'data/achievement_detail_list.dart'; -import 'data/activity_area_list.dart'; import 'data/address.dart'; import 'data/banner.dart'; import 'data/brand_data.dart'; diff --git a/lib/settlement/settlement.dart b/lib/settlement/settlement.dart index b2298413..54624a1d 100644 --- a/lib/settlement/settlement.dart +++ b/lib/settlement/settlement.dart @@ -9,9 +9,11 @@ import 'package:flutter_baidu_mapapi_utils/flutter_baidu_mapapi_utils.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:fluwx/fluwx.dart'; import 'package:huixiang/generated/l10n.dart'; +import 'package:huixiang/retrofit/data/activity_details.dart'; import 'package:huixiang/retrofit/data/address.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/down_order.dart'; +import 'package:huixiang/retrofit/data/launch_join_act.dart'; import 'package:huixiang/retrofit/data/min_order_info.dart'; import 'package:huixiang/retrofit/data/placeOrderFirst.dart'; import 'package:huixiang/retrofit/data/settleOrderInfo.dart'; @@ -58,13 +60,14 @@ class _Settlement extends State { int payChannel = 4; int tableId = 0; int numberOfPeople = 0; - String pageType ="1"; - + String pageType = "1"; Address address; CouponListBean couponListBean; PromotionInfoListBean promotion; String mobile; bool placeOrder = false; + String actProductId; + String actProductSkuId; @override void initState() { @@ -77,6 +80,8 @@ class _Settlement extends State { promotions = widget.arguments["pName"] ?? ""; coupons = widget.arguments["cName"] ?? ""; pageType = widget.arguments["pageType"]; + actProductId = widget.arguments["actProductId"]; + actProductSkuId = widget.arguments["actProductSkuId"]; if (tableId == 0) { placeOrder = true; } @@ -98,6 +103,8 @@ class _Settlement extends State { null, 0, widget.arguments["pid"], + actProductId ?? "", + actProductSkuId ?? "", ); } else if (coupons != null && coupons != "" || tableId <= 0) { queryOrderInfo( @@ -106,9 +113,13 @@ class _Settlement extends State { widget.arguments["cid"], 0, null, + actProductId ?? "", + actProductSkuId ?? "", ); } else - queryOrderInfo(null, selectedBtn, null, 0, null); + queryOrderInfo(null, selectedBtn, null, 0, null, + actProductId ?? "", + actProductSkuId ?? "",); }); weChatResponseEventHandler.listen((event) async { @@ -124,13 +135,17 @@ class _Settlement extends State { memberCouponId, orderId, promotionId, + actProductId, + actProductSkuId, ) async { BaseData baseData = await minService.getOrderInfo({ "addressId": addressId, "isTake": isTake, "memberCouponId": memberCouponId, "orderId": orderId, - "promotionId": promotionId + "promotionId": promotionId, + "actProductId": actProductId, + "actProductSkuId": actProductSkuId }).catchError((error) {}); if (baseData != null && baseData.isSuccess) { setState(() { @@ -138,7 +153,8 @@ class _Settlement extends State { if (settleOrderInfo.orderProductList == null || settleOrderInfo.orderProductList.length == 0) { placeOrder = true; - queryOrderDetails(parentId); + queryOrderDetails( + pageType != null ? widget.arguments["orderId"] : parentId); } }); } @@ -148,7 +164,7 @@ class _Settlement extends State { queryOrderDetails(id) async { print("ididididididid: $id"); BaseData baseData = await minService.getOrderDetails({ - "id": id, + "id": widget.arguments["orderId"], }).catchError((error) {}); if (baseData != null && baseData.isSuccess) { setState(() { @@ -162,7 +178,9 @@ class _Settlement extends State { this.selectedBtn = selectedBtn; }); if (address != null) { - queryOrderInfo(address.id, selectedBtn, null, 0, null); + queryOrderInfo(address.id, selectedBtn, null, 0, null, + actProductId ?? "", + actProductSkuId ?? "",); return; } BaseData> baseDate = @@ -206,7 +224,9 @@ class _Settlement extends State { } } - queryOrderInfo(address.id, selectedBtn, null, 0, null); + queryOrderInfo(address.id, selectedBtn, null, 0, null, + actProductId ?? "", + actProductSkuId ?? "",); } } @@ -222,7 +242,9 @@ class _Settlement extends State { }); }); - queryOrderInfo(address.id, selectedBtn, null, 0, null); + queryOrderInfo(address.id, selectedBtn, null, 0, null, + actProductId ?? "", + actProductSkuId ?? "",); } } @@ -433,9 +455,11 @@ class _Settlement extends State { this.selectedBtn = 0; }); queryOrderInfo(addressId, isTake, - memberCouponId, orderId, promotionId); + memberCouponId, orderId, promotionId, + actProductId ?? "", + actProductSkuId ?? "",); }, queryAddress, storeInfo, address, - selectedAddress,pageType), + selectedAddress, pageType), SizedBox( height: 16, @@ -453,6 +477,7 @@ class _Settlement extends State { settleOrderInfo, minOrderInfo, tableId, + pageType, ), ///优惠券/备注/会员优惠金额 @@ -505,9 +530,9 @@ class _Settlement extends State { ), ), Text( - minOrderInfo != null + (minOrderInfo != null ? "¥${minOrderInfo.orderSumPrice}" - : "¥${settleOrderInfo == null ? "0" : settleOrderInfo.price}", + : "¥${settleOrderInfo == null ? "0" : settleOrderInfo.price}"), style: TextStyle( fontSize: 20.sp, fontWeight: MyFontWeight.semi_bold, @@ -593,6 +618,8 @@ class _Settlement extends State { couponListBean != null ? couponListBean.id : null, 0, null, + actProductId ?? "", + actProductSkuId ?? "", ); } } @@ -617,6 +644,8 @@ class _Settlement extends State { null, 0, promotion != null ? promotion.id : null, + actProductId ?? "", + actProductSkuId ?? "", ); } } diff --git a/lib/settlement/settlement_view/settlement_order_commodity.dart b/lib/settlement/settlement_view/settlement_order_commodity.dart index 3292f7c2..2dcbdef4 100644 --- a/lib/settlement/settlement_view/settlement_order_commodity.dart +++ b/lib/settlement/settlement_view/settlement_order_commodity.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:huixiang/generated/l10n.dart'; +import 'package:huixiang/retrofit/data/activity_details.dart'; import 'package:huixiang/retrofit/data/min_order_info.dart'; import 'package:huixiang/retrofit/data/order_product_vo.dart'; import 'package:huixiang/retrofit/data/settleOrderInfo.dart'; @@ -14,9 +15,10 @@ class SettlementOrderCommodity extends StatefulWidget { final SettleOrderInfo settleOrderInfo; final MinOrderInfo minOrderInfo; + final String pageType; SettlementOrderCommodity( - this.isTakeOut, this.settleOrderInfo, this.minOrderInfo,this.tableId); + this.isTakeOut, this.settleOrderInfo, this.minOrderInfo,this.tableId,this.pageType,); @override State createState() { @@ -111,7 +113,7 @@ class _SettlementOrderCommodity extends State { color: Colors.grey, ), )); - widgets.add(buildTotalPrice()); + // widgets.add(buildTotalPrice()); return widgets; } @@ -315,71 +317,71 @@ class _SettlementOrderCommodity extends State { ); } - Widget buildTotalPrice() { - return Container( - margin: EdgeInsets.only(top: 7.h, bottom: 11.h), - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - crossAxisAlignment: CrossAxisAlignment.baseline, - textBaseline: TextBaseline.alphabetic, - children: [ - Expanded( - child: Text( - S.of(context).gongjijianshangpin((widget.minOrderInfo != null) - ? ((widget.minOrderInfo != null) - ? widget.minOrderInfo.orderProductVOList.length - : "0") - : (widget.settleOrderInfo != null) - ? widget.settleOrderInfo.orderProductList.length - : "0"), - style: TextStyle( - fontSize: 10.sp, - color: Color(0xFFA29E9E), - fontWeight: MyFontWeight.semi_bold, - ), - ), - flex: 1, - ), - Container( - child: Text( - "已优惠:¥${discountPrice()}", - style: TextStyle( - fontSize: 12.sp, - color: Color(0xFF7B7B7B), - fontWeight: MyFontWeight.medium, - ), - ), - ), - SizedBox( - width: 15.w, - ), - - Container( - child: Text( - S.of(context).jiesuanjine, - style: TextStyle( - fontSize: 12.sp, - color: Color(0xFF353535), - fontWeight: MyFontWeight.semi_bold, - ), - ), - ), - SizedBox( - width: 5.w, - ), - Text( - totalPrice(), - textAlign: TextAlign.end, - style: TextStyle( - fontSize: 14.sp, - color: Color(0xFF32A060), - fontWeight: MyFontWeight.semi_bold, - ), - ), - ], - ), - ); - } + // Widget buildTotalPrice() { + // return Container( + // margin: EdgeInsets.only(top: 7.h, bottom: 11.h), + // child: Row( + // mainAxisAlignment: MainAxisAlignment.end, + // crossAxisAlignment: CrossAxisAlignment.baseline, + // textBaseline: TextBaseline.alphabetic, + // children: [ + // Expanded( + // child: Text( + // S.of(context).gongjijianshangpin((widget.minOrderInfo != null) + // ? ((widget.minOrderInfo != null) + // ? widget.minOrderInfo.orderProductVOList.length + // : "0") + // : (widget.settleOrderInfo != null) + // ? widget.settleOrderInfo.orderProductList.length + // : "0"), + // style: TextStyle( + // fontSize: 10.sp, + // color: Color(0xFFA29E9E), + // fontWeight: MyFontWeight.semi_bold, + // ), + // ), + // flex: 1, + // ), + // Container( + // child: Text( + // "已优惠:¥${discountPrice()}", + // style: TextStyle( + // fontSize: 12.sp, + // color: Color(0xFF7B7B7B), + // fontWeight: MyFontWeight.medium, + // ), + // ), + // ), + // SizedBox( + // width: 15.w, + // ), + // + // Container( + // child: Text( + // S.of(context).jiesuanjine, + // style: TextStyle( + // fontSize: 12.sp, + // color: Color(0xFF353535), + // fontWeight: MyFontWeight.semi_bold, + // ), + // ), + // ), + // SizedBox( + // width: 5.w, + // ), + // Text( + // totalPrice(), + // textAlign: TextAlign.end, + // style: TextStyle( + // fontSize: 14.sp, + // color: Color(0xFF32A060), + // fontWeight: MyFontWeight.semi_bold, + // ), + // ), + // ], + // ), + // ); + // } String discountPrice(){ if(widget.minOrderInfo != null){ diff --git a/lib/store/shopping/shopping_goods_details.dart b/lib/store/shopping/shopping_goods_details.dart index 3cfe6b72..7b59f45f 100644 --- a/lib/store/shopping/shopping_goods_details.dart +++ b/lib/store/shopping/shopping_goods_details.dart @@ -15,6 +15,7 @@ import 'package:huixiang/retrofit/data/activity_details.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/launch_join_act.dart'; import 'package:huixiang/retrofit/data/miNiDetail.dart'; +import 'package:huixiang/retrofit/data/placeOrderFirst.dart'; import 'package:huixiang/retrofit/data/shoppingCart.dart'; import 'package:huixiang/retrofit/data/store_info.dart'; import 'package:huixiang/retrofit/min_api.dart'; @@ -53,6 +54,7 @@ class _ShoppingGoodsDetails extends State { MiNiDetail miNiDetail; bool dialogShowing = false; String skuId1; + String skuPrice1; String skuValue1; int count1 = 0; int tableId = 0; @@ -184,7 +186,8 @@ class _ShoppingGoodsDetails extends State { if (baseData != null && baseData.isSuccess) { setState(() { miNiDetail = baseData.data; - if (pageType != null) queryViewProduct(actProductId, pageType); + if (pageType != null) + queryViewProduct(actProductId, pageType); }); refreshController.refreshCompleted(); } else { @@ -240,21 +243,28 @@ class _ShoppingGoodsDetails extends State { showLoading: false, ); BaseData baseData = await minService.launchAct({ - "actProductId":activityDetails.actProduct.id, - "actRecordId":0, - "actTemplateId":activityDetails.actProduct.templateId, - "actTimeId":activityDetails.actProduct.timeId, - "getType":1, - "productId":activityDetails.actProduct.productId, - "skuId":activityDetails.actProduct.skuJson[0].skuId, - "skuPrice":activityDetails.actProduct.skuJson[0].skuPrice, - "templateType":pageType + "actProductId": pageType == null ? miNiDetail.productSkuVOList[0].id : activityDetails.actProduct.id, + "actRecordId": 0, + "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) { setState(() { launchJoinAct = baseData.data; + if(pageType == "3"){ + toBargain(); + }else{ + toOrder(); + } refreshController.refreshCompleted(); }); } else { @@ -262,26 +272,28 @@ class _ShoppingGoodsDetails extends State { } } - ///参与活动 queryJoinAct() async { BaseData baseData = await minService.joinAct({ "actProductId": "", "actRecordId": "", "actTemplateId": "", - "actTimeId":"", - "getType":1, - "productId":"", - "skuId":"", - "skuPrice":"", - "templateType":1 + "actTimeId": "", + "addressId":"", + "isDirectBuy":true, + "getType": 1, + "productId": "", + "skuId": "", + "skuPrice": "", + "templateType": 1 }).catchError((error) { refreshController.refreshFailed(); }); if (baseData != null && baseData.isSuccess) { launchJoinAct = baseData.data; + toOrder(); refreshController.refreshCompleted(); - }else { + } else { refreshController.refreshFailed(); } } @@ -340,9 +352,11 @@ class _ShoppingGoodsDetails extends State { .replaceAll("[", "") .replaceAll("]", "") .replaceAll(",", ""); + String skuPrice = productSku.skuPrice; setState(() { skuId1 = skuId; skuValue1 = skuValue; + skuPrice1 =skuPrice; count1 = count; }); } @@ -438,7 +452,7 @@ class _ShoppingGoodsDetails extends State { "pid": pid, "cName": cName, "cid": cid, - "pageType":pageType, + "pageType": pageType, "shoppingCartSkuItemList": [ { "buyNum": count1, @@ -456,6 +470,37 @@ class _ShoppingGoodsDetails extends State { ); } + ///直接购买去下单结算页面 + toOrder() async { + await Navigator.of(context).pushNamed( + '/router/settlement', + arguments: { + "storeInfo": storeInfo, + "pageType": pageType, + "isDirectBuy":true, + "productId": (pageType!=null) ? activityDetails.actProduct.productId : miNiDetail.id, + "skuId":skuId1, + "buyNum": count1, + "skuValue1":skuValue1, + "orderId":launchJoinAct.orderId, + "actProductId":actProductId, + "actProductSkuId":skuId1, + }, + ); + } + + ///去砍价详情页面 + toBargain() async { + await Navigator.of(context) + .pushNamed('/router/bargain_details',arguments: { + "actRecordId": launchJoinAct.actRecordId, + "limitNumber":limitNumber, + "storeInfo":storeInfo, + "skuId":skuId1 + }); + } + + @override Widget build(BuildContext context) { return Stack( @@ -674,7 +719,11 @@ class _ShoppingGoodsDetails extends State { ), GestureDetector( onTap: () { - toDownOrder(); + if (count1 == 0) { + SmartDialog.showToast("请先选择您要购买的商品!~"); + return; + } + queryLaunchAct(); }, child: Container( alignment: Alignment.center, @@ -894,12 +943,7 @@ class _ShoppingGoodsDetails extends State { SmartDialog.showToast("请先选择您要购买的商品!~"); return; } - Navigator.of(context) - .popAndPushNamed('/router/bargain_details',arguments: { - // "actRecordId": activityDetails.actRecordAndJoinlDTOList[0] - // .actRecordJoinList[index].actRecordId, - // "actProduct":activityDetails.actProduct, - }); + queryLaunchAct(); }, child: Container( alignment: Alignment.center, @@ -932,8 +976,7 @@ class _ShoppingGoodsDetails extends State { ), ), TextSpan( - text: activityDetails - ?.actProduct?.promotionPrice ?? + text: activityDetails?.actProduct?.promotionPrice ?? "", style: TextStyle( fontSize: 10.sp, @@ -966,7 +1009,11 @@ class _ShoppingGoodsDetails extends State { children: [ GestureDetector( onTap: () { - toDownOrder(); + if (count1 == 0) { + SmartDialog.showToast("请先选择您要购买的商品!~"); + return; + } + queryLaunchAct(); }, child: Container( alignment: Alignment.center, @@ -1022,7 +1069,11 @@ class _ShoppingGoodsDetails extends State { ), GestureDetector( onTap: () { - toDownOrder(); + if (count1 == 0) { + SmartDialog.showToast("请先选择您要购买的商品!~"); + return; + } + queryLaunchAct(); }, child: Container( alignment: Alignment.center, @@ -1605,7 +1656,10 @@ class _ShoppingGoodsDetails extends State { ), ), TextSpan( - text: (limitNumber - (activityDetails.actRecordAndJoinlDTOList[0].actRecord.joinNum)).toString(), + text: (limitNumber - + (activityDetails.actRecordAndJoinlDTOList[0] + .actRecord.joinNum)) + .toString(), style: TextStyle( fontSize: 10.sp, fontWeight: MyFontWeight.regular, diff --git a/lib/store/shopping/shopping_home/bargain_details.dart b/lib/store/shopping/shopping_home/bargain_details.dart index a06ea448..5776a55b 100644 --- a/lib/store/shopping/shopping_home/bargain_details.dart +++ b/lib/store/shopping/shopping_home/bargain_details.dart @@ -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 { 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 { 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 { } } + ///发起活动 + 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 { 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 { 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 { ), ), 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 { ], ), 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 { ), ), 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 { } 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]);