IndexController.php
6.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
<?php
/**
* 首页
* Author: xiaojie
* DateTime: 2018/11/26 11:39
*/
namespace app\portal\controller;
use app\portal\model\PageModel;
use app\portal\model\ShowModel;
use app\portal\model\TeamModel;
use cmf\controller\HomeBaseController;
use think\Db;
class IndexController extends HomeBaseController
{
/**
* pc首页,移动banner图页面
* 知名展商(展商名录) 24
* 买家集群 32
* 合作媒体 40
*/
public function index()
{
$data = $this->indexData();
$this->assign('team_list',$data['team_list']);
$this->assign('shower_list',$data['shower_list']);
$this->assign('buyer_list',$data['buyer_list']);
$this->assign('media_list',$data['media_list']);
$this->assign('news_list',$data['news_list']);
$this->assign('news2_list',$data['news2_list']);
$this->assign('news3_list',$data['news3_list']);
$this->assign('banner_index',$data['banner_index']);
return $this->fetch();
}
// //移动端首页
// public function homePage(){
// $data = $this->indexData();
// $this->assign('team_list',$data['team_list']);
// $this->assign('shower_list',$data['shower_list']);
// $this->assign('buyer_list',$data['buyer_list']);
// $this->assign('media_list',$data['media_list']);
// $this->assign('news_list',$data['news_list']);
// $this->assign('news2_list',$data['news2_list']);
// $this->assign('news3_list',$data['news3_list']);
// $this->assign('banner_index',$data['banner_index']);
// return $this->fetch(':homepage');
// }
/**
* 个人中心页面
* 数据和首页一样
* @return mixed
*/
public function person(){
$data = $this->indexData();
$this->assign('team_list',$data['team_list']);
$this->assign('shower_list',$data['shower_list']);
$this->assign('buyer_list',$data['buyer_list']);
$this->assign('media_list',$data['media_list']);
$this->assign('news_list',$data['news_list']);
$this->assign('news2_list',$data['news2_list']);
$this->assign('news3_list',$data['news3_list']);
$this->assign('banner_index',$data['banner_index']);
return $this->fetch(':person_center');
}
/**
* 移动端首页和个人中心公用数据
* @return mixed
*/
public function indexData()
{
$teamModel = new TeamModel();
$showModel = new ShowModel();
$serverModel = new ServerController();
//专业团队
$team_list = $teamModel->getList();
//统计访问量
$serverModel->statistics();
//知名展商
$shower_list = $showModel->getList(24,'',9,'sort ASC,id DESC');
//买家集群
$buyer_list = $showModel->getList(32,'',9,'sort ASC,id DESC');
//合作媒体
$media_list = $showModel->getList(40,'',9,'sort ASC,id DESC');
//展会新闻
$news_list = $showModel->where('cate_id',37)->order('id DESC')->limit(6)->select();
//行业新闻
$news2_list = $showModel->where('cate_id',36)->order('id DESC')->limit(6)->select();
//移动端行业新闻
$news3_list = $showModel->where('cate_id',36)->order('id DESC')->limit(2)->select();
//轮播
$banner_index = Db::name('slide_item')
->field('image,url')
->where('slide_id',1)
->select();
$data = [];
$data['team_list'] = $team_list;
$data['shower_list'] = $shower_list;
$data['buyer_list'] = $buyer_list;
$data['media_list'] = $media_list;
$data['news_list'] = $news_list;
$data['news2_list'] = $news2_list;
$data['news3_list'] = $news3_list;
$data['banner_index'] = $banner_index;
return $data;
}
/**
* 新闻搜索
*/
public function news_search()
{
$showModel = new ShowModel();
$keyword = $this->request->param('keyword');
if(empty($keyword)){
$this->redirect(url('index/index'));
}
$where['title'] = ['like',"%$keyword%"];
$where['cate_id'] = ['in',[36,37,38]];
$list = $showModel
->where($where)
->order('id DESC')
->paginate(6);
//分页样式
$page = $this->getPageStyle($list,$keyword);
//所在位置
$location = [
[
'location' => '全局搜索',
'url' => 'javascript:;'
],
[
'location' => '搜索列表',
'url' => 'javascript:;'
]
];
$this->assign('list',$list);
$this->assign('location',$location);
$this->assign('page',$page);
$this->assign('keyword',$keyword);
return $this->fetch(':list');
}
/**
* 关于我们
* portal/index/aboutus
*/
public function aboutus()
{
$cate_id = 61;
$pageModel = new PageModel();
$info = $pageModel->where('cate_id',$cate_id)->find();
$this->setPageNum($info['id']);
//所在位置
$location = [
[
'location' => '天津振威',
'url' => 'javascript:;'
],
[
'location' => '关于振威',
'url' => 'javascript:;'
]
];
$this->assign('info',$info);
$this->assign('location',$location);
return $this->fetch(':page');
}
/**
* 版权说明
* portal/index/copyright
*/
public function copyright()
{
$cate_id = 62;
$pageModel = new PageModel();
$info = $pageModel->where('cate_id',$cate_id)->find();
$this->setPageNum($info['id']);
//所在位置
$location = [
[
'location' => '天津振威',
'url' => 'javascript:;'
],
[
'location' => '版权说明',
'url' => 'javascript:;'
]
];
$this->assign('info',$info);
$this->assign('location',$location);
return $this->fetch(':page');
}
/**
* 网站地图
* http://tamt.chinaciai.com.cn/portal/index/map
*/
public function map()
{
return $this->fetch();
}
}