// +---------------------------------------------------------------------- namespace app\culture\controller; use think\Controller; use think\Validate; class Agency 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 investors(){ $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('__agen__'); if($keyword){ $rule = [ '__agen__' =>'require|token:__agen__' ]; $message =[ '__agen__.require'=>'令牌缺失' ]; $validate=new Validate($rule,$message); $result=$validate->check(input()); if(!$result){ return json_encode(['investors'=>[],'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/investors/index?".$params; $investors="[]"; try { $investors=go_curl($url,'GET',false,['Accept'=>'application/json']); }catch (\Exception $e){ } return json_encode(['investors'=>$investors,'token'=>$token]); } /** * 获取机构联系⽅式 * @return array|mixed */ public function contact(){ $id=input('id','','intval'); $url=$this->hostpath."/api/investors/".$id."/contact"; $pro=[]; try { $pro=go_curl($url,'GET',false,['Accept'=>'application/json']); $pro=json_decode($pro,true); if(!isset($pro['name']))$pro=[]; }catch (\Exception $e){ } return $pro; } /** * 机构详情 * @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=[]; $title=""; if($id){ $url=$this->hostpath."/api/investors/".$id; try { $header=['Accept'=>'application/json',"Authorization:Bearer ".$this->apitoken]; $pro=go_curl($url,'GET',false,$header); $pro=json_decode($pro,true); $title=$pro['name']; }catch (\Exception $e){ } } if(isset($pro['id'])&&isset($pro['message'])){ $this->error($pro['message']); } if(!isset($pro['name']))$pro=['avatar'=>'','name'=>'','industries'=>[],'investable_type'=>'','individual_info'=>[],'description'=>'','reputation'=>0]; 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'=>$title]); $this->assign('current',$current); $this->assign('detail',$pro); return $this->view->fetch(':agency_detail'); } /** * 机构列表 * @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/investor/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(':agency'); } }