作者 Administrator

网页授权

@@ -17,7 +17,13 @@ use PhpOffice\PhpSpreadsheet\Style\Alignment; @@ -17,7 +17,13 @@ use PhpOffice\PhpSpreadsheet\Style\Alignment;
17 use PhpOffice\PhpSpreadsheet\Style\Border; 17 use PhpOffice\PhpSpreadsheet\Style\Border;
18 use PhpOffice\PhpSpreadsheet\Style\NumberFormat; 18 use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
19 19
20 - 20 +function isWechat(){
  21 + if (strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false) {
  22 + return true;
  23 + } else {
  24 + return false;
  25 + }
  26 +}
21 27
22 28
23 function isInArray($str , $arr){ 29 function isInArray($str , $arr){
@@ -8,9 +8,12 @@ use app\common\model\TemplateView; @@ -8,9 +8,12 @@ use app\common\model\TemplateView;
8 use app\school\model\basic\Teacher; 8 use app\school\model\basic\Teacher;
9 use app\school\model\content\Newscategory; 9 use app\school\model\content\Newscategory;
10 use app\school\model\ManystoreShop; 10 use app\school\model\ManystoreShop;
  11 +use EasyWeChat\Factory;
  12 +use Overtrue\Socialite\AuthorizeFailedException;
11 use think\Config; 13 use think\Config;
12 use think\Cookie; 14 use think\Cookie;
13 use think\Db; 15 use think\Db;
  16 +use think\Exception;
14 use think\Request; 17 use think\Request;
15 18
16 class Index extends Frontend 19 class Index extends Frontend
@@ -73,7 +76,25 @@ class Index extends Frontend @@ -73,7 +76,25 @@ class Index extends Frontend
73 $this->assign('elegant_product',$elegant_product); 76 $this->assign('elegant_product',$elegant_product);
74 $this->assign('links',$links); 77 $this->assign('links',$links);
75 $this->view->assign('index',$index='foot');//首页隐藏头部使用 78 $this->view->assign('index',$index='foot');//首页隐藏头部使用
76 - return $this->view->fetch("/index/school/{$this->template}"); 79 +
  80 + if (isWechat()){
  81 + $config = [
  82 + 'app_id' => 'wx401d047673f1c578',
  83 + 'secret' => '2f99955f1964d30d6e962c345c268274',
  84 + 'response_type' => 'array',
  85 + ];
  86 + $app = Factory::officialAccount($config);
  87 + try {
  88 + $oauth = $app->oauth;
  89 + $user = $oauth->user();
  90 + session("open_id",$user->id);
  91 + }catch (AuthorizeFailedException $e){
  92 + $response = $app->oauth->scopes(['snsapi_userinfo'])
  93 + ->redirect($this->request->domain());
  94 + $response->send();
  95 + }
  96 + }
  97 + return $this->view->fetch("/index/school/{$this->template}");
77 } 98 }
78 99
79 // 导师风采 100 // 导师风采
@@ -107,11 +128,11 @@ class Index extends Frontend @@ -107,11 +128,11 @@ class Index extends Frontend
107 $this->assign("list",$list); 128 $this->assign("list",$list);
108 $this->assign("text",$text); 129 $this->assign("text",$text);
109 $this->assign("page",$page); 130 $this->assign("page",$page);
110 - $this->view->assign('index',$index='foot');//首页隐藏头部使用 131 + $this->view->assign('index',$index='foot');//首页隐藏头部使用
111 return $this->fetch(); 132 return $this->fetch();
112 } 133 }
113 - // 教师团队详情页  
114 - public function teacher_detail(){ 134 + // 教师团队详情页
  135 + public function teacher_detail(){
115 $param = $this->request->param(); 136 $param = $this->request->param();
116 $teacherObj = new Teacher(); 137 $teacherObj = new Teacher();
117 138
@@ -142,26 +163,26 @@ class Index extends Frontend @@ -142,26 +163,26 @@ class Index extends Frontend
142 $this->assign("type",$param['type']); 163 $this->assign("type",$param['type']);
143 $this->assign("info",$info); 164 $this->assign("info",$info);
144 $this->assign("text",$text); 165 $this->assign("text",$text);
145 - $this->view->assign('index',$index='foot');//首页隐藏头部使用  
146 - return $this->fetch();  
147 - }  
148 - //创意产品展  
149 - public function exhibition(){ 166 + $this->view->assign('index',$index='foot');//首页隐藏头部使用
  167 + return $this->fetch();
  168 + }
  169 + //创意产品展
  170 + public function exhibition(){
150 $elegant_list = Db::name("elegant")->where("school_id", $this->school_id)->where('type',2)->paginate(10,false,['param'=>request()->param()]); 171 $elegant_list = Db::name("elegant")->where("school_id", $this->school_id)->where('type',2)->paginate(10,false,['param'=>request()->param()]);
151 $this->assign("list",$elegant_list); 172 $this->assign("list",$elegant_list);
152 - $this->view->assign('index',$index='foot');//首页隐藏头部使用  
153 - return $this->fetch();  
154 - }  
155 - // 创意作品展详情  
156 - public function exhibition_detail($id=0){ 173 + $this->view->assign('index',$index='foot');//首页隐藏头部使用
  174 + return $this->fetch();
  175 + }
  176 + // 创意作品展详情
  177 + public function exhibition_detail($id=0){
157 Db::name("elegant")->where("elegant_id", $id)->setInc("visits_count"); 178 Db::name("elegant")->where("elegant_id", $id)->setInc("visits_count");
158 $info = Db::name("elegant")->where("elegant_id", $id)->find(); 179 $info = Db::name("elegant")->where("elegant_id", $id)->find();
159 $this->assign("info",$info); 180 $this->assign("info",$info);
160 - $this->view->assign('index',$index='foot');//首页隐藏头部使用  
161 - return $this->fetch();  
162 - }  
163 - //风云榜  
164 - public function event_list(){ 181 + $this->view->assign('index',$index='foot');//首页隐藏头部使用
  182 + return $this->fetch();
  183 + }
  184 + //风云榜
  185 + public function event_list(){
165 $page= null; 186 $page= null;
166 $uid = Cookie::get("uid"); 187 $uid = Cookie::get("uid");
167 $elegant_list = Db::name("elegant")->where("school_id", $this->school_id)->where('type',1)->paginate(3,false,['param'=>request()->param()]); 188 $elegant_list = Db::name("elegant")->where("school_id", $this->school_id)->where('type',1)->paginate(3,false,['param'=>request()->param()]);
@@ -177,11 +198,11 @@ class Index extends Frontend @@ -177,11 +198,11 @@ class Index extends Frontend
177 $page = $elegant_list->render(); 198 $page = $elegant_list->render();
178 $this->assign("page",$page); 199 $this->assign("page",$page);
179 $this->assign("elegant_person",$elegant_list); 200 $this->assign("elegant_person",$elegant_list);
180 - $this->view->assign('index',$index='foot');//首页隐藏头部使用  
181 - return $this->fetch();  
182 - }  
183 - //风云榜详情  
184 - public function event_detail($id=0){ 201 + $this->view->assign('index',$index='foot');//首页隐藏头部使用
  202 + return $this->fetch();
  203 + }
  204 + //风云榜详情
  205 + public function event_detail($id=0){
185 $uid = Cookie::get("uid"); 206 $uid = Cookie::get("uid");
186 Db::name("elegant")->where("elegant_id", $id)->setInc("visits_count",1); 207 Db::name("elegant")->where("elegant_id", $id)->setInc("visits_count",1);
187 $info = Db::name("elegant")->where("elegant_id", $id)->find(); 208 $info = Db::name("elegant")->where("elegant_id", $id)->find();
@@ -191,11 +212,11 @@ class Index extends Frontend @@ -191,11 +212,11 @@ class Index extends Frontend
191 // $info_['bio'] = $user['bio']; 212 // $info_['bio'] = $user['bio'];
192 // $info = array_merge($info,$info_); 213 // $info = array_merge($info,$info_);
193 $this->assign("info",$info); 214 $this->assign("info",$info);
194 - $this->view->assign('index',$index='foot');//首页隐藏头部使用  
195 - return $this->fetch();  
196 - } 215 + $this->view->assign('index',$index='foot');//首页隐藏头部使用
  216 + return $this->fetch();
  217 + }
197 218
198 - public function getBasedisplay(){ 219 + public function getBasedisplay(){
199 $param = $this->request->param(); 220 $param = $this->request->param();
200 $baseDisplay = Db::name("base_display")->where("school_id", $this->school_id)->where("category_id",$param['category_id'])->limit(3)->select(); 221 $baseDisplay = Db::name("base_display")->where("school_id", $this->school_id)->where("category_id",$param['category_id'])->limit(3)->select();
201 $data['data'] = $baseDisplay; 222 $data['data'] = $baseDisplay;
@@ -210,33 +231,33 @@ class Index extends Frontend @@ -210,33 +231,33 @@ class Index extends Frontend
210 $this->success('','',$data); 231 $this->success('','',$data);
211 } 232 }
212 233
213 - //学校简介  
214 - public function college_profile(){ 234 + //学校简介
  235 + public function college_profile(){
215 $schoolInfo = ManystoreShop::get($this->school_id); 236 $schoolInfo = ManystoreShop::get($this->school_id);
216 $this->view->assign('schoolinfo',$schoolInfo); 237 $this->view->assign('schoolinfo',$schoolInfo);
217 - $this->view->assign('index',$index='foot');//首页隐藏头部使用  
218 - return $this->fetch();  
219 - }  
220 - //组织架构  
221 - public function organizational(){ 238 + $this->view->assign('index',$index='foot');//首页隐藏头部使用
  239 + return $this->fetch();
  240 + }
  241 + //组织架构
  242 + public function organizational(){
222 $schoolInfo = ManystoreShop::get($this->school_id); 243 $schoolInfo = ManystoreShop::get($this->school_id);
223 $this->view->assign('schoolinfo',$schoolInfo); 244 $this->view->assign('schoolinfo',$schoolInfo);
224 - $this->view->assign('index',$index='foot');//首页隐藏头部使用  
225 - return $this->fetch();  
226 - }  
227 - //政策制度  
228 - public function policy_system(){ 245 + $this->view->assign('index',$index='foot');//首页隐藏头部使用
  246 + return $this->fetch();
  247 + }
  248 + //政策制度
  249 + public function policy_system(){
229 250
230 - $this->view->assign('index',$index='foot');//首页隐藏头部使用  
231 - return $this->fetch();  
232 - }  
233 - //政策详情  
234 - public function policy_detail(){  
235 - $this->view->assign('index',$index='foot');//首页隐藏头部使用  
236 - return $this->fetch();  
237 - } 251 + $this->view->assign('index',$index='foot');//首页隐藏头部使用
  252 + return $this->fetch();
  253 + }
  254 + //政策详情
  255 + public function policy_detail(){
  256 + $this->view->assign('index',$index='foot');//首页隐藏头部使用
  257 + return $this->fetch();
  258 + }
238 259
239 - public function Ilike_elegant(){ 260 + public function Ilike_elegant(){
240 $uid = Cookie::get("uid"); 261 $uid = Cookie::get("uid");
241 if(empty($uid)){ 262 if(empty($uid)){
242 $this->error("请登录",url('student_login/index')); 263 $this->error("请登录",url('student_login/index'));