81 lines
2.2 KiB
PHP
81 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace app\index\controller;
|
|
|
|
use app\common\controller\Frontend;
|
|
|
|
class Index extends Frontend
|
|
{
|
|
|
|
protected $noNeedLogin = ['*'];
|
|
protected $noNeedRight = '*';
|
|
protected $layout = '';
|
|
|
|
public function index()
|
|
{
|
|
$config = \app\common\model\config\System::getConfig('system');
|
|
|
|
if(isset($config['mobile_pc_route']) && $config['mobile_pc_route'] == 'open'){
|
|
//判断当前是PC还是移动端
|
|
if(!isMobile()){
|
|
//thinkphp5重定向
|
|
$this->redirect(request()->domain().'/index.php?i='.UNIACID.'&route=pc#/page/index');
|
|
exit;
|
|
}
|
|
}
|
|
|
|
|
|
if($config['status'] == 'close'){
|
|
return $this->errorPage('店铺暂不可用,请稍后再试');
|
|
}
|
|
|
|
if(isWeixin()){
|
|
$wxOfficialAccountConfig = \app\common\model\config\System::getConfig('wxOfficialAccount');
|
|
if(isset($wxOfficialAccountConfig['status']) && $wxOfficialAccountConfig['status'] != 'open'){
|
|
return $this->errorPage('该终端暂不可用');
|
|
}
|
|
}else{
|
|
$h5Config = \app\common\model\config\System::getConfig('H5');
|
|
if(isset($h5Config['status']) && $h5Config['status'] != 'open'){
|
|
return $this->errorPage('该终端暂不可用');
|
|
}
|
|
}
|
|
|
|
$this->view->assign('config',$this->getPageConfig());
|
|
|
|
return $this->view->fetch();
|
|
}
|
|
|
|
|
|
/**
|
|
* 获取配置
|
|
* @return false|string
|
|
*/
|
|
public function getPageConfig(){
|
|
global $_W,$_GPC;
|
|
|
|
if(\app\common\library\Platform::getSystemType() == 'single'){
|
|
$data['apiUrl'] = $_W['siteroot'].'/index.php?i='.$_W['uniacid'].'&route=api/';
|
|
}else{
|
|
$data['apiUrl'] = $_W['siteroot'].'/app/index.php?i='.$_W['uniacid'].'&c=entry&m=tuzi_v1&do=index&route=api/';
|
|
}
|
|
|
|
return json_encode($data);
|
|
}
|
|
|
|
/**
|
|
* 错误页面
|
|
* @param $message
|
|
* @return mixed
|
|
*/
|
|
public function errorPage($message){
|
|
$this->view->assign('message',$message);
|
|
return $this->view->fetch('error_page');
|
|
}
|
|
|
|
public function exportConfig(){
|
|
(new \app\common\model\fill\Handle())->export('config_system');
|
|
}
|
|
|
|
}
|