From 8724cad0e4c5917d7c4d1e629ab3da746b0bfe55 Mon Sep 17 00:00:00 2001 From: w-R <953969641@qq.com> Date: Fri, 24 Dec 2021 00:36:10 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=92=E6=9D=80=E4=B8=93=E5=8C=BA=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/main.dart | 2 +- lib/mine/vip_detail_page.dart | 2 +- lib/retrofit/data/activity_area_list.dart | 189 ++- lib/retrofit/data/product.dart | 4 +- lib/retrofit/retrofit_api.dart | 3 +- lib/retrofit/retrofit_api.g.dart | 11 +- .../shopping/activity_prefecture_details.dart | 1072 +++++++++-------- .../shopping_home/shopping_acticvity.dart | 9 +- pubspec.lock | 6 +- 9 files changed, 805 insertions(+), 493 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index bf494de9..b3cc5ded 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -281,7 +281,7 @@ Map routers = { '/router/shopping_mall_home': (context, {arguments}) => ShoppingMallHome(arguments: arguments), '/router/activity_prefecture_details': (context, {arguments}) => - ActivityPrefectureDetails(), + ActivityPrefectureDetails(arguments: arguments), '/router/shopping_goods_details': (context, {arguments}) => ShoppingGoodsDetails(), '/router/search_page': (context, {arguments}) => diff --git a/lib/mine/vip_detail_page.dart b/lib/mine/vip_detail_page.dart index a9dc9c4e..e394fb0a 100644 --- a/lib/mine/vip_detail_page.dart +++ b/lib/mine/vip_detail_page.dart @@ -550,7 +550,7 @@ class _VipDetailPage extends State { return "$totalPrice"; } - List goodsItem(List products) { + List goodsItem(List products) { if (products == null) return []; if (products.length > 3) { products = products.sublist(0, 3); diff --git a/lib/retrofit/data/activity_area_list.dart b/lib/retrofit/data/activity_area_list.dart index 27accb42..4cde4d2b 100644 --- a/lib/retrofit/data/activity_area_list.dart +++ b/lib/retrofit/data/activity_area_list.dart @@ -1,7 +1,7 @@ import 'package:huixiang/retrofit/data/product.dart'; /// actTemplate : {"id":"1473198577613275136","createTime":"2021-12-21 15:48:06","createUser":"1333246101196636160","updateTime":"2021-12-21 15:48:06","updateUser":"1333246101196636160","storeId":"1333246101343436800","type":2,"limitTime":null,"limitNumber":0,"coverImg":"https://pos.upload.gznl.top/1175/2021/12/5bf7a846-768b-4a17-872f-e927988c24c9.jpg","shareImg":"https://pos.upload.gznl.top/1175/2021/12/65f6a0f7-14d1-4393-902e-42e5dc464800.jpg","bannerImg":"https://pos.upload.gznl.top/1175/2021/12/9ee395eb-718c-40c0-bfe0-673dbbade4cf.jpg","state":1,"allDay":false,"startTime":"2021-12-20 00:00:00","endTime":"2021-12-30 00:00:00","isDelete":0} -/// timeProductList : [{"actTime":{"id":"1473198590141661184","createTime":"2021-12-21 15:48:09","createUser":"1333246101196636160","updateTime":"2021-12-21 15:48:09","updateUser":"1333246101196636160","storeId":"1333246101343436800","templateId":"1473198577613275136","allDay":false,"startHour":"09:00:00","endHour":"10:00:00","isDelete":0},"productList":[]},{"actTime":{"id":"1473570616966643712","createTime":"2021-12-22 16:26:27","createUser":"1333246101196636160","updateTime":"2021-12-22 16:26:27","updateUser":"1333246101196636160","storeId":"1333246101343436800","templateId":"1473198577613275136","allDay":false,"startHour":"11:00:00","endHour":"17:00:00","isDelete":0},"productList":[{"id":"1473570776908038144","createTime":"2021-12-22 16:27:05","createUser":"1333246101196636160","updateTime":"2021-12-22 16:27:05","updateUser":"1333246101196636160","storeId":"1333246101343436800","templateId":"1473198577613275136","timeId":"1473570616966643712","productId":"1456500820571848704","productName":"毛毛虫面包","productImg":"https://pos.upload.gznl.top/1175/2021/11/4a6ffabd-0e10-4720-ac93-57ec6855c5cf.jpg","productPrice":"8.00","promotionPrice":"8.00","productStock":-20,"sellCount":0,"skuJson":[{"skuId":"1456500821968551936","skuPrice":8,"skuStock":-20}],"isDelete":0}]}] +/// timeProductList : [{"actTime":{"id":"1473198590141661184","createTime":"2021-12-21 15:48:09","createUser":"1333246101196636160","updateTime":"2021-12-21 15:48:09","updateUser":"1333246101196636160","storeId":"1333246101343436800","templateId":"1473198577613275136","allDay":false,"startHour":"09:00:00","endHour":"10:00:00","isDelete":0},"productList":[{"id":"1473543964270264320","createTime":"2021-12-22 14:40:33","createUser":"1333246101196636160","updateTime":"2021-12-22 14:40:33","updateUser":"1333246101196636160","storeId":"1333246101343436800","templateId":"1473198577613275136","timeId":"1473198590141661184","productId":"1425724410261667840","productName":"西瓜椰椰甘露","productImg":"https://pos.upload.gznl.top/1177/2021/08/3471058e-ac5e-47dd-8ed5-148e8cb28316.jpg","productPrice":"15.00","promotionPrice":"15.00","productStock":2847,"sellCount":0,"skuJson":[{"skuId":"1425724410358136832","skuPrice":15,"skuStock":996},{"skuId":"1425724410387496960","skuPrice":15,"skuStock":851},{"skuId":"1425724410454605824","skuPrice":15,"skuStock":1000}],"isDelete":0}]}] class ActivityAreaList { ActivityAreaList({ @@ -40,12 +40,12 @@ class ActivityAreaList { } /// actTime : {"id":"1473198590141661184","createTime":"2021-12-21 15:48:09","createUser":"1333246101196636160","updateTime":"2021-12-21 15:48:09","updateUser":"1333246101196636160","storeId":"1333246101343436800","templateId":"1473198577613275136","allDay":false,"startHour":"09:00:00","endHour":"10:00:00","isDelete":0} -/// productList : [] +/// productList : [{"id":"1473543964270264320","createTime":"2021-12-22 14:40:33","createUser":"1333246101196636160","updateTime":"2021-12-22 14:40:33","updateUser":"1333246101196636160","storeId":"1333246101343436800","templateId":"1473198577613275136","timeId":"1473198590141661184","productId":"1425724410261667840","productName":"西瓜椰椰甘露","productImg":"https://pos.upload.gznl.top/1177/2021/08/3471058e-ac5e-47dd-8ed5-148e8cb28316.jpg","productPrice":"15.00","promotionPrice":"15.00","productStock":2847,"sellCount":0,"skuJson":[{"skuId":"1425724410358136832","skuPrice":15,"skuStock":996},{"skuId":"1425724410387496960","skuPrice":15,"skuStock":851},{"skuId":"1425724410454605824","skuPrice":15,"skuStock":1000}],"isDelete":0}] class TimeProductList { TimeProductList({ ActTime actTime, - List productList,}){ + List productList,}){ _actTime = actTime; _productList = productList; } @@ -60,10 +60,10 @@ class TimeProductList { } } ActTime _actTime; - List _productList; + List _productList; ActTime get actTime => _actTime; - List get productList => _productList; + List get productList => _productList; Map toJson() { final map = {}; @@ -78,6 +78,185 @@ class TimeProductList { } +/// id : "1473543964270264320" +/// createTime : "2021-12-22 14:40:33" +/// createUser : "1333246101196636160" +/// updateTime : "2021-12-22 14:40:33" +/// updateUser : "1333246101196636160" +/// storeId : "1333246101343436800" +/// templateId : "1473198577613275136" +/// timeId : "1473198590141661184" +/// productId : "1425724410261667840" +/// productName : "西瓜椰椰甘露" +/// productImg : "https://pos.upload.gznl.top/1177/2021/08/3471058e-ac5e-47dd-8ed5-148e8cb28316.jpg" +/// productPrice : "15.00" +/// promotionPrice : "15.00" +/// productStock : 2847 +/// sellCount : 0 +/// skuJson : [{"skuId":"1425724410358136832","skuPrice":15,"skuStock":996},{"skuId":"1425724410387496960","skuPrice":15,"skuStock":851},{"skuId":"1425724410454605824","skuPrice":15,"skuStock":1000}] +/// isDelete : 0 + +class ProductList { + ProductList({ + String id, + String createTime, + String createUser, + String updateTime, + String updateUser, + String storeId, + String templateId, + String timeId, + String productId, + String productName, + String productImg, + String productPrice, + String promotionPrice, + int productStock, + int sellCount, + List skuJson, + int isDelete,}){ + _id = id; + _createTime = createTime; + _createUser = createUser; + _updateTime = updateTime; + _updateUser = updateUser; + _storeId = storeId; + _templateId = templateId; + _timeId = timeId; + _productId = productId; + _productName = productName; + _productImg = productImg; + _productPrice = productPrice; + _promotionPrice = promotionPrice; + _productStock = productStock; + _sellCount = sellCount; + _skuJson = skuJson; + _isDelete = isDelete; +} + + ProductList.fromJson(dynamic json) { + _id = json['id']; + _createTime = json['createTime']; + _createUser = json['createUser']; + _updateTime = json['updateTime']; + _updateUser = json['updateUser']; + _storeId = json['storeId']; + _templateId = json['templateId']; + _timeId = json['timeId']; + _productId = json['productId']; + _productName = json['productName']; + _productImg = json['productImg']; + _productPrice = json['productPrice']; + _promotionPrice = json['promotionPrice']; + _productStock = json['productStock']; + _sellCount = json['sellCount']; + if (json['skuJson'] != null) { + _skuJson = []; + json['skuJson'].forEach((v) { + _skuJson.add(SkuJson.fromJson(v)); + }); + } + _isDelete = json['isDelete']; + } + String _id; + String _createTime; + String _createUser; + String _updateTime; + String _updateUser; + String _storeId; + String _templateId; + String _timeId; + String _productId; + String _productName; + String _productImg; + String _productPrice; + String _promotionPrice; + int _productStock; + int _sellCount; + List _skuJson; + int _isDelete; + + String get id => _id; + String get createTime => _createTime; + String get createUser => _createUser; + String get updateTime => _updateTime; + String get updateUser => _updateUser; + String get storeId => _storeId; + String get templateId => _templateId; + String get timeId => _timeId; + String get productId => _productId; + String get productName => _productName; + String get productImg => _productImg; + String get productPrice => _productPrice; + String get promotionPrice => _promotionPrice; + int get productStock => _productStock; + int get sellCount => _sellCount; + List get skuJson => _skuJson; + int get isDelete => _isDelete; + + Map toJson() { + final map = {}; + map['id'] = _id; + map['createTime'] = _createTime; + map['createUser'] = _createUser; + map['updateTime'] = _updateTime; + map['updateUser'] = _updateUser; + map['storeId'] = _storeId; + map['templateId'] = _templateId; + map['timeId'] = _timeId; + map['productId'] = _productId; + map['productName'] = _productName; + map['productImg'] = _productImg; + map['productPrice'] = _productPrice; + map['promotionPrice'] = _promotionPrice; + map['productStock'] = _productStock; + map['sellCount'] = _sellCount; + if (_skuJson != null) { + map['skuJson'] = _skuJson.map((v) => v.toJson()).toList(); + } + map['isDelete'] = _isDelete; + return map; + } + +} + +/// skuId : "1425724410358136832" +/// skuPrice : 15 +/// skuStock : 996 + +class SkuJson { + SkuJson({ + String skuId, + int skuPrice, + int skuStock,}){ + _skuId = skuId; + _skuPrice = skuPrice; + _skuStock = skuStock; +} + + SkuJson.fromJson(dynamic json) { + _skuId = json['skuId']; + _skuPrice = json['skuPrice']; + _skuStock = json['skuStock']; + } + String _skuId; + int _skuPrice; + int _skuStock; + + String get skuId => _skuId; + int get skuPrice => _skuPrice; + int get skuStock => _skuStock; + + Map toJson() { + final map = {}; + map['skuId'] = _skuId; + map['skuPrice'] = _skuPrice; + map['skuStock'] = _skuStock; + return map; + } + +} + /// id : "1473198590141661184" /// createTime : "2021-12-21 15:48:09" /// createUser : "1333246101196636160" diff --git a/lib/retrofit/data/product.dart b/lib/retrofit/data/product.dart index afd86b87..093e9794 100644 --- a/lib/retrofit/data/product.dart +++ b/lib/retrofit/data/product.dart @@ -1,5 +1,5 @@ -class ProductList { +class ProductsList { String _id; String _createTime; String _createUser; @@ -124,7 +124,7 @@ class ProductList { _batch = batch; } - ProductList.fromJson(dynamic json) { + ProductsList.fromJson(dynamic json) { _id = json["id"]; _createTime = json["createTime"]; _createUser = json["createUser"]; diff --git a/lib/retrofit/retrofit_api.dart b/lib/retrofit/retrofit_api.dart index 48b32e23..21274fd8 100644 --- a/lib/retrofit/retrofit_api.dart +++ b/lib/retrofit/retrofit_api.dart @@ -484,6 +484,7 @@ abstract class ApiService { ///活动专区,秒杀,砍价,拼团 @GET("/actTemplate/findActListByType?allDay={allDay}&type={type}") - Future>> findActListByType(@Path("allDay") bool allDay, @Path("type") int type); + Future> findActListByType(@Path("allDay") bool allDay, @Path("type") int type); + } diff --git a/lib/retrofit/retrofit_api.g.dart b/lib/retrofit/retrofit_api.g.dart index 0b1bec7a..4f0a56ba 100644 --- a/lib/retrofit/retrofit_api.g.dart +++ b/lib/retrofit/retrofit_api.g.dart @@ -1774,7 +1774,7 @@ class _ApiService implements ApiService { } @override - Future>> findActListByType(allDay,type) async { + Future> findActListByType(allDay,type) async { ArgumentError.checkNotNull(allDay, 'allDay'); ArgumentError.checkNotNull(type, 'type'); const _extra = {}; @@ -1789,11 +1789,10 @@ class _ApiService implements ApiService { extra: _extra, baseUrl: baseUrl), data: _data); - final value = BaseData>.fromJson( - _result.data, - (json) => (json as List) - .map((i) => ActivityAreaList.fromJson(i as Map)) - .toList()); + final value = BaseData.fromJson( + _result.data, + (json) => ActivityAreaList.fromJson(json), + ); return value; } diff --git a/lib/store/shopping/activity_prefecture_details.dart b/lib/store/shopping/activity_prefecture_details.dart index d2e7f1c6..0f57f20c 100644 --- a/lib/store/shopping/activity_prefecture_details.dart +++ b/lib/store/shopping/activity_prefecture_details.dart @@ -3,6 +3,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:huixiang/retrofit/data/activity_area_list.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; +import 'package:huixiang/retrofit/data/product.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/custom_image.dart'; @@ -11,6 +12,9 @@ import 'package:shared_preferences/shared_preferences.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; class ActivityPrefectureDetails extends StatefulWidget { + final Map arguments; + + ActivityPrefectureDetails({this.arguments}); @override State createState() { return _ActivityPrefectureDetails(); @@ -21,12 +25,14 @@ class _ActivityPrefectureDetails extends State { ApiService apiService; int seckillIndex = 0; RefreshController refreshController = RefreshController(); - List activityAreaList = []; ScrollController _scrollController; ScrollPhysics _scrollPhysics = NeverScrollableScrollPhysics(); bool scrollFlag = false; - - + List actTimeList = []; + List productList = []; + ActTemplate actTemplate; + int actTimeListIndex = 0; + int pageType = 1; @override void initState() { @@ -34,23 +40,25 @@ class _ActivityPrefectureDetails extends State { _scrollController = ScrollController(); _scrollController.addListener(() { setState(() { - if(_scrollController.offset < (325.h-MediaQuery.of(context).padding.top)){ + if (_scrollController.offset < + (325.h - MediaQuery.of(context).padding.top)) { _scrollPhysics = NeverScrollableScrollPhysics(); - } - else{ + } else { _scrollPhysics = BouncingScrollPhysics(); } }); }); + pageType =widget.arguments["type"]; SharedPreferences.getInstance().then((value) { apiService = ApiService(Dio(), context: context, token: value.getString("token")); - queryFindActListByType(false,2); + + queryFindActListByType(pageType == 2 ?false:true); }); } ///秒杀/砍价/拼团列表 - queryFindActListByType(allDay,type) async { + queryFindActListByType(allDay) async { if (apiService == null) { SharedPreferences value = await SharedPreferences.getInstance(); apiService = ApiService( @@ -59,14 +67,27 @@ class _ActivityPrefectureDetails extends State { token: value.getString("token"), ); } - BaseData> baseData = - await apiService.findActListByType(allDay,type).catchError((error) { + BaseData baseData = + await apiService.findActListByType(allDay,pageType).catchError((error) { refreshController.refreshFailed(); }); + setState(() { + actTimeList.clear(); + productList.clear(); + }); if (baseData != null && baseData.isSuccess) { - activityAreaList.clear(); - activityAreaList.addAll(baseData.data); setState(() { + actTemplate = baseData.data.actTemplate; + actTimeList.addAll(baseData.data.timeProductList); + actTimeListIndex = 0; + for (var i = 0; i < actTimeList.length; i++) { + if (timeFlag(actTimeList[i].actTime.startHour) == 1) { + actTimeListIndex = i; + break; + } + } + if (actTimeList.length > actTimeListIndex) + productList.addAll(actTimeList[actTimeListIndex].productList); refreshController.refreshCompleted(); }); } else { @@ -77,17 +98,17 @@ class _ActivityPrefectureDetails extends State { @override Widget build(BuildContext context) { return SingleChildScrollView( - physics: BouncingScrollPhysics(), - controller: _scrollController, - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - seckillProduct(), - seckilList(), - ], - ), - ); + physics: BouncingScrollPhysics(), + controller: _scrollController, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + seckillProduct(), + seckilList(), + ], + ), + ); } Widget seckillProduct() { @@ -108,175 +129,182 @@ class _ActivityPrefectureDetails extends State { child: Column( children: [ swiper(), - seckillIndex == 0 ? - Container( - width: double.infinity, - alignment: Alignment.center, - height: 62.h, - padding: EdgeInsets.only(left: 16.w,right: 16.w), - decoration: BoxDecoration( - color: Color(0xFFFFEED9)), - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Image.asset( - "assets/image/ms.png", - width:38, - height:38, - fit: BoxFit.contain, - ), - SizedBox(width: 14.w,), - Expanded(child:ListView.builder( - scrollDirection: Axis.horizontal, - physics: BouncingScrollPhysics(), - itemCount:activityAreaList != null ? activityAreaList.length : 0, - itemBuilder: (context, position) { - return GestureDetector( - onTap: () { - setState(() { - }); - }, - child: timeItem(activityAreaList[position],position), - ); - }, - )) - , - ], - ), - ) - : Container( - width: double.infinity, - alignment: Alignment.center, - height: 62.h, - padding: EdgeInsets.only(left: 16.w,right: 16.w), - decoration: BoxDecoration( - color: Color(0xFFFFEED9)), - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Image.asset( - "assets/image/ms_t.png", - width:38, - height:38, - fit: BoxFit.contain, - ), - Spacer(), - Text.rich( - TextSpan( + pageType == 2?(seckillIndex == 0 + ? Container( + width: double.infinity, + alignment: Alignment.center, + height: 62.h, + padding: EdgeInsets.only(left: 16.w, right: 16.w), + decoration: BoxDecoration(color: Color(0xFFFFEED9)), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.center, children: [ - TextSpan( - text: "距秒杀结束还有", - style: TextStyle( - fontSize: 14.sp, - fontWeight: MyFontWeight.semi_bold, - color: Colors.black, - ), + Image.asset( + "assets/image/ms.png", + width: 38, + height: 38, + fit: BoxFit.contain, ), - TextSpan( - text: "0", - style: TextStyle( - fontSize: 14.sp, - fontWeight: MyFontWeight.semi_bold, - color: Color(0xFFFB312B), - ), - ), - TextSpan( - text: "天", - style: TextStyle( - fontSize: 14.sp, - fontWeight: MyFontWeight.semi_bold, - color: Colors.black, - ), + SizedBox( + width: 14.w, ), + Expanded( + child: ListView.builder( + scrollDirection: Axis.horizontal, + physics: BouncingScrollPhysics(), + itemCount: actTimeList?.length ?? 0, + itemBuilder: (context, position) { + return GestureDetector( + onTap: () { + setState(() { + actTimeListIndex = position; + productList.clear(); + productList.addAll(actTimeList[actTimeListIndex].productList); + }); + }, + child: timeItem(actTimeList[position], position), + ); + }, + )), ], ), - ), - SizedBox(width: 4.w), - Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center,children: [ - InkWell( - onTap: () { - setState(() { - }); - }, - child:Container( - width: 20, - height: 20, - alignment: Alignment.center, - decoration: BoxDecoration( - color: Color(0xFFFB312B), - borderRadius: BorderRadius.circular(1)), - child: Text( - "22", - style: TextStyle( - color: Colors.white, - fontSize: 14.sp, - fontWeight: MyFontWeight.medium, - ), - ), - ), - ), - Padding(padding:EdgeInsets.only(left: 2.w,right: 2.w), - child:Text( - ":", - style: TextStyle( - fontWeight: MyFontWeight.medium, - fontSize: 14.sp, - color: Color(0xFFFB312B), - ), - ),), - Container( - width: 20, - height: 20, - alignment: Alignment.center, - decoration: BoxDecoration( - color: Color(0xFFFB312B), - borderRadius: BorderRadius.circular(1)), - child: Text( - "22", - style: TextStyle( - color: Colors.white, - fontSize: 14.sp, - fontWeight: MyFontWeight.medium, - ), - ), - ), - Padding(padding:EdgeInsets.only(left: 2.w,right: 2.w), - child:Text( - ":", - style: TextStyle( - fontWeight: MyFontWeight.medium, - fontSize: 14.sp, - color: Color(0xFFFB312B), + ) + : Container( + width: double.infinity, + alignment: Alignment.center, + height: 62.h, + padding: EdgeInsets.only(left: 16.w, right: 16.w), + decoration: BoxDecoration(color: Color(0xFFFFEED9)), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Image.asset( + "assets/image/ms_t.png", + width: 38, + height: 38, + fit: BoxFit.contain, ), - ),), - InkWell( - onTap: () { - }, - child: Container( - width: 20, - height: 20, - alignment: Alignment.center, - decoration: BoxDecoration( - color: Color(0xFFFB312B), - borderRadius: BorderRadius.circular(1)), - child: Text( - "22", - style: TextStyle( - color: Colors.white, - fontSize: 14.sp, - fontWeight: MyFontWeight.medium, + Spacer(), + Text.rich( + TextSpan( + children: [ + TextSpan( + text: "距秒杀结束还有", + style: TextStyle( + fontSize: 14.sp, + fontWeight: MyFontWeight.semi_bold, + color: Colors.black, + ), + ), + TextSpan( + text: "0", + style: TextStyle( + fontSize: 14.sp, + fontWeight: MyFontWeight.semi_bold, + color: Color(0xFFFB312B), + ), + ), + TextSpan( + text: "天", + style: TextStyle( + fontSize: 14.sp, + fontWeight: MyFontWeight.semi_bold, + color: Colors.black, + ), + ), + ], ), ), - ), + SizedBox(width: 4.w), + Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + InkWell( + onTap: () { + setState(() {}); + }, + child: Container( + width: 20, + height: 20, + alignment: Alignment.center, + decoration: BoxDecoration( + color: Color(0xFFFB312B), + borderRadius: BorderRadius.circular(1)), + child: Text( + "22", + style: TextStyle( + color: Colors.white, + fontSize: 14.sp, + fontWeight: MyFontWeight.medium, + ), + ), + ), + ), + Padding( + padding: EdgeInsets.only(left: 2.w, right: 2.w), + child: Text( + ":", + style: TextStyle( + fontWeight: MyFontWeight.medium, + fontSize: 14.sp, + color: Color(0xFFFB312B), + ), + ), + ), + Container( + width: 20, + height: 20, + alignment: Alignment.center, + decoration: BoxDecoration( + color: Color(0xFFFB312B), + borderRadius: BorderRadius.circular(1)), + child: Text( + "22", + style: TextStyle( + color: Colors.white, + fontSize: 14.sp, + fontWeight: MyFontWeight.medium, + ), + ), + ), + Padding( + padding: EdgeInsets.only(left: 2.w, right: 2.w), + child: Text( + ":", + style: TextStyle( + fontWeight: MyFontWeight.medium, + fontSize: 14.sp, + color: Color(0xFFFB312B), + ), + ), + ), + InkWell( + onTap: () {}, + child: Container( + width: 20, + height: 20, + alignment: Alignment.center, + decoration: BoxDecoration( + color: Color(0xFFFB312B), + borderRadius: BorderRadius.circular(1)), + child: Text( + "22", + style: TextStyle( + color: Colors.white, + fontSize: 14.sp, + fontWeight: MyFontWeight.medium, + ), + ), + ), + ), + ], + ) + ], ), - ],) - ], - ), - ) + )) :Container(), ], ), ); @@ -288,14 +316,16 @@ class _ActivityPrefectureDetails extends State { aspectRatio: 1.3698, child: Stack( children: [ - MImage( - "", - width:double.infinity, + Positioned( + top: 0,left: 0,right: 0,bottom: 0, + child: MImage( + actTemplate?.coverImg ?? "", + width: double.infinity, height: 330.h, fit: BoxFit.cover, errorSrc: "assets/image/default_1.png", fadeSrc: "assets/image/default_1.png", - ), + )), GestureDetector( onTap: () { Navigator.of(context).pop(); @@ -310,106 +340,113 @@ class _ActivityPrefectureDetails extends State { ), ), ), + pageType == 2 ? Align( alignment: Alignment.topCenter, - child:Container( + child: Container( margin: EdgeInsets.only(top: 52), decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), color: Color.fromRGBO(0, 0, 0, 69000000), ), - width:160.w, + width: 160.w, height: 30.h, child: Row( children: [ GestureDetector( - onTap: (){ - setState(() { - seckillIndex =0; - }); - }, + onTap: () { + setState(() { + seckillIndex = 0; + queryFindActListByType(false); + }); + }, child: Container( - alignment: Alignment.center, - width: 72.w, - height:22.h, - margin: EdgeInsets.only(left:6.w), - decoration: BoxDecoration( - gradient: new LinearGradient( - begin: Alignment.centerRight, - end: Alignment.centerLeft, - colors: [ - seckillIndex == 0 ? Color(0xFFF67E5F):Colors.transparent, - seckillIndex == 0 ? Color(0xFFFC5237):Colors.transparent, - ]), - borderRadius: BorderRadius.circular(16), - boxShadow: [ - BoxShadow( - color: Colors.black.withAlpha(12), - offset: Offset(0, 3), - blurRadius: 14, - spreadRadius: 0, - ), - ], - ), - child: Opacity( - opacity: seckillIndex == 0 ? 1 :0.5, - child: Text( - "限时秒杀", - style: TextStyle( - fontSize: 14.sp, - fontWeight: MyFontWeight.medium, - color: Colors.white, - ), + alignment: Alignment.center, + width: 72.w, + height: 22.h, + margin: EdgeInsets.only(left: 6.w), + decoration: BoxDecoration( + gradient: new LinearGradient( + begin: Alignment.centerRight, + end: Alignment.centerLeft, + colors: [ + seckillIndex == 0 + ? Color(0xFFF67E5F) + : Colors.transparent, + seckillIndex == 0 + ? Color(0xFFFC5237) + : Colors.transparent, + ]), + borderRadius: BorderRadius.circular(16), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(12), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, + ), + ], ), - ) - ) - ), + child: Opacity( + opacity: seckillIndex == 0 ? 1 : 0.5, + child: Text( + "限时秒杀", + style: TextStyle( + fontSize: 14.sp, + fontWeight: MyFontWeight.medium, + color: Colors.white, + ), + ), + ))), GestureDetector( - onTap: (){ - setState(() { - seckillIndex = 1; - }); - }, + onTap: () { + setState(() { + seckillIndex = 1; + queryFindActListByType(true); + }); + }, child: Container( - alignment: Alignment.center, - width: 72.w, - height:22.h, - margin: EdgeInsets.only(left:6.w), - decoration: BoxDecoration( - gradient: new LinearGradient( - begin: Alignment.centerRight, - end: Alignment.centerLeft, - colors: [ - seckillIndex == 1 ? Color(0xFFF67E5F):Colors.transparent, - seckillIndex == 1 ? Color(0xFFFC5237):Colors.transparent, - ]), - borderRadius: BorderRadius.circular(16), - boxShadow: [ - BoxShadow( - color: Colors.black.withAlpha(12), - offset: Offset(0, 3), - blurRadius: 14, - spreadRadius: 0, - ), - ], - ), - child:Opacity( - opacity: seckillIndex == 1 ? 1 :0.5, - child: Text( - "限天秒杀", - style: TextStyle( - fontSize: 14.sp, - fontWeight: MyFontWeight.medium, - color: Colors.white, - ), + alignment: Alignment.center, + width: 72.w, + height: 22.h, + margin: EdgeInsets.only(left: 6.w), + decoration: BoxDecoration( + gradient: new LinearGradient( + begin: Alignment.centerRight, + end: Alignment.centerLeft, + colors: [ + seckillIndex == 1 + ? Color(0xFFF67E5F) + : Colors.transparent, + seckillIndex == 1 + ? Color(0xFFFC5237) + : Colors.transparent, + ]), + borderRadius: BorderRadius.circular(16), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(12), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, + ), + ], ), - ) - ) - ), + child: Opacity( + opacity: seckillIndex == 1 ? 1 : 0.5, + child: Text( + "限天秒杀", + style: TextStyle( + fontSize: 14.sp, + fontWeight: MyFontWeight.medium, + color: Colors.white, + ), + ), + ))), ], ), ), - ), + ) : Container(), ], ), ), @@ -419,265 +456,354 @@ class _ActivityPrefectureDetails extends State { ///秒杀列表 Widget seckilList() { return Container( - height: MediaQuery.of(context).size.height-62.h-MediaQuery.of(context).padding.top, + height: MediaQuery.of(context).size.height - + 62.h - + MediaQuery.of(context).padding.top, padding: EdgeInsets.fromLTRB(16.w, 16.h, 16.w, 16.h), + color: Colors.white, child: ListView.builder( padding: EdgeInsets.zero, - itemCount:10, + itemCount: productList?.length ?? 0, scrollDirection: Axis.vertical, shrinkWrap: true, physics: _scrollPhysics, itemBuilder: (context, position) { return GestureDetector( onTap: () { - setState(() {}); + setState(() { + }); }, - child: seckilItem(), + child: seckilItem(productList[position]), ); }, ), ); } - Widget timeItem(ActivityAreaList activityAreaList,position) { + int timeFlag(String time) { + var now = DateTime.now().hour; + var tHour = int.tryParse(time.substring(0, 2)); + if (now < tHour) + return 0; + else if (now == tHour) + return 1; + else + return 2; + } + + Widget timeItem(TimeProductList actTimeList, index) { + var tStatus = timeFlag(actTimeList.actTime.startHour); return Container( - margin: EdgeInsets.only(right:12.w,top:8.h,bottom:8.h), + margin: EdgeInsets.only(right: 12.w, top: 8.h, bottom: 8.h), child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( - activityAreaList.timeProductList[position].actTime.startHour, + actTimeList.actTime.startHour, style: TextStyle( fontSize: 17.sp, fontWeight: MyFontWeight.semi_bold, - color: Color(0xFFFC3127), + color: index == actTimeListIndex + ? Color(0xFFFC3127) + : Color(0xFF4D4D4D), ), ), - Expanded(child: Container( - alignment: Alignment.center, - width:48.w, - height:15.h, - decoration: BoxDecoration( - color: Color(0xFFFB312B), - borderRadius: BorderRadius.circular(16), - boxShadow: [ - BoxShadow( - color: Colors.black.withAlpha(12), - offset: Offset(0, 3), - blurRadius: 14, - spreadRadius: 0, - ), - ], - ), - child: Text( - "已结束", - style: TextStyle( - fontSize:10.sp, - fontWeight: MyFontWeight.regular, - color: Colors.white, - ), - ), - )) + Expanded( + child: tStatus == 0 + ? Container( + alignment: Alignment.center, + width: 48.w, + height: 15.h, + decoration: BoxDecoration( + color: index == actTimeListIndex + ? Color(0xFFFB312B) + : Colors.transparent, + borderRadius: BorderRadius.circular(16), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(12), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, + ), + ], + ), + child: Text( + "即将开始", + style: TextStyle( + fontSize: 10.sp, + fontWeight: MyFontWeight.regular, + color: index == actTimeListIndex + ? Colors.white + : Color(0xFF4D4D4D), + ), + ), + ) + : (tStatus == 1 + ? Container( + alignment: Alignment.center, + width: 48.w, + height: 15.h, + decoration: BoxDecoration( + color: index == actTimeListIndex + ? Color(0xFFFB312B) + : Colors.transparent, + borderRadius: BorderRadius.circular(16), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(12), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, + ), + ], + ), + child: Text( + "马上抢", + style: TextStyle( + fontSize: 10.sp, + fontWeight: MyFontWeight.regular, + color: index == actTimeListIndex + ? Colors.white + : Color(0xFF4D4D4D), + ), + ), + ) + : Container( + alignment: Alignment.center, + width: 48.w, + height: 15.h, + decoration: BoxDecoration( + color: index == actTimeListIndex + ? Color(0xFFFB312B) + : Colors.transparent, + borderRadius: BorderRadius.circular(16), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(12), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, + ), + ], + ), + child: Text( + "已结束", + style: TextStyle( + fontSize: 10.sp, + fontWeight: MyFontWeight.regular, + color: index == actTimeListIndex + ? Colors.white + : Color(0xFF4D4D4D), + ), + ), + ))) ], ), ); } - Widget seckilItem() { + Widget seckilItem(ProductList productList) { + var tStatus = timeFlag(actTimeList[actTimeListIndex].actTime.startHour); return Container( - margin: EdgeInsets.only(right:12.w,top: 12.h,bottom: 12.h), + margin: EdgeInsets.only(right: 12.w, top: 12.h, bottom: 12.h), child: Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ - // MImage( - // "", - // width: 94.w, - // height: 94.h, - // fit: BoxFit.cover, - // errorSrc: "assets/image/default_1.png", - // fadeSrc: "assets/image/default_1.png", - // ), - Image.asset( - "assets/image/icon_story_td.png", + MImage( + productList.productImg, width: 94, height: 94, fit: BoxFit.cover, + errorSrc: "assets/image/default_1.png", + fadeSrc: "assets/image/default_1.png", ), - SizedBox(width:12.w,), - Expanded(child: Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "[生态小农]山林放养鸡蛋30枚/盒", - maxLines: 2, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 15.sp, - fontWeight: MyFontWeight.medium, - color: Color(0xFF353535), + SizedBox( + width: 12.w, + ), + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + productList.productName, + maxLines: 2, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 15.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF353535), + ), ), - ), - Text( - "限量45件", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: Color(0xFF4D4D4D), + Text( + "限量${productList.productStock}件", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: Color(0xFF4D4D4D), + ), ), - ), - Row( - children: [ - ClipRRect( - borderRadius: BorderRadius.circular(6.5), - child: - Stack( + Row( children: [ - Container( - width: 180.w, - height: 8.h, - color: Color(0xFFF5F5F5), + ClipRRect( + borderRadius: BorderRadius.circular(6.5), + child: Stack( + children: [ + Container( + width: 180.w, + height: 8.h, + color: Color(0xFFF5F5F5), + ), + Container( + width: 100.w, + height: 8.h, + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.centerLeft, + end: Alignment.centerRight, + colors: [ + Color(0xFFFDBA56), + Color(0xFFFB2B2B) + ])), + ) + ], + )), + SizedBox( + width: 5, ), - Container( - width: 100.w, - height: 8.h, - decoration: BoxDecoration( - gradient: LinearGradient( - begin: Alignment.centerLeft, - end: Alignment.centerRight, - colors: [Color(0xFFFDBA56), Color(0xFFFB2B2B)])), - ) - ], - )), - SizedBox(width: 5,), - Text( - "已售67%", - style: TextStyle( - fontSize: 10.sp, - fontWeight: MyFontWeight.regular, - color: Color(0xFF353535), + Text( + "已售${productList.sellCount}", + style: TextStyle( + fontSize: 10.sp, + fontWeight: MyFontWeight.regular, + color: Color(0xFF353535), + ), ), - ), - ], - ), - Row( - children: [ - Text.rich( - TextSpan( - children: [ - TextSpan( - text: "¥", - style: TextStyle( - fontSize: 14.sp, - fontWeight: MyFontWeight.semi_bold, - color: Color(0xFFFB2E2C), + ], + ), + Row( + children: [ + Text.rich( + TextSpan( + children: [ + TextSpan( + text: "¥", + style: TextStyle( + fontSize: 14.sp, + fontWeight: MyFontWeight.semi_bold, + color: Color(0xFFFB2E2C), + ), ), - ), - TextSpan( - text: "123.00", - style: TextStyle( - fontSize: 18.sp, - fontWeight: MyFontWeight.semi_bold, - color: Color(0xFFFB2E2C), + TextSpan( + text: productList.promotionPrice, + style: TextStyle( + fontSize: 18.sp, + fontWeight: MyFontWeight.semi_bold, + color: Color(0xFFFB2E2C), + ), ), - ), - ], - ), - ), - Expanded(child: Text( - "¥234.00", - style: TextStyle( - fontSize: 10.sp, - decoration: TextDecoration.lineThrough, - decorationColor: Color(0xFF585858), - fontWeight: MyFontWeight.regular, - color: Color(0xFF353535), + ], + ), ), - ),), - Container( - alignment: Alignment.center, - width:60.w, - height:24.h, - decoration: BoxDecoration( - color: Color(0xFFFB312B), - borderRadius: BorderRadius.circular(12), - boxShadow: [ - BoxShadow( - color: Colors.black.withAlpha(12), - offset: Offset(0, 3), - blurRadius: 14, - spreadRadius: 0, + Expanded( + child: Text( + productList.productPrice, + style: TextStyle( + fontSize: 10.sp, + decoration: TextDecoration.lineThrough, + decorationColor: Color(0xFF585858), + fontWeight: MyFontWeight.regular, + color: Color(0xFF353535), ), - ], - ), - child: Text( - "马上抢", - style: TextStyle( - fontSize:12.sp, - fontWeight: MyFontWeight.medium, - color: Colors.white, ), ), - ), - // Container( - // alignment: Alignment.center, - // width:60.w, - // height:24.h, - // decoration: BoxDecoration( - // color: Color(0xFFE2F6EA), - // borderRadius: BorderRadius.circular(12), - // boxShadow: [ - // BoxShadow( - // color: Colors.black.withAlpha(12), - // offset: Offset(0, 3), - // blurRadius: 14, - // spreadRadius: 0, - // ), - // ], - // ), - // child: Text( - // "即将开始", - // style: TextStyle( - // fontSize:12.sp, - // fontWeight: MyFontWeight.medium, - // color: Color(0xFF52AF79), - // ), - // ), - // ), - // Container( - // alignment: Alignment.center, - // width:60.w, - // height:24.h, - // decoration: BoxDecoration( - // color: Colors.transparent, - // borderRadius: BorderRadius.circular(12), - // boxShadow: [ - // BoxShadow( - // color: Colors.black.withAlpha(12), - // offset: Offset(0, 3), - // blurRadius: 14, - // spreadRadius: 0, - // ), - // ], - // ), - // child: Text( - // "已结束", - // style: TextStyle( - // fontSize:12.sp, - // fontWeight: MyFontWeight.medium, - // color: Color(0xFFADADAD), - // ), - // ), - // ), - ], - ), - ], - ),) + tStatus == 0 + ? Container( + alignment: Alignment.center, + width: 60.w, + height: 24.h, + decoration: BoxDecoration( + color: Color(0xFFE2F6EA), + borderRadius: BorderRadius.circular(12), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(12), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, + ), + ], + ), + child: Text( + "即将开始", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF52AF79), + ), + ), + ) + : (tStatus == 1 + ? Container( + alignment: Alignment.center, + width: 60.w, + height: 24.h, + decoration: BoxDecoration( + color: Color(0xFFFB312B), + borderRadius: BorderRadius.circular(12), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(12), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, + ), + ], + ), + child: Text( + "马上抢", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + color: Colors.white, + ), + ), + ) + : Container( + alignment: Alignment.center, + width: 60.w, + height: 24.h, + decoration: BoxDecoration( + color: Colors.transparent, + borderRadius: BorderRadius.circular(12), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(12), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, + ), + ], + ), + child: Text( + "已结束", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFFADADAD), + ), + ), + )), + ], + ), + ], + ), + ) ], ), ); } - } diff --git a/lib/store/shopping/shopping_home/shopping_acticvity.dart b/lib/store/shopping/shopping_home/shopping_acticvity.dart index 0a443d42..0f939ed7 100644 --- a/lib/store/shopping/shopping_home/shopping_acticvity.dart +++ b/lib/store/shopping/shopping_home/shopping_acticvity.dart @@ -39,7 +39,10 @@ class _ShoppingActivity extends State { children: [ GestureDetector( onTap: () { - Navigator.of(context).pushNamed('/router/activity_prefecture_details'); + Navigator.of(context).pushNamed('/router/activity_prefecture_details', + arguments: { + "type":2 + }); }, child: Container( margin: EdgeInsets.symmetric(horizontal: 5.w ), @@ -127,6 +130,8 @@ class _ShoppingActivity extends State { children: [ GestureDetector( onTap: () { + Navigator.of(context).pushNamed('/router/activity_prefecture_details', + arguments: { "type":3}); }, child: Container( margin: EdgeInsets.symmetric(horizontal: 5.w), @@ -218,6 +223,8 @@ class _ShoppingActivity extends State { ), GestureDetector( onTap: () { + Navigator.of(context).pushNamed('/router/activity_prefecture_details', + arguments: { "type":1}); }, child: Container( margin: EdgeInsets.symmetric(horizontal: 5.w), diff --git a/pubspec.lock b/pubspec.lock index 45429d08..0fe9042a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -269,7 +269,7 @@ packages: name: flutter_screenutil url: "https://pub.flutter-io.cn" source: hosted - version: "5.0.1+2" + version: "5.0.1+3" flutter_smart_dialog: dependency: "direct main" description: @@ -615,7 +615,7 @@ packages: name: scan url: "https://pub.flutter-io.cn" source: hosted - version: "1.5.0" + version: "1.6.0" shared_preferences: dependency: "direct main" description: @@ -846,7 +846,7 @@ packages: name: video_player_web url: "https://pub.flutter-io.cn" source: hosted - version: "2.0.4" + version: "2.0.5" wakelock: dependency: transitive description: