diff --git a/application/admin/controller/Ajax.php b/application/admin/controller/Ajax.php index cf06e372..8796d196 100644 --- a/application/admin/controller/Ajax.php +++ b/application/admin/controller/Ajax.php @@ -437,16 +437,20 @@ class Ajax extends Backend $type = $this->request->get('type'); $pid = $this->request->get('pid'); $where = ['status' => 'normal']; - if ($type) + $categorylist = null; + if ($pid !== '') { - $where['type'] = $type; - } - if ($pid) - { - $where['pid'] = $pid; - } + if ($type) + { + $where['type'] = $type; + } + if ($pid) + { + $where['pid'] = $pid; + } - $categorylist = Db::name('category')->where($where)->field('id as value,name')->order('weigh desc,id desc')->select(); + $categorylist = Db::name('category')->where($where)->field('id as value,name')->order('weigh desc,id desc')->select(); + } $this->code = 1; $this->data = $categorylist; return; @@ -460,17 +464,24 @@ class Ajax extends Backend $province = $this->request->get('province'); $city = $this->request->get('city'); $where = ['pid' => 0, 'level' => 1]; - if ($province) + $provincelist = null; + if ($province !== '') { - $where['pid'] = $province; - $where['level'] = 2; + if ($province) + { + $where['pid'] = $province; + $where['level'] = 2; + } + if ($city !== '') + { + if ($city) + { + $where['pid'] = $city; + $where['level'] = 3; + } + $provincelist = Db::name('area')->where($where)->field('id as value,name')->select(); + } } - if ($city) - { - $where['pid'] = $city; - $where['level'] = 3; - } - $provincelist = Db::name('area')->where($where)->field('id as value,name')->select(); $this->code = 1; $this->data = $provincelist; return; diff --git a/application/admin/controller/Category.php b/application/admin/controller/Category.php index a3e6ba41..bc2e9e74 100644 --- a/application/admin/controller/Category.php +++ b/application/admin/controller/Category.php @@ -24,15 +24,16 @@ class Category extends Backend $this->model = model('Category'); $tree = Tree::instance(); - $tree->init(CategoryModel::getCategoryArray(), 'pid'); + $tree->init($this->model->order('weigh desc,id desc')->select(), 'pid'); $this->categorylist = $tree->getTreeList($tree->getTreeArray(0), 'name'); $categorydata = [0 => __('None')]; foreach ($this->categorylist as $k => $v) { $categorydata[$v['id']] = $v['name']; } - $this->view->assign("typelist", CategoryModel::getTypeList()); - $this->view->assign("parentlist", $categorydata); + $this->view->assign("flagList", $this->model->getFlagList()); + $this->view->assign("typeList", CategoryModel::getTypeList()); + $this->view->assign("parentList", $categorydata); } /** diff --git a/application/admin/controller/wechat/Menu.php b/application/admin/controller/wechat/Menu.php index 5db67282..1a1b7132 100644 --- a/application/admin/controller/wechat/Menu.php +++ b/application/admin/controller/wechat/Menu.php @@ -3,7 +3,6 @@ namespace app\admin\controller\wechat; use app\common\controller\Backend; -use app\common\model\Configvalue; use app\common\model\WechatResponse; use EasyWeChat\Foundation\Application; use think\Config; @@ -64,19 +63,47 @@ class Menu extends Backend try { - $ret = $app->menu->add(json_decode($this->wechatcfg->value, TRUE)); - if ($ret->errcode == 0) + $hasError = false; + $menu = json_decode($this->wechatcfg->value, TRUE); + foreach ($menu as $k => $v) { - $this->code = 1; + if (isset($v['sub_button'])) + { + foreach ($v['sub_button'] as $m => $n) + { + if (isset($n['key']) && !$n['key']) + { + $hasError = true; + break 2; + } + } + } + else if (isset($v['key']) && !$v['key']) + { + $hasError = true; + break; + } + } + if (!$hasError) + { + $ret = $app->menu->add($menu); + if ($ret->errcode == 0) + { + $this->code = 1; + } + else + { + $this->msg = $ret->errmsg; + } } else { - $this->content = $ret->errmsg; + $this->msg = __('Invalid parameters'); } } catch (Exception $e) { - $this->content = $e->getMessage(); + $this->msg = $e->getMessage(); } return; } diff --git a/application/admin/lang/zh-cn/category.php b/application/admin/lang/zh-cn/category.php index abe94cbe..1ee91d34 100644 --- a/application/admin/lang/zh-cn/category.php +++ b/application/admin/lang/zh-cn/category.php @@ -1,8 +1,14 @@ '自定义别名', - 'Keywords' => '关键字', - 'Description' => '描述', - 'keywords' => '关键字', + 'Pid' => '父ID', + 'Type' => '栏目类型', + 'Image' => '图片', + 'Keywords' => '关键字', + 'Description' => '描述', + 'Diyname' => '自定义名称', + 'Createtime' => '创建时间', + 'Updatetime' => '更新时间', + 'Weigh' => '权重', + 'Status' => '状态' ]; diff --git a/application/admin/validate/Category.php b/application/admin/validate/Category.php new file mode 100644 index 00000000..b3591edb --- /dev/null +++ b/application/admin/validate/Category.php @@ -0,0 +1,27 @@ + [], + 'edit' => [], + ]; + +} diff --git a/application/admin/view/category/add.html b/application/admin/view/category/add.html index edbdb699..7ab24afa 100644 --- a/application/admin/view/category/add.html +++ b/application/admin/view/category/add.html @@ -1,54 +1,89 @@ -