Authored by 郭成尧

店铺简介图片获取

... ... @@ -15,7 +15,7 @@ use Plugin\Images;
/**
* 商品列表相关的模板数据模型
*
*
* @name ListModel
* @package models/Product
* @copyright yoho.inc
... ... @@ -27,7 +27,7 @@ class ListModel
/**
* 获取品类商品列表数据
*
*
* @param array $condition 条件
* @return array | false
*
... ... @@ -60,8 +60,7 @@ class ListModel
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
if (empty($result)) {
$result = Cache::get($key, 'slave');
}
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
} // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
else {
Cache::set($key, $result, 1800); // 缓存30分钟
}
... ... @@ -72,7 +71,7 @@ class ListModel
/**
* 获取品牌信息
*
*
* @param int $id 唯一的ID
* @param int $uid 用户ID
* @param string $title 网站标题
... ... @@ -103,7 +102,7 @@ class ListModel
/**
* 获取品牌商品列表数据
*
*
* @param array $condition 条件参数
* @param string $title 网站标题
* @return array
... ... @@ -143,8 +142,7 @@ class ListModel
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
if (empty($result)) {
$result = Cache::get($key, 'slave');
}
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
} // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
else {
Cache::set($key, $result, 1800); // 缓存30分钟
}
... ... @@ -155,7 +153,7 @@ class ListModel
/**
* 根据品牌ID获取品牌LOGO
*
*
* @param int $id 品牌ID
* @param string $title 品牌标题
* @return array | false
... ... @@ -189,8 +187,7 @@ class ListModel
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
if (empty($result)) {
$result = Cache::get($key, 'slave');
}
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
} // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
else {
Cache::set($key, $result); // 缓存1小时
}
... ... @@ -201,7 +198,7 @@ class ListModel
/**
* 根据品牌ID获取品牌LOGO
*
*
* @param int $id 品牌ID
* @param string $title 品牌标题
* @return array | false
... ... @@ -236,8 +233,7 @@ class ListModel
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
if (empty($result)) {
$result = Cache::get($key, 'slave');
}
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
} // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
else {
Cache::set($key, $result); // 缓存1小时
}
... ... @@ -248,7 +244,7 @@ class ListModel
/**
* 获取所有的品牌名称列表
*
*
* @return array(
* 品牌ID => 品牌域名(domain)
* )
... ... @@ -287,8 +283,7 @@ class ListModel
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
if (empty($result)) {
$result = Cache::get($key, 'slave');
}
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
} // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
else {
Cache::set($key, $result);
}
... ... @@ -299,7 +294,7 @@ class ListModel
/**
* 获取所有的品牌名称列表
*
*
* @return array(
* 品牌域名(domain) => 品牌名称(name)
* )
... ... @@ -338,8 +333,7 @@ class ListModel
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
if (empty($result)) {
$result = Cache::get($key, 'slave');
}
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
} // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
else {
Cache::set($key, $result);
}
... ... @@ -354,7 +348,7 @@ class ListModel
* @return array 返回的处理好的数据
* @author chengyao.guo
*/
public static function categoryData($data , $shop_id)
public static function categoryData($data, $shop_id)
{
$result = array();
$result['class'] = array();
... ... @@ -372,9 +366,18 @@ class ListModel
}
array_push($result['category'], array('subcategory' => $item['sub']));
}
$result['allproduct'] = Helpers::url('/search/list', array(
'shop' => $shop_id,
));
return $result;
}
public static function introData(&$data)
{
$data['shop_logo'] = Images::getImageUrl($data['shop_logo'], 640, 480);
return $data;
}
/**
* 店铺所有品牌信息处理
* @author chengyao.guo
... ... @@ -382,7 +385,7 @@ class ListModel
* @param $shop_id
* @return mixed
*/
public static function brandData($data,$shop_id)
public static function brandData($data, $shop_id)
{
// 处理图片链接
foreach ($data as &$item) {
... ... @@ -395,6 +398,7 @@ class ListModel
}
return $data;
}
/**
* 新店铺首页
* @param int $shopId 店铺id
... ...
... ... @@ -432,7 +432,7 @@ class IndexController extends AbstractAction
$result = array();
$resource = ShopData::getShopIntro($requestData['shop_id']);
if ($resource['code'] === 200) {
$result = $resource['data'];
$result = ListModel::introData($resource['data']);
}
if(Mobile::isMobile()){
$this->setTitle('店铺简介');
... ...