...
|
...
|
@@ -19,6 +19,28 @@ class ShopProcess |
|
|
private static $single = false;
|
|
|
|
|
|
/**
|
|
|
* 修改资源位的链接
|
|
|
* @param $val
|
|
|
* @param $shopId
|
|
|
* @return string
|
|
|
*/
|
|
|
private static function modifyUrl($val, $shopId)
|
|
|
{
|
|
|
if (isset($val['linkType']) && $val['linkType'] == 1) {
|
|
|
return Helpers::url('/search/list', array('poolId' => $val['categoryId'],
|
|
|
'title' => $val['categoryName']));
|
|
|
} else {
|
|
|
|
|
|
if (isset($val['url'])) {
|
|
|
return $val['url'];
|
|
|
} else {
|
|
|
return '';
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 组织店铺页面数据
|
|
|
* @param array $data 接口返回的店铺页所需数据
|
|
|
* @param int $shopId 店铺id
|
...
|
...
|
@@ -34,7 +56,7 @@ class ShopProcess |
|
|
if (empty($val) || !is_callable("self::$key")) {
|
|
|
continue;
|
|
|
}
|
|
|
self::$key($val);
|
|
|
self::$key($val, $shopId);
|
|
|
}
|
|
|
if (self::$single) {
|
|
|
self::$shopData['favId'] = self::$shopData['shopId'];
|
...
|
...
|
@@ -87,16 +109,37 @@ class ShopProcess |
|
|
* @param array $data
|
|
|
* @author sefon 2016-4-26 22:04:04
|
|
|
*/
|
|
|
private static function decorator($data)
|
|
|
private static function decorator($data, $shopId)
|
|
|
{
|
|
|
if (!isset($data['code']) || $data['code'] != 200 || !isset($data['data']['list']) || empty($data['data']['list'])) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
foreach ($data['data']['list'] as $val) {
|
|
|
if (empty($val['resource_data']) || !is_callable("self::$val[resource_name]")) {
|
|
|
continue;
|
|
|
}
|
|
|
self::$val['resource_name'](json_decode($val['resource_data'], true));
|
|
|
|
|
|
$json = json_decode($val['resource_data'], true);
|
|
|
|
|
|
foreach ($json as &$val2) {
|
|
|
$url = self::modifyUrl($val2, $shopId);
|
|
|
|
|
|
if (!empty($url)) {
|
|
|
$val2['url'] = $url;
|
|
|
}
|
|
|
|
|
|
if (isset($val2['data']) && is_array($val2['data'])) {
|
|
|
foreach ($val2['data'] as &$v) {
|
|
|
$url2 = self::modifyUrl($v, $shopId);
|
|
|
if (!empty($url2)) {
|
|
|
$v['url'] = $url2;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
self::$val['resource_name']($json);
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
|