header("referer"); // $userInfo = WechatService::getWebOauthInfo($source,1,false); $userInfo['openid'] = 123; if (empty($userInfo['openid'])) { return success("ok",['url' => $userInfo['url'],'type' => 1]); // 跳转 } else { $user = (new SystemUserOpen)->where(['openid' => $userInfo['openid']])->findOrEmpty(); if ($user->isEmpty()) { return success("ok",['url' => '','type' => 2,'token' => ['access_token' => $userInfo['openid']]]); // 跳到绑定用户 } $loginUser = (new SystemUser)->where(['id' => $user['uid']])->findOrEmpty(); return success("ok",['url' => '','type' => 3,'menu' => $this->getMenu(),'token' => get_object_vars((new Auth)->guard("admin")->login($loginUser))]); // 正常登陆进入 } } catch (\Throwable $th) { return error($th->getMessage()); } } /** * @return array[] */ protected function getMenu(): array { return [ [ "path" => "/dashboard", "name" => "dashboard", "component" => "dashboard", "meta" => [ "icon" => "", "title" => "总揽", "type" => "menu" ] ],[ "path" => "/shop/detail", "name" => "shop/detail", "component" => "shop/detail", "meta" => [ "icon" => "", "title" => "店铺详情", "type" => "menu" ] ],[ "path" => "/print", "name" => "print/index", "component" => "print/index", "meta" => [ "icon" => "", "title" => "打印机", "type" => "menu" ] ],[ "path" => "/print/price", "name" => "print/price", "component" => "print/price", "meta" => [ "icon" => "", "title" => "价格设置", "type" => "menu" ] ],[ "path" => "/print/discount", "name" => "print/discount", "component" => "print/discount", "meta" => [ "icon" => "", "title" => "折扣设置", "type" => "menu" ] ],[ "path" => "/order", "name" => "order/index", "component" => "order/index", "meta" => [ "icon" => "", "title" => "实时订单", "type" => "menu" ] ],[ "path" => "/turnover/index", "name" => "turnover/index", "component" => "turnover/index", "meta" => [ "icon" => "", "title" => "营业额", "type" => "menu" ] ],[ "path" => "/member/index", "name" => "member/index", "component" => "member/index", "meta" => [ "icon" => "", "title" => "会员卡", "type" => "menu" ] ],[ "path" => "/wallet/index", "name" => "wallet/index", "component" => "wallet/index", "meta" => [ "icon" => "", "title" => "我的钱包", "type" => "menu" ] ],[ "path" => "/shop/bind", "name" => "shop/bind", "component" => "shop/bind", "meta" => [ "icon" => "", "title" => "绑定门店", "type" => "menu" ] ],[ "path" => "/shop/change", "name" => "shop/change", "component" => "shop/change", "meta" => [ "icon" => "", "title" => "切换门店", "type" => "menu" ] ],[ "path" => "/shop/msg", "name" => "shop/msg", "component" => "shop/msg", "meta" => [ "icon" => "", "title" => "消息开关", "type" => "menu" ] ] ]; } /** * 获取当前请求的完整 URL * @param bool $withQuery 是否包含查询参数 * @return string */ protected function getFullUrl($withQuery = true) { // 1. 获取协议(支持代理) $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443) ? 'https' : 'http'; // 2. 获取主机名(支持代理) $host = $_SERVER['HTTP_X_FORWARDED_HOST'] ?? $_SERVER['HTTP_HOST'] ?? $_SERVER['SERVER_NAME'] ?? 'localhost'; // 3. 获取端口(支持代理) $port = $_SERVER['HTTP_X_FORWARDED_PORT'] ?? $_SERVER['SERVER_PORT'] ?? 80; // 4. 获取请求URI(包含路径和查询参数) $requestUri = $_SERVER['REQUEST_URI'] ?? '/'; // 5. 构建基础URL $baseUrl = $protocol . '://' . $host; // 6. 如果不是标准端口,添加端口号 $isStandardPort = ($protocol === 'http' && $port == 80) || ($protocol === 'https' && $port == 443); if (!$isStandardPort) { $baseUrl .= ':' . $port; } // 7. 返回完整URL return $baseUrl . $requestUri; } }