'common\helpers\CaptchaAction', 'width' => 120, 'height' => 40, 'padding' => 0, 'minLength' => 4, 'maxLength' => 4, 'offset'=>8, //设置字符偏移量 有效果 'testLimit'=>1, ]; return $actions; } /** * 请求服务器时间差 * @return mixed * @throws \yii\web\HttpException */ public function actionDaysDiff(){ return static::notice(['daysDiff'=>Yii::$app->params['daysDiff']]); } /** * 请求页面数据 * @return mixed * @throws \yii\web\HttpException */ public function actionPageData() { $pageId = PageSnowFake::instance()->generateId(); return static::notice(['pageId'=>$pageId]); } public function actionBaseInfo(){ // 会员级别 $decLevels = Cache::getDecLevelConfig(); // 聘级 $empLevels = Cache::getEmpLevelConfig(); // 注册类型 $regTypes = RegType::getTypes(); // 类型 $dealTypes = DealType::getAllTypes(); // 体系 $systems = UserSystem::getAllSystems(); // 菜单 $menu = require Yii::getAlias('@backendApi/config/menu.php'); $menu = $this->_childMenu($menu); // 管理员角色 $adminRoles = Cache::getAdminRole(); // 超级管理员角色ID $superAdminRoleId = Yii::$app->params['superAdminRoleId']; // 时间差 $daysDiff = Yii::$app->params['daysDiff']; // 钱包 $shopWalletType = Yii::$app->params['shopWalletType']; // 全部报单中心角色 $decRoles = DecRole::find()->where('1=1')->select('ID,ROLE_NAME')->indexBy('ID')->asArray()->all(); // 全部子公司 $subCompanies = []; // 全部会员状态 $allStatus = Yii::$app->params['userStatus']; // 全部银行 $allOpenBank = OpenBank::find()->where('1=1 AND STATUS=1')->select('BANK_NAME,BANK_CODE')->indexBy('BANK_CODE')->asArray()->all(); // 钱包 $allNation = Yii::$app->params['nation']; // 期数 $period = Period::instance(); $periodNum = $period->getNowPeriodNum(); return [ 'decLevels' => $decLevels, 'empLevels' => $empLevels, 'regTypes' => $regTypes, 'dealTypes' => $dealTypes, 'systems' => $systems, 'menu' => $menu, 'adminRoles' => $adminRoles, 'superAdminRoleId' => $superAdminRoleId, 'daysDiff' => $daysDiff, 'shopWalletType' => $shopWalletType, 'decRoles' => $decRoles, 'subCompanies' => $subCompanies, 'allStatus' => $allStatus, 'allOpenBank' => $allOpenBank, 'allNation' => $allNation, 'nowPeriodNum' => $periodNum, ]; } private function _childMenu($parentArray){ $menuResult = []; foreach($parentArray as $key => $parentMenu){ // 菜单是否显示 if(isset($parentMenu['show']) && !$parentMenu['show']){ continue; } // 查看是否有该控制器的权限 if(isset($parentMenu['controller']) && $parentMenu['controller']){ if(!Yii::$app->user->validateAdminController($parentMenu['controller'])) continue; } // 查看是否有权限 if(isset($parentMenu['action']) && $parentMenu['action']){ if(!Yii::$app->user->validateAdminAction($parentMenu['controller'], $parentMenu['action'])) continue; } // 子菜单同样设置 if(isset($parentMenu['child']) && !empty($parentMenu['child'])){ $parentMenu['child'] = $this->_childMenu($parentMenu['child']); } // 如果在白名单的不显示菜单 if(isset($parentMenu['controller']) && $parentMenu['controller']){ if(Yii::$app->user->noCheckAdminController($parentMenu['controller'])) continue; } $menuResult[] = $parentMenu; } return $menuResult; } }