作者 Administrator

网页授权

... ... @@ -17,7 +17,13 @@ use PhpOffice\PhpSpreadsheet\Style\Alignment;
use PhpOffice\PhpSpreadsheet\Style\Border;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
function isWechat(){
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false) {
return true;
} else {
return false;
}
}
function isInArray($str , $arr){
... ...
... ... @@ -8,9 +8,12 @@ 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
... ... @@ -73,7 +76,25 @@ class Index extends Frontend
$this->assign('elegant_product',$elegant_product);
$this->assign('links',$links);
$this->view->assign('index',$index='foot');//首页隐藏头部使用
return $this->view->fetch("/index/school/{$this->template}");
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}");
}
// 导师风采
... ... @@ -107,11 +128,11 @@ class Index extends Frontend
$this->assign("list",$list);
$this->assign("text",$text);
$this->assign("page",$page);
$this->view->assign('index',$index='foot');//首页隐藏头部使用
$this->view->assign('index',$index='foot');//首页隐藏头部使用
return $this->fetch();
}
// 教师团队详情页
public function teacher_detail(){
// 教师团队详情页
public function teacher_detail(){
$param = $this->request->param();
$teacherObj = new Teacher();
... ... @@ -142,26 +163,26 @@ class Index extends Frontend
$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(){
$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){
$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(){
$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()]);
... ... @@ -177,11 +198,11 @@ class Index extends Frontend
$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){
$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();
... ... @@ -191,11 +212,11 @@ class Index extends Frontend
// $info_['bio'] = $user['bio'];
// $info = array_merge($info,$info_);
$this->assign("info",$info);
$this->view->assign('index',$index='foot');//首页隐藏头部使用
return $this->fetch();
}
$this->view->assign('index',$index='foot');//首页隐藏头部使用
return $this->fetch();
}
public function getBasedisplay(){
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;
... ... @@ -210,33 +231,33 @@ class Index extends Frontend
$this->success('','',$data);
}
//学校简介
public function college_profile(){
//学校简介
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(){
$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_system(){
$this->view->assign('index',$index='foot');//首页隐藏头部使用
return $this->fetch();
}
//政策详情
public function policy_detail(){
$this->view->assign('index',$index='foot');//首页隐藏头部使用
return $this->fetch();
}
$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(){
public function Ilike_elegant(){
$uid = Cookie::get("uid");
if(empty($uid)){
$this->error("请登录",url('student_login/index'));
... ...