<?php
namespace app\admin\controller;
use think\Controller;
use think\Db;
use Think\Config;
/*
后台操作页面
*/
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2021 http://115cms.com.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: 作者@梦雨 <50361804@qq.com>
// +----------------------------------------------------------------------
class Admin extends Common
{
    //后台分类首页
    public function cate_index()
    {
        hook('phpadminadmina');
        //权限
        if (socha(user('tid'), 13) != 1) {
            $this->error('权限不足');
        }
        return md5Qm();
    }
    //分类添加编辑
    public function cate_add()
    {
        hook('phpadminadminb');
        //权限
        if (socha(user('tid'), 36) != 1) {
            $this->error('权限不足');
        }
        $c=Db::name('cateAdmin')->where(array('id' => get('id',0)))->find();
        $this->assign('c',$c);
        return view();
    }
	//基本设置
    public function set()
    {
        hook('phpadminadminac');
	    if (request()->isPost()) {
			//权限
            if (socha(user('tid'), 23) != 1) {
                $this->error('权限不足');
            }
            $data = $this->request->param();
            $id = $data['id'];
            $config = $data['config'];
            $flag = Db::name('set')->where(array('id'=>$id))->setField('config', json_encode($config));
            if ($flag !== false) {
                return json(array('code' => 1, 'msg' => '保存配置成功'));
            } else {
                return json(array('code' => 0, 'msg' => '保存配置失败'));
            }
		}
        return md5Qm();
    }
    //添加设置项目
    public function set_add()
    {
        hook('phpadminadmind');
        return md5Qm();
    }
    // 配置添加修改
    public function set_config()
    {
        hook('phpadminadmine');
        $c=Db::name('set_config')->find(get('or',0));
        $this->assign('c',$c);
        return md5Qm();
    }
}