<?php
namespace siruisoft\admin\controller;

use think\facade\Cache;

class Sysconfig extends Adminbase
{

	function site(){
		if($this->request->post()){
			$data['web_open']  =  input('post.web_open/d');
			$data['site_name'] = input('post.site_name/s');
			$data['site_keywords'] = input('post.site_keywords/s');
			$data['site_slogan'] = input('post.site_slogan/s');
			$data['site_home_slogan'] = input('post.site_home_slogan/s');
			$data['site_description'] = input('post.site_description/s');
			$data['site_copyright'] = input('post.site_copyright/s');
			$data['site_logo'] = input('post.site_logo/d');
			$data['site_logo_mobile'] = input('post.site_logo_mobile/d');
			$data['wx_qrcode'] = input('post.wx_qrcode/d');
			$data['site_qq'] = input('post.site_qq/s');
			$data['site_phone'] = input('post.site_phone/s');
			$data['site_analytics_open'] = input('post.site_analytics_open/d');
			$data['site_analytics_code'] = input('post.site_analytics_code/s');
        	try{
        		model('Xdata')->put("admin_sysconfig:site", $data);
        		$this->log_record('站点配置修改');
        		return json(['error'=>0,'msg'=>'操作成功']);
        	}catch(Exception $e){
        		return json(['error'=>1,'msg'=>'操作失败']);
        	}
		}
        $row =  model('Xdata')->get("admin_sysconfig:site");
        $this->assign('row',$row);
		return $this->fetch();
	}

	


	


	/**
     * [sms 短信设置]
     * @Author   思睿软件<363359328@qq.com>
     * @DateTime 2020-01-02T16:12:59+0800
     * @return   [type]                   [description]
     */
	function sms(){
		if($this->request->post()){
			$data['sms_option'] = input('post.sms_option/d');
			$data['live_notice'] = input('post.live_notice/d');
        	try{
        		model('Xdata')->put("admin_sysconfig:sms", $data);
        		$this->log_record('短信基本设置');
        		return json(['error'=>0,'msg'=>'操作成功']);
        	}catch(Exception $e){
        		return json(['error'=>1,'msg'=>'操作失败']);
        	}
		}
        $row =  model('Xdata')->get("admin_sysconfig:sms");
        $this->assign('row',$row);
        $row1= model('Xdata')->get("admin_sysconfig:alisms");
        $this->assign('row1',$row1);
		return $this->fetch();
	}


	//阿里云短信设置
	function alisms(){
		if($this->request->post()){
			$data['accessKeyId'] = input('post.accessKeyId/s');
			$data['accessKeySecret'] = input('post.accessKeySecret/s');
			$data['SignName'] = input('post.SignName/s');
			$data['TemplateCode'] = input('post.TemplateCode/s');
			$data['NotifyTemplateCode'] = input('post.NotifyTemplateCode/s');
			$data['GoodsNotifyTemplateCode'] = input('post.GoodsNotifyTemplateCode/s');
        	try{
        		model('Xdata')->put("admin_sysconfig:alisms", $data);
        		$this->log_record('阿里云短信接口设置');
        		return json(['error'=>0,'msg'=>'操作成功']);
        	}catch(Exception $e){
				return json(['error'=>1,'msg'=>'操作失败']);
        	}
		}
        $row =  model('Xdata')->get("admin_sysconfig:alisms");
        $this->assign('row',$row);
		return $this->fetch();
	}


	

	//附件配置 基本配置
	function attach(){
		if($this->request->post()){
			$data['attach_max_size'] = input('post.attach_max_size/f');
			$data['attach_allow_extension'] = input('post.attach_allow_extension/s');
			$data['real_delete'] = input('post.real_delete/d');	
        	try{
        		model('Xdata')->put("admin_sysconfig:attach", $data);
        		$this->log_record('上传基本设置');
        		return json(['error'=>0,'msg'=>'操作成功']);
        	}catch(Exception $e){
        		return json(['error'=>1,'msg'=>'操作失败']);
        	}
		}
        $row =  model('Xdata')->get("admin_sysconfig:attach");
        $this->assign('row',$row);
        $row1 =  model('Xdata')->get("admin_sysconfig:attachimage");
        $this->assign('row1',$row1);
		return $this->fetch();
	}


	

	//附件配置 图片配置
	function attachimage(){
		if($this->request->post()){
			$data['attach_max_size'] = input('post.attach_max_size/f');
			$data['attach_allow_extension'] = input('post.attach_allow_extension/s');
        	try{
        		model('Xdata')->put("admin_sysconfig:attachimage", $data);
        		$this->log_record('上传图片设置');
        		return json(['error'=>0,'msg'=>'操作成功']);
        	}catch(Exception $e){
        		return json(['error'=>1,'msg'=>'操作失败']);
        	}
		}
        $row =  model('Xdata')->get("admin_sysconfig:attachimage");
        $this->assign('row',$row);
		return $this->fetch();
	}


}