From fa6622ee0f7c0c185e40e71772a10f976076f1d1 Mon Sep 17 00:00:00 2001 From: Karson Date: Tue, 4 Jul 2017 22:35:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=A1=A8=E6=A0=BC=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=90=9C=E7=B4=A2=E7=9A=84=E7=A4=BA=E4=BE=8B?= =?UTF-8?q?=20=E6=96=B0=E5=A2=9E=E5=BE=AE=E4=BF=A1=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=9C=A8=E6=9C=AA=E9=85=8D=E7=BD=AE=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E6=97=B6=E7=9A=84=E9=94=99=E8=AF=AF=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=20=E6=96=B0=E5=A2=9Erenderer=E7=9A=84meta=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E7=A4=BA=E4=BE=8B=E6=98=BE=E7=A4=BA=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E7=9A=84BUG=20=E4=BF=AE=E5=A4=8D=E5=A4=9A=E7=BA=A7?= =?UTF-8?q?=E8=81=94=E5=8A=A8=E5=9C=A8=E4=B8=8D=E9=80=89=E4=B8=AD=E5=80=BC?= =?UTF-8?q?=E6=97=B6=E7=9A=84BUG=20=E4=BF=AE=E5=A4=8D=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E9=82=AE=E4=BB=B6=E6=94=B6=E4=BB=B6=E4=BA=BA=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E7=9A=84BUG=20=E4=BF=AE=E5=A4=8D=E8=A1=A8=E6=A0=BC=E7=AD=9B?= =?UTF-8?q?=E9=80=89=E6=8C=89=E9=92=AE=E7=A6=81=E7=94=A8=E6=97=B6=E4=B8=8D?= =?UTF-8?q?=E8=83=BD=E9=80=89=E4=B8=AD=E9=A6=96=E5=88=97=E7=9A=84BUG=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8Dsummernote=E4=BD=BF=E7=94=A8=E6=BA=90?= =?UTF-8?q?=E7=A0=81=E6=A8=A1=E5=BC=8F=E4=B8=8B=E7=9A=84BUG=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E5=AE=89=E8=A3=85=E6=97=B6=E4=B8=8B=E8=BD=BD=E9=93=BE?= =?UTF-8?q?=E6=8E=A5=E9=94=99=E8=AF=AF=E7=9A=84BUG=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=89=8D=E7=AB=AFrequire-frontend.js=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/Ajax.php | 45 +++--- application/admin/controller/Category.php | 7 +- application/admin/controller/wechat/Menu.php | 39 +++++- application/admin/lang/zh-cn/category.php | 14 +- application/admin/validate/Category.php | 27 ++++ application/admin/view/category/add.html | 129 +++++++++++------- application/admin/view/category/edit.html | 129 +++++++++++------- application/admin/view/common/meta.html | 1 + .../view/example/bootstraptable/index.html | 2 +- .../view/example/tabletemplate/index.html | 2 +- application/common/library/Email.php | 2 +- application/common/model/Category.php | 30 +++- application/index/view/layout/bootstrap.html | 1 + application/index/view/layout/user.html | 1 + public/assets/css/backend.css | 6 +- public/assets/css/backend.min.css | 2 +- public/assets/js/backend/category.js | 22 ++- .../js/backend/example/bootstraptable.js | 35 +++-- public/assets/js/backend/wechat/menu.js | 1 - public/assets/js/require-backend.min.js | 80 +++++++---- public/assets/js/require-frontend.js | 26 +++- public/assets/js/require-frontend.min.js | 26 +++- public/assets/js/require-table.js | 48 +++---- public/assets/less/backend.less | 6 +- public/install.php | 2 +- 25 files changed, 457 insertions(+), 226 deletions(-) create mode 100644 application/admin/validate/Category.php 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 @@ -
-
-
-
- - {:build_select('row[type]', $typelist, [], ['id'=>'c-type','class'=>'form-control selectpicker','data-rule'=>'required'])} -
-
- - -
-
- - -
-
- - -
-
- - -
-
-
-
- - -
-
-
-
-
+ -
- - {:build_select('row[pid]', $parentlist, null, ['id'=>'c-pid','class'=>'form-control selectpicker','data-rule'=>'required'])} -
-
- - {:build_select('row[flag]', ['recommend'=>__('Recommend'), 'index'=>__('Index'), 'hot'=>__('Hot')], null, ['id'=>'c-flag','class'=>'form-control selectpicker','data-rule'=>'required'])} -
-
- -
- {:build_radios('row[status]', ['normal'=>__('Normal'), 'hidden'=>__('Hidden')])} -
+
+ +
+ + + +
+
+
+ +
+ + + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + + +
+
+
+ +
+
+ + + +
    -