Authored by xuqi

Merge branch 'develop' of http://git.dev.yoho.cn/web/yohobuy into develop

... ... @@ -23,7 +23,7 @@ class SearchData
* 模糊搜索提供的关键词
*
* @param string $keyword 关键词
* @return array 根据定关键词搜索到的结果,包括数据数目count和提供的关键词keyword
* @return array 根据定关键词搜索到的结果,包括数据数目count和提供的关键词keyword
*/
public static function searchFuzzyDatas($keyword)
{
... ... @@ -38,7 +38,7 @@ class SearchData
}
/**
* 根据定查询数据搜索数据列表
* 根据定查询数据搜索数据列表
*
* @param string $query 查询条件, 默认为null
* @param string $brand 品牌,默认为null
... ... @@ -97,9 +97,9 @@ class SearchData
return Yohobuy::get(self::$_searchurl, $param);
}
/**
* 根据定查询数据搜索数据列表
* 根据定查询数据搜索数据列表
*
* @param string $query 查询条件, 默认为null
* @param string $brand 品牌,默认为null
... ...
... ... @@ -123,10 +123,9 @@ class Helpers
* @param bool $showTag 控制是否显示标签
* @param bool $showNew 控制是否显示NEW图标
* @param bool $showSale 控制是否显示SALE图标
* @param bool $fromSearch 是否是搜索页搜出来的商品数据
* @return array | false
*/
public static function formatProduct($productData, $showTags = true, $showNew = true, $showSale = true, $fromSearch = false)
public static function formatProduct($productData, $showTags = true, $showNew = true, $showSale = true)
{
// 商品信息有问题,则不显示
... ... @@ -139,7 +138,7 @@ class Helpers
$productData['market_price'] = false;
}
// 如果$productData['default_images']为null,就取$productData['goods_list']中第一个,为空就不处理
// 如果$productData['default_images']为,就取$productData['goods_list']中第一个,为空就不处理
if (empty($productData['default_images'])) {
$productData['default_images'] = $productData['goods_list'][0];
}
... ... @@ -148,12 +147,7 @@ class Helpers
$result['id'] = $productData['product_skn'];
$result['product_id'] = $productData['product_id'];
// // 如果是来自搜索页搜索出来的图片要先处理一下
// if ($fromSearch && $productData['default_images']) {
// $productData['default_images'] = Images::template($productData['default_images'], 'goodsimg');
// }
$result['thumb'] = self::getImageUrl($productData['default_images'], 235, 314);
$result['thumb'] = Images::getImageUrl($productData['default_images'], 235, 314);
$result['name'] = $productData['product_name'];
$result['price'] = $productData['market_price'];
$result['salePrice'] = $productData['sales_price'];
... ...
... ... @@ -37,7 +37,6 @@ class Images
*/
static function template($fileName, $bucket = 'yhfair', $mode = 1)
{
return self::url($fileName, $bucket, $mode);
}
... ... @@ -65,26 +64,12 @@ class Images
* @param string $bucket
* @return mixed
*/
public static function getImageUrl($fileName, $width, $height, $mode = 1, $bucket = 'yhfair'){
public static function getImageUrl($fileName, $width, $height, $mode = 1, $bucket = 'goodsimg')
{
if(!preg_match('|http://|', $fileName)){
$fileName = self::template($fileName, $bucket, $mode);
}
return str_replace('{width}', $width, str_replace('{height}', $height, str_replace('{mode}', $mode, $fileName)));
}
/**
* 缩略图模板
* @param $fileName
* @param $bucket
* @param string $position ()
* @param string $background
* @return string
*/
static function template2($fileName, $bucket, $position = 'center', $background = 'd2hpdGU=')
{
$domain = self::getDomain($bucket, $fileName);
$key = $bucket . $fileName;
return self::MakeBaseUrl($domain, $key) . '?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/' . $background . '/position/' . $position.'/quality/90';
return strtr($fileName, array('{width}' => $width, '{height}' => $height, '{mode}' => $mode));
}
/**
... ... @@ -140,34 +125,17 @@ class Images
return "http://$domain/$keyEsc";
}
private static function MakeTemplateRequest($url)
{
private static function MakeTemplateRequest($url)
{
$ops = array();
$ops[] = '{mode}';
$ops[] = 'w/{width}';
$ops[] = 'h/{height}';
if (empty($ops)) {
return $url;
}
return $url . "?imageView/" . implode('/', $ops);
}
$ops[] = '{mode}';
$ops[] = 'w/{width}';
$ops[] = 'h/{height}';
/**
* 获取老的图片地址
* @param $fileName
* @param $bucket
* @param $width
* @param $height
* @param string $position
* @param string $background
* @return mixed
*/
public static function getUrl($fileName,$width,$height,$bucket, $position = 'center', $background = 'd2hpdGU=')
{
if(empty($fileName)){
$fileName = self::$default_image;
if (empty($ops)) {
return $url;
}
$url = self::template2($fileName, $bucket, $position, $background);
return str_replace(array('{width}','{height}'),array($width,$height),$url);
return $url . "?imageView/" . implode('/', $ops);
}
}
\ No newline at end of file
... ...