Authored by zhangxiaoru

首页

@@ -221,6 +221,7 @@ class BrandData @@ -221,6 +221,7 @@ class BrandData
221 * 通过域名获取品牌LOGO信息 221 * 通过域名获取品牌LOGO信息
222 * 222 *
223 * @param int $id 用户ID 223 * @param int $id 用户ID
  224 + * @modify sefon 2016-4-29 01:59:23
224 * @return array 225 * @return array
225 */ 226 */
226 public static function getBrandLogoByDomain($domain) 227 public static function getBrandLogoByDomain($domain)
@@ -228,4 +229,19 @@ class BrandData @@ -228,4 +229,19 @@ class BrandData
228 return Yohobuy::yarClient(Yohobuy::SERVICE_URL . '/shops/service/v1/brand', 'getBrandByDomain', array($domain)); 229 return Yohobuy::yarClient(Yohobuy::SERVICE_URL . '/shops/service/v1/brand', 'getBrandByDomain', array($domain));
229 } 230 }
230 231
  232 + /**
  233 + * 根据品牌域名获取品牌店铺信息
  234 + * @param string $domain
  235 + * @author sefon 2016-4-28 23:35:28
  236 + * @return mixed
  237 + */
  238 + public static function getShopInfoByBrandDomain($domain)
  239 + {
  240 + $param = Yohobuy::param();
  241 + $param['method'] = 'web.brand.byDomain';
  242 + $param['domain'] = $domain;
  243 + $param['client_secret'] = Sign::getSign($param);
  244 + return Yohobuy::get('http://192.168.102.218:8080/gateway/', $param);
  245 + }
  246 +
231 } 247 }
@@ -77,15 +77,17 @@ class ListData @@ -77,15 +77,17 @@ class ListData
77 /** 77 /**
78 * 获取店铺信息 78 * 获取店铺信息
79 * @param int $shopId 店铺id 79 * @param int $shopId 店铺id
  80 + * @param int $uid 用户id 判断用户是否收藏店铺
80 * @param int $cache 接口缓存 81 * @param int $cache 接口缓存
81 * @author sefon 2016-4-26 21:32:57 82 * @author sefon 2016-4-26 21:32:57
82 * @return array 83 * @return array
83 */ 84 */
84 - public static function getShopInfo($shopId, $cache = 600) 85 + public static function getShopInfo($shopId, $uid = 0, $cache = 600)
85 { 86 {
86 $param = Yohobuy::param(); 87 $param = Yohobuy::param();
87 $param['method'] = 'app.shops.getIntro'; 88 $param['method'] = 'app.shops.getIntro';
88 $param['shop_id'] = $shopId; 89 $param['shop_id'] = $shopId;
  90 + $param['uid'] = $uid;
89 $param['client_secret'] = Sign::getSign($param); 91 $param['client_secret'] = Sign::getSign($param);
90 //TODO 92 //TODO
91 // return Yohobuy::get(Yohobuy::API_URL, $param); 93 // return Yohobuy::get(Yohobuy::API_URL, $param);
@@ -128,5 +130,21 @@ class ListData @@ -128,5 +130,21 @@ class ListData
128 return Yohobuy::get('http://192.168.102.218:8080/gateway/', $param, $cache); 130 return Yohobuy::get('http://192.168.102.218:8080/gateway/', $param, $cache);
129 } 131 }
130 132
  133 + /**
  134 + * 根据brandid获取相关店铺
  135 + * @param int $brandId
  136 + * @author sefon 2016-4-28 13:41:09
  137 + * @return array
  138 + */
  139 + public static function getShopByBrandId($brandId, $cache = 600)
  140 + {
  141 + $param = Yohobuy::param();
  142 + $param['method'] = 'app.shop.queryShopByBrandId';
  143 + $param['brand_id'] = $brandId;
  144 + $param['client_secret'] = Sign::getSign($param);
  145 + //TODO
  146 +// return Yohobuy::get(Yohobuy::API_URL, $param);
  147 + return Yohobuy::get('http://192.168.102.218:8080/gateway/', $param, $cache);
  148 + }
131 149
132 } 150 }
@@ -101,4 +101,51 @@ class ShopData @@ -101,4 +101,51 @@ class ShopData
101 exit; 101 exit;
102 } 102 }
103 } 103 }
  104 +
  105 + /**
  106 + * 收藏店铺
  107 + * @param int $uid
  108 + * @param int $shopId
  109 + * @param string $gender
  110 + * @author sefon 2016-4-28 22:09:30
  111 + * @return mixed
  112 + */
  113 + public static function shopFav($uid, $shopId, $gender = '')
  114 + {
  115 + $param = Yohobuy::param();
  116 + $param['method'] = 'app.favorite.add';
  117 + $param['uid'] = $uid;
  118 + $param['id'] = $shopId;
  119 + $param['fav_id'] = $shopId;
  120 + $param['type'] = 'shop';
  121 + if (!empty($gender)) {
  122 + $param['gender'] = $gender;
  123 + }
  124 + $param['client_secret'] = Sign::getSign($param);
  125 + return Yohobuy::get(Yohobuy::API_URL, $param);
  126 + }
  127 +
  128 + /**
  129 + * 取消收藏店铺
  130 + * @param int $uid
  131 + * @param int $shopId
  132 + * @param string $gender
  133 + * @author sefon 2016-4-28 22:09:30
  134 + * @return mixed
  135 + */
  136 + public static function cancelShopFav($uid, $shopId, $gender = '')
  137 + {
  138 + $param = Yohobuy::param();
  139 + $param['method'] = 'app.favorite.cancel';
  140 + $param['uid'] = $uid;
  141 + $param['id'] = $shopId;
  142 + $param['fav_id'] = $shopId;
  143 + $param['type'] = 'shop';
  144 + if ($gender) {
  145 + $param['gender'] = $gender;
  146 + }
  147 + $param['client_secret'] = Sign::getSign($param);
  148 + return Yohobuy::get(Yohobuy::API_URL, $param);
  149 + }
  150 +
104 } 151 }
@@ -118,7 +118,7 @@ class SearchData @@ -118,7 +118,7 @@ class SearchData
118 // return 'http://101.200.31.165/yohosearch/brand/list.json'; 118 // return 'http://101.200.31.165/yohosearch/brand/list.json';
119 // return 'http://182.92.99.119:8080/yohosearch/brand/list.json'; 119 // return 'http://182.92.99.119:8080/yohosearch/brand/list.json';
120 } 120 }
121 - return 'http://101.200.31.165/yohosearch/search.json'; 121 + return 'http://101.200.31.165/yohosearch/search.json';//支持shop_id
122 //return 'http://101.200.31.165/yohosearch/search.json'; 122 //return 'http://101.200.31.165/yohosearch/search.json';
123 // return 'http://182.92.99.119:8080/yohosearch/search.json'; 123 // return 'http://182.92.99.119:8080/yohosearch/search.json';
124 } 124 }
@@ -11,30 +11,48 @@ use Plugin\Images; @@ -11,30 +11,48 @@ use Plugin\Images;
11 class ShopProcess 11 class ShopProcess
12 { 12 {
13 private static $shopData = array(); 13 private static $shopData = array();
  14 + private static $shopId = 0;
  15 +
14 /** 16 /**
15 * 组织店铺页面数据 17 * 组织店铺页面数据
16 * @param array $data 接口返回的店铺页所需数据 18 * @param array $data 接口返回的店铺页所需数据
17 - * @param int $type 店铺模板id 19 + * @param int $shopId 店铺id
18 * @author sefon 2016-4-26 21:56:32 20 * @author sefon 2016-4-26 21:56:32
19 * @return array 21 * @return array
20 */ 22 */
21 - public static function formShopData($data, $type = 2) 23 + public static function formShopData($data, $shopId)
22 { 24 {
  25 + self::$shopId = $shopId;
23 foreach ($data as $key => $val) { 26 foreach ($data as $key => $val) {
24 if (empty($val) || !is_callable("self::$key")) { 27 if (empty($val) || !is_callable("self::$key")) {
25 continue; 28 continue;
26 } 29 }
27 self::$key($val); 30 self::$key($val);
28 } 31 }
29 -// exit;  
30 return self::$shopData; 32 return self::$shopData;
31 } 33 }
32 34
33 /** 35 /**
  36 + * 店铺基本信息
  37 + * @param $data
  38 + * @author sefon 2016-4-29 01:48:50
  39 + */
  40 + private static function shopInfo($data)
  41 + {
  42 + self::$shopData['logoImg'] = Images::getImageUrl($data['data']['shop_logo'], 500, 500, 'shopLogo');
  43 + self::$shopData['storeName'] = $data['data']['shop_name'];
  44 + //用户是否收藏店铺
  45 + self::$shopData['favorite'] = $data['data']['is_favorite'] == 'Y' ? true : false;
  46 + //店铺简介页地址
  47 + self::$shopData['shopIntroHref'] = Helpers::url('/product/index/intro', array('shop_id' => self::$shopId));
  48 + //全部商品链接
  49 + self::$shopData['allGoods'] = Helpers::url('', array('shop_id' => self::$shopId, 'title' => '全部商品'), 'search');
  50 + }
  51 +
  52 + /**
34 * 组织店铺装修 53 * 组织店铺装修
35 * @param array $data 54 * @param array $data
36 * @author sefon 2016-4-26 22:04:04 55 * @author sefon 2016-4-26 22:04:04
37 - * @return array  
38 */ 56 */
39 private static function decorator($data) 57 private static function decorator($data)
40 { 58 {
@@ -47,24 +65,12 @@ class ShopProcess @@ -47,24 +65,12 @@ class ShopProcess
47 } 65 }
48 self::$val['resource_name'](json_decode($val['resource_data'], true)); 66 self::$val['resource_name'](json_decode($val['resource_data'], true));
49 } 67 }
50 -// print_r($data); exit;  
51 - }  
52 -  
53 - /**  
54 - * 店铺基本信息  
55 - * @param $data  
56 - */  
57 - private static function shopInfo($data)  
58 - {  
59 - self::$shopData['logoImg'] = Images::getImageUrl($data['data']['shop_logo'], 500, 500, 'shopLogo');  
60 - self::$shopData['storeName'] = $data['data']['shop_name'];  
61 } 68 }
62 69
63 /** 70 /**
64 * 店铺Banner 71 * 店铺Banner
65 * @param array $data 72 * @param array $data
66 * @author sefon 2016-4-27 08:40:05 73 * @author sefon 2016-4-27 08:40:05
67 - * @return array  
68 */ 74 */
69 private static function shopTopBanner_APP($data) 75 private static function shopTopBanner_APP($data)
70 { 76 {
@@ -75,11 +81,9 @@ class ShopProcess @@ -75,11 +81,9 @@ class ShopProcess
75 * 资源位小图 接口返回两组,取每组第一张 81 * 资源位小图 接口返回两组,取每组第一张
76 * @param array $data 82 * @param array $data
77 * @author sefon 2016-4-27 08:37:30 83 * @author sefon 2016-4-27 08:37:30
78 - * @return array  
79 */ 84 */
80 private static function oneRowTwoColImages_APP($data) 85 private static function oneRowTwoColImages_APP($data)
81 { 86 {
82 -// print_r($data); exit;  
83 foreach ($data as $key => $val) { 87 foreach ($data as $key => $val) {
84 if (empty($val['data'])) { 88 if (empty($val['data'])) {
85 continue; 89 continue;
@@ -89,7 +93,6 @@ class ShopProcess @@ -89,7 +93,6 @@ class ShopProcess
89 'springType' => $val['data'][0]['src'] 93 'springType' => $val['data'][0]['src']
90 ); 94 );
91 } 95 }
92 - return $data;  
93 } 96 }
94 97
95 /** 98 /**
@@ -100,14 +103,16 @@ class ShopProcess @@ -100,14 +103,16 @@ class ShopProcess
100 */ 103 */
101 private static function brandBrowse($data) 104 private static function brandBrowse($data)
102 { 105 {
103 -// print_r($data); exit;  
104 foreach ($data as $val) { 106 foreach ($data as $val) {
105 - self::$shopData['multiList'][] = array( 107 + self::$shopData['brandList']['list'][] = array(
106 'url' => Helpers::url('', '', $val['brandDomain']), 108 'url' => Helpers::url('', '', $val['brandDomain']),
107 'img' => Images::getImageUrl($val['brandIco'], 640, 400), 109 'img' => Images::getImageUrl($val['brandIco'], 640, 400),
108 'brandName' => $val['brandName'] 110 'brandName' => $val['brandName']
109 ); 111 );
110 } 112 }
  113 + if (count($data) > 5) {
  114 + self::$shopData['brandList']['url'] = Helpers::url('/product/index/allBrand', array('shop_id' => self::$shopId));
  115 + }
111 } 116 }
112 117
113 /** 118 /**
@@ -117,14 +122,11 @@ class ShopProcess @@ -117,14 +122,11 @@ class ShopProcess
117 */ 122 */
118 private static function largeSlideImg($data) 123 private static function largeSlideImg($data)
119 { 124 {
120 -// print_r($data); exit;  
121 - foreach ($data as $val) {  
122 - if (!isset($data['data']) || !empty($data['data'])) {  
123 - continue;  
124 - }  
125 - foreach ($data['data'] as $slide) {  
126 - self::$shopData['bannerTop']['list'][] = array('url' => $slide['url'], 'img' => $slide['shopSrc']);  
127 - } 125 + if (empty($data[0]['data'])) {
  126 + return;
  127 + }
  128 + foreach ($data[0]['data'] as $slide) {
  129 + self::$shopData['bannerTop']['list'][] = array('url' => $slide['url'], 'img' => $slide['src']);
128 } 130 }
129 } 131 }
130 /** 132 /**
@@ -146,22 +148,18 @@ class ShopProcess @@ -146,22 +148,18 @@ class ShopProcess
146 * 人气单品 148 * 人气单品
147 * @param array $data 149 * @param array $data
148 * @author sefon 2016-4-27 08:38:36 150 * @author sefon 2016-4-27 08:38:36
149 - * @return array  
150 */ 151 */
151 private static function hotProducts($data) 152 private static function hotProducts($data)
152 { 153 {
153 -// print_r($data);  
154 foreach ($data as $val) { 154 foreach ($data as $val) {
155 self::$shopData['hotList'][] = array( 155 self::$shopData['hotList'][] = array(
156 - 'url' => $val['url'], 156 + 'url' => Helpers::getUrlBySkc($val['product_id'], $val['goods_id'], $val['cn_alphabet']),
157 'img' => Helpers::getImageUrl($val['src'], 235, 314), 157 'img' => Helpers::getImageUrl($val['src'], 235, 314),
158 'productName' => $val['productName'], 158 'productName' => $val['productName'],
159 'salesPrice' => '¥'.$val['salesPrice'], 159 'salesPrice' => '¥'.$val['salesPrice'],
160 'presentPrice' => '¥'.$val['salesPrice'] 160 'presentPrice' => '¥'.$val['salesPrice']
161 ); 161 );
162 } 162 }
163 -  
164 - return $data;  
165 } 163 }
166 164
167 /** 165 /**
@@ -173,12 +171,12 @@ class ShopProcess @@ -173,12 +171,12 @@ class ShopProcess
173 if (isset($data['code']) && $data['code'] == 200 && !empty($data['data'])) { 171 if (isset($data['code']) && $data['code'] == 200 && !empty($data['data'])) {
174 $total = count($data['data']); 172 $total = count($data['data']);
175 if ($total > 5) { 173 if ($total > 5) {
176 - self::$shopData['shopCategory']['url'] = 'http://m.yohobuy.com'; 174 + self::$shopData['shopCategory']['url'] = Helpers::url('/product/index/category', array('shop_id' => self::$shopId));
177 return; 175 return;
178 } 176 }
179 foreach ($data['data'] as $key => $val) { 177 foreach ($data['data'] as $key => $val) {
180 self::$shopData['shopCategory']['list'][] = array( 178 self::$shopData['shopCategory']['list'][] = array(
181 - 'url' => '', 179 + 'url' => Helpers::url('', array('shop_id' => self::$shopId), 'search'),
182 'categoryId' => $val['category_id'], 180 'categoryId' => $val['category_id'],
183 'name' => $val['category_name'] 181 'name' => $val['category_name']
184 ); 182 );
@@ -51,7 +51,7 @@ @@ -51,7 +51,7 @@
51 </a> 51 </a>
52 <p>{{brandName}}</p> 52 <p>{{brandName}}</p>
53 </li> 53 </li>
54 - {{/each}} 54 + {{/each}}
55 </ul> 55 </ul>
56 </div> 56 </div>
57 </div> 57 </div>
@@ -201,6 +201,7 @@ class ListModel @@ -201,6 +201,7 @@ class ListModel
201 * 201 *
202 * @param int $id 品牌ID 202 * @param int $id 品牌ID
203 * @param string $title 品牌标题 203 * @param string $title 品牌标题
  204 + * @modify sefon 2016-4-29 01:57:14 添加shopId / type
204 * @return array | false 205 * @return array | false
205 */ 206 */
206 public static function getBrandLogoByDomain($domain, &$title) 207 public static function getBrandLogoByDomain($domain, &$title)
@@ -218,6 +219,7 @@ class ListModel @@ -218,6 +219,7 @@ class ListModel
218 219
219 // 调用接口查询数据 220 // 调用接口查询数据
220 $brandLogo = BrandData::getBrandLogoByDomain($domain); 221 $brandLogo = BrandData::getBrandLogoByDomain($domain);
  222 +// $brandLogo = BrandData::getShopInfoByBrandDomain($domain); // TODO 获取品牌店铺信息
221 // 处理返回的数据 223 // 处理返回的数据
222 if (isset($brandLogo['data'])) { 224 if (isset($brandLogo['data'])) {
223 $result = array( 225 $result = array(
@@ -225,6 +227,8 @@ class ListModel @@ -225,6 +227,8 @@ class ListModel
225 'url' => Helpers::url('', null, $brandLogo['data']['brand_domain']), 227 'url' => Helpers::url('', null, $brandLogo['data']['brand_domain']),
226 'thumb' => Helpers::getImageUrl($brandLogo['data']['brand_ico'], 75, 40), 228 'thumb' => Helpers::getImageUrl($brandLogo['data']['brand_ico'], 75, 40),
227 'name' => $brandLogo['data']['brand_name'], 229 'name' => $brandLogo['data']['brand_name'],
  230 +// 'shopId' => $brandLogo['data']['shop_id'],//店铺id
  231 +// 'type' => $brandLogo['data']['type'],//TODO 无店铺:0--->品牌页 无单品店有多品店:1--->搜索页 有单品店:2--->店铺页面
228 ); 232 );
229 $title = $result['name']; 233 $title = $result['name'];
230 } 234 }
@@ -414,19 +418,37 @@ class ListModel @@ -414,19 +418,37 @@ class ListModel
414 418
415 } 419 }
416 //店铺信息 420 //店铺信息
417 - $data['shopInfo'] = ListData::getShopInfo($shopId); 421 + $data['shopInfo'] = ListData::getShopInfo($shopId, $uid);
418 //店铺分类 422 //店铺分类
419 $data['shopCategory'] = ListData::getShopCategory($shopId); 423 $data['shopCategory'] = ListData::getShopCategory($shopId);
420 //店铺装修资源数据 424 //店铺装修资源数据
421 $data['decorator'] = ListData::getShopDecorator($shopId); 425 $data['decorator'] = ListData::getShopDecorator($shopId);
422 -// print_r($data); exit;  
423 - //品牌一览  
424 - //$data['shopBrands'] = ListData::getShopBrands($shopId);  
425 - //商品列表  
426 - $data['products'] = array(); 426 +// print_r($data);
427 //组织楼层数据 427 //组织楼层数据
428 - $result = ShopProcess::formShopData($data); 428 + $result = ShopProcess::formShopData($data, $shopId);
429 return $result; 429 return $result;
430 } 430 }
431 431
  432 + /**
  433 + * 根据brandId 获取相关店铺列表
  434 + * @param int $brandId
  435 + * @author sefon 2016-4-28 13:38:23
  436 + * @return array
  437 + */
  438 + public static function brandShop($brandId)
  439 + {
  440 + $brandShop = ListData::getShopByBrandId($brandId);
  441 +// print_r($brandShop); exit;
  442 + }
  443 +
  444 + /**
  445 + * 根据brand domain查询店铺信息
  446 + * @param string $domain
  447 + * @author sefon 2016-4-28 23:39:04
  448 + * @return array
  449 + */
  450 + public static function getShopInfo($domain)
  451 + {
  452 + return ShopData::getShopInfoByBrandDomain($domain);
  453 + }
432 } 454 }
@@ -131,17 +131,23 @@ class IndexController extends AbstractAction @@ -131,17 +131,23 @@ class IndexController extends AbstractAction
131 if (empty($domain)) { 131 if (empty($domain)) {
132 $this->go(SITE_MAIN); 132 $this->go(SITE_MAIN);
133 } 133 }
134 - 134 + // 当前的登录用户UID
  135 + $uid = $this->getUid();
135 // 存标题信息 136 // 存标题信息
136 $title = ''; 137 $title = '';
  138 + //TODO 通过品牌域名获取店铺shopId 先固定shopId = 672
137 $brandLogo = Product\ListModel::getBrandLogoByDomain($domain, $title); 139 $brandLogo = Product\ListModel::getBrandLogoByDomain($domain, $title);
  140 + $brandLogo['shopId'] = 672;
  141 + if (isset($brandLogo['shopId']) && !empty($brandLogo['shopId'])) {
  142 + $this->shop($brandLogo['shopId'], $uid);
  143 + exit;
  144 + }
138 $brandId = 0; 145 $brandId = 0;
139 if ($brandLogo && isset($brandLogo['id'])) { 146 if ($brandLogo && isset($brandLogo['id'])) {
140 $brandId = $brandLogo['id']; 147 $brandId = $brandLogo['id'];
141 } 148 }
142 149
143 - // 当前的登录用户UID  
144 - $uid = $this->getUid(); 150 +
145 151
146 /* 搜索框相关 */ 152 /* 搜索框相关 */
147 $from = $this->get('from'); 153 $from = $this->get('from');
@@ -446,17 +452,13 @@ class IndexController extends AbstractAction @@ -446,17 +452,13 @@ class IndexController extends AbstractAction
446 452
447 /** 453 /**
448 * 店铺首页 454 * 店铺首页
  455 + * @param int $shopId
449 * @author sefon 2016-4-26 20:50:58 456 * @author sefon 2016-4-26 20:50:58
450 */ 457 */
451 - public function shopAction() 458 + private function shop($shopId)
452 { 459 {
453 - $title = '';  
454 - $domain = 'vans';  
455 - //TODO  
456 - $brandLogo = Product\ListModel::getBrandLogoByDomain($domain, $title);  
457 - $shopId = 0;  
458 - $shopId = 672;  
459 $uid = $this->getUid(true); 460 $uid = $this->getUid(true);
  461 + $title = '';
460 $data = ListModel::shopData($shopId, $uid); 462 $data = ListModel::shopData($shopId, $uid);
461 $this->setTitle($title); 463 $this->setTitle($title);
462 $this->setNavHeader($title, true, SITE_MAIN); 464 $this->setNavHeader($title, true, SITE_MAIN);
@@ -477,21 +479,45 @@ class IndexController extends AbstractAction @@ -477,21 +479,45 @@ class IndexController extends AbstractAction
477 } 479 }
478 480
479 /** 481 /**
480 - * 店铺上新 482 + * 店铺收藏
  483 + * @author sefon 2016-4-28 23:00:11
481 */ 484 */
482 - public function shopNewPro() 485 + public function shopFav()
483 { 486 {
484 - 487 + $data = array();
  488 + $shopId = $this->get('shopId', 0);
  489 + $uid = $this->getUid();
  490 + do {
  491 + if (!IS_AJAX) {
  492 + break;
  493 + }
  494 + if (!empty($shopId) && !empty($uid)) {
  495 + $data = ShopData::shopFav($uid, $shopId);
  496 + }
  497 + } while(false);
  498 + $this->echoJson($data);
485 } 499 }
486 500
487 /** 501 /**
488 - * 店铺人气 502 + * 取消店铺收藏
  503 + * @author sefon 2016-4-28 23:01:43
489 */ 504 */
490 - public function shopTops() 505 + public function cancelShopFav()
491 { 506 {
492 - 507 + $data = array();
  508 + $shopId = $this->get('shopId', 0);
  509 + $uid = $this->getUid();
  510 + do {
  511 + if (!IS_AJAX) {
  512 + break;
  513 + }
  514 + if (!empty($shopId) && !empty($uid)) {
  515 + $data = ShopData::cancelShopFav($uid, $shopId);
  516 + }
  517 + } while(false);
  518 + $this->echoJson($data);
493 } 519 }
494 - /** 520 + /**
495 * 店铺品牌首页 521 * 店铺品牌首页
496 * 522 *
497 * @return mixed 523 * @return mixed