@@ -6,6 +6,9 @@ class GoodsDetailsPageRepository { | |||
// 商品详情的封面图片 | |||
String _parentGoodsCoverImg; | |||
// ⚠️ 列表带过来的商品轮播图,避免详情接口获取不到轮播图的情况(1张或者1张以下) | |||
List<String> _imageList; | |||
// 优惠券 | |||
String _couponPrice; | |||
@@ -86,27 +89,55 @@ class GoodsDetailsPageRepository { | |||
// ⚠️ 为了商品详情的轮播图能够快速加载,故把上一个页面传进来的第一张图片插入到轮播图集合的第一个图片中 | |||
if (item['mod_name'] == 'product_detail_carousel') { | |||
// parentInput = true 说明数据是从列表传进来的 | |||
if (parentInput) { | |||
try { | |||
var imageList = data['image_list']; | |||
// 默认封面图片 | |||
_parentGoodsCoverImg = coverImage; | |||
if (!EmptyUtil.isEmpty(imageList)) { | |||
_parentGoodsCoverImg = imageList[0]; | |||
if (EmptyUtil.isEmpty(_parentGoodsCoverImg)) { | |||
_parentGoodsCoverImg = imageList[0]?.toString(); | |||
} else if (_parentGoodsCoverImg != imageList[0]) { | |||
// 列表轮播图第一张为封面,加快显示 | |||
imageList.insert(0, _parentGoodsCoverImg); | |||
data['image_list'] = imageList; | |||
} | |||
// 缓存列表的轮播图 | |||
_imageList = List<String>.from(imageList); | |||
} else if (!EmptyUtil.isEmpty(coverImage)) { | |||
_parentGoodsCoverImg = coverImage; | |||
data['image_list'] = [coverImage]; | |||
} | |||
// Logger.log('列表传过来的默认图片 = ' + _parentGoodsCoverImg); | |||
} catch (e, s) { | |||
Logger.error(e, s); | |||
} | |||
} else { | |||
try { | |||
if (!EmptyUtil.isEmpty(_parentGoodsCoverImg) && !EmptyUtil.isEmpty(data) && !EmptyUtil.isEmpty(data['image_list'])) { | |||
if (data['image_list'][0] != _parentGoodsCoverImg) { | |||
data['image_list'].insert(0, _parentGoodsCoverImg); | |||
// 如果存在轮播图,并且轮播图的第一张和列表封面图不一样,就把缓存的图片插到第一张,加快显示 | |||
if(data['image_list'].length > 1) { | |||
if (data['image_list'][0] != _parentGoodsCoverImg) { | |||
data['image_list'].insert(0, _parentGoodsCoverImg); | |||
} | |||
} else if (!EmptyUtil.isEmpty(_imageList)) { | |||
data['image_list'] = _imageList; | |||
// 详情接口轮播图只有一张或者一张以下图片的时候 | |||
if (_imageList[0] != _parentGoodsCoverImg) { | |||
data['image_list'].insert(0, _parentGoodsCoverImg); | |||
} | |||
} | |||
} else if (!EmptyUtil.isEmpty(_parentGoodsCoverImg) && !EmptyUtil.isEmpty(data) && EmptyUtil.isEmpty(data['image_list'])) { | |||
data['image_list'] = [_parentGoodsCoverImg]; | |||
if (!EmptyUtil.isEmpty(_imageList)) { | |||
if (_imageList[0] != _parentGoodsCoverImg) { | |||
_imageList.insert(0, _parentGoodsCoverImg); | |||
} | |||
data['image_list'] = _imageList; | |||
} else { | |||
data['image_list'] = [_parentGoodsCoverImg]; | |||
} | |||
} | |||
// Logger.log('详情接口的默认图片 = ' + data['image_list'][0]); | |||
} catch (e, s) { | |||
Logger.error(e, s); | |||
} | |||
@@ -116,7 +116,7 @@ class __CustomQuickEntryContainerState extends State<_CustomQuickEntryContainer> | |||
iconHeight = 43.5; | |||
} | |||
// 标题的高度 | |||
double titleHeight = 21.0; | |||
double titleHeight = 22; | |||
// 子元素的高度 | |||
double itemHeight = iconHeight; | |||
@@ -144,10 +144,10 @@ class __CustomQuickEntryContainerState extends State<_CustomQuickEntryContainer> | |||
} | |||
// 分类导航高度 | |||
double categoryHeight = 24; | |||
// double categoryHeight = 24; | |||
// 分类导航到多眼导航的边距 | |||
double categoryBottomMargin = 15.0; | |||
bool hasCategory = false; | |||
// double categoryBottomMargin = 15.0; | |||
// bool hasCategory = false; | |||
// if(!EmptyUtil.isEmpty(model?.typeList) && model.typeList.length >= 2){ | |||
// totalHeight = totalHeight + categoryHeight + categoryBottomMargin; | |||
// hasCategory = true; | |||
@@ -173,7 +173,7 @@ class __CustomQuickEntryContainerState extends State<_CustomQuickEntryContainer> | |||
bottomRight: Radius.circular(ParseUtil.stringParseDouble(model?.bottomRightRadius)), | |||
)), | |||
child: Container( | |||
margin: EdgeInsets.only(top: !hasCategory ? 15 : 0, bottom: totalPage > 1 ? 8 : 0), | |||
margin: EdgeInsets.only(top: 15, bottom: totalPage > 1 ? 8 : 0), | |||
height: totalHeight, | |||
// 总体高度 | |||
width: double.infinity, | |||
@@ -193,7 +193,7 @@ class __CustomQuickEntryContainerState extends State<_CustomQuickEntryContainer> | |||
Expanded( | |||
child: Container( | |||
width: double.infinity, | |||
height: hasCategory ? totalHeight - categoryHeight - categoryBottomMargin : totalHeight, | |||
height: totalHeight, | |||
child: Swiper( | |||
controller: _controller, | |||
itemCount: totalPage, | |||
@@ -566,7 +566,7 @@ class _CustomQuickCateEntryState extends State<CustomQuickCateEntry> with Ticker | |||
iconHeight = 43.5; | |||
} | |||
// 标题的高度 | |||
double titleHeight = 21.0; | |||
double titleHeight = 22; | |||
// 子元素的高度 | |||
double itemHeight = iconHeight; | |||
@@ -37,16 +37,31 @@ class GoodsDetailsTagWidget extends StatelessWidget { | |||
} | |||
Widget _buildMainWidget() { | |||
int labelSize = _model?.labelList?.length ?? 0; | |||
int tagSize = _model?.tagList?.length ?? 0; | |||
if (labelSize == 0 || tagSize == 0 || labelSize != tagSize) { | |||
return Container(); | |||
} | |||
return Row( | |||
mainAxisAlignment: MainAxisAlignment.start, | |||
children: <Widget>[ | |||
/// 领券立减100元 widget | |||
Visibility(visible: !EmptyUtil.isEmpty(_model?.couponText), child: _getCoumstonButtomWidget(_model?.couponText, _model?.tagList[1]?.textColor ?? '#FF4242', _model?.tagList[1]?.bgColor ?? '#FFE0E0')), | |||
/// 收货后返现5.5元 | |||
Visibility(visible: !EmptyUtil.isEmpty(_model?.commissionText), child: _getCoumstonButtomWidget(_model?.commissionText, _model?.tagList[0]?.textColor ?? '#B78107', _model?.tagList[0]?.bgColor ?? '#FFEFDA')), | |||
], | |||
children: _model.labelList.asMap().keys.map((index) => | |||
Visibility( | |||
visible: !EmptyUtil.isEmpty(_model.labelList[index]), | |||
child: _getCoumstonButtomWidget(_model.labelList[index] ?? '', _model?.tagList[index]?.textColor ?? '#FF4242', _model?.tagList[index]?.bgColor ?? '#FFE0E0')), | |||
).toList() | |||
); | |||
// return Row( | |||
// mainAxisAlignment: MainAxisAlignment.start, | |||
// children: <Widget>[ | |||
// /// 领券立减100元 widget | |||
// Visibility(visible: !EmptyUtil.isEmpty(_model?.couponText), child: _getCoumstonButtomWidget(_model?.couponText, _model?.tagList[1]?.textColor ?? '#FF4242', _model?.tagList[1]?.bgColor ?? '#FFE0E0')), | |||
// | |||
// /// 收货后返现5.5元 | |||
// Visibility(visible: !EmptyUtil.isEmpty(_model?.commissionText), child: _getCoumstonButtomWidget(_model?.commissionText, _model?.tagList[0]?.textColor ?? '#B78107', _model?.tagList[0]?.bgColor ?? '#FFEFDA')), | |||
// ], | |||
// ); | |||
} | |||
@@ -17,8 +17,12 @@ class GoodsDetailsTagModel { | |||
List<String> sourceList; | |||
// data | |||
// 弃用 | |||
String commissionText; | |||
// 弃用 | |||
String couponText; | |||
// commissionText couponText 改成这个 | |||
List<String> labelList; | |||
String providerName; | |||
String title; | |||
@@ -44,6 +48,7 @@ class GoodsDetailsTagModel { | |||
this.couponText, | |||
this.providerName, | |||
this.title, | |||
this.labelList, | |||
}); | |||
GoodsDetailsTagModel.fromJson(Map<String, dynamic> json) { | |||
@@ -67,12 +72,13 @@ class GoodsDetailsTagModel { | |||
tagList.add(new TagList.fromJson(v)); | |||
}); | |||
} | |||
sourceList = json['source_list'].cast<String>(); | |||
sourceList = json['source_list']?.cast<String>(); | |||
commissionText = json['commission_text']; | |||
couponText = json['coupon_text']; | |||
providerName = json['provider_name']; | |||
title = json['title']; | |||
labelList = json['label_list']?.cast<String>(); | |||
} | |||
Map<String, dynamic> toJson() { | |||
@@ -100,6 +106,7 @@ class GoodsDetailsTagModel { | |||
data['coupon_text'] = this.couponText; | |||
data['provider_name'] = this.providerName; | |||
data['title'] = this.title; | |||
data['label_list'] = this.labelList; | |||
return data; | |||
} | |||