Index.php
12.2 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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
<?php
namespace app\index\controller;
use app\common\controller\Frontend;
use app\common\library\Auth;
use app\common\model\TemplateView;
use app\school\model\basic\Teacher;
use app\school\model\content\Newscategory;
use app\school\model\ManystoreShop;
use EasyWeChat\Factory;
use Overtrue\Socialite\AuthorizeFailedException;
use think\Config;
use think\Cookie;
use think\Db;
use think\Exception;
use think\Request;
class Index extends Frontend
{
protected $noNeedLogin = '*';
protected $noNeedRight = '*';
protected $layout = 'default';
protected $template = 'weilai';
public function _initialize()
{
dump($config = get_addon_config('upyun'));die;
parent::_initialize(); // TODO: Change the autogenerated stub
$template = TemplateView::getSchoolTemplate( $this->school_id);
$this->layout = $template->layout ?? 'default';
$this->template = $template->template_url;
}
public function index()
{
$newsCategoryVo = new Newscategory();
$elegant_person = Db::name("elegant")->where("school_id", $this->school_id)->where('type',1)->limit(3)->select();
$elegant_product = Db::name("elegant")->where("school_id", $this->school_id)->where('type',2)->limit(3)->select();
$baseDisplayCategory = Db::name("basedisplay_category")->where("school_id", $this->school_id)->limit(4)->select();
if(!empty($baseDisplayCategory)){
$baseDisplay = Db::name("base_display")->where("school_id", $this->school_id)->where("category_id",$baseDisplayCategory[0]['category_id'])->limit(3)->select();
}else{
$baseDisplay= null;
}
$achievementsCategory = Db::name("achievements_category")->where("school_id", $this->school_id)->limit(4)->select();
if(!empty($achievementsCategory)){
$achievements = Db::name("achievements")->where("school_id", $this->school_id)->where("category_id",$achievementsCategory[0]['category_id'])->limit(3)->select();
}else{
$achievements = null;
}
$newsCategory = $newsCategoryVo ->where('flag','index')->where(['school_id' => $this->school_id,'status'=>["<>",'lock']])->where('type','新闻')->limit(3)->order('weigh','desc')->select();
$links = Db::name("friend_link")->where("school_id", $this->school_id)->limit(4)->select();
foreach ($links as $k=>$v){
if(strpos($v['link_url'],'http://') !== 0 && strpos($v['link_url'],'https://') !== 0){
$v['link_url'] = 'http://'.$v['link_url'];
}
$links[$k] = $v;
}
$double_list = Db::name("project_double")->where("school_id",$this->school_id)->order("id","desc")->limit(4)->select();
$config = Config::get("upload");
$this->assign('double_list',$double_list);
$this->assign('category',$newsCategory);
$this->assign('cdnurl',$config['cdnurl']);
$this->assign('baseDisplayCategory',$baseDisplayCategory);
$this->assign('baseDisplay',$baseDisplay);
$this->assign('achievementsCategory',$achievementsCategory);
$this->assign('achievements',$achievements);
$this->assign('elegant_person',$elegant_person);
$this->assign('elegant_product',$elegant_product);
$this->assign('links',$links);
$this->view->assign('index',$index='foot');//首页隐藏头部使用
if (isWechat()){
$config = [
'app_id' => 'wx401d047673f1c578',
'secret' => '2f99955f1964d30d6e962c345c268274',
'response_type' => 'array',
];
$app = Factory::officialAccount($config);
try {
$oauth = $app->oauth;
$user = $oauth->user();
session("open_id",$user->id);
}catch (AuthorizeFailedException $e){
$response = $app->oauth->scopes(['snsapi_userinfo'])
->redirect($this->request->domain());
$response->send();
}
}
return $this->view->fetch("/index/school/{$this->template}");
}
// 导师风采
public function teacherlist(){
$param = $this->request->param();
switch(intval($param['type'])){
case 1://校园导师
$list = Db::name("teacher")->where("type",1)->where("school_id",$this->school_id)->paginate(3,false,['param'=>request()->param()]);
$text='校园导师';
break;
case 2://企业导师
$list = Db::name("teacher")->where("type",2)->where("school_id",$this->school_id)->paginate(3,false,['param'=>request()->param()]);
$text='企业导师';
break;
case 3://专家评委
$list = Db::name("project_experts")->field('*,nickname as username')->where("school_id",$this->school_id)->paginate(3,false,['param'=>request()->param()]);;
$text='专家评委';
break;
default:
$text='校园导师';
$list = Db::name("teacher")->where("type",1)->where("school_id",$this->school_id)->paginate(3,false,['param'=>request()->param()]);
}
$page = null;
if(!empty($list)){
$page = $list->render();
}
$this->assign("type",$param['type']);
$this->assign("list",$list);
$this->assign("text",$text);
$this->assign("page",$page);
$this->view->assign('index',$index='foot');//首页隐藏头部使用
return $this->fetch();
}
// 教师团队详情页
public function teacher_detail(){
$param = $this->request->param();
$teacherObj = new Teacher();
switch(intval($param['type'])){
case 1://校园导师
$info = $teacherObj->where("id",$param['id'])->find();
$text='校园导师';
break;
case 2://企业导师
$info = $teacherObj->where("id",$param['id'])->find();
$text='企业导师';
break;
case 3://专家评委
$info = Db::name("project_experts")->where("id",$param['id'])->find();
// $info = $teacherObj->where("id",$param['id'])->find();
$text='专家评委';
break;
default:
$text='校园导师';
$info = $teacherObj->where("id",$param['id'])->find();
}
// dump($param);die;
$info['project'] = Db::name("project_register")->field("project_name")->where("find_in_set(:id,`project_teacher_ids`)",["id"=>$info['id']])->limit(5)->select();
// $match_items= Db::name("match_items_details")->whereraw("teacher_id = {$info['id']}")->column("match_items_id");
// $matchs = Db::name("match_items")->whereIn("match_id",array_unique($match_items))->column("match_id");
// $info["match"] =Db::name("match")->whereIn("id",$matchs)->select();
// $info["match"] =Db::name("match")->whereIn("id",$matchs)->select();
$this->assign("type",$param['type']);
$this->assign("info",$info);
$this->assign("text",$text);
$this->view->assign('index',$index='foot');//首页隐藏头部使用
return $this->fetch();
}
//创意产品展
public function exhibition(){
$elegant_list = Db::name("elegant")->where("school_id", $this->school_id)->where('type',2)->paginate(10,false,['param'=>request()->param()]);
$this->assign("list",$elegant_list);
$this->view->assign('index',$index='foot');//首页隐藏头部使用
return $this->fetch();
}
// 创意作品展详情
public function exhibition_detail($id=0){
Db::name("elegant")->where("elegant_id", $id)->setInc("visits_count");
$info = Db::name("elegant")->where("elegant_id", $id)->find();
$this->assign("info",$info);
$this->view->assign('index',$index='foot');//首页隐藏头部使用
return $this->fetch();
}
//风云榜
public function event_list(){
$page= null;
$uid = Cookie::get("uid");
$elegant_list = Db::name("elegant")->where("school_id", $this->school_id)->where('type',1)->paginate(3,false,['param'=>request()->param()]);
foreach ($elegant_list as $k=>$v){
$like =Db::name('like')->where(["user_id"=>$uid,'data_id'=>$v['elegant_id'],'table_name'=>'elegant'])->find();
if(empty($like)){
$v['like'] =0;
}else{
$v['like'] =1;
}
$elegant_list[$k] = $v;
}
$page = $elegant_list->render();
$this->assign("page",$page);
$this->assign("elegant_person",$elegant_list);
$this->view->assign('index',$index='foot');//首页隐藏头部使用
return $this->fetch();
}
//风云榜详情
public function event_detail($id=0){
$uid = Cookie::get("uid");
Db::name("elegant")->where("elegant_id", $id)->setInc("visits_count",1);
$info = Db::name("elegant")->where("elegant_id", $id)->find();
// $info_['college'] = $user['college'];
// $info_['specialty'] = $user['specialty'];
// $info_['bio'] = $user['bio'];
// $info = array_merge($info,$info_);
$this->assign("info",$info);
$this->view->assign('index',$index='foot');//首页隐藏头部使用
return $this->fetch();
}
public function getBasedisplay(){
$param = $this->request->param();
$baseDisplay = Db::name("base_display")->where("school_id", $this->school_id)->where("category_id",$param['category_id'])->limit(3)->select();
$data['data'] = $baseDisplay;
$data['type'] = 1;
$this->success('','',$data);
}
public function getAchievements(){
$param = $this->request->param();
$achievements = Db::name("achievements")->where("school_id", $this->school_id)->where("category_id",$param['category_id'])->limit(3)->select();
$data['data'] = $achievements;
$data['type'] = 2;
$this->success('','',$data);
}
//学校简介
public function college_profile(){
$schoolInfo = ManystoreShop::get($this->school_id);
$this->view->assign('schoolinfo',$schoolInfo);
$this->view->assign('index',$index='foot');//首页隐藏头部使用
return $this->fetch();
}
//组织架构
public function organizational(){
$schoolInfo = ManystoreShop::get($this->school_id);
$this->view->assign('schoolinfo',$schoolInfo);
$this->view->assign('index',$index='foot');//首页隐藏头部使用
return $this->fetch();
}
//政策制度
public function policy_system(){
$this->view->assign('index',$index='foot');//首页隐藏头部使用
return $this->fetch();
}
//政策详情
public function policy_detail(){
$this->view->assign('index',$index='foot');//首页隐藏头部使用
return $this->fetch();
}
public function Ilike_elegant(){
$uid = Cookie::get("uid");
if(empty($uid)){
$this->error("请登录",url('student_login/index'));
}
$param = $this->request->param();
if(!empty($param['id'])){
$type = 0;
$insert['user_id'] = $uid;
$insert['data_id'] = $param['id'];
$insert['table_name'] = 'elegant';
$info = Db::name('like')->where($insert)->find();
if(empty($info)){
$insert['type'] = 0;
$insert["create_time"] = time();
$status = Db::name('like')->insert($insert);
if($status){
$status =Db::name("elegant")->where("elegant_id", $insert['data_id'])->setInc("like_count");
if($status){
$this->success('','',1);
}
}
}else{
$status= Db::name('like')->where('id',$info['id'])->delete();
if($status){
$status = Db::name("elegant")->where("elegant_id", $insert['data_id'])->setDec("like_count");
if($status){
$this->success('','',2);
}
}
}
}
}
}