diff --git a/lib/pages/goods_details_page/bloc/goods_details_page_bloc.dart b/lib/pages/goods_details_page/bloc/goods_details_page_bloc.dart index 9a5182f..f107da4 100644 --- a/lib/pages/goods_details_page/bloc/goods_details_page_bloc.dart +++ b/lib/pages/goods_details_page/bloc/goods_details_page_bloc.dart @@ -43,5 +43,7 @@ class GoodsDetailsPageBloc extends Bloc cacheTurnChainStyleData() async { + if (!EmptyUtil.isEmpty(_providerName)) { + bool result = await TurnChainUtil.cacheTurnChainDialogStyle(_goodsId, _providerName, _commission, _couponPrice); + Logger.debug('cache result = $result'); + } + } + /// 获取上个页面传进来的数据 Future>> fetchParentPageData(final Map model) async { try { @@ -13,8 +34,8 @@ class GoodsDetailsPageRepository { String goodId = model['good_id']?.toString(); if (!EmptyUtil.isEmpty(provider) && !EmptyUtil.isEmpty(goodId)) { Map detailData = model['detail_data']; - String good_image = model['good_image']; - return _baseDataProcess(true, goodId, provider, detailData, good_image); + String goodImage = model['good_image']; + return _baseDataProcess(true, goodId, provider, detailData, goodImage); } } } catch (e, s) { @@ -42,25 +63,30 @@ class GoodsDetailsPageRepository { } /// 数据处理 - List> _baseDataProcess(bool parentInput,String goodId, String provider, final Map model, String coverImage) { + List> _baseDataProcess(bool parentInput, String goodId, String provider, final Map model, String coverImage) { if (!EmptyUtil.isEmpty(provider) && !EmptyUtil.isEmpty(goodId) && !EmptyUtil.isEmpty(model)) { try { + _couponPrice = model['coupon_price']; + _commission = model['commission']; + _providerName = model['provider_name']; + _goodsId = model['good_id']; List> _pageData = []; - Map baseData = {'provider': provider, 'good_id': goodId}; + Map baseData = {'provider': provider, 'good_id': _goodsId, 'commission': _commission, 'coupon_price': _couponPrice}; List modLists = model['mod_list']; + for (int i = 0; i < modLists.length; i++) { Map item = modLists[i]; // ⚠️ 这里之所以要判断是否是String类型,是因为修改的是父亲页面传进来的model -> data 类型了。把dynamic变成了String Map data = !EmptyUtil.isEmpty(item['data']) ? item['data'] is String ? jsonDecode(item['data']) : item['data'] : new Map(); // ⚠️ 为了商品详情的轮播图能够快速加载,故把上一个页面传进来的第一张图片插入到轮播图集合的第一个图片中 - if(item['mod_name'] == 'product_detail_carousel') { + if (item['mod_name'] == 'product_detail_carousel') { if (parentInput) { try { var imageList = data['image_list']; if (!EmptyUtil.isEmpty(imageList)) { _parentGoodsCoverImg = imageList[0]; - }else if (!EmptyUtil.isEmpty(coverImage)){ + } else if (!EmptyUtil.isEmpty(coverImage)) { _parentGoodsCoverImg = coverImage; data['image_list'] = [coverImage]; } @@ -70,19 +96,19 @@ class GoodsDetailsPageRepository { } else { try { if (!EmptyUtil.isEmpty(_parentGoodsCoverImg) && !EmptyUtil.isEmpty(data) && !EmptyUtil.isEmpty(data['image_list'])) { - if(data['image_list'][0] != _parentGoodsCoverImg) { + if (data['image_list'][0] != _parentGoodsCoverImg) { data['image_list'].insert(0, _parentGoodsCoverImg); } - }else if(!EmptyUtil.isEmpty(_parentGoodsCoverImg) && !EmptyUtil.isEmpty(data) && EmptyUtil.isEmpty(data['image_list'])){ + } else if (!EmptyUtil.isEmpty(_parentGoodsCoverImg) && !EmptyUtil.isEmpty(data) && EmptyUtil.isEmpty(data['image_list'])) { data['image_list'] = [_parentGoodsCoverImg]; } - }catch(e, s){ + } catch (e, s) { Logger.error(e, s); } } } - Map style =!EmptyUtil.isEmpty(item['style']) ? jsonDecode(item['style']) : new Map(); + Map style = !EmptyUtil.isEmpty(item['style']) ? jsonDecode(item['style']) : new Map(); style.addAll(baseData); if (!EmptyUtil.isEmpty(data)) { @@ -101,5 +127,4 @@ class GoodsDetailsPageRepository { } return null; } - } diff --git a/lib/widgets/goods_details/coupon/counpon_widget.dart b/lib/widgets/goods_details/coupon/counpon_widget.dart index 441f055..7a9cfa5 100644 --- a/lib/widgets/goods_details/coupon/counpon_widget.dart +++ b/lib/widgets/goods_details/coupon/counpon_widget.dart @@ -58,7 +58,7 @@ class _CounponWidgetContainerState extends State { /// 点击领取 void _onJump(CounponModel model) async{ - TurnChainUtil.openReceiveCoupon(context, _user, model.provider, model?.convertArgs?.toJson()); + TurnChainUtil.openReceiveCoupon(context, _user, model?.good_id, model.provider, model?.convertArgs?.toJson()); } @override diff --git a/lib/widgets/goods_details/coupon/model/counpon_model.dart b/lib/widgets/goods_details/coupon/model/counpon_model.dart index 3f3b0c9..94bbb10 100644 --- a/lib/widgets/goods_details/coupon/model/counpon_model.dart +++ b/lib/widgets/goods_details/coupon/model/counpon_model.dart @@ -11,11 +11,12 @@ class CounponModel { String price_type_color; String buy_url; String provider; - String goood_id; + String good_id; ConvertArgs convertArgs; + String commission; CounponModel({ - this.goood_id, + this.good_id, this.provider, this.bg_img, this.coupon_endtime, @@ -29,11 +30,12 @@ class CounponModel { this.price_type_color, this.buy_url, this.convertArgs, + this.commission, }); factory CounponModel.fromJson(Map json) { return CounponModel( - goood_id: json['goood_id'], + good_id: json['good_id'], provider: json['provider'], bg_img: json['bg_img'], coupon_endtime: json['coupon_endtime'], @@ -47,7 +49,7 @@ class CounponModel { price_type_color: json['price_type_color'], buy_url: json['buy_url'], convertArgs: json['convert_args'] != null ? ConvertArgs.fromJson(json['convert_args']) : null, - + commission: json['commission'], ); } @@ -65,11 +67,11 @@ class CounponModel { data['price_type_color'] = this.price_type_color; data['buy_url'] = this.buy_url; data['provider'] = this.provider; - data['goood_id'] = this.goood_id; + data['good_id'] = this.good_id; if (this.convertArgs != null) { data['convert_args'] = this.convertArgs.toJson(); } - + data['commission'] = this.commission; return data; } } @@ -81,8 +83,9 @@ class ConvertArgs { String couponPrice; String activityUrl; String isShare; + String commission; - ConvertArgs({this.gid, this.goodUrl, this.couponUrl, this.couponPrice, this.activityUrl, this.isShare}); + ConvertArgs({this.gid, this.goodUrl, this.couponUrl, this.couponPrice, this.activityUrl, this.isShare, this.commission}); ConvertArgs.fromJson(Map json) { gid = json['gid']; @@ -91,6 +94,7 @@ class ConvertArgs { couponPrice = json['coupon_price']; activityUrl = json['activity_url']; isShare = json['is_share']; + commission = json['commission']; } Map toJson() { @@ -101,7 +105,7 @@ class ConvertArgs { data['coupon_price'] = this.couponPrice; data['activity_url'] = this.activityUrl; data['is_share'] = this.isShare; + data['commission'] = this.commission; return data; } } - 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 44632b1..b0f2ed8 100644 --- a/lib/widgets/goods_details/footer/goods_details_footer_widget.dart +++ b/lib/widgets/goods_details/footer/goods_details_footer_widget.dart @@ -116,7 +116,7 @@ class _GooddsDetailsFooterContainerState extends State GoodsSharePage(widget.model))); // } - Map result = await TurnChainUtil.getShareTurnChain(context, _user, model.provider, model.convertArgs.toJson()); + Map result = await TurnChainUtil.getShareTurnChain(context, _user, model?.good_id, model.provider, model.convertArgs.toJson()); if (!EmptyUtil.isEmpty(result)) { model.shareUrlArgs.buyUrl = result['open_app_url']; Navigator.of(context).push(CupertinoPageRoute(builder: (context) => GoodsSharePage(model.toJson()))); @@ -125,7 +125,7 @@ class _GooddsDetailsFooterContainerState extends State json) { gid = json['gid']; @@ -252,6 +253,7 @@ class ConvertArgs { couponPrice = json['coupon_price']; activityUrl = json['activity_url']; isShare = json['is_share']; + commission = json['commission']; } Map toJson() { @@ -262,6 +264,7 @@ class ConvertArgs { data['coupon_price'] = this.couponPrice; data['activity_url'] = this.activityUrl; data['is_share'] = this.isShare; + data['commission'] = this.commission; return data; } }