## API配置
>[info]配置文件
配置 商城 用户中心 支付中心 key url id
pacenter.php
配置 支付中心
shop.php
配置商城地址
ucenter.php
配置用户中心
/**
* @desc api url显示
*
*/
public function index(){
$config = [
'shop' => ['label'=>"商城配置"],
'ucenter' => ['label'=>"用户中心配置"],
'paycenter' => ['label'=>"支付中心配置"],
];
foreach ($config as $key => $value) {
$config[$key]['form'] = config($key)?:$this->default;
}
$data['config'] = $config;
return view('configapi',$data);
}
/**
* @desc 保存数据
*
*/
public function save(){
$type = post_data('type');
if(!$type){
exit(json_encode(['status'=>0,'msg'=>__('修改失败')]));
}else{
$file = BASE.'/configs/'.$type.'.php';
$data = post_data('form');
foreach ($this->default as $key => $value) {
$new[$key] = trim($data[$key]);
}
$flag = file_put_contents($file, "<?php\nreturn ".var_export($data,true)."\n;");
if(!$flag){
exit(json_encode(['status'=>0,'msg'=>__('文件不可写')]));
}
}
exit(json_encode(['status'=>1,'msg'=>__('操作成功') ]));
}