107 lines
2.9 KiB
PHP
Executable File
107 lines
2.9 KiB
PHP
Executable File
<?php
|
|
|
|
namespace app\admin\controller;
|
|
|
|
use \think\facade\Request;
|
|
use \think\facade\View;
|
|
use think\facade\Db;
|
|
|
|
|
|
class Config extends Base
|
|
{
|
|
public function base(Request $request)
|
|
{
|
|
$config = getConfig('base');
|
|
View::assign("key", "base");
|
|
View::assign("data", $config);
|
|
return View::fetch('Config/base');
|
|
}
|
|
|
|
//微信支付
|
|
public function weixinpay(Request $request)
|
|
{
|
|
$config = getConfig('weixinpay');
|
|
View::assign("key", "weixinpay");
|
|
View::assign("data", $config);
|
|
return View::fetch('Config/weixinpay');
|
|
}
|
|
|
|
//签到设置
|
|
public function sign(Request $request)
|
|
{
|
|
$config = getConfig('sign');
|
|
|
|
View::assign("key", "sign");
|
|
View::assign("data", $config);
|
|
return View::fetch('Config/sign');
|
|
}
|
|
|
|
//上传设置
|
|
public function uploads(Request $request)
|
|
{
|
|
$config = getConfig('uploads');
|
|
View::assign("key", "uploads");
|
|
View::assign("data", $config);
|
|
return View::fetch('Config/uploads');
|
|
}
|
|
|
|
//微信公众号
|
|
public function wechatofficialaccount(Request $request)
|
|
{
|
|
$config = getConfig('wechatofficialaccount');
|
|
View::assign("key", "wechatofficialaccount");
|
|
View::assign("data", $config);
|
|
return View::fetch('Config/weixinpay');
|
|
}
|
|
|
|
//系统设置
|
|
public function systemconfig(Request $request)
|
|
{
|
|
$config = getConfig('systemconfig');
|
|
View::assign("key", "systemconfig");
|
|
View::assign("data", $config);
|
|
return View::fetch('Config/systemconfig');
|
|
}
|
|
|
|
//修改
|
|
public function update()
|
|
{
|
|
$data = input("post.");
|
|
$data['update_time'] = time();
|
|
|
|
// 处理同步地址数据格式
|
|
if ($data['key'] == 'systemconfig') {
|
|
$syncAddresses = [];
|
|
$addressNames = isset($data['sync_address_names']) ? $data['sync_address_names'] : [];
|
|
$addressUrls = isset($data['sync_address_urls']) ? $data['sync_address_urls'] : [];
|
|
|
|
// 移除原有数组
|
|
unset($data['sync_address_names']);
|
|
unset($data['sync_address_urls']);
|
|
|
|
// 构建新的数据格式
|
|
for ($i = 0; $i < count($addressUrls); $i++) {
|
|
if (!empty($addressUrls[$i])) {
|
|
$syncAddresses[] = [
|
|
'name' => isset($addressNames[$i]) ? $addressNames[$i] : '',
|
|
'sync_address' => $addressUrls[$i]
|
|
];
|
|
}
|
|
}
|
|
|
|
// 使用新的格式设置同步地址
|
|
$data['sync_address'] = $syncAddresses;
|
|
}
|
|
|
|
$result = setConfig($data['key'], $data);
|
|
if ($result) {
|
|
return $this->renderSuccess('修改成功');
|
|
} else {
|
|
return $this->renderError('修改失败');
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
?>
|