Index.php
7.3 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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
<?php
namespace app\index\controller;
use app\common\controller\Frontend;
use app\common\library\Token;
use function GuzzleHttp\uri_template;
use think\Db;
class Index extends Frontend
{
protected $noNeedLogin = '*';
protected $noNeedRight = '*';
protected $layout = '';
protected $limit = 20;
protected $page = 1;
protected $group = 8;//分组
protected $title = '';
protected $keys = '';
protected $description = '';
public function _initialize()
{
parent::_initialize();
//SEO标题
$title = Db::table('fa_config')->where('id',1)->find();
$this->title = $title['value'];
//SEO关键字
$keys = Db::table('fa_config')->where('id',18)->find();
$this->keys = $keys['value'];
//SEO描述
$description = Db::table('fa_config')->where('id',19)->find();
$this->description = $description['value'];
}
public function index(){
//普通新闻列表
$custom = Db::name('custom')
->field('id,url,image,weigh')
->order('weigh','desc')
->select();
$count = ceil(count($custom)/$this->group);
$list = 0;
$arr = [];
for($i=0;$i<$count;$i++){
$list += $this->group;
foreach($custom as $key1=>$c_value){
if($key1>=$list-$this->group && $key1<$list){
$arr[$i]['data'][] = $c_value;
}
}
}
$this->assign('custom',$arr);
//SEO标题关键字,描述
$this->assign('title',$this->title);
$this->assign('keys',$this->keys);
$this->assign('description',$this->description);
$isMobile = Request()->isMobile();
if($isMobile){
$custom = Db::name('custom')
->field('id,url,image,weigh')
->limit(4)
->order('weigh','desc')
->select();
$this->assign('mobileCustom',$custom);
return $this->fetch('/mobile/index');
}else{
return $this->fetch();
}
}
//新闻资讯
public function news(){
//普通新闻列表
$news = Db::name('news')
->where('flag','<>','index')
->page(1,10)
->order('weigh','desc')
->select();
//热门文章
$hot = Db::name('news')
->where(['flag'=>'hot'])
->limit(20)
->order('weigh','desc')
->select();
//置顶列表
$top = Db::name('news')
->where(['flag'=>'index'])
->limit(3)
->order('weigh','desc')
->select();
$this->assign('hot',$hot);
$this->assign('list',$news);
$this->assign('top',$top);
//SEO标题关键字,描述
$this->assign('title',$this->title);
$this->assign('keys',$this->keys);
$this->assign('description',$this->description);
$isMobile = Request()->isMobile();
if($isMobile){
$mobileHot = Db::name('news')
->where(['flag'=>'hot'])
->order('weigh','desc')
->select();
$this->assign('mobileHot',$mobileHot);
return $this->fetch('/mobile/news');
}else{
return $this->fetch();
}
}
public function loadNews(){
$data = Db::name('news')
->where('flag','<>','index')
->order('weigh','desc')
->select();
foreach($data as &$v){
$v['createtime'] = date('Y-m-d',$v['createtime']);
}
echo json_encode($data);
}
//新闻详情页
public function news_detail(){
$id = $this->request->get('id');
$detail = Db::name('news')
->where('id',$id)
->find();
$hot = Db::name('news')
->where(['flag'=>'hot'])
->limit($this->limit)
->order('weigh','desc')
->select();
if($detail){
$detail['createtime'] = date('Y-m-d',$detail['createtime']);
}
$this->assign('hot',$hot);
$this->assign('detail',$detail);
//SEO标题关键字,描述
$this->assign('title',$this->title);
$this->assign('keys',$this->keys);
$this->assign('description',$this->description);
$isMobile = Request()->isMobile();
if($isMobile){
return $this->fetch('/mobile/news_detail');
}else{
return $this->fetch();
}
}
//加载地图
public function map(){
//SEO标题关键字,描述
$this->assign('title',$this->title);
$this->assign('keys',$this->keys);
$this->assign('description',$this->description);
$isMobile = Request()->isMobile();
if($isMobile){
return $this->fetch('/mobile/map');
}else{
return $this->fetch();
}
}
//课程体系
public function course(){
//SEO标题关键字,描述
$this->assign('title',$this->title);
$this->assign('keys',$this->keys);
$this->assign('description',$this->description);
$isMobile = Request()->isMobile();
if($isMobile){
return $this->fetch('/mobile/course');
}else{
return $this->fetch();
}
}
public function contact(){
//SEO标题关键字,描述
$this->assign('title',$this->title);
$this->assign('keys',$this->keys);
$this->assign('description',$this->description);
$isMobile = Request()->isMobile();
if($isMobile){
return $this->fetch('/mobile/contact');
}else{
return $this->fetch();
}
}
//业务介绍
public function business(){
//SEO标题关键字,描述
$this->assign('title',$this->title);
$this->assign('keys',$this->keys);
$this->assign('description',$this->description);
$isMobile = Request()->isMobile();
if($isMobile){
return $this->fetch('/mobile/business');
}else{
return $this->fetch();
}
}
//关于我们
public function about(){
//SEO标题关键字,描述
$this->assign('title',$this->title);
$this->assign('keys',$this->keys);
$this->assign('description',$this->description);
$isMobile = Request()->isMobile();
if($isMobile){
return $this->fetch('/mobile/about');
}else{
return $this->fetch();
}
}
//关于我们更多
public function guidelines(){
//SEO标题关键字,描述
$this->assign('title',$this->title);
$this->assign('keys',$this->keys);
$this->assign('description',$this->description);
$isMobile = Request()->isMobile();
if($isMobile){
return $this->fetch('/mobile/guidelines');
}else{
return $this->fetch();
}
}
//公司介绍
public function introduce(){
//SEO标题关键字,描述
$this->assign('title',$this->title);
$this->assign('keys',$this->keys);
$this->assign('description',$this->description);
$isMobile = Request()->isMobile();
if($isMobile){
return $this->fetch('/mobile/introduce');
}else{
return $this->fetch();
}
}
}