Brands.php
8.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<?php
use Action\WebAction;
use WebPlugin\Helpers;
use WebPlugin\Paging;
use Index\BrandsModel;
use Index\HomeModel;
use Guang\PlusstarModel;
/**
* 品牌相关的控制器
*/
class BrandsController extends WebAction
{
/**
* 品牌一览
*/
public function indexAction()
{
$channel = Helpers::getChannelNameByCookie();
//品牌一览头部
$this->setWebNavHeader($channel);
// 品牌一览列表
$brandTop = BrandsModel::getBrandViewTop($channel);
$brandList = BrandsModel::getBrandViewList($channel, 1, 5); //分屏加载 取第一屏数据 前5个数据
$navigation = $brandList['navigation']; //导航
unset($brandList['navigation']);
// 添加网站的SEO
switch ($channel) {
default:
case 'boys':
$this->setTitle('品牌一览|男装品牌排行榜,男装品牌大全|YOHO!BUY 有货 100%正品保证');
$this->setKeywords('品牌一览,男装品牌,男装品牌排行榜,男装品牌大全,YOHO!BUY 有货');
$this->setDescription('YOHO!BUY 有货男装品牌一览汇集国内国际各大男装品牌大全,为广大爱好时尚的男士青年提供品牌男装、休闲男装、商务男装.YOHO!BUY 有货,100%正品保证');
break;
case 'girls':
$this->setTitle('品牌一览|女装品牌排行榜,女装品牌大全|YOHO!BUY 有货 100%正品保证');
$this->setKeywords('品牌一览,女装品牌,女装品牌排行榜,女装品牌大全,YOHO!BUY 有货');
$this->setDescription('YOHO!BUY 有货女装品牌一览汇集国内国际各大女装品牌,为广大爱美女生提供品牌女装、休闲女装、商务女装.买品牌女装就上YOHO!BUY 有货,100%正品保证');
break;
case 'kids':
$this->setTitle('品牌一览|童装童鞋品牌,儿童鞋包配饰排行榜,潮童品牌大全|YOHO!BUY 有货 100%正品保证');
$this->setKeywords('童装品牌,童装童鞋排行榜,儿童鞋包配饰排行榜,潮童品牌大全,品牌一览,YOHO!BUY 有货');
$this->setDescription('YOHO!BUY 有货童装品牌一览汇集国内国际各大童装品牌大全,为广大爱好潮流的儿童提供品牌童装、童鞋,儿童鞋包配饰.YOHO!BUY 有货,100%正品保证');
break;
case 'lifestyle':
$this->setTitle('品牌一览|数码3c,居家,玩具娱乐,文具,美妆品牌|YOHO!BUY 有货 100%正品保证');
$this->setKeywords('数码3c品牌,居家品牌,玩具娱乐品牌,文具品牌,美妆品牌');
$this->setDescription('YOHO!BUY 有货女装品牌一览汇集国内国际各大数码3c品牌,居家品牌,玩具娱乐品牌,文具品牌,美妆品牌.买创意生活家居就上YOHO!BUY 有货,100%正品保证');
break;
}
// 数据整合
$data = array();
$data['brandsHomePage'] = true;
$data['brands'] = $brandTop;
$data['brands']['navigation'] = $navigation;
$data['brands']['category'] = $brandList;
$data['brands']['pathNav'] = array(
HomeModel::getHomeChannelNav($channel),
array('name' => '品牌一览')
);
$this->_view->display('brands', $data);
}
/**
* brandList-Ajax调用
*/
public function brandListAction()
{
$data['category'] = array();
do {
/* 判断是不是AJAX请求 */
if (!$this->isAjax()) {
break;
}
$start = intval($this->post('start'));
$channel = Helpers::getChannelNameByCookie();
$brandList = BrandsModel::getBrandViewList($channel, $start);
unset($brandList['navigation']);
$data['category'] = $brandList;
}
while (false);
$this->_view->display('brand-list', $data);
}
/**
* 品牌接口数据
*
* @param string brandId 获取品牌ID
* @return json
*/
public function brandinfoAction()
{
do {
/* 判断是不是AJAX请求 */
if (!$this->isAjax()) {
break;
}
$brandId = $this->get('brandId', 0);
$uid = $this->getUid(false);
$data = BrandsModel::getBrandInfo($brandId, $uid);
$brand = empty($data) ? array() : $data;
$code = empty($data) ? 400 : 200;
$result = array(
'code' => $code,
'brand' => $brand
);
}
while (false);
$this->echoJson($result);
}
/**
* 品牌plusstar列表
*/
public function plusstarAction()
{
$this->setWebNavHeader();
$id = $this->get('id', 1);
$gender = $this->get('gender', Helpers::getGenderByCookie());
$channel = Helpers::getChannelNameByCookie();
$brandType = 1;
$offset = 0;
$limit = 20;
$items = BrandsModel::getPlusstarBrandListItem($channel);
// 添加网站的SEO
switch ($channel) {
default:
case 'boys':
$this->setTitle('品牌一览|男装品牌排行榜,男装品牌大全|YOHO!BUY 有货 100%正品保证');
$this->setKeywords('品牌一览,男装品牌,男装品牌排行榜,男装品牌大全,YOHO!BUY 有货');
break;
case 'girls':
$this->setTitle('品牌一览|女装品牌排行榜,女装品牌大全|YOHO!BUY 有货 100%正品保证');
$this->setKeywords('品牌一览,女装品牌,女装品牌排行榜,女装品牌大全,YOHO!BUY 有货');
break;
case 'kids':
$this->setTitle('品牌一览|童装童鞋品牌,儿童鞋包配饰排行榜,潮童品牌大全|YOHO!BUY 有货 100%正品保证');
$this->setKeywords('童装品牌,童装童鞋排行榜,儿童鞋包配饰排行榜,潮童品牌大全,品牌一览,YOHO!BUY 有货');
break;
case 'lifestyle':
$this->setTitle('品牌一览|数码3c,居家,玩具娱乐,文具,美妆品牌|YOHO!BUY 有货 100%正品保证');
$this->setKeywords('数码3c品牌,居家品牌,玩具娱乐品牌,文具品牌,美妆品牌');
break;
}
if (isset($items[$id])) {
$brandType = $items[$id]['brandType'];
}
$brandIds = array();
$brands = array();
$list = PlusstarModel::getPlustarList($brandType, $gender);
$paging = new Paging('yoho');
if (!empty($list)) {
$paging->setTotal(count($list))->setSize($limit)->setQuery(array('id' => $id));
$offset = $paging->getOffset();
$brandIds = array_slice(array_keys($list), $offset, $limit);
}
if (!empty($brandIds)) {
//获取品牌信息
$brandsInfo = BrandsModel::getBrandInfoByIds($brandIds);
foreach ($brandIds as $brandId) {
if (isset($brandsInfo[$brandId])) {
$list[$brandId]['desc'] = $brandsInfo[$brandId]['desc'];
$list[$brandId]['url'] = $brandsInfo[$brandId]['url'] . '?gender=' . $gender;
}
$brands[] = $list[$brandId];
}
}
$brandList = array('items' => $brands, 'tabs' => $items, 'page' => $paging->view(false), 'home' => HomeModel::getHomeChannelNav());
$data = array(
'brandsHomePage' => true,
'brands' => $brandList
);
$this->_view->display('plusstar', $data);
}
/**
* plusstar首页
*/
public function plusstarindexAction()
{
$this->setWebNavHeader();
$gender = $this->get('gender', Helpers::getGenderByCookie());
$channel = Helpers::getChannelNameByCookie();
$articles = PlusstarModel::getArticleBySortId(0, $gender, 1, 11);
if(empty($articles)) {
$articles = array();
}
$brands = BrandsModel::getPlusstarIndexInfo($channel, $articles);
$data = array(
'brandsHomePage' => true,
'brands' => $brands
);
$this->_view->display('plusstarindex', $data);
}
}