Plusstar.php
3.74 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
<?php
use Action\AbstractAction;
use LibModels\Wap\Guang\PlusstarData;
use Plugin\Helpers;
/**
* 明星品牌和原创品牌
*/
class PlusstarController extends AbstractAction
{
/**
* 国际精选-品牌列表页
*
* @param int gender "1,3"表示男, "2,3"表示女
*/
public function indexAction()
{
$this->setTitle('国际优选');
$this->setNavHeader('国际优选', true, SITE_MAIN);
$gender = $this->get('gender', '1,3');
$data = Guang\PlusstarModel::getFirstBrands($gender);
$data['psList'] = true; // 控制模板中的JS使用
$this->_view->display('index', $data);
}
/**
* 明星原创-品牌列表页
*
* @param int gender "1,3"表示男, "2,3"表示女
*/
public function listAction()
{
$this->setTitle('明星原创');
$this->setNavHeader('明星原创', true, SITE_MAIN);
$gender = $this->get('gender', '1,3');
$data = Guang\PlusstarModel::getBrands($gender);
$data['psList'] = true; // 控制模板中的JS使用
$this->_view->display('list', $data);
}
/**
* 品牌介绍页
*/
public function detailAction()
{
$data = array();
$id = $this->get('id');
$gender = $this->get('gender', '1,3');
$uid = $this->getUid();
$udid = $this->getUdid();
do {
/* 判断参数是否有效 */
if (!is_numeric($id) || ($gender !== '1,3' && $gender !== '2,3')) {
break;
}
/* 判断品牌信息是否为空 */
$brandInfo = PlusstarData::brandInfo($id, $gender, $uid, $udid);
if (empty($brandInfo['getBrandInfo']['data']['brand_id'])) {
break;
}
$data['psDetail'] = true;
$data['ps']['id'] = $brandInfo['getBrandInfo']['data']['brand_id'];
$data['ps']['banner'] = Helpers::getImageUrl($brandInfo['getBrandInfo']['data']['cover_img'], 640, 309);
$data['ps']['logo'] = Helpers::getImageUrl($brandInfo['getBrandInfo']['data']['brand_ico'], 160, 160);
$data['ps']['name'] = $brandInfo['getBrandInfo']['data']['brand_name'];
$data['ps']['isLike'] = $brandInfo['getUidBrandFav'];
$data['ps']['likeUrl'] = false; //"http://guang.m.yohobuy.com/plustar/brandinfo?id=285&openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"http:\/\/guang.m.yohobuy.com\/plustar\/brandinfo","param":{"id":285}},"requesturl":{"url":"\/guang\/api\/v1\/favorite\/togglebrand","param":{"brand_id":"701"}},"priority":"Y"}}";
$data['ps']['intro'] = empty($brandInfo['getBrandInfo']['data']['brand_intro']) ? '' : strtr(strip_tags($brandInfo['getBrandInfo']['data']['brand_intro']), array(' ' => ' '));
$data['ps']['newArrival'] = array();
$data['ps']['newArrival']['moreUrl'] = '/product/list/brand?brand='.$id; // @todo 品牌列表页面
$data['ps']['newArrival']['naList'] = $brandInfo['getNewProduct'];
$data['ps']['infos'] = array();
if (empty($brandInfo['getArticleByBrand'])) {
break;
}
// 相关文章
foreach ($brandInfo['getArticleByBrand'] as $value) {
$data['ps']['infos'][] = Helpers::formatArticle($value, false, false, false);
}
$brandInfo = array();
} while (false);
if (array() === $data) {
$this->error();
} else {
$this->_view->display('detail', $data);
}
}
}