Authored by htoooth

增加页面模板

... ... @@ -24,7 +24,7 @@
<ul>
{{#largeSlideImg}}
<li>
<a href="{{url}}"><img src="{{img}}"></a>
<a target="_blank" href="{{url}}"><img src="{{img}}"></a>
</li>
{{/largeSlideImg}}
</ul>
... ... @@ -32,7 +32,7 @@
</div>
<div class="slider-right pull-right">
{{#oneRowTwoColImages}}
<a class="slider-item" href="{{url}}"><img src="{{img}}"></a>
<a class="slider-item" target="_blank" href="{{url}}"><img src="{{img}}"></a>
{{/oneRowTwoColImages}}
</div>
</div>
... ...
<?php
namespace Product;
use LibModels\Wap\Guang\OptData;
use Product\SearchModel;
use LibModels\Web\Product\SearchData;
use LibModels\Web\Product\ShopData;
... ... @@ -29,7 +30,7 @@ class ShopModel
foreach ($shopList['data']['list'] as $list) {
$fun = $list['resource_name'];
if (is_callable("self::$fun")) {
$list = self::$fun(self::getResourceData($list), $parameters);
$list = self::$fun(self::getResourceData($list, $shopId), $parameters);
switch ($fun) {
case 'signboard':
//过滤不合法的数据
... ... @@ -122,7 +123,7 @@ class ShopModel
foreach ($shopList['data']['list'] as $list) {
$fun = $list['resource_name'];
if (is_callable("self::$fun")) {
$list = self::$fun(self::getResourceData($list), $parameters);
$list = self::$fun(self::getResourceData($list, $shopId), $parameters);
switch ($fun) {
case 'newProducts':
case 'hotProducts':
... ... @@ -374,7 +375,7 @@ class ShopModel
foreach ($resource['data'] as $val) {
$result[] = array(
'img' => self::imageView2($val['src'], 660, 360),
'url' => Helpers::getUrlSafe($val['url']),
'url' => Helpers::getUrlSafe($val['url']),
);
}
}
... ... @@ -397,9 +398,9 @@ class ShopModel
Helpers::substrEllipsis($resource['enName'], 5) : Helpers::substrEllipsis($resource['enName'], 10),
'name' => Helpers::isChinese($resource['name']) ?
Helpers::substrEllipsis($resource['name'], 5) : Helpers::substrEllipsis($resource['name'], 6),
'img'=> self::imageView2($resource['src'], 50, 50),
'title'=> $resource['title'],
'url'=> Helpers::getUrlSafe($resource['url']),
'img' => self::imageView2($resource['src'], 50, 50),
'title' => $resource['title'],
'url' => Helpers::getUrlSafe($resource['url']),
);
}
if (empty($result)) {
... ... @@ -423,9 +424,9 @@ class ShopModel
foreach ($data['resource_data'] as $resource) {
$result[] = array(
'img'=> self::imageView2($resource['src'], 160, 240),
'title'=> $resource['title'],
'url'=> Helpers::getUrlSafe($resource['url']),
'img' => self::imageView2($resource['src'], 160, 240),
'title' => $resource['title'],
'url' => Helpers::getUrlSafe($resource['url']),
);
}
if (empty($result)) {
... ... @@ -453,8 +454,8 @@ class ShopModel
foreach ($resource['data'] as $val) {
$result[] = array(
'img'=> self::imageView2($val['src'], 160, 240),
'url'=> Helpers::getUrlSafe($val['url']),
'img' => self::imageView2($val['src'], 160, 240),
'url' => Helpers::getUrlSafe($val['url']),
);
}
}
... ... @@ -572,7 +573,7 @@ class ShopModel
* @param type $data
* @return type []
*/
public static function hotProducts($data,$opts)
public static function hotProducts($data, $opts)
{
$result = array();
... ... @@ -605,7 +606,7 @@ class ShopModel
foreach ($shopList['data']['list'] as $list) {
$fun = $list['resource_name'];
if (is_callable("self::$fun")) {
$list = self::$fun(self::getResourceData($list), $parameters);
$list = self::$fun(self::getResourceData($list, $shopId), $parameters);
switch ($fun) {
case 'shopTopBanner_base':
case 'signboard':
... ... @@ -681,15 +682,34 @@ class ShopModel
return Helpers::getUrlSafe("{$src}imageView2/1/w/{$width}/h/{$heigh}");
}
private static function modifyUrl($val, $shopId)
{
if (isset($val['linkType']) && $val['linkType'] == 1) {
return Helpers::url('/product/index/shoplist', array('poolId' => $val['categoryId'], 'shopId' => $shopId));
} else {
return $val['url'];
}
}
/**
* 解析resource_data 参数
* @param type $data
* @return type []
*/
public static function getResourceData($data)
public static function getResourceData($data, $shopId)
{
$data['resource_data'] = isset($data['resource_data']) ? json_decode($data['resource_data'], true) : array();
$result = isset($data['resource_data']) ? json_decode($data['resource_data'], true) : array();
foreach ($result as &$val) {
$val['url'] = self::modifyUrl($val, $shopId);
if (isset($val['data']) && is_array($val['data'])) {
foreach ($val['data'] as &$v) {
$v['url'] = self::modifyUrl($v, $shopId);
}
}
}
$data['resource_data'] = $result;
return $data;
}
... ...
... ... @@ -29,8 +29,6 @@ class IndexController extends WebAction
}
//根据品牌域名获取品牌id(同时判断品牌域名是否有效),无效跳转首页
$result = BrandsModel::getBrandByDomain($domain);
print_r($result);
exit();
if (!$result) {
$this->go(SITE_MAIN);
}
... ...