* 'master' of http://test.akuhotel.com:8099/laiiihz/recook:
  进口标签添加判断条件
  修改首页、品牌列表、格子列表、品类列表、热销榜单等样式
master
laiiihz 5 years ago
commit 11425269a2

@ -43,6 +43,9 @@ class Data {
String brandName;
String brandImg;
num brandId;
int isImport;
int isFerme;
int storehouse;
Data(
{this.id,
this.goodsName,
@ -58,7 +61,10 @@ class Data {
this.index = 0,
this.brandName,
this.brandImg,
this.brandId
this.brandId,
this.isFerme,
this.isImport,
this.storehouse,
});
Data.fromJson(Map<String, dynamic> json) {
@ -76,6 +82,9 @@ class Data {
brandName = json['brandName'];
brandImg = json['brandImg'];
brandId = json['brandId'];
isImport=json['isImport'];
isFerme=json['isFerme'];
storehouse=json['storehouse'];
}
Map<String, dynamic> toJson() {
@ -91,6 +100,9 @@ class Data {
data['originalPrice'] = this.originalPrice;
data['commission'] = this.commission;
data['coupon'] = this.coupon;
data['isImport']=this.isImport;
data['isFerme']=this.isFerme;
data['storehouse']=this.storehouse;
return data;
}
}

@ -7,7 +7,6 @@ class GoodsSimpleListModel {
List<GoodsSimple> data;
GoodsSimpleListModel({this.code, this.msg, this.data});
GoodsSimpleListModel.fromJson(Map<String, dynamic> json) {
code = json['code'];
msg = json['msg'];
@ -49,6 +48,9 @@ class GoodsSimple {
String brandName;
String brandImg;
num brandId;
int isImport;
int isFerme;
int storehouse;
GoodsSimple(
{this.id,
this.goodsName,
@ -68,6 +70,9 @@ class GoodsSimple {
this.brandName,
this.brandImg,
this.brandId,
this.isFerme,
this.isImport,
this.storehouse,
});
GoodsSimple.fromJson(Map<String, dynamic> json) {
@ -91,6 +96,9 @@ class GoodsSimple {
brandName = json['brandName'];
brandImg = json['brandImg'];
brandId = json['brandId'];
isImport=json['isImport'];
isFerme=json['isFerme'];
storehouse=json['storehouse'];
}
Map<String, dynamic> toJson() {
@ -109,6 +117,9 @@ class GoodsSimple {
data['percent'] = this.percent;
data['startTime'] = this.startTime;
data['endTime'] = this.endTime;
data['isImport']=this.isImport;
data['isFerme']=this.isFerme;
data['storehouse']=this.storehouse;
return data;
}

@ -7,20 +7,29 @@
* ====================================================
*/
import 'package:extended_image/extended_image.dart';
import 'package:extended_text/extended_text.dart';
import 'package:flutter/material.dart';
import 'package:path/path.dart';
import 'package:recook/constants/api.dart';
import 'package:recook/constants/header.dart';
import 'package:recook/models/goods_list_model.dart';
import 'package:recook/models/goods_simple_list_model.dart';
import 'package:recook/pages/goods/small_coupon_widget.dart';
import 'package:recook/pages/home/classify/commodity_detail_page.dart';
import 'package:recook/pages/home/items/item_tag_widget.dart';
import 'package:recook/pages/home/promotion_time_tool.dart';
import 'package:recook/utils/user_level_tool.dart';
import 'package:recook/widgets/custom_cache_image.dart';
import 'package:recook/widgets/custom_image_button.dart';
class BrandDetailGridItem extends StatelessWidget {
// final Goods goods;
final GoodsSimple goods;
final VoidCallback buyClick;
final Function onBrandClick;
const BrandDetailGridItem({Key key, this.goods}) : super(key: key);
const BrandDetailGridItem({Key key, this.goods, this.buyClick, this.onBrandClick})
: super(key: key);
static final Color colorGrey = Color(0xff999999);
@override
Widget build(BuildContext context) {
@ -29,137 +38,342 @@ class BrandDetailGridItem extends StatelessWidget {
return ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(8)),
child: Container(
color: Colors.white,
padding: EdgeInsets.only(bottom: 8),
child: Column(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
width: width,
height: width,
child: Stack(
children: <Widget>[
AspectRatio(
aspectRatio: 1,
child: CustomCacheImage(
fit: BoxFit.cover,
placeholder: AppImageName.placeholder_1x1,
imageUrl:
Api.getResizeImgUrl(goods.mainPhotoUrl, 300))),
Positioned(
child: isSoldOut
? ItemTagWidget.imageMaskWidget(
padding: 40,
width: width - 80,
height: width - 80)
: Container(),
)
],
),
color: Colors.white,
padding: EdgeInsets.fromLTRB(ScreenAdapterUtils.setWidth(5), 0,
ScreenAdapterUtils.setWidth(5), ScreenAdapterUtils.setWidth(8)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
width: width,
height: width,
child: Stack(
children: <Widget>[
AspectRatio(
aspectRatio: 1,
child: CustomCacheImage(
fit: BoxFit.cover,
placeholder: AppImageName.placeholder_1x1,
imageUrl:
Api.getResizeImgUrl(goods.mainPhotoUrl, 300))),
Positioned(
child: isSoldOut
? ItemTagWidget.imageMaskWidget(
padding: 40, width: width - 80, height: width - 80)
: Container(),
)
],
),
Container(
// height: 60,
child: Padding(
padding: const EdgeInsets.only(
left: 8, right: 0, top: 8, bottom: 0),
child: Text(
goods.goodsName,
overflow: TextOverflow.ellipsis,
maxLines: 2,
softWrap: false,
style: AppTextStyle.generate(15,
color: isSoldOut ? colorGrey : Colors.black,
fontWeight: FontWeight.w400),
),
Container(
margin: EdgeInsets.only(top: ScreenAdapterUtils.setWidth(4)),
child: ExtendedText.rich(
TextSpan(
children: [
this.goods.isImport == 1
? WidgetSpan(
alignment: PlaceholderAlignment.middle,
child: Container(
alignment: Alignment.center,
width: 24,
height: 15,
decoration: BoxDecoration(
color: Color(0xFFCC1B4F),
borderRadius: BorderRadius.circular(
ScreenAdapterUtils.setWidth(3)),
),
child: Text(
'进口',
style: TextStyle(
color: Colors.white,
fontSize: ScreenAdapterUtils.setSp(10),
fontWeight: FontWeight.w600,
),
),
),
)
: WidgetSpan(child: SizedBox()),
this.goods.isImport == 1
? WidgetSpan(
child: Container(
width: ScreenAdapterUtils.setWidth(5),
))
: WidgetSpan(child: SizedBox()),
TextSpan(
text: this.goods.goodsName,
style: AppTextStyle.generate(
ScreenAdapterUtils.setSp(15),
fontWeight: FontWeight.w600),
),
],
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
),
Spacer(),
Container(
margin: EdgeInsets.only(left: 8, right: 8, bottom: 2),
height: 15,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: goods.tags != null && goods.tags.length > 0
? goods.tags.length
: 0,
itemBuilder: (BuildContext context, int index) {
return ItemTagWidget.getWidgetWithTag(goods.tags[index],
color: goods.inventory <= 0
? colorGrey
: AppColor.themeColor);
},
),
Container(
alignment: Alignment.centerLeft,
padding:
const EdgeInsets.only(left: 0, right: 0, top: 5, bottom: 5),
child: this.goods.description == null
? Container()
: Text(
this.goods.description,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: AppTextStyle.generate(ScreenAdapterUtils.setSp(10),
color: Colors.black54, fontWeight: FontWeight.w300),
),
),
AppConfig.getShowCommission() ? _brandWidget() : Spacer(),
_saleNumberWidget(this.goods),
SizedBox(height: ScreenAdapterUtils.setWidth(4),),
Row(
children: [
Text(
'¥${this.goods.originalPrice.toStringAsFixed(0)}',
style: TextStyle(
decoration: TextDecoration.lineThrough,
decorationColor: Color(0xff898989),
fontSize: ScreenAdapterUtils.setSp(12),
color: Color(0xff898989),
fontWeight: FontWeight.w400),
),
),
Container(
margin: EdgeInsets.only(left: 5),
child: Row(
children: <Widget>[
RichText(
text: TextSpan(
text: "",
style: AppTextStyle.generate(
ScreenAdapterUtils.setSp(
13,
),
color: isSoldOut
? colorGrey
: AppColor.priceColor),
children: [
TextSpan(
text: goods.discountPrice.toStringAsFixed(2),
style: AppTextStyle.generate(
ScreenAdapterUtils.setSp(16),
color: isSoldOut
? colorGrey
: AppColor.priceColor),
),
TextSpan(
text: AppConfig.getShowCommission() ? "/" : "",
style: AppTextStyle.generate(
ScreenAdapterUtils.setSp(17),
color:
isSoldOut ? colorGrey : AppColor.priceColor,
fontWeight: FontWeight.w300),
),
TextSpan(
text: AppConfig.getShowCommission()
? "${goods.commission.toStringAsFixed(2)}"
: "",
style: AppTextStyle.generate(
ScreenAdapterUtils.setSp(13),
color: isSoldOut
? colorGrey
: AppColor.themeColor),
),
])),
Spacer(),
],
Spacer(),
Text(
"累计已售${this.goods.salesVolume}",
style: TextStyle(
color: Color(0xff595757),
fontSize: ScreenAdapterUtils.setSp(12),
),
),
],
),
SizedBox(height: ScreenAdapterUtils.setWidth(2),),
Container(
width: double.infinity,
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Container(
width: 1,
),
Container(
// height: double.infinity,
alignment: Alignment.center,
child: ExtendedText.rich(
TextSpan(children: [
TextSpan(
text: "券后 ¥ ",
style: AppTextStyle.generate(
ScreenAdapterUtils.setSp(12),
color: Color(0xFFFA6400),
fontWeight: FontWeight.w500),
),
TextSpan(
text:
"${(this.goods.discountPrice - this.goods.discountPrice.toInt()) > 0 ? this.goods.discountPrice.toStringAsFixed(1) : this.goods.discountPrice.toStringAsFixed(0)}",
// text: "${model.discountPrice>=100?model.discountPrice.toStringAsFixed(0):model.discountPrice.toStringAsFixed(1)}",
style: TextStyle(
letterSpacing: -1,
wordSpacing: -1,
fontSize: ScreenAdapterUtils.setSp(18),
color: Color(0xFFC92219),
fontWeight: FontWeight.w500),
),
WidgetSpan(
child: SizedBox(
width: 5,
)),
]),
),
),
Spacer(),
// GestureDetector(
// child: CustomImageButton(
// height: 21,
// title: "导购",
// style: TextStyle(
// fontSize: ScreenAdapterUtils.setSp(13),
// color: sellout ? Colors.grey : _shareTextColor),
// padding: EdgeInsets.symmetric(
// horizontal: rSize(8),
// vertical: rSize(0)),
// borderRadius: BorderRadius.only(
// topLeft: Radius.circular(40),
// bottomLeft: Radius.circular(40)),
// border: Border.all(
// color: sellout ? Colors.grey : _shareTextColor,
// width: 0.5),
// pureDisplay: true,
// ),
// onTap: () {
// // if (shareClick != null) shareClick();
// if (shareClick != null) {
// shareClick();
// } else {
// _shareEvent();
// }
// },
// ),
Container(
width: 10,
),
GestureDetector(
child: CustomImageButton(
direction: Direction.horizontal,
height: 21,
title: this.goods.inventory <= 0 ? "已售完" : "自购",
style: TextStyle(
color: Colors.white,
fontSize: ScreenAdapterUtils.setSp(13),
),
padding: EdgeInsets.symmetric(
horizontal: ScreenAdapterUtils.setWidth(
UserLevelTool.currentRoleLevelEnum() ==
UserRoleLevel.Vip &&
this.goods.getPromotionStatus() ==
PromotionStatus.start
? 16
: 8),
vertical: rSize(0)),
borderRadius: BorderRadius.circular(40),
// borderRadius: BorderRadius.only(
// topLeft: Radius.circular(
// UserLevelTool.currentRoleLevelEnum() ==
// UserRoleLevel.Vip
// ? 40
// : 0),
// bottomLeft: Radius.circular(
// UserLevelTool.currentRoleLevelEnum() ==
// UserRoleLevel.Vip
// ? 40
// : 0),
// topRight: Radius.circular(40),
// bottomRight: Radius.circular(40)),
backgroundColor: this.goods.inventory <= 0
? AppColor.greyColor
: Color(0xFFC92219),
pureDisplay: true,
),
onTap: () {
_buyEvent(context);
},
),
],
),
),
],
),
),
);
}
_saleNumberWidget(GoodsSimple goods) {
return Container(
child: Stack(
children: <Widget>[
Row(
children: <Widget>[
(goods.coupon != null && goods.coupon != 0)
? Container(
margin: EdgeInsets.only(right: 5),
child: SmallCouponWidget(
height: 18,
number: goods.coupon,
),
)
: SizedBox(),
AppConfig.commissionByRoleLevel
? Container(
child: Stack(
alignment: Alignment.center,
children: <Widget>[
Container(
margin: EdgeInsets.symmetric(vertical: 2),
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(2),
border: Border.all(
color: Color(0xffec294d),
width: 0.5,
)),
padding: EdgeInsets.symmetric(horizontal: 3),
child: Text(
"" + goods.commission.toStringAsFixed(2),
style: TextStyle(
color: Colors.white.withAlpha(0),
fontSize: ScreenAdapterUtils.setSp(12),
),
),
),
AppConfig.getShowCommission()
? Container(
alignment: Alignment.center,
child: Text(
"" + goods.commission.toStringAsFixed(2),
style: TextStyle(
color: Color(0xffeb0045),
fontSize: ScreenAdapterUtils.setSp(12),
),
),
)
: SizedBox(),
],
),
)
: SizedBox(),
Spacer(),
],
),
],
),
);
}
_buyEvent(BuildContext context) {
if (buyClick != null) {
buyClick();
} else {
AppRouter.push(context, RouteName.COMMODITY_PAGE,
arguments: CommodityDetailPage.setArguments(this.goods.id));
}
}
_brandWidget() {
return GestureDetector(
onTap: () {
if (onBrandClick != null) onBrandClick();
},
child: Container(
width: double.infinity,
height: 25,
color: Colors.white,
child: Row(
children: <Widget>[
Container(
height: 3,
),
Container(
margin: EdgeInsets.symmetric(horizontal: rSize(5)),
child: Row(
children: <Widget>[
Spacer(),
Container(
margin: EdgeInsets.only(right: 8),
child: Text(
"${goods.salesVolume}人付款",
style: AppTextStyle.generate(12, color: Colors.grey),
width: 13 * 1.5,
height: 13 * 1.5,
child: TextUtils.isEmpty(this.goods.brandImg)
? SizedBox()
: ExtendedImage.network(
Api.getImgUrl(this.goods.brandImg),
fit: BoxFit.fill,
),
),
],
),
SizedBox(
width: 4,
),
Text(
TextUtils.isEmpty(this.goods.brandName) ? "" : this.goods.brandName,
style: TextStyle(
color: Color(0xffc70404),
fontSize: ScreenAdapterUtils.setSp(12),
),
),
Container(
height: 2,
)
],
)),
);
),
));
}
}

@ -11,7 +11,7 @@ class ItemTagWidget {
childAspectRatio: _displayList
? MediaQuery.of(context).size.width /
((MediaQuery.of(context).size.width - 20) * 150.0 / 350.0)
: 0.57,
: 174/320,
crossAxisCount: _displayList ? 1 : 2);
}

@ -14,6 +14,7 @@ import 'package:recook/utils/share_tool.dart';
import 'package:recook/utils/user_level_tool.dart';
import 'package:recook/widgets/custom_cache_image.dart';
import 'package:recook/widgets/custom_image_button.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
enum GoodsItemType {
NONE,
@ -38,6 +39,7 @@ class GoodsItemWidget extends StatelessWidget {
final num id;
final String brandName;
final String brandPictureUrl;
final int isImport;
final GoodsItemType widgetType;
@ -64,7 +66,8 @@ class GoodsItemWidget extends StatelessWidget {
this.buyClick,
this.brandName = "",
this.brandPictureUrl = "",
this.onBrandClick})
this.onBrandClick,
this.isImport})
: widgetType = GoodsItemType.NONE,
super(key: key);
@ -92,6 +95,7 @@ class GoodsItemWidget extends StatelessWidget {
id = model.id,
promotionStatus = model.getPromotionStatus(),
widgetType = GoodsItemType.NORMAL,
isImport=model.isImport,
super(key: key);
///Hot List
@ -120,6 +124,7 @@ class GoodsItemWidget extends StatelessWidget {
//TODO hot list unset promotion status;
promotionStatus = PromotionStatus.none,
widgetType = GoodsItemType.HOT_LIST,
isImport=data.isImport,
super(key: key);
///
@ -146,6 +151,7 @@ class GoodsItemWidget extends StatelessWidget {
id = model.goodsId,
promotionStatus = model.getPromotionStatus(),
widgetType = GoodsItemType.ROW_GOODS,
isImport=model.isImport,
super(key: key);
final BuildContext buildCtx;
final VoidCallback shareClick;
@ -259,12 +265,48 @@ class GoodsItemWidget extends StatelessWidget {
Container(
height: 2,
),
Text(
this.goodsName,
ExtendedText.rich(
TextSpan(
children: [
this.isImport == 1
? WidgetSpan(
alignment: PlaceholderAlignment.middle,
child: Container(
alignment: Alignment.center,
width: 24,
height: 15,
decoration: BoxDecoration(
color: Color(0xFFCC1B4F),
borderRadius: BorderRadius.circular(
ScreenAdapterUtils.setWidth(3)),
),
child: Text(
'进口',
style: TextStyle(
color: Colors.white,
fontSize: ScreenAdapterUtils.setSp(10),
fontWeight: FontWeight.w600,
),
),
),
)
: WidgetSpan(child: SizedBox()),
this.isImport == 1
? WidgetSpan(
child: Container(
width: ScreenAdapterUtils.setWidth(5),
))
: WidgetSpan(child: SizedBox()),
TextSpan(
text: this.goodsName,
style: AppTextStyle.generate(
ScreenAdapterUtils.setSp(15),
fontWeight: FontWeight.w600),
),
],
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: AppTextStyle.generate(ScreenAdapterUtils.setSp(15),
fontWeight: FontWeight.w600),
),
Container(
alignment: Alignment.centerLeft,

Loading…
Cancel
Save