<?php

namespace Admin\Controller;

use Think\Controller;

/**
 * 系统设置（控制器）
 *
 * @author sunxiaodong
 */
class XitongController extends CheckController {

    public function index() {

        if (IS_POST) {
            $id = I('post.id');
            $data = I('post.');
            $data['content'] = $_POST['content'];
            $config = array(//配置格式
                'rootPath' => './Public/upload/',
                'maxSize' => '3145728', // 设置LOGO上传大小
                'exts' => array('png', 'jpg', 'jpeg'), //允许上传的文件后缀
            );



            if (!empty($_FILES['img']['name'])) {

                $upload = new \Think\Upload($config);      //掉用TP自带的upload上传工具
                // 上传文件
                $info = $upload->uploadOne($_FILES['img']);   //获取到表单的name 和文件路径
                $data['logo'] = "/Public/upload/" . $info['savepath'] . $info['savename'];
                if (!$info) {
                    $this->error($upload->getError());
                    die();
                }
            }

            if (M('setting')->where("id=$id")->save($data)) {
                echo "<script>alert('修改成功')</script>";
            } else {
                echo "<script>alert('修改成功')</script>";
            }
        }
        $list = M('setting')->find();

        $on = I('column');
        $this->assign('on', $on);
        $this->assign("list", $list);
        $this->display();
    }

    //微信支付配置

    public function weixin() {
        if (IS_POST) {
            $id = I('post.id');
            $data = I('post.');
            if (M('weixinpeizhi')->where("id=$id")->save($data)) {
                echo "<script>alert('修改成功')</script>";
            } else {
                $this->error("保存失败!");
            }
        }

        $list = M('weixinpeizhi')->find();

        $on = I('column');
        $this->assign("list", $list);
        $this->assign('on', $on);
        $this->display();
    }

    //支付宝支付配置

    public function zhifubao() {
                if (IS_POST) {
            $id = I('post.id');
            $data = I('post.');
            if (M('zhifubaopeizhi')->where("id=$id")->save($data)) {
                echo "<script>alert('修改成功')</script>";
            } else {
                $this->error("保存失败!");
            }
        }
        $list = M('zhifubaopeizhi')->find();
         $this->assign("list", $list);
        $on = I('column');
       
        $this->assign('on', $on);
        $this->display();
    }

    //永纯配置

    public function yongchun() {
        if (IS_POST) {
            $id = I('post.id');
            $data = I('post.');
            if (M('yongchun')->where("id=$id")->save($data)) {
                echo "<script>alert('修改成功')</script>";
            } else {
                $this->error("保存失败!");
            }
        }
        $list = M('yongchun')->find();
         $this->assign("list", $list);
        $on = I('column');
        $this->assign('on', $on);
        $this->display();
    }

}
