Authored by zhangxiaoru

首页

... ... @@ -221,6 +221,7 @@ class BrandData
* 通过域名获取品牌LOGO信息
*
* @param int $id 用户ID
* @modify sefon 2016-4-29 01:59:23
* @return array
*/
public static function getBrandLogoByDomain($domain)
... ... @@ -228,4 +229,19 @@ class BrandData
return Yohobuy::yarClient(Yohobuy::SERVICE_URL . '/shops/service/v1/brand', 'getBrandByDomain', array($domain));
}
/**
* 根据品牌域名获取品牌店铺信息
* @param string $domain
* @author sefon 2016-4-28 23:35:28
* @return mixed
*/
public static function getShopInfoByBrandDomain($domain)
{
$param = Yohobuy::param();
$param['method'] = 'web.brand.byDomain';
$param['domain'] = $domain;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get('http://192.168.102.218:8080/gateway/', $param);
}
}
... ...
... ... @@ -77,15 +77,17 @@ class ListData
/**
* 获取店铺信息
* @param int $shopId 店铺id
* @param int $uid 用户id 判断用户是否收藏店铺
* @param int $cache 接口缓存
* @author sefon 2016-4-26 21:32:57
* @return array
*/
public static function getShopInfo($shopId, $cache = 600)
public static function getShopInfo($shopId, $uid = 0, $cache = 600)
{
$param = Yohobuy::param();
$param['method'] = 'app.shops.getIntro';
$param['shop_id'] = $shopId;
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
//TODO
// return Yohobuy::get(Yohobuy::API_URL, $param);
... ... @@ -128,5 +130,21 @@ class ListData
return Yohobuy::get('http://192.168.102.218:8080/gateway/', $param, $cache);
}
/**
* 根据brandid获取相关店铺
* @param int $brandId
* @author sefon 2016-4-28 13:41:09
* @return array
*/
public static function getShopByBrandId($brandId, $cache = 600)
{
$param = Yohobuy::param();
$param['method'] = 'app.shop.queryShopByBrandId';
$param['brand_id'] = $brandId;
$param['client_secret'] = Sign::getSign($param);
//TODO
// return Yohobuy::get(Yohobuy::API_URL, $param);
return Yohobuy::get('http://192.168.102.218:8080/gateway/', $param, $cache);
}
}
... ...
... ... @@ -101,4 +101,51 @@ class ShopData
exit;
}
}
/**
* 收藏店铺
* @param int $uid
* @param int $shopId
* @param string $gender
* @author sefon 2016-4-28 22:09:30
* @return mixed
*/
public static function shopFav($uid, $shopId, $gender = '')
{
$param = Yohobuy::param();
$param['method'] = 'app.favorite.add';
$param['uid'] = $uid;
$param['id'] = $shopId;
$param['fav_id'] = $shopId;
$param['type'] = 'shop';
if (!empty($gender)) {
$param['gender'] = $gender;
}
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 取消收藏店铺
* @param int $uid
* @param int $shopId
* @param string $gender
* @author sefon 2016-4-28 22:09:30
* @return mixed
*/
public static function cancelShopFav($uid, $shopId, $gender = '')
{
$param = Yohobuy::param();
$param['method'] = 'app.favorite.cancel';
$param['uid'] = $uid;
$param['id'] = $shopId;
$param['fav_id'] = $shopId;
$param['type'] = 'shop';
if ($gender) {
$param['gender'] = $gender;
}
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
}
\ No newline at end of file
... ...
... ... @@ -118,7 +118,7 @@ class SearchData
// return 'http://101.200.31.165/yohosearch/brand/list.json';
// return 'http://182.92.99.119:8080/yohosearch/brand/list.json';
}
return 'http://101.200.31.165/yohosearch/search.json';
return 'http://101.200.31.165/yohosearch/search.json';//支持shop_id
//return 'http://101.200.31.165/yohosearch/search.json';
// return 'http://182.92.99.119:8080/yohosearch/search.json';
}
... ...
... ... @@ -11,30 +11,48 @@ use Plugin\Images;
class ShopProcess
{
private static $shopData = array();
private static $shopId = 0;
/**
* 组织店铺页面数据
* @param array $data 接口返回的店铺页所需数据
* @param int $type 店铺模板id
* @param int $shopId 店铺id
* @author sefon 2016-4-26 21:56:32
* @return array
*/
public static function formShopData($data, $type = 2)
public static function formShopData($data, $shopId)
{
self::$shopId = $shopId;
foreach ($data as $key => $val) {
if (empty($val) || !is_callable("self::$key")) {
continue;
}
self::$key($val);
}
// exit;
return self::$shopData;
}
/**
* 店铺基本信息
* @param $data
* @author sefon 2016-4-29 01:48:50
*/
private static function shopInfo($data)
{
self::$shopData['logoImg'] = Images::getImageUrl($data['data']['shop_logo'], 500, 500, 'shopLogo');
self::$shopData['storeName'] = $data['data']['shop_name'];
//用户是否收藏店铺
self::$shopData['favorite'] = $data['data']['is_favorite'] == 'Y' ? true : false;
//店铺简介页地址
self::$shopData['shopIntroHref'] = Helpers::url('/product/index/intro', array('shop_id' => self::$shopId));
//全部商品链接
self::$shopData['allGoods'] = Helpers::url('', array('shop_id' => self::$shopId, 'title' => '全部商品'), 'search');
}
/**
* 组织店铺装修
* @param array $data
* @author sefon 2016-4-26 22:04:04
* @return array
*/
private static function decorator($data)
{
... ... @@ -47,24 +65,12 @@ class ShopProcess
}
self::$val['resource_name'](json_decode($val['resource_data'], true));
}
// print_r($data); exit;
}
/**
* 店铺基本信息
* @param $data
*/
private static function shopInfo($data)
{
self::$shopData['logoImg'] = Images::getImageUrl($data['data']['shop_logo'], 500, 500, 'shopLogo');
self::$shopData['storeName'] = $data['data']['shop_name'];
}
/**
* 店铺Banner
* @param array $data
* @author sefon 2016-4-27 08:40:05
* @return array
*/
private static function shopTopBanner_APP($data)
{
... ... @@ -75,11 +81,9 @@ class ShopProcess
* 资源位小图 接口返回两组,取每组第一张
* @param array $data
* @author sefon 2016-4-27 08:37:30
* @return array
*/
private static function oneRowTwoColImages_APP($data)
{
// print_r($data); exit;
foreach ($data as $key => $val) {
if (empty($val['data'])) {
continue;
... ... @@ -89,7 +93,6 @@ class ShopProcess
'springType' => $val['data'][0]['src']
);
}
return $data;
}
/**
... ... @@ -100,14 +103,16 @@ class ShopProcess
*/
private static function brandBrowse($data)
{
// print_r($data); exit;
foreach ($data as $val) {
self::$shopData['multiList'][] = array(
self::$shopData['brandList']['list'][] = array(
'url' => Helpers::url('', '', $val['brandDomain']),
'img' => Images::getImageUrl($val['brandIco'], 640, 400),
'brandName' => $val['brandName']
);
}
if (count($data) > 5) {
self::$shopData['brandList']['url'] = Helpers::url('/product/index/allBrand', array('shop_id' => self::$shopId));
}
}
/**
... ... @@ -117,14 +122,11 @@ class ShopProcess
*/
private static function largeSlideImg($data)
{
// print_r($data); exit;
foreach ($data as $val) {
if (!isset($data['data']) || !empty($data['data'])) {
continue;
}
foreach ($data['data'] as $slide) {
self::$shopData['bannerTop']['list'][] = array('url' => $slide['url'], 'img' => $slide['shopSrc']);
}
if (empty($data[0]['data'])) {
return;
}
foreach ($data[0]['data'] as $slide) {
self::$shopData['bannerTop']['list'][] = array('url' => $slide['url'], 'img' => $slide['src']);
}
}
/**
... ... @@ -146,22 +148,18 @@ class ShopProcess
* 人气单品
* @param array $data
* @author sefon 2016-4-27 08:38:36
* @return array
*/
private static function hotProducts($data)
{
// print_r($data);
foreach ($data as $val) {
self::$shopData['hotList'][] = array(
'url' => $val['url'],
'url' => Helpers::getUrlBySkc($val['product_id'], $val['goods_id'], $val['cn_alphabet']),
'img' => Helpers::getImageUrl($val['src'], 235, 314),
'productName' => $val['productName'],
'salesPrice' => '¥'.$val['salesPrice'],
'presentPrice' => '¥'.$val['salesPrice']
);
}
return $data;
}
/**
... ... @@ -173,12 +171,12 @@ class ShopProcess
if (isset($data['code']) && $data['code'] == 200 && !empty($data['data'])) {
$total = count($data['data']);
if ($total > 5) {
self::$shopData['shopCategory']['url'] = 'http://m.yohobuy.com';
self::$shopData['shopCategory']['url'] = Helpers::url('/product/index/category', array('shop_id' => self::$shopId));
return;
}
foreach ($data['data'] as $key => $val) {
self::$shopData['shopCategory']['list'][] = array(
'url' => '',
'url' => Helpers::url('', array('shop_id' => self::$shopId), 'search'),
'categoryId' => $val['category_id'],
'name' => $val['category_name']
);
... ...
... ... @@ -51,7 +51,7 @@
</a>
<p>{{brandName}}</p>
</li>
{{/each}}
{{/each}}
</ul>
</div>
</div>
... ...
... ... @@ -201,6 +201,7 @@ class ListModel
*
* @param int $id 品牌ID
* @param string $title 品牌标题
* @modify sefon 2016-4-29 01:57:14 添加shopId / type
* @return array | false
*/
public static function getBrandLogoByDomain($domain, &$title)
... ... @@ -218,6 +219,7 @@ class ListModel
// 调用接口查询数据
$brandLogo = BrandData::getBrandLogoByDomain($domain);
// $brandLogo = BrandData::getShopInfoByBrandDomain($domain); // TODO 获取品牌店铺信息
// 处理返回的数据
if (isset($brandLogo['data'])) {
$result = array(
... ... @@ -225,6 +227,8 @@ class ListModel
'url' => Helpers::url('', null, $brandLogo['data']['brand_domain']),
'thumb' => Helpers::getImageUrl($brandLogo['data']['brand_ico'], 75, 40),
'name' => $brandLogo['data']['brand_name'],
// 'shopId' => $brandLogo['data']['shop_id'],//店铺id
// 'type' => $brandLogo['data']['type'],//TODO 无店铺:0--->品牌页 无单品店有多品店:1--->搜索页 有单品店:2--->店铺页面
);
$title = $result['name'];
}
... ... @@ -414,19 +418,37 @@ class ListModel
}
//店铺信息
$data['shopInfo'] = ListData::getShopInfo($shopId);
$data['shopInfo'] = ListData::getShopInfo($shopId, $uid);
//店铺分类
$data['shopCategory'] = ListData::getShopCategory($shopId);
//店铺装修资源数据
$data['decorator'] = ListData::getShopDecorator($shopId);
// print_r($data); exit;
//品牌一览
//$data['shopBrands'] = ListData::getShopBrands($shopId);
//商品列表
$data['products'] = array();
// print_r($data);
//组织楼层数据
$result = ShopProcess::formShopData($data);
$result = ShopProcess::formShopData($data, $shopId);
return $result;
}
/**
* 根据brandId 获取相关店铺列表
* @param int $brandId
* @author sefon 2016-4-28 13:38:23
* @return array
*/
public static function brandShop($brandId)
{
$brandShop = ListData::getShopByBrandId($brandId);
// print_r($brandShop); exit;
}
/**
* 根据brand domain查询店铺信息
* @param string $domain
* @author sefon 2016-4-28 23:39:04
* @return array
*/
public static function getShopInfo($domain)
{
return ShopData::getShopInfoByBrandDomain($domain);
}
}
... ...
... ... @@ -131,17 +131,23 @@ class IndexController extends AbstractAction
if (empty($domain)) {
$this->go(SITE_MAIN);
}
// 当前的登录用户UID
$uid = $this->getUid();
// 存标题信息
$title = '';
//TODO 通过品牌域名获取店铺shopId 先固定shopId = 672
$brandLogo = Product\ListModel::getBrandLogoByDomain($domain, $title);
$brandLogo['shopId'] = 672;
if (isset($brandLogo['shopId']) && !empty($brandLogo['shopId'])) {
$this->shop($brandLogo['shopId'], $uid);
exit;
}
$brandId = 0;
if ($brandLogo && isset($brandLogo['id'])) {
$brandId = $brandLogo['id'];
}
// 当前的登录用户UID
$uid = $this->getUid();
/* 搜索框相关 */
$from = $this->get('from');
... ... @@ -446,17 +452,13 @@ class IndexController extends AbstractAction
/**
* 店铺首页
* @param int $shopId
* @author sefon 2016-4-26 20:50:58
*/
public function shopAction()
private function shop($shopId)
{
$title = '';
$domain = 'vans';
//TODO
$brandLogo = Product\ListModel::getBrandLogoByDomain($domain, $title);
$shopId = 0;
$shopId = 672;
$uid = $this->getUid(true);
$title = '';
$data = ListModel::shopData($shopId, $uid);
$this->setTitle($title);
$this->setNavHeader($title, true, SITE_MAIN);
... ... @@ -477,21 +479,45 @@ class IndexController extends AbstractAction
}
/**
* 店铺上新
* 店铺收藏
* @author sefon 2016-4-28 23:00:11
*/
public function shopNewPro()
public function shopFav()
{
$data = array();
$shopId = $this->get('shopId', 0);
$uid = $this->getUid();
do {
if (!IS_AJAX) {
break;
}
if (!empty($shopId) && !empty($uid)) {
$data = ShopData::shopFav($uid, $shopId);
}
} while(false);
$this->echoJson($data);
}
/**
* 店铺人气
* 取消店铺收藏
* @author sefon 2016-4-28 23:01:43
*/
public function shopTops()
public function cancelShopFav()
{
$data = array();
$shopId = $this->get('shopId', 0);
$uid = $this->getUid();
do {
if (!IS_AJAX) {
break;
}
if (!empty($shopId) && !empty($uid)) {
$data = ShopData::cancelShopFav($uid, $shopId);
}
} while(false);
$this->echoJson($data);
}
/**
/**
* 店铺品牌首页
*
* @return mixed
... ...