From 130c87ccb9677b8281fae1ef1098c880d463a4d3 Mon Sep 17 00:00:00 2001 From: PH2 <1293456824@qq.com> Date: Thu, 22 Oct 2020 17:45:26 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E4=BB=8A=E6=97=A5=E7=83=AD=E6=A6=9C?= =?UTF-8?q?=E8=BF=9B=E5=85=A5=E5=95=86=E5=93=81=E8=AF=A6=E6=83=85=E7=9A=84?= =?UTF-8?q?=E9=A2=84=E5=8A=A0=E8=BD=BD=202=E3=80=81=E5=95=86=E5=93=81?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E7=9A=84=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../goods_details/coupon/counpon_widget.dart | 32 +++-- .../detail_img/goods_details_img.dart | 15 +- .../footer/goods_details_footer_widget.dart | 135 +++++++----------- .../goods_details_slide_banner_widget.dart | 10 +- .../goods_details/store/store_widget.dart | 15 +- .../hot_ranking_goods/hot_ranking_goods.dart | 3 +- .../model/hot_ranking_list_data_model.dart | 29 ++-- .../mine_header/mine_header_container.dart | 2 +- 8 files changed, 128 insertions(+), 113 deletions(-) diff --git a/lib/widgets/goods_details/coupon/counpon_widget.dart b/lib/widgets/goods_details/coupon/counpon_widget.dart index a0e3da8..211cb8f 100644 --- a/lib/widgets/goods_details/coupon/counpon_widget.dart +++ b/lib/widgets/goods_details/coupon/counpon_widget.dart @@ -19,18 +19,28 @@ class CounponWidget extends StatelessWidget { Widget build(BuildContext context) { // return Container(); return BlocProvider( - create: (_) => CounponBloc(repository: CounponRepository())..add(CounponInitEvent(model: model)), - child: CounponWidgetContainer(), + create: (_) => CounponBloc(repository: CounponRepository()), //..add(CounponInitEvent(model: model)), + child: CounponWidgetContainer(model, key: UniqueKey(),), ); } } class CounponWidgetContainer extends StatefulWidget { + final Map model; + + const CounponWidgetContainer(this.model, {Key key}) : super(key: key); + @override _CounponWidgetContainerState createState() => _CounponWidgetContainerState(); } class _CounponWidgetContainerState extends State { + @override + void initState() { + BlocProvider.of(context).add(CounponInitEvent(model: widget?.model)); + super.initState(); + } + /// 点击领取 void _onJump(CounponModel model) {} @@ -69,19 +79,18 @@ class _CounponWidgetContainerState extends State { width: double.infinity, padding: const EdgeInsets.only(left: 18.5, top: 12, bottom: 14), decoration: BoxDecoration( - image: DecorationImage( - image: CachedNetworkImageProvider( - model?.bg_img ??'', - ), - fit: BoxFit.fill - ) - ), + image: DecorationImage( + image: CachedNetworkImageProvider( + model?.bg_img ?? '', + ), + fit: BoxFit.fill)), alignment: Alignment.centerLeft, child: Row( children: [ /// 价格 _getPriceWidget(model), const SizedBox(width: 7.5), + /// 有效期 _getTimeWidget(model) ], @@ -102,7 +111,8 @@ class _CounponWidgetContainerState extends State { Text(model?.price_type ?? '¥ ', style: TextStyle(fontSize: 15, color: HexColor.fromHex(model?.price_type_color ?? '#FFFFFF'))), /// 价格 - Text(model?.coupon_price ??'100', style: TextStyle(fontSize: 30, color: HexColor.fromHex(model?.coupon_price_color ?? '#FFFFFF'), fontFamily: 'Din', package: 'zhiying_base_widget')), + Text(model?.coupon_price ?? '100', + style: TextStyle(fontSize: 30, color: HexColor.fromHex(model?.coupon_price_color ?? '#FFFFFF'), fontFamily: 'Din', package: 'zhiying_base_widget')), ], ); } @@ -113,7 +123,7 @@ class _CounponWidgetContainerState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ /// 标题 - Text(model?.coupon_title ?? '优惠券', style: TextStyle(fontSize: 17, color: HexColor.fromHex( model?.coupon_title_color ?? '#FFFFFF'))), + Text(model?.coupon_title ?? '优惠券', style: TextStyle(fontSize: 17, color: HexColor.fromHex(model?.coupon_title_color ?? '#FFFFFF'))), /// 到期时间 Text(model?.coupon_endtime ?? '有效期至2020-10-01', style: TextStyle(fontSize: 10, color: HexColor.fromHex(model?.coupon_time_color ?? '#FFFFFF'))) diff --git a/lib/widgets/goods_details/detail_img/goods_details_img.dart b/lib/widgets/goods_details/detail_img/goods_details_img.dart index 7dd395d..b597396 100644 --- a/lib/widgets/goods_details/detail_img/goods_details_img.dart +++ b/lib/widgets/goods_details/detail_img/goods_details_img.dart @@ -19,18 +19,29 @@ class GoodsDetailsImgWidget extends StatelessWidget { @override Widget build(BuildContext context) { return BlocProvider( - create: (_) => GoodsDetailsImgBloc(repository: GoodsDetailsImgRepository())..add(GoodsDetailsImgInitEvent(model: model)), - child: GoodsDetailsImgWidgetContainer(), + create: (_) => GoodsDetailsImgBloc(repository: GoodsDetailsImgRepository()),//..add(GoodsDetailsImgInitEvent(model: model)), + child: GoodsDetailsImgWidgetContainer(model, key: UniqueKey(),), ); } } class GoodsDetailsImgWidgetContainer extends StatefulWidget { + + final Map model; + const GoodsDetailsImgWidgetContainer(this.model, {Key key}) : super(key: key); + @override _GoodsDetailsImgWidgetContainerState createState() => _GoodsDetailsImgWidgetContainerState(); } class _GoodsDetailsImgWidgetContainerState extends State { + + @override + void initState() { + BlocProvider.of(context).add(GoodsDetailsImgInitEvent(model: widget?.model)); + super.initState(); + } + @override Widget build(BuildContext context) { return BlocConsumer( diff --git a/lib/widgets/goods_details/footer/goods_details_footer_widget.dart b/lib/widgets/goods_details/footer/goods_details_footer_widget.dart index 508a525..3968c51 100644 --- a/lib/widgets/goods_details/footer/goods_details_footer_widget.dart +++ b/lib/widgets/goods_details/footer/goods_details_footer_widget.dart @@ -30,10 +30,12 @@ class GoodsDetailsFooterWidget extends StatelessWidget { visible: !EmptyUtil.isEmpty(model), replacement: GoodsDetailsFooterSkeleton(), child: BlocProvider( - create: (_) => - GoodsDetailsFooterBloc(repository: GoodsDetailsFooterRepository()) - ..add(GoodsDetailsFooterInitEvent(model: model)), - child: GooddsDetailsFooterContainer(model), + create: (_) => GoodsDetailsFooterBloc(repository: GoodsDetailsFooterRepository()), + //..add(GoodsDetailsFooterInitEvent(model: model)), + child: GooddsDetailsFooterContainer( + model, + key: UniqueKey(), + ), ), ); } @@ -45,21 +47,24 @@ class GooddsDetailsFooterContainer extends StatefulWidget { const GooddsDetailsFooterContainer(this.model, {Key key}) : super(key: key); @override - _GooddsDetailsFooterContainerState createState() => - _GooddsDetailsFooterContainerState(); + _GooddsDetailsFooterContainerState createState() => _GooddsDetailsFooterContainerState(); } -class _GooddsDetailsFooterContainerState - extends State { +class _GooddsDetailsFooterContainerState extends State { + UserInfoModel _user; + @override + void initState() { + BlocProvider.of(context).add(GoodsDetailsFooterInitEvent(model: widget?.model)); + super.initState(); + } + /// 打开首页 void _openHome() { Navigator.pushAndRemoveUntil( context, - CupertinoPageRoute( - builder: (BuildContext context) => - PageFactory.create('homePage', null)), + CupertinoPageRoute(builder: (BuildContext context) => PageFactory.create('homePage', null)), (Route route) => false, ); } @@ -95,8 +100,7 @@ class _GooddsDetailsFooterContainerState return; } } - Navigator.of(context).push(CupertinoPageRoute( - builder: (context) => GoodsSharePage(widget.model))); + Navigator.of(context).push(CupertinoPageRoute(builder: (context) => GoodsSharePage(widget.model))); } } @@ -166,8 +170,7 @@ class _GooddsDetailsFooterContainerState return SafeArea( child: Container( width: double.infinity, - padding: EdgeInsets.only( - bottom: (height > 10 ? 0 : 8), top: 8, left: 21, right: 12.5), + padding: EdgeInsets.only(bottom: (height > 10 ? 0 : 8), top: 8, left: 21, right: 12.5), decoration: BoxDecoration( // boxShadow: [ // BoxShadow(color: Colors.grey[300], offset: Offset(0.0, 0.0), blurRadius: 5.0, spreadRadius: 2.0), @@ -206,18 +209,12 @@ class _GooddsDetailsFooterContainerState onTap: () => _openHome(), child: Padding( padding: const EdgeInsets.only(right: 35), - child: _getCustomWidget(model?.home ?? '首页', - model?.home_color ?? '999999', model?.home_icon ?? ''), + child: _getCustomWidget(model?.home ?? '首页', model?.home_color ?? '999999', model?.home_icon ?? ''), )), GestureDetector( behavior: HitTestBehavior.opaque, onTap: () => _collectOnClick(), - child: Padding( - padding: const EdgeInsets.only(right: 0), - child: _getCustomWidget( - model?.collect ?? '收藏', - model?.collect_color ?? '999999', - model?.collect_icon ?? ''))) + child: Padding(padding: const EdgeInsets.only(right: 0), child: _getCustomWidget(model?.collect ?? '收藏', model?.collect_color ?? '999999', model?.collect_icon ?? ''))) ], ); } @@ -244,40 +241,30 @@ class _GooddsDetailsFooterContainerState width: 110, // padding: const EdgeInsets.only(left: 30, right: 30, top: 5, bottom: 5), decoration: BoxDecoration( - gradient: LinearGradient(colors: [ - HexColor.fromHex(model?.share_earn_bg1_color ?? '#FFCA66'), - HexColor.fromHex(model?.share_earn_bg2_color ?? '#FFD961') - ], begin: Alignment.centerLeft, end: Alignment.centerRight), - borderRadius: BorderRadius.only( - bottomLeft: Radius.circular(25), topLeft: Radius.circular(25))), + gradient: LinearGradient( + colors: [HexColor.fromHex(model?.share_earn_bg1_color ?? '#FFCA66'), HexColor.fromHex(model?.share_earn_bg2_color ?? '#FFD961')], + begin: Alignment.centerLeft, + end: Alignment.centerRight), + borderRadius: BorderRadius.only(bottomLeft: Radius.circular(25), topLeft: Radius.circular(25))), child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: [ RichText( - text: TextSpan( - text: '¥ ', - style: TextStyle( - fontSize: 12, - color: HexColor.fromHex( - model?.share_earn_val_color ?? 'FFFFFF')), - children: [ - TextSpan( - text: model?.share_value ?? '0.0', - style: TextStyle( - fontSize: 15, - fontWeight: FontWeight.bold, - color: HexColor.fromHex( - model?.share_earn_color ?? '#FFFFFF'), - fontFamily: 'Din', - package: 'zhiying_base_widget')), - ]), + text: TextSpan(text: '¥ ', style: TextStyle(fontSize: 12, color: HexColor.fromHex(model?.share_earn_val_color ?? 'FFFFFF')), children: [ + TextSpan( + text: model?.share_value ?? '0.0', + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.bold, + color: HexColor.fromHex(model?.share_earn_color ?? '#FFFFFF'), + fontFamily: 'Din', + package: 'zhiying_base_widget')), + ]), ), Text( model?.share_earn ?? '分享赚', - style: TextStyle( - color: HexColor.fromHex(model?.share_earn_color ?? '#FFFFFF'), - fontSize: 12), + style: TextStyle(color: HexColor.fromHex(model?.share_earn_color ?? '#FFFFFF'), fontSize: 12), ), ], ), @@ -296,42 +283,29 @@ class _GooddsDetailsFooterContainerState height: 44, width: 110, decoration: BoxDecoration( - gradient: LinearGradient(colors: [ - HexColor.fromHex(model?.save_earn_bg1_color ?? '#FF6969'), - HexColor.fromHex(model?.save_earn_bg2_color ?? '#FF4646') - ], begin: Alignment.centerLeft, end: Alignment.centerRight), - borderRadius: BorderRadius.only( - bottomRight: Radius.circular(25), - topRight: Radius.circular(25))), + gradient: LinearGradient( + colors: [HexColor.fromHex(model?.save_earn_bg1_color ?? '#FF6969'), HexColor.fromHex(model?.save_earn_bg2_color ?? '#FF4646')], + begin: Alignment.centerLeft, + end: Alignment.centerRight), + borderRadius: BorderRadius.only(bottomRight: Radius.circular(25), topRight: Radius.circular(25))), child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: [ RichText( - text: TextSpan( - text: '¥ ', - style: TextStyle( - fontSize: 12, - color: HexColor.fromHex( - model?.save_earn_val_color ?? 'FFFFFF')), - children: [ - TextSpan( - text: model?.slef_buy_value ?? '0.0', - style: TextStyle( - fontSize: 15, - fontWeight: FontWeight.bold, - color: HexColor.fromHex( - model?.save_earn_val_color ?? '#FFFFFF'), - fontFamily: 'Din', - package: 'zhiying_base_widget', - )), - ]), + text: TextSpan(text: '¥ ', style: TextStyle(fontSize: 12, color: HexColor.fromHex(model?.save_earn_val_color ?? 'FFFFFF')), children: [ + TextSpan( + text: model?.slef_buy_value ?? '0.0', + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.bold, + color: HexColor.fromHex(model?.save_earn_val_color ?? '#FFFFFF'), + fontFamily: 'Din', + package: 'zhiying_base_widget', + )), + ]), ), - Text(model?.save_earn ?? '自购省', - style: TextStyle( - color: - HexColor.fromHex(model?.save_earn_color ?? '#FFFFFF'), - fontSize: 12)) + Text(model?.save_earn ?? '自购省', style: TextStyle(color: HexColor.fromHex(model?.save_earn_color ?? '#FFFFFF'), fontSize: 12)) ], ), ), @@ -354,8 +328,7 @@ class _GooddsDetailsFooterContainerState const SizedBox(height: 5), /// 图片 - Text(text, - style: TextStyle(color: HexColor.fromHex(textColor), fontSize: 11)) + Text(text, style: TextStyle(color: HexColor.fromHex(textColor), fontSize: 11)) ], ); } diff --git a/lib/widgets/goods_details/slide_banner/goods_details_slide_banner_widget.dart b/lib/widgets/goods_details/slide_banner/goods_details_slide_banner_widget.dart index de9b966..0379973 100644 --- a/lib/widgets/goods_details/slide_banner/goods_details_slide_banner_widget.dart +++ b/lib/widgets/goods_details/slide_banner/goods_details_slide_banner_widget.dart @@ -19,8 +19,8 @@ class GoodsDetailsSlideBannerWidget extends StatelessWidget { @override Widget build(BuildContext context) { return BlocProvider( - create: (_) => GoodsDetailsSlideBannerBloc(repository: GoodsDetailsSlideBannerRepository())..add(GoodsDetailsSlideBannerInitEvent(model: model)), - child: GoodsDetailsSlideBannerContainer(model), + create: (_) => GoodsDetailsSlideBannerBloc(repository: GoodsDetailsSlideBannerRepository()),//..add(GoodsDetailsSlideBannerInitEvent(model: model)), + child: GoodsDetailsSlideBannerContainer(model, key: UniqueKey(),), ); } } @@ -40,6 +40,12 @@ class _GoodsDetailsSlideBannerContainerState extends State(context).add(GoodsDetailsSlideBannerInitEvent(model: widget?.model)); + super.initState(); + } + @override Widget build(BuildContext context) { return BlocConsumer( diff --git a/lib/widgets/goods_details/store/store_widget.dart b/lib/widgets/goods_details/store/store_widget.dart index 393e5d7..60d05b8 100644 --- a/lib/widgets/goods_details/store/store_widget.dart +++ b/lib/widgets/goods_details/store/store_widget.dart @@ -20,18 +20,29 @@ class StoreWidget extends StatelessWidget { @override Widget build(BuildContext context) { return BlocProvider( - create: (_) => StoreBloc(repository: StoreRepository())..add(StoreInitEvent(model: model)), - child: StoreContainer(), + create: (_) => StoreBloc(repository: StoreRepository()),//..add(StoreInitEvent(model: model)), + child: StoreContainer(model, key: UniqueKey(),), ); } } class StoreContainer extends StatefulWidget { + final Map model; + + const StoreContainer(this.model, {Key key}) : super(key: key); + @override _StoreContainerState createState() => _StoreContainerState(); } class _StoreContainerState extends State { + + @override + void initState() { + BlocProvider.of(context).add(StoreInitEvent(model: widget?.model)); + super.initState(); + } + /// 点击更多 void _onMoreClick() {} diff --git a/lib/widgets/hot_ranking/hot_ranking_goods/hot_ranking_goods.dart b/lib/widgets/hot_ranking/hot_ranking_goods/hot_ranking_goods.dart index 998fd95..479a0a2 100644 --- a/lib/widgets/hot_ranking/hot_ranking_goods/hot_ranking_goods.dart +++ b/lib/widgets/hot_ranking/hot_ranking_goods/hot_ranking_goods.dart @@ -26,8 +26,7 @@ class HotRankingGoods extends StatelessWidget { Providers providers = getProvider(good.provider); return GestureDetector( onTap: () { - RouterUtil.route(SkipModel(skipIdentifier: "goods_details"), - {"provider": good.provider, "good_id": good.goodId}, context); + RouterUtil.route(SkipModel(skipIdentifier: "goods_details"), good?.toJson(), context); }, child: Stack( children: [ diff --git a/lib/widgets/hot_ranking/hot_ranking_list/model/hot_ranking_list_data_model.dart b/lib/widgets/hot_ranking/hot_ranking_list/model/hot_ranking_list_data_model.dart index 04b2de2..520b2b4 100644 --- a/lib/widgets/hot_ranking/hot_ranking_list/model/hot_ranking_list_data_model.dart +++ b/lib/widgets/hot_ranking/hot_ranking_list/model/hot_ranking_list_data_model.dart @@ -36,19 +36,22 @@ class Good { String marketPrice; String currentPrice; String inorderCount; + Map detailData; - Good( - {this.provider, - this.providerName, - this.goodId, - this.goodImage, - this.goodTitle, - this.shopName, - this.coupon, - this.commission, - this.marketPrice, - this.currentPrice, - this.inorderCount}); + Good({ + this.provider, + this.providerName, + this.goodId, + this.goodImage, + this.goodTitle, + this.shopName, + this.coupon, + this.commission, + this.marketPrice, + this.currentPrice, + this.inorderCount, + this.detailData, + }); Good.fromJson(Map json) { provider = json['provider']; @@ -62,6 +65,7 @@ class Good { marketPrice = json['market_price']; currentPrice = json['current_price']; inorderCount = json['inorder_count']; + detailData = json['detail_data']; } Map toJson() { @@ -77,6 +81,7 @@ class Good { data['market_price'] = this.marketPrice; data['current_price'] = this.currentPrice; data['inorder_count'] = this.inorderCount; + data['detail_data'] = this.detailData; return data; } } diff --git a/lib/widgets/mine/mine_header/mine_header_container.dart b/lib/widgets/mine/mine_header/mine_header_container.dart index 1e9513c..7c47b49 100644 --- a/lib/widgets/mine/mine_header/mine_header_container.dart +++ b/lib/widgets/mine/mine_header/mine_header_container.dart @@ -58,7 +58,7 @@ class _MineHeaderContainerState extends State { child: ClipRRect( borderRadius: BorderRadius.circular(28), child: CachedNetworkImage( - imageUrl: profile.avatar, + imageUrl: profile?.avatar ?? '', fit: BoxFit.cover, ), ),