<?php
/**
 * @Statement: [ An Ordinary Person ]
 * @Author: 闻子 < QQ：270988107 >
 * @Copyright: 闻子 2016-2019 All rights reserved.
 *
 *    .--,       .--,
 *   ( (  \.---./  ) )
 *    '.__/o   o\__.'
 *       {=  ^  =}
 *        >  -  <
 *       /       \
 *      //       \\
 *     //|   .   |\\
 *     "'\       /'"_.-~^`'-.
 *        \  _  /--'         `
 *      ___)( )(___
 *     (((__) (__)))    高山仰止,景行行止.虽不能至,心向往之.
 *
 */

namespace app\ohbbs\controller;

use think\Db;

use Env;

use app\common\logic\Upgrade as LogicUpgrade;

use app\common\logic\Config as LogicConfig;

use app\common\controller\Base as BaseController;

class Config extends BaseController
{
	/**
	 * 继承基类
	 * @Author: 闻子 < QQ：270988107 >
	 */
    use Base;

	/**
	 * 定义逻辑
	 * @Author: 闻子 < QQ：270988107 >
	 */
	private static $UpgradeLogic = null;
	private static $ConfigLogic = null;

	/**
	 * 实例化权限
	 * @Author: 闻子 < QQ：270988107 >
	 */
    public function __construct()
    {
    	parent::__construct();
        $userinfo = Db::name('user')->where('id',session('admin.id'))->find();
        if ($userinfo['manager'] != 1) {
        	$this->redirect('/member/index');
        }
        self::$UpgradeLogic = get_sington_object('LogicUpgrade', LogicUpgrade::class);
        self::$ConfigLogic = get_sington_object('LogicConfig', LogicConfig::class);
    }

	/**
	 * 会员管理
	 * @Author: 闻子 < QQ：270988107 >
	 */
    public function user()
    {
    	return view();
    }

	/**
	 * 会员充值
	 * @Author: 闻子 < QQ：270988107 >
	 */
    public function pay()
    {
    	return view();
    }

	/**
	 * 友情链接
	 * @Author: 闻子 < QQ：270988107 >
	 */
    public function link()
    {
    	return view();
    }

	/**
	 * 标签云
	 * @Author: 闻子 < QQ：270988107 >
	 */
    public function tag()
    {
    	return view();
    }
    
	/**
	 * 网站设置
	 * @Author: 闻子 < QQ：270988107 >
	 */
	public function index()
	{
		$data = Db::name('config')->where('id',1)->find();
		$this->request->isPost() && $this->jump(self::$ConfigLogic->formdata(input('post.')));
		return view('',compact('data'));
	}

	/**
	 * 会员升级
	 * @Author: 闻子 < QQ：270988107 >
	 */
	public function upgrade()
	{
		return view();
	}

	/**
	 * 评论列表
	 * @Author: 闻子 < QQ：270988107 >
	 */
	public function comment()
	{
		return view();
	}

    /**
     * 上传LOGO
     * @Author: 闻子 < QQ：270988107 >
     */
    public function uplogo()
    {
        $file = request()->file('file');
        $info = $file->move(Env::get('root_path') . 'public/static/skin/img', 'logo.png');
        if ($info) {
            $res['code'] = 1;
            $res['msg'] = '上传成功';
            $res['name'] = 'logo.png';
            $res['filepath'] = '/public/static/skin/img/' . $res['name'];
        } else {
            $res['code'] = 0;
            $res['msg'] = '上传失败' . $file->getError();
        }
        return $res;

    }
}