Plusstar.php
5.08 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
<?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 listAction()
{
$data = array('ps' => array('star' => array(), 'plus' => array()));
$brandList = array();
$build = array();
$imgs = array();
$gender = $this->get('gender', '1,3');
// 女
if ($gender === '2,3') {
$brandList = PlusstarData::brandList('2,3', 2);
}
// 男
else {
$brandList = PlusstarData::brandList('1,3', 1);
}
// 明星品牌列表
if (!empty($brandList['star']['data']['list'][0]['data'])) {
foreach ($brandList['star']['data']['list'][0]['data'] as $star) {
$imgs = array();
$build = array();
// 情况1: 多张图
if (isset($star['data'][1])) {
foreach ($star['data'] as $value) {
$build['url'] = $value['url'];
$build['img'] = Helpers::getImageUrl($value['src'], 640, 310);
$imgs[] = $build;
}
$data['ps']['star'][] = array('imgs' => $imgs);
}
// 情况2: 单张图
elseif (isset($star['data'][0])) {
$build['url'] = $star['data'][0]['url'];
$build['img'] = $star['data'][0]['src'];
$data['ps']['star'][] = $build;
}
}
}
// 原创品牌列表
if (!empty($brandList['original']['data']['list'][0]['data'])) {
foreach ($brandList['original']['data']['list'][0]['data'] as $original) {
$imgs = array();
$build = array();
// 情况1: 多张图
if (isset($original['data'][1])) {
foreach ($original['data'] as $value) {
$build['url'] = $value['url'];
$build['img'] = Helpers::getImageUrl($value['src'], 640, 310);
$build['deps'] = $original['brand_title'];
$imgs[] = $build;
}
$data['ps']['plus'][] = array('imgs' => $imgs);
}
// 情况2: 单张图
elseif (isset($original['data'][0])) {
$build['url'] = $original['data'][0]['url'];
$build['img'] = Helpers::getImageUrl($original['data'][0]['src'], 640, 310);
$build['deps'] = $original['brand_title'];
$data['ps']['plus'][] = $build;
}
}
}
$this->_view->display('list', $data);
$brandList = array();
$data = array();
}
/**
* 品牌介绍页
*/
public function detailAction()
{
$data = array();
$id = $this->get('id');
$gender = $this->get('gender', '1,3');
$uid = 0; // @todo
$udid = null; // @todo
do {
/* 判断参数是否有效 */
if (!is_numeric($id) || ($gender !== '1,3' && $gender !== '2,3')) {
break;
}
/* 判断品牌信息是否为空 */
$brandInfo = PlusstarData::brandInfo($id, $gender, $uid, $udid); var_dump($brandInfo); exit;
if (empty($brandInfo['getBrandInfo']['brand_id'])) {
break;
}
$data['id'] = $brandInfo['getBrandInfo']['brand_id'];
$data['banner'] = Helpers::getImageUrl($brandInfo['getBrandInfo']['cover_img'], 640, 309);
$data['logo'] = Helpers::getImageUrl($brandInfo['getBrandInfo']['brand_ico'], 160, 160);
$data['name'] = $brandInfo['getBrandInfo']['name'];
$data['isLike'] = $brandInfo['getUidBrandFav'];
$data['likeUrl'] = "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['intro'] = empty($brandInfo['brand_intro']) ? '' : strip_tags($brandInfo['brand_intro']);
$data['newArrival'] = array();
$data['newArrival']['moreUrl'] = ''; // @todo
$data['newArrival']['naList'] = $brandInfo['getNewProduct'];
$data['infos'] = array();
$brandInfo = array();
} while (false);
if (array() === $data) {
$this->error();
} else {
$this->_view->display('detail', $data);
}
}
}