StarClass.php
6.28 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
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2016-4-12
* Time: 9:53
*/
namespace Guang;
use Plugin\Helpers;
use LibModels\Wap\Guang\StarClassData;
use Api\Yohobuy;
/**
* Class TrendClassesroom
* 星潮教室
* @package Guang
*/
class StarClassModel
{
//星潮教室首页
public static function getStarClass($uid)
{
$result = array();
$result['title'] = '星潮教室';
$result['headTab'] = self::getHeadTab('index');
//组装资源位获取星潮教室首页数据URL
$contentCode = '8adc27fcf5676f356602889afcfd2a8e';
$res['starClassIndex'] = StarClassData::getResourceDataUrl($contentCode);
//组装获得每日签到数据接口URL
$res['rankInfo'] = StarClassData::rankInfoDataUrl($uid);
//print_r($res['rankInfo']);exit;
$data = Yohobuy::getMulti($res);
// print_r($data['starClassIndex']);
// print_r($data);exit;
//调用成功封装数据
if (isset($data['starClassIndex']) && !empty($data['starClassIndex'])) {
$starClassIndex = $data['starClassIndex'];
$build = array();
foreach ($starClassIndex as $value) {
if (empty($value)) {
continue;
}
$fun = $value['template_name'];
if (empty($value['data']) || !is_callable("self::$fun")) {
continue;
}
$build = self::$fun($value['data']);
if (empty($build)) {
continue;
}
$result[] = $build;
}
$build = array();
}
return $result;
}
//星专题
public static function getspecial()
{
$result = array();
$result['title'] = '星潮教室';
$result['headTab'] = self::getHeadTab('special');
//组装资源位获取星潮教室首页数据URL
$contentCode = '89cc20483ee2cbc8a716dcfe2b6c7603';
$data = StarClassData::getResourceData($contentCode);
if (isset($data['code']) && $data['code'] == 200) {
$build = array();
foreach ($data['data'] as $value) {
if (empty($value)) {
continue;
}
$fun = $value['template_name'];
if (empty($value['data']) || !is_callable("self::$fun")) {
continue;
}
$build = self::$fun($value['data']);
if (empty($build)) {
continue;
}
$result['resources'][] = $build;
}
$build = array();
}
return $result;
}
/**
* 星搭配
*/
public static function getCollocation($page)
{
$result = array();
$result['title'] = '星潮教室';
$result['headTab'] = self::getHeadTab('collocation');
$data = StarClassData::collocationData($page);
// print_r($data);
$collocationList = array();
if (isset($data['code']) && $data['code'] == 200) {
foreach ($data['data']['list']['artList'] as $key=>$value) {
$collocationList[$key]['img'] = Helpers::getImageUrl($value['src'], 640, 240);
$collocationList[$key]['url'] = $value['url'];
$collocationList[$key]['title'] = $value['title'];
$collocationList[$key]['content'] = $value['intro'];
$collocationList[$key]['time'] = $value['publish_time'];
$collocationList[$key]['seeNum'] = $value['views_num'];
$collocationList[$key]['zanNum'] = $value['praise_num'];
$collocationList[$key]['isLiked '] = $value['isPraise'];
$collocationList[$key]['isCollected'] = $value['isFavor'];
}
$result['collocationList'] = $collocationList;
}
return $result;
}
//签到操作
public static function sign($uid)
{
$data = StarClassData::sign($uid);
//print_r($data);
$result = array();
if (isset($data['code']) && $data['code'] == 200) {
$result['signDay'];
foreach ($data['data']['logs'] as $key=>$value) {
$result['signDay'] .= date('N', $value['createTime']) . ',';
}
$result['intimacyNum'] = $data['data']['addNum'];
$result['fanCharts'] = $data['data']['rankList'];
foreach ($data['data']['rankList'] as $key=>$value) {
$result['fanCharts'][$key]['num'] = intval($key)+1;
$result['fanCharts'][$key]['img'] = Helpers::getImageUrl($value['avatar'], 640, 240);
$result['fanCharts'][$key]['name'] = $value['username'];
$result['fanCharts'][$key]['intimacyNum'] = $value['num'];
}
}
return $result;
}
/**
* 获取headTab
*/
public static function getHeadTab($tab)
{
$result = array(
array(
'name' => '全部',
'url' => Helpers::url('/guang/starclass/index'),
),
array(
'name' => '星专题',
'url' => Helpers::url('/guang/starclass/special')
),
array(
'name' => '星搭配',
'url' => Helpers::url('/guang/starclass/collocation')
),
array(
'name' => '星鲜事',
'url' => Helpers::url('/guang/starclass/fresh')
)
);
switch ($tab) {
case 'index':
$result[0]['cur'] = true;
break;
case 'special':
$result[1]['cur'] = true;
break;
case 'collocation':
$result[2]['cur'] = true;
break;
case 'fresh':
$result[3]['cur'] = true;
break;
default:
break;
}
return $result;
}
//single_name_image
public static function single_name_image($data)
{
$result = array();
$result['url'] = $data['url'];
$result['img'] = $data['src'];
$result['title'] = $data['title'];
$result['subject'] = true;
return $result;
}
}