isMobile() || $pc_on_display == 0) { return $this->redirect(Url::build('wap/index/index')); } try { $this->redisModel = new Redis(); } catch (\Exception $e) { parent::serRedisPwd($e->getMessage()); } $NoWechantVisitWhite = $this->NoWechantVisitWhite(); $this->subjectUrl = getUrlToDomain(); try { $uid = User::getActiveUid(); if (!empty($uid)) { $this->userInfo = User::getUserInfo($uid); MemberShip::memberExpiration($uid); $this->uid = $this->userInfo['uid']; $this->phone = User::getLogPhone($uid); if (!isset($this->userInfo['uid'])) $this->userInfo['uid'] = 0; if (!isset($this->userInfo['avatar'])) $this->userInfo['avatar'] = ''; if (!isset($this->userInfo['nickname'])) $this->userInfo['nickname'] = ''; if (!$NoWechantVisitWhite) { if (!$this->userInfo || !isset($this->uid)) return $this->failed('读取用户信息失败!'); if (!$this->userInfo['status']) return $this->failed('已被禁止登陆!'); } } } catch (\Exception $e) { Cookie::delete('is_login'); Cookie::delete('__login_phone'); Session::clear('web'); if (!$NoWechantVisitWhite) { if ($this->request->isAjax()) return JsonService::fail('请登录再进行访问'); else return $this->redirect(Url::build('web/index/index')); } } $codeUrl = SystemConfigService::get('wechat_qrcode'); $balance_switch = SystemConfigService::get('balance_switch');//余额开关 $is_alipay = SystemConfigService::get('pc_alipay_code_scanning_payment_switch');//pc端支付宝扫码开关 $is_wechat = SystemConfigService::get('pc_wechat_code_scanning_payment_switch');//pc端微信扫码支付开关 $seo_title = SystemConfigService::get('seo_title');//SEO标题 $seo_description = SystemConfigService::get('description');//SEO内容 $now_money = isset($this->userInfo['now_money']) ? $this->userInfo['now_money'] : 0; $business = isset($this->userInfo['business']) ? $this->userInfo['business'] : 0;//是否是讲师 $this->assign([ 'is_yue' => $balance_switch, 'is_alipay' => $is_alipay, 'code_url' => $codeUrl, 'is_wechat' => $is_wechat, 'phone' => $this->phone, 'userInfo' => $this->userInfo, 'seo_title' => $seo_title, 'seo_description' => $seo_description, 'business' => $business, 'now_money' => $now_money, 'Auth_site_name' => SystemConfigService::get('site_name') ]); } /** * 检查白名单控制器方法 存在带名单返回 true 不存在则进行登录 * @return bool */ protected function NoWechantVisitWhite() { list($module, $controller, $action, $className) = $this->getCurrentController(); if (method_exists($className, 'WhiteList')) { $whitelist = $className::WhiteList(); if (!is_array($whitelist)) return false; foreach ($whitelist as $item) { if (strtolower($module . '\\' . $controller . '\\' . $item) == strtolower($module . '\\' . $controller . '\\' . $action)) { return true; } } } return false; } /** * 获取当前的控制器名,模块名,方法名,类名并返回 * @return array */ protected function getCurrentController() { $module = $this->request->module(); $controller = $this->request->controller(); $action = $this->request->action(); if (strstr($controller, '.')) $controllerv1 = str_replace('.', '\\', $controller); else $controllerv1 = $controller; $className = 'app\\' . $module . '\\controller\\' . $controllerv1; return [$module, $controller, $action, $className]; } }