Index.php
7.54 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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
<?php
use Action\WebAction;
use LibModels\Web\Product\BrandData;
use LibModels\Web\Product\FavoriteData;
use \LibModels\Web\Product\HotrankData;
use product\HotrankModel;
use LibModels\Web\Home\IndexData;
class IndexController extends WebAction
{
/**
* 品牌首页
*/
public function brandAction()
{
//品牌域名
$domain = $this->param('named');
if (empty($domain)) {
$this->go(SITE_MAIN);
}
$uid = $this->getUid();
//根据品牌域名获取品牌id(同时判断品牌域名是否有效)
$fields = 'id,brand_name,brand_name_cn,brand_name_en,brand_domain,brand_alif,brand_banner,brand_ico,static_content_code';
$brandInfo = BrandData::getBrandLogoByDomain($domain, $fields);
if (!empty($brandInfo['data']) && $brandInfo['code'] == 200) {
$brandId = $brandInfo['data']['id'];
$node = isset($brandInfo['data']['static_content_code']) ? $brandInfo['data']['static_content_code'] : false;
$brandBanner = $brandInfo['data']['brand_banner'];
} else {
$this->go(SITE_MAIN);
}
//品牌ID参数
$condition = array();
$condition['brand'] = $brandId;
//品牌系列参数
$folderId = $this->get('folder_id');
$condition['folder_id'] = $folderId;
//$options参数数组
$options = array();
$options['brandName'] = $domain;
$options['uid'] = $uid;
$options['brandId'] = $brandId;
$options['node'] = $node;
$options['brandBanner'] = $brandBanner;
$options['reviewNum'] = 6;
//调用模型获得数据
$data = Product\BrandsModel::getBrandSearchData($condition, $options);
$data = array(
//初始化js
'searchListPage' => true,
'list' => $data
);
$this->setWebNavHeader();
//渲染模板
$this->_view->display('list',$data);
}
//品牌介绍页
public function brandIntroAction()
{
//品牌域名
$domain = $this->param('named');
if (empty($domain)) {
$this->go(SITE_MAIN);
}
$uid = $this->getUid();
//根据品牌域名获取品牌id(同时判断品牌域名是否有效)
$fields = 'id,brand_name,brand_name_cn,brand_banner,brand_ico,brand_intro';
$brandInfo = BrandData::getBrandLogoByDomain($domain, $fields);
if (!empty($brandInfo['data']) && $brandInfo['code'] == 200) {
$brandId = $brandInfo['data']['id'];
$brandBanner = $brandInfo['data']['brand_banner'];
$brandAbout = $brandInfo['data']['brand_intro'];
} else {
$this->go(SITE_MAIN);
}
//品牌ID参数
$condition = array();
$condition['brand'] = $brandId;
//$options参数数组
$options = array();
$options['brandName'] = $domain;
$options['uid'] = $uid;
$options['brandId'] = $brandId;
$options['brandBanner'] = $brandBanner;
$options['brandAbout'] = $brandAbout;
//调用模型获得数据
$data = Product\BrandsModel::getBrandIntro($condition, $options);
$data = array(
//初始化js
'searchListPage' => true,
'list' => $data
);
$this->setWebNavHeader();
//渲染模板
$this->_view->display('list',$data);
}
//收藏品牌
public function favoriteBrandAction($uid = '', $brandId = '')
{
if (!$this->isAjax()) {
return;
}
if ($uid && $brandId) {
//调用接口收藏或取消收藏
$result = FavoriteData::changeFavoriteBrand($uid, $brandId);
if (isset($result['code']) && $result['code'] == 200) {
$this ->echoJson($result['message']);
}
}
}
/**
* 热销排行
*/
public function hotrankAction()
{
//获取频道
$channel = \product\HotrankModel::getChannelResource();
$this->setWebNavHeader($channel['channel']);
$data = array( 'hotrankPage' => true,
'footerTop'=> true,
'hotrank' => array()
);
//焦点图 热门品牌
$focus = \Index\HomeModel::getChannelResource($channel['channel'], $channel['code']);
$data['hotrank']['slide'] = $focus[0]['slide'];
$data['hotrank']['hotBrands'] = $focus[1]['hotBrands'];
//人气单品 一周热卖
$page = $this->get('page',1);
$sort_id = $this->get('sid',0);
$viewNum = 60;
$param = array('order'=>'s_n_desc','viewNum'=>$viewNum,'page'=>$page,'stocknumber'=>1,'status'=>1,'gender'=>$channel['gender'],'attribute_not'=>2);
if($sort_id != 0)
{
$param['sort'] = $sort_id;
}
if($channel['road'] == 3)
{
$param['msort'] = 365;
}elseif($channel['road'] == 4){
$param['msort'] = 10;
}else{
$param['not_maxSortId'] = '10,365';
}
$publiclist = \product\HotrankModel::getSearchData($param,$page,0);
$data['hotrank']['popular'] = $publiclist['popular'];
$data['hotrank']['hotWeek'] = $publiclist['hotWeek'];
//分类标签
$nav = \product\HotrankModel::getHotranktag('web',$channel['road'],true);
$data['hotrank']['hotWeek']['nav'] = $nav;
$this->_view->display('hotrank', $data);
}
/*
* 一周热卖加载更多
*/
public function getdataAction()
{
$page = $this->get('page',1);
//加载到100个以后停止
if($page > 2)
{
echo json_encode(array('code'=>201,'data'=>''));
exit;
}
$sid = $this->get('sid',1);
$sort = '';
//是否是默认标签
if($sid > 1)
{
//通过ID获取标签信息
$info = \LibModels\Web\Product\HotrankData::getTagById($sid, false);
if(!empty($info['data']))
{
$sort = $info['data']['category_id'];
}
}
$viewNum = 60;
//获取频道资源
$channel = \product\HotrankModel::getChannelResource();
$param = array('order'=>'s_n_desc','viewNum'=>$viewNum,'page'=>$page,'sort'=>$sort,'stocknumber'=>1,'status'=>1,
'gender'=>$channel['gender'],'attribute_not'=>2,);
if(empty($param['sort']))
{
if($channel['road'] == 3)
{
$param['msort'] = 365;
}elseif($channel['road'] == 4){
$param['msort'] = 10;
}else{
$param['not_maxSortId'] = '10,365';
}
}
//一周热卖
$list = \product\HotrankModel::getSearchData($param, $page, 1);
$lister = $list['hotWeek']['list'];
$lister = array_values($lister);
if($sid == 1 && $page == 1)
{
$lister = array_slice($lister, 10, 50);
}else{
$lister = array_slice($lister, 0, 50);
}
$data = array( 'code'=>200, 'data'=>$lister,);
echo json_encode($data);
exit;
}
}