why.xingtongworld.com项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

197 lines
7.4 KiB

<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\culture\controller;
use app\common\controller\Common;
use app\admin\model\Options;
use think\Db;
use think\Session;
use think\Request;
class Base extends Common{
protected $hostpath;
protected $menu_arr;
protected function _initialize(){
parent::_initialize();
$this->hostpath=config('hostpath');
$this->curren_menu_id=7;
//菜单
$this->menu_id=input('id',0,'intval');
if($this->menu_id){
$this->menu_arr=get_menu_parents($this->menu_id);
if($this->menu_arr){
$this->curren_menu_id=$this->menu_arr[0];
}
}
$this->assign('curren_menu_id',$this->curren_menu_id);
$this->assign('menu_arr',$this->menu_arr);
//主题
$site_options=Options::get_options('site_options',$this->lang);
$this->site_options=$site_options;
$site_options['site_tongji']=htmlspecialchars_decode($site_options['site_tongji']);
$site_options['site_copyright']=htmlspecialchars_decode($site_options['site_copyright']);
//主题
$theme=$site_options['site_tpl'];
$this->assign($site_options);
$this->view=$this->view->config('view_path',APP_PATH.request()->module().'/view/'.$theme.'/');
$yf_theme_path=__ROOT__.'/app/culture/view/'.$theme.'/';
$this->assign('yf_theme_path',$yf_theme_path);
$yf_theme_path=__ROOT__.'/app/home/view/'.$theme.'/';
$this->assign('yf_home_path',$yf_theme_path);
$home_slides=Db::name('link')->where(['lk_cid'=>3,'lk_status'=>1])->order('lk_order')->select();
$this->assign("home_slides",$home_slides);
$is_mobile=0;
if(request()->isMobile()){
$is_mobile=1;
}
$is_admin=false;
$address='';
$this->user=array();
$uid=session('hid');
if(session('hid')){
$this->user=Db::name('member_list')->find(session('hid'));
if(!empty($this->user['member_list_province'])){
$rst=Db::name('region')->field('name')->find($this->user['member_list_province']);
$address.=$rst?$rst['name'].lang('province'):'';
}
if(!empty($this->user['member_list_city'])){
$rst=Db::name('region')->field('name')->find($this->user['member_list_city']);
$address.=$rst?$rst['name'].lang('city'):'';
}
if(!empty($this->user['member_list_town'])){
$rst=Db::name('region')->field('name')->find($this->user['member_list_town']);
$address.=$rst?$rst['name']:'';
}
//未读通知数
$notice_unread=Db::name('cult4notice')->alias('a')
->where(['a.user_id'=>session('hid'),'is_read'=>0])
->count();
$this->assign('notice_unread',$notice_unread);
}
//友情链接
$links=get_links(2);
$this->assign("links",$links);$this->user['address']=$address;
$this->assign("user",$this->user);
$this->assign("is_admin",$is_admin);
$this->assign("is_mobile",$is_mobile);
//同意协议
$agreesys=Options::get_options('agree_options',$this->lang);
$this->assign("agreesys",$agreesys);
//托管同意协议
$tg_agreesys1=Options::get_options('agree_options1',$this->lang);
$this->assign("agreesys1",$tg_agreesys1);
$tg_agreesys2=Options::get_options('agree_options2',$this->lang);
$this->assign("agreesys2",$tg_agreesys2);
$tg_agreesys3=Options::get_options('agree_options3',$this->lang);
$this->assign("agreesys3",$tg_agreesys3);
$tg_agreesys4=Options::get_options('agree_options4',$this->lang);
$this->assign("agreesys4",$tg_agreesys4);
$tg_agreesys5=Options::get_options('agree_options5',$this->lang);
$this->assign("agreesys5",$tg_agreesys5);
//托管同意协议
$tg_agreesys1=Options::get_options('tgagree_options1',$this->lang);
$this->assign("tg_agreesys1",$tg_agreesys1);
$tg_agreesys2=Options::get_options('tgagree_options2',$this->lang);
$this->assign("tg_agreesys2",$tg_agreesys2);
$tg_agreesys3=Options::get_options('tgagree_options3',$this->lang);
$this->assign("tg_agreesys3",$tg_agreesys3);
$tg_agreesys4=Options::get_options('tgagree_options4',$this->lang);
$this->assign("tg_agreesys4",$tg_agreesys4);
$tg_agreesys5=Options::get_options('tgagree_options5',$this->lang);
$this->assign("tg_agreesys5",$tg_agreesys5);
//托管同意协议
$org_agreesys= Db::name('org_temp')->where(['code'=>'orgagree_options'])->find();
$this->assign("org_agreesys",$org_agreesys);
//登录掌柜文化金服token
$this->assign("user_token",session('user_token'));
//浏览器检测
$broswer=getBroswer(true);
$this->assign('broswer', $broswer);
}
// 获取sign
protected function getSign2($data){
$aes=config('aes');
$crypt = new \Aes(\Aes::AES_128_CBC);
$crypt->setKey($aes['key']);
$crypt->setIV($aes['iv']);
if (isset($data['token']))
unset($data['token']);
// 对数组的值按key排序
ksort($data);
// 生成url的形式
$params = http_build_query($data);
// 生成sign
$sign = md5($params.$aes['key']);
return $crypt->enUrl($sign);
}
/**
* 上传方法
*/
public function upload(Request $request){
// 获取表单上传文件
$key=$request->param('key');
if(!$key)return $this->error('參數錯誤');
$file = request()->file($key);
// 移动到框架应用根目录/uploads/ 目录下
$uploadpath=config('upload_path');
$path=ROOT_PATH . config('upload_path');
$validate = config('upload_validate');
$info = $file->validate($validate)->move($path);
if($info){
$data=array();
$data['ext']=$info->getExtension();
$data['path']=$uploadpath.DS.$info->getSaveName();
$data['filename']=$info->getFilename();
return $this->success('上傳成功','',$data);
}else{
return $this->error($file->getError());
}
}
protected function getUserProfile(){
$url=$this->hostpath."/api/user/profiles";
$userinfo=[];
try {
$apitoken=session("api_token");
$res=go_curl($url,'GET',false,["Accept:application/json","Authorization:Bearer ".$apitoken]);
$userinfo=json_decode($res,true);
if(empty($res)){
$userinfo=[];
}
}catch (\Exception $e){
}
return $userinfo;
}
}