72 lines
2.1 KiB
PHP
72 lines
2.1 KiB
PHP
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: lock
|
|
* Date: 2021/12/10
|
|
* Time: 8:21 AM
|
|
*/
|
|
|
|
namespace app\index\controller;
|
|
|
|
|
|
use app\common\classLibrary\ClWechat;
|
|
use think\Request;
|
|
use think\Session;
|
|
|
|
class SysConfig extends Common
|
|
{
|
|
/**
|
|
* update
|
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|\think\response\View
|
|
*/
|
|
public function edit()
|
|
{
|
|
$key = Request::instance()->param('key');
|
|
$url = config('api_domain').'/config/get';
|
|
$session = Session::get('admin');
|
|
$params = array();
|
|
$params['token'] = $session['password'];
|
|
$params['key'] = $key;
|
|
$params['debug'] = 1;
|
|
$result = ClWechat::http_post($url,$params);
|
|
$json_arr = json_decode($result,true);
|
|
$this->assign('info',$json_arr['info']);
|
|
return view();
|
|
}
|
|
|
|
/**
|
|
* actionUpdate
|
|
* @return \think\response\Json
|
|
*/
|
|
public function actionUpdate()
|
|
{
|
|
$field_arr = array(
|
|
array('field_name' => 'id','rule' => 'require|require'),
|
|
array('field_name' => 'value','rule' => 'require'),
|
|
);
|
|
$check_arr = $this->checkHave($field_arr);
|
|
if($check_arr[self::$error_code_name] == 0)
|
|
{
|
|
$url = config('api_domain').'/config/update';
|
|
$session = Session::get('admin');
|
|
$params = array();
|
|
$params['token'] = $session['password'];
|
|
$params['debug'] = 1;
|
|
$params['id'] = $check_arr[self::$data_name]['id'];
|
|
$params['value'] = $check_arr[self::$data_name]['value'];
|
|
$result = ClWechat::http_post($url,$params);
|
|
$json_arr = json_decode($result,true);
|
|
self::$result = $json_arr;
|
|
}else
|
|
{
|
|
if($check_arr[self::$error_code_name] == 1)
|
|
{
|
|
self::$result[self::$error_code_name] = 10004;
|
|
self::$result[self::$error_message] = $check_arr[self::$error_message];
|
|
}else{
|
|
self::$result[self::$error_code_name] = 10001;
|
|
}
|
|
}
|
|
return json(self::$result);
|
|
}
|
|
} |