Authored by htoooth

增加页面模板

@@ -24,7 +24,7 @@ @@ -24,7 +24,7 @@
24 <ul> 24 <ul>
25 {{#largeSlideImg}} 25 {{#largeSlideImg}}
26 <li> 26 <li>
27 - <a href="{{url}}"><img src="{{img}}"></a> 27 + <a target="_blank" href="{{url}}"><img src="{{img}}"></a>
28 </li> 28 </li>
29 {{/largeSlideImg}} 29 {{/largeSlideImg}}
30 </ul> 30 </ul>
@@ -32,7 +32,7 @@ @@ -32,7 +32,7 @@
32 </div> 32 </div>
33 <div class="slider-right pull-right"> 33 <div class="slider-right pull-right">
34 {{#oneRowTwoColImages}} 34 {{#oneRowTwoColImages}}
35 - <a class="slider-item" href="{{url}}"><img src="{{img}}"></a> 35 + <a class="slider-item" target="_blank" href="{{url}}"><img src="{{img}}"></a>
36 {{/oneRowTwoColImages}} 36 {{/oneRowTwoColImages}}
37 </div> 37 </div>
38 </div> 38 </div>
1 <?php 1 <?php
2 namespace Product; 2 namespace Product;
3 3
  4 +use LibModels\Wap\Guang\OptData;
4 use Product\SearchModel; 5 use Product\SearchModel;
5 use LibModels\Web\Product\SearchData; 6 use LibModels\Web\Product\SearchData;
6 use LibModels\Web\Product\ShopData; 7 use LibModels\Web\Product\ShopData;
@@ -29,7 +30,7 @@ class ShopModel @@ -29,7 +30,7 @@ class ShopModel
29 foreach ($shopList['data']['list'] as $list) { 30 foreach ($shopList['data']['list'] as $list) {
30 $fun = $list['resource_name']; 31 $fun = $list['resource_name'];
31 if (is_callable("self::$fun")) { 32 if (is_callable("self::$fun")) {
32 - $list = self::$fun(self::getResourceData($list), $parameters); 33 + $list = self::$fun(self::getResourceData($list, $shopId), $parameters);
33 switch ($fun) { 34 switch ($fun) {
34 case 'signboard': 35 case 'signboard':
35 //过滤不合法的数据 36 //过滤不合法的数据
@@ -122,7 +123,7 @@ class ShopModel @@ -122,7 +123,7 @@ class ShopModel
122 foreach ($shopList['data']['list'] as $list) { 123 foreach ($shopList['data']['list'] as $list) {
123 $fun = $list['resource_name']; 124 $fun = $list['resource_name'];
124 if (is_callable("self::$fun")) { 125 if (is_callable("self::$fun")) {
125 - $list = self::$fun(self::getResourceData($list), $parameters); 126 + $list = self::$fun(self::getResourceData($list, $shopId), $parameters);
126 switch ($fun) { 127 switch ($fun) {
127 case 'newProducts': 128 case 'newProducts':
128 case 'hotProducts': 129 case 'hotProducts':
@@ -374,7 +375,7 @@ class ShopModel @@ -374,7 +375,7 @@ class ShopModel
374 foreach ($resource['data'] as $val) { 375 foreach ($resource['data'] as $val) {
375 $result[] = array( 376 $result[] = array(
376 'img' => self::imageView2($val['src'], 660, 360), 377 'img' => self::imageView2($val['src'], 660, 360),
377 - 'url' => Helpers::getUrlSafe($val['url']), 378 + 'url' => Helpers::getUrlSafe($val['url']),
378 ); 379 );
379 } 380 }
380 } 381 }
@@ -397,9 +398,9 @@ class ShopModel @@ -397,9 +398,9 @@ class ShopModel
397 Helpers::substrEllipsis($resource['enName'], 5) : Helpers::substrEllipsis($resource['enName'], 10), 398 Helpers::substrEllipsis($resource['enName'], 5) : Helpers::substrEllipsis($resource['enName'], 10),
398 'name' => Helpers::isChinese($resource['name']) ? 399 'name' => Helpers::isChinese($resource['name']) ?
399 Helpers::substrEllipsis($resource['name'], 5) : Helpers::substrEllipsis($resource['name'], 6), 400 Helpers::substrEllipsis($resource['name'], 5) : Helpers::substrEllipsis($resource['name'], 6),
400 - 'img'=> self::imageView2($resource['src'], 50, 50),  
401 - 'title'=> $resource['title'],  
402 - 'url'=> Helpers::getUrlSafe($resource['url']), 401 + 'img' => self::imageView2($resource['src'], 50, 50),
  402 + 'title' => $resource['title'],
  403 + 'url' => Helpers::getUrlSafe($resource['url']),
403 ); 404 );
404 } 405 }
405 if (empty($result)) { 406 if (empty($result)) {
@@ -423,9 +424,9 @@ class ShopModel @@ -423,9 +424,9 @@ class ShopModel
423 424
424 foreach ($data['resource_data'] as $resource) { 425 foreach ($data['resource_data'] as $resource) {
425 $result[] = array( 426 $result[] = array(
426 - 'img'=> self::imageView2($resource['src'], 160, 240),  
427 - 'title'=> $resource['title'],  
428 - 'url'=> Helpers::getUrlSafe($resource['url']), 427 + 'img' => self::imageView2($resource['src'], 160, 240),
  428 + 'title' => $resource['title'],
  429 + 'url' => Helpers::getUrlSafe($resource['url']),
429 ); 430 );
430 } 431 }
431 if (empty($result)) { 432 if (empty($result)) {
@@ -453,8 +454,8 @@ class ShopModel @@ -453,8 +454,8 @@ class ShopModel
453 454
454 foreach ($resource['data'] as $val) { 455 foreach ($resource['data'] as $val) {
455 $result[] = array( 456 $result[] = array(
456 - 'img'=> self::imageView2($val['src'], 160, 240),  
457 - 'url'=> Helpers::getUrlSafe($val['url']), 457 + 'img' => self::imageView2($val['src'], 160, 240),
  458 + 'url' => Helpers::getUrlSafe($val['url']),
458 ); 459 );
459 } 460 }
460 } 461 }
@@ -572,7 +573,7 @@ class ShopModel @@ -572,7 +573,7 @@ class ShopModel
572 * @param type $data 573 * @param type $data
573 * @return type [] 574 * @return type []
574 */ 575 */
575 - public static function hotProducts($data,$opts) 576 + public static function hotProducts($data, $opts)
576 { 577 {
577 $result = array(); 578 $result = array();
578 579
@@ -605,7 +606,7 @@ class ShopModel @@ -605,7 +606,7 @@ class ShopModel
605 foreach ($shopList['data']['list'] as $list) { 606 foreach ($shopList['data']['list'] as $list) {
606 $fun = $list['resource_name']; 607 $fun = $list['resource_name'];
607 if (is_callable("self::$fun")) { 608 if (is_callable("self::$fun")) {
608 - $list = self::$fun(self::getResourceData($list), $parameters); 609 + $list = self::$fun(self::getResourceData($list, $shopId), $parameters);
609 switch ($fun) { 610 switch ($fun) {
610 case 'shopTopBanner_base': 611 case 'shopTopBanner_base':
611 case 'signboard': 612 case 'signboard':
@@ -681,15 +682,34 @@ class ShopModel @@ -681,15 +682,34 @@ class ShopModel
681 return Helpers::getUrlSafe("{$src}imageView2/1/w/{$width}/h/{$heigh}"); 682 return Helpers::getUrlSafe("{$src}imageView2/1/w/{$width}/h/{$heigh}");
682 } 683 }
683 684
  685 + private static function modifyUrl($val, $shopId)
  686 + {
  687 + if (isset($val['linkType']) && $val['linkType'] == 1) {
  688 + return Helpers::url('/product/index/shoplist', array('poolId' => $val['categoryId'], 'shopId' => $shopId));
  689 + } else {
  690 + return $val['url'];
  691 + }
  692 + }
  693 +
684 /** 694 /**
685 * 解析resource_data 参数 695 * 解析resource_data 参数
686 * @param type $data 696 * @param type $data
687 * @return type [] 697 * @return type []
688 */ 698 */
689 - public static function getResourceData($data) 699 + public static function getResourceData($data, $shopId)
690 { 700 {
691 - $data['resource_data'] = isset($data['resource_data']) ? json_decode($data['resource_data'], true) : array(); 701 + $result = isset($data['resource_data']) ? json_decode($data['resource_data'], true) : array();
  702 + foreach ($result as &$val) {
  703 + $val['url'] = self::modifyUrl($val, $shopId);
  704 +
  705 + if (isset($val['data']) && is_array($val['data'])) {
  706 + foreach ($val['data'] as &$v) {
  707 + $v['url'] = self::modifyUrl($v, $shopId);
  708 + }
  709 + }
  710 + }
692 711
  712 + $data['resource_data'] = $result;
693 return $data; 713 return $data;
694 } 714 }
695 715
@@ -29,8 +29,6 @@ class IndexController extends WebAction @@ -29,8 +29,6 @@ class IndexController extends WebAction
29 } 29 }
30 //根据品牌域名获取品牌id(同时判断品牌域名是否有效),无效跳转首页 30 //根据品牌域名获取品牌id(同时判断品牌域名是否有效),无效跳转首页
31 $result = BrandsModel::getBrandByDomain($domain); 31 $result = BrandsModel::getBrandByDomain($domain);
32 - print_r($result);  
33 - exit();  
34 if (!$result) { 32 if (!$result) {
35 $this->go(SITE_MAIN); 33 $this->go(SITE_MAIN);
36 } 34 }