From 390e86204a5a2b6716eca12a2819bb47f876fd16 Mon Sep 17 00:00:00 2001 From: Anyon Date: Mon, 21 Sep 2020 16:43:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BE=AE=E4=BF=A1=E5=B0=8F?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/data/controller/Config.php | 34 +++++++++++++++++++++++++++++++ app/data/controller/api/Wxapp.php | 16 ++++++--------- app/data/view/config/wxapp.html | 30 +++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 10 deletions(-) create mode 100644 app/data/view/config/wxapp.html diff --git a/app/data/controller/Config.php b/app/data/controller/Config.php index 55dd02fab..0403bb4bc 100644 --- a/app/data/controller/Config.php +++ b/app/data/controller/Config.php @@ -3,6 +3,7 @@ namespace app\data\controller; use think\admin\Controller; +use think\admin\storage\LocalStorage; /** * 应用参数配置 @@ -11,6 +12,24 @@ use think\admin\Controller; */ class Config extends Controller { + /** + * 微信小程序配置 + * @auth true + * @menu true + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function wxapp() + { + if ($this->request->isGet()) { + $this->title = '微信小程序配置'; + $this->fetch(); + } else { + $this->__save(); + } + } + /** * 首页轮播图片 * @menu true @@ -34,4 +53,19 @@ class Config extends Controller } } } + + /** + * 保存配置参数 + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + private function __save() + { + if ($this->request->isPost()) { + $data = $this->request->post(); + foreach ($data as $k => $v) sysconf($k, $v); + $this->success('配置保存成功!'); + } + } } \ No newline at end of file diff --git a/app/data/controller/api/Wxapp.php b/app/data/controller/api/Wxapp.php index 9c7608e42..ce77ccb0c 100644 --- a/app/data/controller/api/Wxapp.php +++ b/app/data/controller/api/Wxapp.php @@ -23,20 +23,16 @@ class Wxapp extends Controller protected $config; /** - * 接口初始化 + * 接口服务初始化 + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException */ protected function initialize() { $this->config = [ - 'appid' => '', - 'appsecret' => '', - // 商户支付配置 - 'mch_id' => '', - 'mch_key' => '', - // 支付证书配置 - 'ssl_key' => '', // 需要配置证书文件的绝对路径 - 'ssl_cer' => '', // 需要配置证书文件的绝对路径 - // 支付缓存配置 + 'appid' => sysconf('data.wxapp_appid'), + 'appsecret' => sysconf('data.wxapp_appkey'), 'cache_path' => $this->app->getRuntimePath() . 'wxapp' . DIRECTORY_SEPARATOR, ]; } diff --git a/app/data/view/config/wxapp.html b/app/data/view/config/wxapp.html new file mode 100644 index 000000000..84911ae26 --- /dev/null +++ b/app/data/view/config/wxapp.html @@ -0,0 +1,30 @@ +{extend name="../../admin/view/main"} + +{block name="content"} +
+
+
+ {$title|default='小程序接口配置'} ( 需要从微信公众号平台获取 ) +
+
+ + + + + +
+
+ +
+
+
+
+{/block} \ No newline at end of file