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

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

@ -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<String, dynamic> json) {
id = json['id'];
activityUrl = json['activityUrl'];
logoUrl = json['logoUrl'];
topUrl = json['topUrl'];
activitySortId = json['activity_sort_id'];
}
Map<String, dynamic> 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<String>()
@ -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;

@ -1188,9 +1188,11 @@ class _HomePageState extends BaseStoreState<HomePage>
// 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<HomePage>
);
}
_placeholder() {
_placeholder() {
return Image.asset(
R.ASSETS_PLACEHOLDER_NEW_1X1_A_PNG,
fit: BoxFit.fill,
@ -1436,11 +1438,27 @@ class _HomePageState extends BaseStoreState<HomePage>
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;

@ -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<HomeWeatherWidget>
solarDay: nowDateTime.day,
solarMonth: nowDateTime.month);
Lunar lunar = LunarSolarConverter.solarToLunar(solar);
return Container(
color: _backgroundColor,
child: Column(
children: <Widget>[
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: <Widget>[
Row(
children: <Widget>[
Text(
_normalText(widget.homeWeatherModel.tem),
style: TextStyle(
color: Colors.white,
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,
return GestureDetector(
onTap: () {
Get.to(HomeWeatherDetailPage());
},
child: Container(
color: _backgroundColor,
child: Column(
children: <Widget>[
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: <Widget>[
Row(
children: <Widget>[
Row(
Text(
_normalText(widget.homeWeatherModel.tem),
style: TextStyle(
color: Colors.white,
fontSize: 25,
fontWeight: FontWeight.w500),
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
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: <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,
],
),
Container(
width: 2,
),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Row(
children: <Widget>[
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: <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(
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,
),
)),
],
),
],
),
),
),
],
),
)
],
],
),
)
],
),
),
);
}

Loading…
Cancel
Save