From 31749237a42224f30552142d1259097979d32164 Mon Sep 17 00:00:00 2001 From: wanghongjun <1445693971@qq,com> Date: Fri, 14 Jul 2023 10:32:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=95=B0=E6=8D=AE=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/api/controller/Controller.php | 6 +++-- .../api/controller/stadium/Param.php | 26 +++++++++++++++++++ source/application/config.php | 19 +++++++++++--- 3 files changed, 46 insertions(+), 5 deletions(-) create mode 100644 source/application/api/controller/stadium/Param.php diff --git a/source/application/api/controller/Controller.php b/source/application/api/controller/Controller.php index e4e4b23..6483278 100644 --- a/source/application/api/controller/Controller.php +++ b/source/application/api/controller/Controller.php @@ -26,8 +26,10 @@ class Controller extends \think\Controller */ public function _initialize() { - header("Access-Control-Allow-Origin: http://192.168.66.220:8080"); - header("Access-Control-Allow-Origin: http://192.168.66.220:8081"); + $config = config('api_config'); + foreach ($config['access_control_allow_origin'] as $value) { + header("Access-Control-Allow-Origin: ".$value); + } header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE"); header("Access-Control-Allow-Headers: Content-Type"); header("Access-Control-Allow-Credentials: true"); diff --git a/source/application/api/controller/stadium/Param.php b/source/application/api/controller/stadium/Param.php new file mode 100644 index 0000000..3ad996e --- /dev/null +++ b/source/application/api/controller/stadium/Param.php @@ -0,0 +1,26 @@ + $config['host'], + 'port' => $config['port'], + 'appkey' => $config['cid'], + 'secret' => $config['cskey'] + ]; + + $base64 = base64_encode(json_encode($returnArr)) . "=="; + $base64Two = base64_encode($base64); + + return $this->renderSuccess(compact('base64Two')); + } + +} \ No newline at end of file diff --git a/source/application/config.php b/source/application/config.php index de7d099..a368a38 100644 --- a/source/application/config.php +++ b/source/application/config.php @@ -243,11 +243,24 @@ return [ // | 自定义配置 // +---------------------------------------------------------------------- 'api_config' => [ - // 调用网址地址 - 'host_url' => 'https://192.168.66.13:443/artemis', + # 调用网址地址 + 'host' => '192.168.66.13', + # 端口号 'port' => '443', + # 请求key 'cid' => '29940726', + # 请求密钥 'cskey' => 'SkTCnQdFbNW4Z2suNj8P', - 'host_path' => 'http://btgym.xingtongworld.com/index.php?s=' + # 请求智慧景区接口地址 + 'host_url' => 'https://192.168.66.13:443/artemis', + # 脚本数据推送创建数据地址 + //'host_path' => 'http://btgym.xingtongworld.com/index.php?s=' + 'host_path' => 'http://192.168.66.16/index.php?s=', +// 'host_path' => 'http://www.stadium.com/index.php?s=' + # 允许跨域 请求的IP地址 + 'access_control_allow_origin' => [ + 'http://192.168.66.220:8080', + 'http://192.168.66.220:8081' + ] ] ];