123 lines
4.3 KiB
PHP
123 lines
4.3 KiB
PHP
<?php
|
|
/**
|
|
* SAAS应用系统 --- 十年开发经验汇集巨献!
|
|
* ==========================================================
|
|
* Copy right 2020-2050 成都众联思索科技有限公司,保留所有权利。
|
|
* ----------------------------------------------------------
|
|
* 官方网址: https://www.zoomtk.com
|
|
* 这不是自由软件!未经允许不得用于商业目或程序代码摘取及修改。
|
|
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布传播。
|
|
* 唯一发布渠道www.zoomtk.com;非官方渠道统一视为侵权行为。
|
|
* ==========================================================
|
|
*/
|
|
|
|
namespace addon\supply\shop\controller;
|
|
|
|
use app\Controller;
|
|
use app\model\shop\Shop;
|
|
use app\model\system\Menu;
|
|
use app\model\system\Site;
|
|
use app\model\system\User as UserModel;
|
|
use app\model\web\Config as ConfigModel;
|
|
use app\model\web\WebSite;
|
|
|
|
class BaseSupplyshop extends Controller
|
|
{
|
|
protected $uid;
|
|
protected $url;
|
|
protected $app_module = "shop";
|
|
protected $addon = '';
|
|
protected $site_id;
|
|
protected $website_id;
|
|
protected $shop_info;
|
|
protected $replace = []; //视图输出字符串内容替换 相当于配置文件中的'view_replace_str'
|
|
protected $init_menu = [];
|
|
protected $crumbs_array = [];
|
|
|
|
public function initialize()
|
|
{
|
|
//检测基础登录
|
|
$user_model = new UserModel();
|
|
$this->url = request()->parseUrl();
|
|
$this->addon = request()->addon() ? request()->addon() : '';
|
|
$this->user_info = $user_model->userInfo($this->app_module);
|
|
if(empty($this->user_info)) {
|
|
$this->redirect(url('shop/login/login'));
|
|
return;
|
|
}
|
|
$this->site_id = request()->siteid($this->user_info['site_id']);
|
|
$this->uid = $user_model->uid($this->app_module, $this->site_id);
|
|
$this->assign("user_info", $this->user_info);
|
|
if ($this->site_id > 0) {
|
|
//获取店铺信息
|
|
//获取店铺信息
|
|
$site_model = new Site();
|
|
$shop_info = $site_model->getSiteInfo([['site_id', '=', $this->site_id]], 'site_id,agent_id,is_try,group_id,group_name,site_name,contacts_mobile,logo,seo_keywords,seo_description,create_time,expire_time');
|
|
$this->website_id = $this->site_id;
|
|
$this->shop_info = $shop_info['data'];
|
|
$this->assign("shop_info", $shop_info['data']);
|
|
}
|
|
if (!request()->isAjax()) {
|
|
$this->initBaseInfo();
|
|
$this->replace = [
|
|
'SHOP_SUPPLY_LOCAL_CSS' => __ROOT__ . '/addon/supply/shop/view/public/css',
|
|
'SHOP_SUPPLY_LOCAL_JS' => __ROOT__ . '/addon/supply/shop/view/public/js',
|
|
'SHOP_SUPPLY_LOCAL_IMG' => __ROOT__ . '/addon/supply/shop/view/public/img',
|
|
];
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 加载基础信息
|
|
*/
|
|
private function initBaseInfo()
|
|
{
|
|
//获取一级权限菜单
|
|
$menu_model = new Menu();
|
|
$info_result = $menu_model->getMenuInfoByUrl($this->url, $this->app_module, $this->addon);
|
|
$info = [];
|
|
if (!empty($info_result["data"])) {
|
|
$info = $info_result["data"];
|
|
}
|
|
|
|
$this->assign("menu_info", $info);
|
|
//加载网站基础信息
|
|
$website = new WebSite();
|
|
$website_info = $website->getWebSite([['site_id', '=', 0]], 'title,logo,desc,keywords,web_status,close_reason,web_qrcode,web_phone');
|
|
$this->assign("website_info", $website_info['data']);
|
|
//加载版权信息
|
|
$config_model = new ConfigModel();
|
|
$copyright = $config_model->getCopyright();
|
|
$this->assign('copyright', $copyright['data']['value']);
|
|
}
|
|
|
|
/**
|
|
* 验证登录
|
|
*/
|
|
protected function checkLogin()
|
|
{
|
|
$config_model = new ConfigModel();
|
|
if (!$this->uid) {
|
|
if (!request()->isAjax()) {
|
|
//验证基础登录
|
|
$this->redirect(url('shop/login/login'));
|
|
} else {
|
|
return $config_model->error([], 'NOT_LOGIN');
|
|
}
|
|
} else {
|
|
return $config_model->success([]);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 获取顶级菜单
|
|
*/
|
|
protected function getTopMenu()
|
|
{
|
|
$list = array_filter($this->menus, function ($v) {
|
|
return $v['parent'] == '0';
|
|
});
|
|
return $list;
|
|
}
|
|
}
|