<?php namespace Phpcmf\Controllers\Admin;

class Config extends \Phpcmf\Common
{

    public function __construct(...$params) {
        parent::__construct(...$params);
        \Phpcmf\Service::V()->assign('menu', \Phpcmf\Service::M('Auth')->_admin_menu(
            [
                '商城设置' => ['mall/config/index', 'fa fa-cog'],
            ]
        ));
    }

    public function index() {

        $page = intval(\Phpcmf\Service::L('Input')->get('page'));
        $data = \Phpcmf\Service::M('Mall', 'mall')->get_config('config');

        if (IS_AJAX_POST) {
            \Phpcmf\Service::M('Mall', 'mall')->save_config('config', 0, \Phpcmf\Service::L('Input')->post('data'));
            $this->_json(1, dr_lang('操作成功'));
        }

        \Phpcmf\Service::V()->assign([
            'data' => $data,
            'page' => $page,
            'form' => dr_form_hidden(['page' => $page]),
        ]);
        \Phpcmf\Service::V()->display('config_index.html');
    }


}
