Authored by 郭成尧

'數據封裝頁面開發完畢'

... ... @@ -12,6 +12,7 @@ use Product\ShopModel;
class IndexController extends WebAction
{
private $_information = array('code' => 400, 'message' => '操作失败,请稍后再试!');
/**
* 品牌首页
*/
... ... @@ -19,7 +20,7 @@ class IndexController extends WebAction
{
//品牌域名,没有获取到品牌域名的跳转首页
$domain = $this->param('named');
$domain = 's';
// $domain = 's'; // tar note 待处理 开发完毕后删除
if (empty($domain)) {
$this->go(SITE_MAIN);
}
... ... @@ -28,10 +29,10 @@ class IndexController extends WebAction
if (!$result) {
$this->go(SITE_MAIN);
}
//获取uid
$uid = $this->getUid();
// 1 该品牌在多个店铺存在,2 该品牌只有一个店铺
$type = intval(isset($result['type']) ? $result['type'] : '');
switch ($type) {
... ... @@ -65,12 +66,16 @@ class IndexController extends WebAction
exit(0);
}
break;
default:
break;
}
// 判断是否是基础模板
$isBasicTpl = !empty($result['shopTemplateType']) && $result['shopTemplateType'] === 1 && !empty($result['shopId']);
//基础模板
if (!empty($result['shopTemplateType']) && $result['shopTemplateType'] === 1 && !empty($result['shopId'])) {
if ($isBasicTpl) {
$basisData = ShopModel::basisTemplate($result['shopId']);
$result['brandBanner'] = empty($basisData['shopTopBanner_base']['banner']) ?
$result['shopBanner'] = empty($basisData['shopTopBanner_base']['banner']) ?
$result['brandBanner'] : $basisData['shopTopBanner_base']['banner'] . '?';
$result['signboard'] = $basisData['signboard'];
if (isset($result['node'])) {
... ... @@ -112,24 +117,43 @@ class IndexController extends WebAction
//调用模型获得品牌页数据
$data = BrandsModel::getBrandSearchData($condition, $options);
/* 为使用基础模板的店铺添加 banner */
if ($isBasicTpl) {
if (isset($result['shopBanner']) && !empty($result['shopBanner'])) {
$shopIntro = ShopModel::getIntro($this->get('shopId'), $this->getUid());
$data['shopBanner'] = array(
'banner' => $result['shopBanner'],
'shopHome' => Helpers::url('', array('shopId' => $result['shopId']), $domain),
'shopIntro' => Helpers::url('/aboutShop', array('shopId' => $result['shopId'])),
'coled' => $shopIntro['isFavorite'],
'shopId' => $result['shopId']
);
$data['brandBanner'] = array(); // 刪除品牌banner
}
}
$data['signboard'] = isset($result['signboard']) ? $result['signboard'] : '';//水牌
//统计前三个商品
$skn=array();
$arr=array();
$skn = array();
$arr = array();
if (isset($data['goods']) && !empty($data['goods'])) {
$arr = array_slice($data['goods'],0,3);
foreach ($arr as $key=>$value) {
$arr = array_slice($data['goods'], 0, 3);
foreach ($arr as $key => $value) {
$skn[] = $value['skn'];
}
$arr = array('skn'=>$skn);
}else{
$arr = array('skn'=>array());
$arr = array('skn' => $skn);
} else {
$arr = array('skn' => array());
}
/* if (!empty($result['multBrandShopType']) && !empty($result['shopId']) && $result['multBrandShopType'] === 2) {
//多品牌无banner
$data['brandBanner'] = array();
}*/
/* if (!empty($result['multBrandShopType']) && !empty($result['shopId']) && $result['multBrandShopType'] === 2) {
//多品牌无banner
$data['brandBanner'] = array();
}*/
$seo = $data['seo'];
$data = array(
... ... @@ -175,7 +199,7 @@ class IndexController extends WebAction
$brandId = $this->post('brandId');
//$status = $this->post('status');
if (!isset($brandId)) {
return array('code'=>201,'brandId is null');
return array('code' => 201, 'brandId is null');
}
$result = BrandsModel::getAdNav($brandId);
... ... @@ -190,6 +214,7 @@ class IndexController extends WebAction
{
//品牌域名
$domain = $this->param('named');
// $domain = 'al203'; // tar note 待删除
if (empty($domain)) {
$this->go(SITE_MAIN);
}
... ... @@ -227,6 +252,48 @@ class IndexController extends WebAction
}
/**
* 店铺介绍
*/
public function aboutShopAction()
{
$shopId = $this->get('shopId');
$domain = $this->param('named');
// $domain = 's'; // tar note 待删除
$shopIntro = ShopModel::getIntro($this->get('shopId'), $this->getUid());
$data = array(
//初始化js
'searchListPage' => true,
);
if (!empty($shopId)) {
$basisData = ShopModel::basisTemplate($shopId);
if (!empty($basisData)) {
$data['list'] = array(
'shopBanner' => array(
'banner' => $basisData['shopTopBanner_base']['banner'], // 2600x150
'shopHome' => Helpers::url('/', array('shopId' => $shopId), $domain),
'shopIntro' => Helpers::url('/aboutShop', array('shopId' => $shopId)),
'coled' => $shopIntro['isFavorite'],
'shopId' => $shopId
),
'shopAbout' => empty($shopIntro['brandCont']) ? $shopIntro['brandName']: $shopIntro['brandCont']
);
} else {
return array('code' => 201, 'no data get from api or data error');
}
} else {
return array('code' => 201, 'no shop id');
}
$this->setWebNavHeader();
$this->setTitle($shopIntro['brandName'] . $shopIntro['domain'], true, '|');
$this->_view->display('list', $data);
}
/**
* 收藏品牌ajax请求
*/
public function favoriteBrandAction()
... ... @@ -254,13 +321,50 @@ class IndexController extends WebAction
$result = FavoriteData::changeFavoriteBrand($uid, $brandId);
break;
}
}
while (false);
} while (false);
//返回json格式
$this->echoJson($result);
}
/**
* 收藏店鋪,基礎模板
*/
public function favoriteShopAction()
{
if (!$this->isAjax()) {
return;
}
$result = array(
'code' => 400,
'message' => '操作失败'
);
$uid = $this->getUid();
$shopId = $this->post('shopId');
$isFavorite = $this->post('isFavorite');
$needColloect = $this->post('needColloect', 0);
do {
// if (!$uid) {
// $result = array(
// 'code' => 403,
// 'message' => '用户ID不存在',
// 'data' => array('url' => Helpers::url('/signin.html', array())),
// );
// break;
// }
if (!$uid && $shopId) {
//调用接口收藏或取消收藏
$result = ShopModel::setFavorite($shopId, $isFavorite, $uid);
break;
}
} while (false);
//返回json格式
$this->echoJson($result);
}
/**
* 判断品牌是否收藏
*/
... ... @@ -274,7 +378,7 @@ class IndexController extends WebAction
if ($uid && $brandId) {
//调用接口收藏或取消收藏
$result = FavoriteData::isFavoriteBrand($uid, $brandId);
$this ->echoJson($result);
$this->echoJson($result);
}
}
... ... @@ -347,9 +451,9 @@ class IndexController extends WebAction
'shop' => $shopId
),
array(
'controller' => 'Index',
'action' => 'index',
'misort' => $misort
'controller' => 'Index',
'action' => 'index',
'misort' => $misort
)
);
$data['shopIndexPage'] = true;
... ... @@ -388,7 +492,7 @@ class IndexController extends WebAction
$this->_view->display('shop-index', $data);
}
//店铺列表页
public function shopListAction()
{
... ... @@ -431,7 +535,7 @@ class IndexController extends WebAction
}
/**
* 店铺收藏与取消
* 店铺收藏与取消,經典模板
* @return type json
*/
public function setFavoriteAction()
... ... @@ -444,7 +548,7 @@ class IndexController extends WebAction
//获取uid
$uid = $this->getUid();
do{
do {
if (empty($uid)) {
$result = array(
'code' => 401,
... ...