mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-05-22 22:59:14 +08:00
增加微信小程序配置
This commit is contained in:
parent
ba3fd7fae9
commit
390e86204a
@ -3,6 +3,7 @@
|
|||||||
namespace app\data\controller;
|
namespace app\data\controller;
|
||||||
|
|
||||||
use think\admin\Controller;
|
use think\admin\Controller;
|
||||||
|
use think\admin\storage\LocalStorage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 应用参数配置
|
* 应用参数配置
|
||||||
@ -11,6 +12,24 @@ use think\admin\Controller;
|
|||||||
*/
|
*/
|
||||||
class Config extends 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
|
* @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('配置保存成功!');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -23,20 +23,16 @@ class Wxapp extends Controller
|
|||||||
protected $config;
|
protected $config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 接口初始化
|
* 接口服务初始化
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
*/
|
*/
|
||||||
protected function initialize()
|
protected function initialize()
|
||||||
{
|
{
|
||||||
$this->config = [
|
$this->config = [
|
||||||
'appid' => '',
|
'appid' => sysconf('data.wxapp_appid'),
|
||||||
'appsecret' => '',
|
'appsecret' => sysconf('data.wxapp_appkey'),
|
||||||
// 商户支付配置
|
|
||||||
'mch_id' => '',
|
|
||||||
'mch_key' => '',
|
|
||||||
// 支付证书配置
|
|
||||||
'ssl_key' => '', // 需要配置证书文件的绝对路径
|
|
||||||
'ssl_cer' => '', // 需要配置证书文件的绝对路径
|
|
||||||
// 支付缓存配置
|
|
||||||
'cache_path' => $this->app->getRuntimePath() . 'wxapp' . DIRECTORY_SEPARATOR,
|
'cache_path' => $this->app->getRuntimePath() . 'wxapp' . DIRECTORY_SEPARATOR,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
30
app/data/view/config/wxapp.html
Normal file
30
app/data/view/config/wxapp.html
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
{extend name="../../admin/view/main"}
|
||||||
|
|
||||||
|
{block name="content"}
|
||||||
|
<div class="think-box-shadow">
|
||||||
|
<form class="layui-form layui-card noshadow" action="{:request()->url()}" data-auto="true" method="post" autocomplete="off" style="width:850px">
|
||||||
|
<div class="layui-card-header text-center margin-20 font-w7 color-text layui-bg-gray border-radius-5">
|
||||||
|
{$title|default='小程序接口配置'}<span class="color-desc font-s12"> ( 需要从微信公众号平台获取 )</span>
|
||||||
|
</div>
|
||||||
|
<div class="layui-card-body padding-left-40 padding-top-30 padding-bottom-0">
|
||||||
|
|
||||||
|
<label class="layui-form-item margin-bottom-20 block relative">
|
||||||
|
<span class="color-green font-s14 font-w7 margin-right-10">小程序 ID</span><span class="nowrap color-desc">AppID</span>
|
||||||
|
<input name="data.wxapp_appid" required maxlength="18" pattern="^wx[0-9a-z]{16}$" placeholder="请输入18位小程序 AppID(必填)" value="{:sysconf('data.wxapp_appid')}" class="layui-input">
|
||||||
|
<span class="help-block">微信小程序 AppID 需要微信公众号平台获取!</span>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<label class="layui-form-item margin-bottom-20 block relative">
|
||||||
|
<span class="color-green font-s14 font-w7 margin-right-10">小程序密钥 Secret</span><span class="nowrap color-desc">AppSecret</span>
|
||||||
|
<input name="data.wxapp_appkey" required maxlength="32" pattern="^[0-9a-z]{32}$" placeholder="请输入32位小程序 AppSecret(必填)" value="{:sysconf('data.wxapp_appkey')}" class="layui-input">
|
||||||
|
<span class="help-block">微信小程序 AppSecret 需要微信公众号平台获取!</span>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<div class="hr-line-dashed margin-top-30"></div>
|
||||||
|
<div class="layui-form-item text-center padding-left-20">
|
||||||
|
<button class="layui-btn" data-submit>保存数据</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
{/block}
|
Loading…
x
Reference in New Issue
Block a user