// +---------------------------------------------------------------------- namespace app\culture\controller; use think\Db; use think\Validate; class Project extends Base{ protected $current=[['title'=>'文化金融服务项目']]; protected $apitoken=''; public function _initialize(){ parent::_initialize(); $this->assign('current',$this->current); $this->apitoken=session('api_token'); } /** * 项目列表 * @return string */ public function ajaxprojects(){ $page=input('page',1,'intval'); $industry_id=input('industry_id','','intval'); $investment_id=input('investment_id','','intval'); $region_id=input('region_id','','intval'); $keyword=input('keyword'); $sort=input('sort'); $token=request()->token('__cult__'); if($keyword){ $rule = [ '__cult__' =>'require|token:__cult__' ]; $message =[ '__cult__.require'=>'令牌缺失' ]; $validate=new Validate($rule,$message); $result=$validate->check(input()); if(!$result){ return json_encode(['projects'=>[],'token'=>$token]); } } $parmas=['page'=>$page,'industry_id'=>$industry_id,'region_id'=>$region_id,'investment_id'=>$investment_id,'keyword'=>$keyword,'sort'=>$sort]; $params=http_build_query($parmas); $url=$this->hostpath."/api/projects/index?".$params; $projects="[]"; try { $projects=go_curl($url,'GET',false,['Accept'=>'application/json']); }catch (\Exception $e){ } return json_encode(['projects'=>$projects,'token'=>$token]); } /** * 机构详情 * @return string */ public function detail(){ $id=input('id','','intval'); $this->assign('id',$id); $this->assign('type','项目'); $apitoken=session('api_token'); if(empty($apitoken)){ $this->error('请先登录'); } $pro=[]; $url=$this->hostpath."/api/projects/".$id; try { $pro=go_curl($url,'GET',false,['Accept'=>'application/json',"Authorization:Bearer ".$this->apitoken]); $pro=json_decode($pro,true); }catch (\Exception $e){ } if(isset($pro['id'])&&isset($pro['message'])){ $this->error($pro['message']); } if(!isset($pro['name']))$pro=['name'=>'','reputation'=>0,'logo'=>'','project_introduction'=>'','major_product_introduction'=>'','core_team_introduction'=>'','financing_introduction'=>'']; if(isset($pro['reputation'])){ $score=$pro['reputation']; $userinfo=$this->getUserProfile(); if(!isset($userinfo['reputation'])||$score>$userinfo['reputation']){ $this->error('你的信誉积分不足,请补全认证资料增加信誉积分才可以查看'); } } $current=$this->current; $current[0]['jump']=url('index'); array_push($current, ['title'=>$pro['name']]); $this->assign('current',$current); $this->assign('detail',$pro); return $this->view->fetch(':project_detail'); } /** * 检查积分 */ protected function checkscore(){ $apitoken=session('api_token'); if(empty($apitoken)){ $this->error('请先登录'); } $id=input('id'); $score=input('score'); $userinfo=$this->getUserProfile(); if(!isset($userinfo['reputation'])||$score>$userinfo['reputation']){ $this->error('你的信誉积分不足,请补全认证资料增加信誉积分才可以查看'); } $jump=url('detail',['id'=>$id]); $this->success('可访问',$jump); } /** * 项目列表 * @return string */ public function index(){ $userscore=''; $profile=false; $apitoken=session('api_token'); if($apitoken){ $userinfo=$this->getUserProfile(); if(isset($userinfo['reputation'])){ $userscore=$userinfo['reputation']; } if(isset($userinfo['profile_completed'])){ $profile=$userinfo['profile_completed']; } } $this->assign('profile',intval($profile)); $this->assign('userscore',$userscore); $url=$this->hostpath."/api/project/filters"; $profilters="[]"; try { $profilters=go_curl($url,'GET',false,['Accept'=>'application/json']); $profilters=json_decode($profilters,true); if(isset($profilters['id']))$profilters=[]; }catch (\Exception $e){ } $this->assign('profilters',$profilters); return $this->view->fetch(':index'); } }