Skip to content

Commit

Permalink
微信小程序产品界面,规格属性图片不显示以及无法点击的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
fancyecommerce committed Jan 22, 2021
1 parent 23fabe6 commit d3175f4
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions app/appserver/modules/Catalog/controllers/ProductController.php
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,10 @@ protected function getSameSpuInfo()
}
}
// 得到当前的spu下面的所有的值
$select = ['name', 'image', 'url_key'];
$productPrimaryKey = Yii::$service->product->getPrimaryKey();
$select = [$productPrimaryKey, 'name', 'image', 'url_key'];

//$select = ['name', 'image', 'url_key'];
$data = $this->getSpuData($select);
$spuValColl = [];
// 通过值,找到spu。
Expand All @@ -559,7 +562,7 @@ protected function getSameSpuInfo()

//$active = 'class="active"';
$one['main_img'] = isset($one['image']['main']['image']) ? $one['image']['main']['image'] : '';
$one['url'] = Yii::$service->url->getUrl($one['url_key']);
$one['url'] = '/catalog/product/'.(string)$one[$productPrimaryKey];
$reverse_val_spu[$reverse_key] = $one;
$showAsImgVal = $one[$this->_spuAttrShowAsImg];
if ($showAsImgVal) {
Expand Down Expand Up @@ -588,10 +591,12 @@ protected function getSameSpuInfo()
$attr_coll = [];
foreach ($attrValArr as $attrVal) {
$attr_info = $this->getSpuAttrInfo($spuAttr, $attrVal, $reverse_val_spu);
$attr_info['attr_val'] = Yii::$service->page->translate->__($attr_info['attr_val']);
$attr_coll[] = $attr_info;
}
$spuShowArr[] = [
'label' => $spuAttr,
//'label' => $spuAttr,
'label' => Yii::$service->page->translate->__($spuAttr),
'value' => $attr_coll,
];
}
Expand Down Expand Up @@ -621,7 +626,7 @@ protected function getSpuAttrInfo($spuAttr, $attrVal, $reverse_val_spu)
$return[$k] = $v;
}
if ($spuAttr == $this->_spuAttrShowAsImg) {
$return['show_as_img'] = $arr['main_img'];
$return['show_as_img'] = Yii::$service->product->image->getResize($arr['main_img'],[50,55],false);
}
} else if ($this->_spuAttrShowAsImg){
// 如果是图片,不存在,则使用备用的。
Expand All @@ -633,7 +638,7 @@ protected function getSpuAttrInfo($spuAttr, $attrVal, $reverse_val_spu)
$return[$k] = $v;
}
}
$return['show_as_img'] = $arr['main_img'];
$return['show_as_img'] = Yii::$service->product->image->getResize($arr['main_img'],[50,55],false);
}
} else if ($this->_spuAttrShowAsTop){
if ($spuAttr == $this->_spuAttrShowAsTop) {
Expand All @@ -649,7 +654,9 @@ protected function getSpuAttrInfo($spuAttr, $attrVal, $reverse_val_spu)
if ($active) {
$return['active'] = 'current';
}

$productPrimaryKey = Yii::$service->product->getPrimaryKey();
$return['_id'] = (string)$return[$productPrimaryKey];

return $return;
}

Expand Down

0 comments on commit d3175f4

Please sign in to comment.