特推多品根据后台配置位置

master
章文轩 4 years ago
parent a3e9cd2a8a
commit 47c88bfb22

@ -63,18 +63,24 @@ class PromotionModel {
class PromotionActivityModel { class PromotionActivityModel {
int id; int id;
int activitySortId;
String activityUrl; String activityUrl;
String logoUrl; String logoUrl;
String topUrl; String topUrl;
PromotionActivityModel( PromotionActivityModel(
{this.id, this.activityUrl, this.logoUrl, this.topUrl}); {this.id,
this.activityUrl,
this.logoUrl,
this.topUrl,
this.activitySortId});
PromotionActivityModel.fromJson(Map<String, dynamic> json) { PromotionActivityModel.fromJson(Map<String, dynamic> json) {
id = json['id']; id = json['id'];
activityUrl = json['activityUrl']; activityUrl = json['activityUrl'];
logoUrl = json['logoUrl']; logoUrl = json['logoUrl'];
topUrl = json['topUrl']; topUrl = json['topUrl'];
activitySortId = json['activity_sort_id'];
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
@ -83,6 +89,7 @@ class PromotionActivityModel {
data['activityUrl'] = this.activityUrl; data['activityUrl'] = this.activityUrl;
data['logoUrl'] = this.logoUrl; data['logoUrl'] = this.logoUrl;
data['topUrl'] = this.topUrl; data['topUrl'] = this.topUrl;
data['activity_sort_id'] = this.activitySortId;
return data; return data;
} }
} }
@ -181,7 +188,7 @@ class PromotionGoodsModel {
isImport = json['isImport']; isImport = json['isImport'];
storehouse = json['storehouse']; storehouse = json['storehouse'];
isFerme = json['isFerme']; isFerme = json['isFerme'];
living = living =
json['living'] != null ? new Living.fromJson(json['living']) : null; json['living'] != null ? new Living.fromJson(json['living']) : null;
specialSale = json['special_sale'] != null specialSale = json['special_sale'] != null
? json['special_sale'].cast<String>() ? json['special_sale'].cast<String>()
@ -222,7 +229,7 @@ class PromotionGoodsModel {
data['isImport'] = this.isImport; data['isImport'] = this.isImport;
data['storehouse'] = this.storehouse; data['storehouse'] = this.storehouse;
data['isFerme'] = this.isFerme; data['isFerme'] = this.isFerme;
if (this.living != null) { if (this.living != null) {
data['living'] = this.living.toJson(); data['living'] = this.living.toJson();
} }
data['special_sale'] = this.specialSale; data['special_sale'] = this.specialSale;

@ -1188,9 +1188,11 @@ class _HomePageState extends BaseStoreState<HomePage>
// fit: BoxFit.fill, // fit: BoxFit.fill,
// ), // ),
CachedNetworkImage( CachedNetworkImage(
imageUrl: icon, placeholder: (context,url) => Image.asset( imageUrl: icon,
R.ASSETS_PLACEHOLDER_NEW_1X1_A_PNG,fit: BoxFit.fill, placeholder: (context, url) => Image.asset(
)), R.ASSETS_PLACEHOLDER_NEW_1X1_A_PNG,
fit: BoxFit.fill,
)),
), ),
Container( Container(
margin: EdgeInsets.only(top: 8), margin: EdgeInsets.only(top: 8),
@ -1213,7 +1215,7 @@ class _HomePageState extends BaseStoreState<HomePage>
); );
} }
_placeholder() { _placeholder() {
return Image.asset( return Image.asset(
R.ASSETS_PLACEHOLDER_NEW_1X1_A_PNG, R.ASSETS_PLACEHOLDER_NEW_1X1_A_PNG,
fit: BoxFit.fill, fit: BoxFit.fill,
@ -1436,11 +1438,27 @@ class _HomePageState extends BaseStoreState<HomePage>
array.addAll(model.data.goodsList); array.addAll(model.data.goodsList);
} }
if (model.data.activityList != null && model.data.activityList.length > 0) { if (model.data.activityList != null && model.data.activityList.length > 0) {
if (array.length > 3) { if (model.data.activityList.first.activitySortId != 0) {
array.insert(3, model.data.activityList.first); 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 { } 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 = model.data.goodsList;
_promotionGoodsList = array; _promotionGoodsList = array;

@ -3,6 +3,7 @@ import 'package:flutter/widgets.dart';
import 'package:extended_text/extended_text.dart'; import 'package:extended_text/extended_text.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:lunar_calendar_converter/lunar_solar_converter.dart'; import 'package:lunar_calendar_converter/lunar_solar_converter.dart';
import 'package:recook/constants/header.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/models/home_weather_model.dart';
import 'package:recook/utils/date/recook_lunar.dart'; import 'package:recook/utils/date/recook_lunar.dart';
import 'home_weather_detail_page.dart';
class HomeWeatherWidget extends StatefulWidget { class HomeWeatherWidget extends StatefulWidget {
final HomeWeatherModel homeWeatherModel; final HomeWeatherModel homeWeatherModel;
final Color backgroundColor; final Color backgroundColor;
@ -45,122 +48,128 @@ class HomeWeatherWidgetState extends State<HomeWeatherWidget>
solarDay: nowDateTime.day, solarDay: nowDateTime.day,
solarMonth: nowDateTime.month); solarMonth: nowDateTime.month);
Lunar lunar = LunarSolarConverter.solarToLunar(solar); Lunar lunar = LunarSolarConverter.solarToLunar(solar);
return Container(
color: _backgroundColor, return GestureDetector(
child: Column( onTap: () {
children: <Widget>[ Get.to(HomeWeatherDetailPage());
Container( },
height: 40 + ScreenUtil().statusBarHeight, child: Container(
), color: _backgroundColor,
Container( child: Column(
width: MediaQuery.of(context).size.width, children: <Widget>[
height: 40, Container(
padding: EdgeInsets.only(left: 23, right: 16), height: 40 + ScreenUtil().statusBarHeight,
child: widget.homeWeatherModel == null ),
? Container() Container(
: Row( width: MediaQuery.of(context).size.width,
mainAxisAlignment: MainAxisAlignment.start, height: 40,
children: <Widget>[ padding: EdgeInsets.only(left: 23, right: 16),
Row( child: widget.homeWeatherModel == null
children: <Widget>[ ? Container()
Text( : Row(
_normalText(widget.homeWeatherModel.tem), mainAxisAlignment: MainAxisAlignment.start,
style: TextStyle( children: <Widget>[
color: Colors.white, Row(
fontSize: 25,
fontWeight: FontWeight.w500),
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
"",
style: textStyle,
),
Text(
" ",
style: textStyle,
),
],
),
],
),
Container(
width: 2,
),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[ children: <Widget>[
Row( Text(
_normalText(widget.homeWeatherModel.tem),
style: TextStyle(
color: Colors.white,
fontSize: 25,
fontWeight: FontWeight.w500),
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[ children: <Widget>[
Text( Text(
_normalText(widget.homeWeatherModel.wea), "",
style: textStyle, style: textStyle,
), ),
Container(width: 2),
Image.asset(
_getWeatherImage(_normalText(
widget.homeWeatherModel.weaImg)),
height: 10,
width: 10,
),
Spacer(),
Text( Text(
"${nowDateTime.year}.${nowDateTime.month}.${nowDateTime.day}${_normalText(widget.homeWeatherModel.week)}", " ",
style: textStyle), style: textStyle,
),
], ],
), ),
Flex( ],
direction: Axis.horizontal, ),
children: <Widget>[ Container(
Expanded( width: 2,
child: ExtendedText.rich( ),
TextSpan( Expanded(
children: [ child: Column(
TextSpan( mainAxisAlignment: MainAxisAlignment.center,
text: children: <Widget>[
"湿度:${_normalText(widget.homeWeatherModel.humidity)} 温度:${_normalText(widget.homeWeatherModel.tem2)}-${_normalText(widget.homeWeatherModel.tem1)}", Row(
style: textStyle), children: <Widget>[
// TextSpan(text:" 温度:${_normalText(widget.homeWeatherModel.tem2)}-${_normalText(widget.homeWeatherModel.tem1)}", style: textStyle), Text(
WidgetSpan( _normalText(widget.homeWeatherModel.wea),
child: Container( style: textStyle,
margin: EdgeInsets.only( ),
left: 5, right: 2), Container(width: 2),
child: Image.asset( Image.asset(
"assets/weatherCake/airquality.png", _getWeatherImage(_normalText(
height: 11, widget.homeWeatherModel.weaImg)),
width: 11, height: 10,
width: 10,
),
Spacer(),
Text(
"${nowDateTime.year}.${nowDateTime.month}.${nowDateTime.day}${_normalText(widget.homeWeatherModel.week)}",
style: textStyle),
],
),
Flex(
direction: Axis.horizontal,
children: <Widget>[
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(
TextSpan( text:
text: "${_normalText(widget.homeWeatherModel.air)}${_normalText(widget.homeWeatherModel.airLevel)}",
"${_normalText(widget.homeWeatherModel.air)}${_normalText(widget.homeWeatherModel.airLevel)}", style: textStyle),
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,
),
)),
],
),
],
),
), ),
), ],
], ),
), )
) ],
], ),
), ),
); );
} }

Loading…
Cancel
Save