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; } }