From fac4bc321fd8174c86ad39ba5ee313f92f4f9f58 Mon Sep 17 00:00:00 2001 From: liufumingren Date: Mon, 21 Sep 2026 17:34:24 +0800 Subject: [PATCH] 1 --- application/index/controller/Index.php | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/application/index/controller/Index.php b/application/index/controller/Index.php index 84cf3b4..622b931 100644 --- a/application/index/controller/Index.php +++ b/application/index/controller/Index.php @@ -401,18 +401,11 @@ class Index extends Frontend } } - private function getAuthUrl($type, $view, $state = '') + private function getAuthUrl($type, $view) { $component_token = $this->component_token(); $preauthcode = $this->create_preauthcode(); - - // 回跳地址必须携带 state:微信只会额外回传 auth_code/expires_in, - // 不带 state 时 authNotic 无法定位授权上下文(会报“参数不完整”) - $redirectUri = "https://ye4s.wms.gztbyc.com/index/index/authNotic"; - if (!empty($state)) { - $redirectUri .= '?state=' . $state; - } - $redirect_uri = urlencode($redirectUri); + $redirect_uri = urlencode("https://ye4s.wms.gztbyc.com/index/index/authNotic"); switch ($view) { case 'pc': @@ -540,21 +533,15 @@ class Index extends Frontend return view('error', ['msg' => '系统处理异常,请稍后重试']); } } - public function auth($state = null) + public function auth($state) { - // 兼容未传 state 的情况(如直接访问 /index/index/auth),避免"方法参数错误:state" - if (empty($state)) { - $state = $this->request->get('state', ''); - } - \think\Log::info('进入授权页 auth,state: ' . $state); - // 获取参数 $type = $this->request->get('type', 3); // 默认授权所有权限 $view = $this->request->get('view', 'pc'); // 默认PC端 $appid = $this->request->get('appid', ''); // 可选:指定要授权的公众号appid - // 生成授权链接(带上 state,微信回跳 authNotic 时才能还原上下文) - $authUrl = $this->getAuthUrl($type, $view, $state); + // 生成授权链接 + $authUrl = $this->getAuthUrl($type, $view); if (empty($authUrl)) { $this->error('获取授权链接失败,请检查配置');