From a5d1bc0da9358789572e28a22d818589e5b0e0df Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Thu, 3 Dec 2020 14:08:45 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=AD=E7=89=A9=E8=BD=A6=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/models/shopping_cart_list_model.dart | 6 ++ lib/models/shopping_cart_list_model.g.dart | 3 + .../home/items/item_brand_detail_grid.dart | 102 ++++++++++-------- lib/pages/home/items/item_tag_widget.dart | 2 +- .../item/item_shopping_cart.dart | 86 +++++++++++++-- 5 files changed, 144 insertions(+), 55 deletions(-) diff --git a/lib/models/shopping_cart_list_model.dart b/lib/models/shopping_cart_list_model.dart index e096d2e..83f3358 100644 --- a/lib/models/shopping_cart_list_model.dart +++ b/lib/models/shopping_cart_list_model.dart @@ -141,6 +141,9 @@ class ShoppingCartGoodsModel extends Object { Promotion promotion; num commission; num originalPrice; + int isImport; + int isFerme; + int storehouse; ShoppingCartGoodsModel( this.shoppingTrolleyId, this.goodsId, @@ -156,6 +159,9 @@ class ShoppingCartGoodsModel extends Object { this.promotion, this.commission, this.originalPrice, + this.isImport, + this.isFerme, + this.storehouse, ) { this.selected = false; } diff --git a/lib/models/shopping_cart_list_model.g.dart b/lib/models/shopping_cart_list_model.g.dart index 4d803c8..1bba078 100644 --- a/lib/models/shopping_cart_list_model.g.dart +++ b/lib/models/shopping_cart_list_model.g.dart @@ -71,6 +71,9 @@ ShoppingCartGoodsModel _$ShoppingCartGoodsModelFromJson( : Promotion.fromJson(json['promotion'] as Map), json['commission'] as num, json['originalPrice'] as num, + json['isImport'] as num, + json['isFerme'] as num, + json['storehouse'] as int, ); } diff --git a/lib/pages/home/items/item_brand_detail_grid.dart b/lib/pages/home/items/item_brand_detail_grid.dart index 3cfe5d5..e400b6a 100644 --- a/lib/pages/home/items/item_brand_detail_grid.dart +++ b/lib/pages/home/items/item_brand_detail_grid.dart @@ -28,7 +28,8 @@ class BrandDetailGridItem extends StatelessWidget { final VoidCallback buyClick; final Function onBrandClick; - const BrandDetailGridItem({Key key, this.goods, this.buyClick, this.onBrandClick}) + const BrandDetailGridItem( + {Key key, this.goods, this.buyClick, this.onBrandClick}) : super(key: key); static final Color colorGrey = Color(0xff999999); @override @@ -68,52 +69,51 @@ class BrandDetailGridItem extends StatelessWidget { 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, - ), + 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, + ), + ) + : 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, + ), ), Container( alignment: Alignment.centerLeft, - padding: + margin: const EdgeInsets.only(left: 0, right: 0, top: 5, bottom: 5), child: this.goods.description == null ? Container() @@ -125,13 +125,17 @@ class BrandDetailGridItem extends StatelessWidget { color: Colors.black54, fontWeight: FontWeight.w300), ), ), - AppConfig.getShowCommission() ? _brandWidget() : Spacer(), + Spacer(), + AppConfig.getShowCommission() ? _brandWidget() : SizedBox(), + Spacer(), _saleNumberWidget(this.goods), - SizedBox(height: ScreenAdapterUtils.setWidth(4),), + SizedBox( + height: ScreenAdapterUtils.setWidth(4), + ), Row( children: [ Text( - '¥${this.goods.originalPrice.toStringAsFixed(0)}', + '¥${this.goods.originalPrice.toStringAsFixed(2)}', style: TextStyle( decoration: TextDecoration.lineThrough, decorationColor: Color(0xff898989), @@ -149,7 +153,9 @@ class BrandDetailGridItem extends StatelessWidget { ), ], ), - SizedBox(height: ScreenAdapterUtils.setWidth(2),), + SizedBox( + height: ScreenAdapterUtils.setWidth(2), + ), Container( width: double.infinity, child: Row( @@ -341,7 +347,7 @@ class BrandDetailGridItem extends StatelessWidget { } } - _brandWidget() { + _brandWidget() { return GestureDetector( onTap: () { if (onBrandClick != null) onBrandClick(); @@ -366,7 +372,9 @@ class BrandDetailGridItem extends StatelessWidget { width: 4, ), Text( - TextUtils.isEmpty(this.goods.brandName) ? "" : this.goods.brandName, + TextUtils.isEmpty(this.goods.brandName) + ? "" + : this.goods.brandName, style: TextStyle( color: Color(0xffc70404), fontSize: ScreenAdapterUtils.setSp(12), diff --git a/lib/pages/home/items/item_tag_widget.dart b/lib/pages/home/items/item_tag_widget.dart index 9ef72f9..f6be172 100644 --- a/lib/pages/home/items/item_tag_widget.dart +++ b/lib/pages/home/items/item_tag_widget.dart @@ -11,7 +11,7 @@ class ItemTagWidget { childAspectRatio: _displayList ? MediaQuery.of(context).size.width / ((MediaQuery.of(context).size.width - 20) * 150.0 / 350.0) - : 174/320, + : 174/330, crossAxisCount: _displayList ? 1 : 2); } diff --git a/lib/pages/shopping_cart/item/item_shopping_cart.dart b/lib/pages/shopping_cart/item/item_shopping_cart.dart index 2e4b326..17930f0 100644 --- a/lib/pages/shopping_cart/item/item_shopping_cart.dart +++ b/lib/pages/shopping_cart/item/item_shopping_cart.dart @@ -7,6 +7,7 @@ * ==================================================== */ +import 'package:extended_text/extended_text.dart'; import 'package:flutter/material.dart'; import 'package:recook/constants/api.dart'; import 'package:recook/constants/header.dart'; @@ -217,12 +218,48 @@ class _ShoppingCartItemState extends State { mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text( - goods.goodsName, + ExtendedText.rich( + TextSpan( + children: [ + 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()), + goods.isImport == 1 + ? WidgetSpan( + child: Container( + width: ScreenAdapterUtils.setWidth(5), + )) + : WidgetSpan(child: SizedBox()), + TextSpan( + text: goods.goodsName, + style: AppTextStyle.generate( + ScreenAdapterUtils.setSp(15), + fontWeight: FontWeight.w600), + ), + ], + ), maxLines: 2, overflow: TextOverflow.ellipsis, - style: AppTextStyle.generate(ScreenAdapterUtils.setSp(14), - fontWeight: FontWeight.w300), ), Container( margin: EdgeInsets.only(top: 5), @@ -242,8 +279,44 @@ class _ShoppingCartItemState extends State { fontWeight: FontWeight.w300), ), ), - Container( - height: 10, + SizedBox( + height: ScreenAdapterUtils.setWidth(2), + ), + goods.isFerme==1 + ? Row( + children: [ + Container( + width: ScreenAdapterUtils.setWidth(32), + height: ScreenAdapterUtils.setWidth(14), + alignment: Alignment.center, + decoration: BoxDecoration( + color: Color(0xFFFFE5ED), + borderRadius: BorderRadius.circular( + ScreenAdapterUtils.setWidth(7.5)), + ), + child: Text( + '包税', + style: TextStyle( + color: Color(0xFFCC1B4F), + fontSize: ScreenAdapterUtils.setSp(10), + ), + ), + ), + SizedBox( + width: ScreenAdapterUtils.setWidth(2), + ), + Text( + '进口税¥${(goods.price * 1.2 * 9.1 / 100).toDouble().toStringAsFixed(2)},由瑞库客承担', + style: TextStyle( + color: Color(0xFF666666), + fontSize: ScreenAdapterUtils.setSp(10)), + ), + ], + ) + : SizedBox(), + + SizedBox( + height: ScreenAdapterUtils.setWidth(7), ), Row( children: [ @@ -285,7 +358,6 @@ class _ShoppingCartItemState extends State { // ), ], ), - Container( height: 7, ),