From 47c88bfb22e4821fe64c9e6d79d5f4c867bce129 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AB=A0=E6=96=87=E8=BD=A9?= <12812285557@qq.com> Date: Fri, 27 Aug 2021 14:33:05 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=B9=E6=8E=A8=E5=A4=9A=E5=93=81=E6=A0=B9?= =?UTF-8?q?=E6=8D=AE=E5=90=8E=E5=8F=B0=E9=85=8D=E7=BD=AE=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/models/promotion_goods_list_model.dart | 13 +- lib/pages/home/home_page.dart | 32 ++- lib/pages/home/widget/home_weather_view.dart | 215 ++++++++++--------- 3 files changed, 147 insertions(+), 113 deletions(-) diff --git a/lib/models/promotion_goods_list_model.dart b/lib/models/promotion_goods_list_model.dart index d855483..ef196ed 100644 --- a/lib/models/promotion_goods_list_model.dart +++ b/lib/models/promotion_goods_list_model.dart @@ -63,18 +63,24 @@ class PromotionModel { class PromotionActivityModel { int id; + int activitySortId; String activityUrl; String logoUrl; String topUrl; PromotionActivityModel( - {this.id, this.activityUrl, this.logoUrl, this.topUrl}); + {this.id, + this.activityUrl, + this.logoUrl, + this.topUrl, + this.activitySortId}); PromotionActivityModel.fromJson(Map json) { id = json['id']; activityUrl = json['activityUrl']; logoUrl = json['logoUrl']; topUrl = json['topUrl']; + activitySortId = json['activity_sort_id']; } Map toJson() { @@ -83,6 +89,7 @@ class PromotionActivityModel { data['activityUrl'] = this.activityUrl; data['logoUrl'] = this.logoUrl; data['topUrl'] = this.topUrl; + data['activity_sort_id'] = this.activitySortId; return data; } } @@ -181,7 +188,7 @@ class PromotionGoodsModel { isImport = json['isImport']; storehouse = json['storehouse']; isFerme = json['isFerme']; - living = + living = json['living'] != null ? new Living.fromJson(json['living']) : null; specialSale = json['special_sale'] != null ? json['special_sale'].cast() @@ -222,7 +229,7 @@ class PromotionGoodsModel { data['isImport'] = this.isImport; data['storehouse'] = this.storehouse; data['isFerme'] = this.isFerme; - if (this.living != null) { + if (this.living != null) { data['living'] = this.living.toJson(); } data['special_sale'] = this.specialSale; diff --git a/lib/pages/home/home_page.dart b/lib/pages/home/home_page.dart index b6d8940..57ca987 100644 --- a/lib/pages/home/home_page.dart +++ b/lib/pages/home/home_page.dart @@ -1188,9 +1188,11 @@ class _HomePageState extends BaseStoreState // fit: BoxFit.fill, // ), CachedNetworkImage( - imageUrl: icon, placeholder: (context,url) => Image.asset( - R.ASSETS_PLACEHOLDER_NEW_1X1_A_PNG,fit: BoxFit.fill, - )), + imageUrl: icon, + placeholder: (context, url) => Image.asset( + R.ASSETS_PLACEHOLDER_NEW_1X1_A_PNG, + fit: BoxFit.fill, + )), ), Container( margin: EdgeInsets.only(top: 8), @@ -1213,7 +1215,7 @@ class _HomePageState extends BaseStoreState ); } - _placeholder() { + _placeholder() { return Image.asset( R.ASSETS_PLACEHOLDER_NEW_1X1_A_PNG, fit: BoxFit.fill, @@ -1436,11 +1438,27 @@ class _HomePageState extends BaseStoreState array.addAll(model.data.goodsList); } if (model.data.activityList != null && model.data.activityList.length > 0) { - if (array.length > 3) { - array.insert(3, model.data.activityList.first); + if (model.data.activityList.first.activitySortId != 0) { + if (array.length >= model.data.activityList.first.activitySortId) { + array.insert(model.data.activityList.first.activitySortId - 1, + model.data.activityList.first); + } else { + array.add(model.data.activityList.first); + } } else { - array.add(model.data.activityList.first); + if (array.length > 3) { + array.insert(3, model.data.activityList.first); + } else { + array.add(model.data.activityList.first); + } } + + // if (array.length > 3) { + + // array.insert(3, model.data.activityList.first); + // } else { + // array.add(model.data.activityList.first); + // } } // _promotionGoodsList = model.data.goodsList; _promotionGoodsList = array; diff --git a/lib/pages/home/widget/home_weather_view.dart b/lib/pages/home/widget/home_weather_view.dart index 8516401..2ab8262 100644 --- a/lib/pages/home/widget/home_weather_view.dart +++ b/lib/pages/home/widget/home_weather_view.dart @@ -3,6 +3,7 @@ import 'package:flutter/widgets.dart'; import 'package:extended_text/extended_text.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; import 'package:lunar_calendar_converter/lunar_solar_converter.dart'; import 'package:recook/constants/header.dart'; @@ -10,6 +11,8 @@ import 'package:recook/constants/styles.dart'; import 'package:recook/models/home_weather_model.dart'; import 'package:recook/utils/date/recook_lunar.dart'; +import 'home_weather_detail_page.dart'; + class HomeWeatherWidget extends StatefulWidget { final HomeWeatherModel homeWeatherModel; final Color backgroundColor; @@ -45,122 +48,128 @@ class HomeWeatherWidgetState extends State solarDay: nowDateTime.day, solarMonth: nowDateTime.month); Lunar lunar = LunarSolarConverter.solarToLunar(solar); - return Container( - color: _backgroundColor, - child: Column( - children: [ - Container( - height: 40 + ScreenUtil().statusBarHeight, - ), - Container( - width: MediaQuery.of(context).size.width, - height: 40, - padding: EdgeInsets.only(left: 23, right: 16), - child: widget.homeWeatherModel == null - ? Container() - : Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Row( - children: [ - Text( - _normalText(widget.homeWeatherModel.tem), - style: TextStyle( - color: Colors.white, - fontSize: 25, - fontWeight: FontWeight.w500), - ), - Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - "℃", - style: textStyle, - ), - Text( - " ", - style: textStyle, - ), - ], - ), - ], - ), - Container( - width: 2, - ), - Expanded( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, + + return GestureDetector( + onTap: () { + Get.to(HomeWeatherDetailPage()); + }, + child: Container( + color: _backgroundColor, + child: Column( + children: [ + Container( + height: 40 + ScreenUtil().statusBarHeight, + ), + Container( + width: MediaQuery.of(context).size.width, + height: 40, + padding: EdgeInsets.only(left: 23, right: 16), + child: widget.homeWeatherModel == null + ? Container() + : Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Row( children: [ - Row( + Text( + _normalText(widget.homeWeatherModel.tem), + style: TextStyle( + color: Colors.white, + fontSize: 25, + fontWeight: FontWeight.w500), + ), + Column( + mainAxisAlignment: MainAxisAlignment.center, children: [ Text( - _normalText(widget.homeWeatherModel.wea), + "℃", style: textStyle, ), - Container(width: 2), - Image.asset( - _getWeatherImage(_normalText( - widget.homeWeatherModel.weaImg)), - height: 10, - width: 10, - ), - Spacer(), Text( - "${nowDateTime.year}.${nowDateTime.month}.${nowDateTime.day}${_normalText(widget.homeWeatherModel.week)}", - style: textStyle), + " ", + style: textStyle, + ), ], ), - Flex( - direction: Axis.horizontal, - children: [ - Expanded( - child: ExtendedText.rich( - TextSpan( - children: [ - TextSpan( - text: - "湿度:${_normalText(widget.homeWeatherModel.humidity)} 温度:${_normalText(widget.homeWeatherModel.tem2)}-${_normalText(widget.homeWeatherModel.tem1)}℃", - style: textStyle), - // TextSpan(text:" 温度:${_normalText(widget.homeWeatherModel.tem2)}-${_normalText(widget.homeWeatherModel.tem1)}℃", style: textStyle), - WidgetSpan( - child: Container( - margin: EdgeInsets.only( - left: 5, right: 2), - child: Image.asset( - "assets/weatherCake/airquality.png", - height: 11, - width: 11, + ], + ), + Container( + width: 2, + ), + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Row( + children: [ + Text( + _normalText(widget.homeWeatherModel.wea), + style: textStyle, + ), + Container(width: 2), + Image.asset( + _getWeatherImage(_normalText( + widget.homeWeatherModel.weaImg)), + height: 10, + width: 10, + ), + Spacer(), + Text( + "${nowDateTime.year}.${nowDateTime.month}.${nowDateTime.day}${_normalText(widget.homeWeatherModel.week)}", + style: textStyle), + ], + ), + Flex( + direction: Axis.horizontal, + children: [ + Expanded( + child: ExtendedText.rich( + TextSpan( + children: [ + TextSpan( + text: + "湿度:${_normalText(widget.homeWeatherModel.humidity)} 温度:${_normalText(widget.homeWeatherModel.tem2)}-${_normalText(widget.homeWeatherModel.tem1)}℃", + style: textStyle), + // TextSpan(text:" 温度:${_normalText(widget.homeWeatherModel.tem2)}-${_normalText(widget.homeWeatherModel.tem1)}℃", style: textStyle), + WidgetSpan( + child: Container( + margin: EdgeInsets.only( + left: 5, right: 2), + child: Image.asset( + "assets/weatherCake/airquality.png", + height: 11, + width: 11, + ), ), ), - ), - TextSpan( - text: - "${_normalText(widget.homeWeatherModel.air)}${_normalText(widget.homeWeatherModel.airLevel)}", - style: textStyle), - ], + TextSpan( + text: + "${_normalText(widget.homeWeatherModel.air)}${_normalText(widget.homeWeatherModel.airLevel)}", + style: textStyle), + ], + ), + maxLines: 1, + overflow: TextOverflow.clip, ), - maxLines: 1, - overflow: TextOverflow.clip, - ), - ), - Expanded( - child: Container( - alignment: Alignment.centerRight, - child: Text( - RecookLunar(lunar).toString(), - style: textStyle, ), - )), - ], - ), - ], + Expanded( + child: Container( + alignment: Alignment.centerRight, + child: Text( + RecookLunar(lunar).toString(), + style: textStyle, + ), + )), + ], + ), + ], + ), ), - ), - ], - ), - ) - ], + ], + ), + ) + ], + ), ), ); }