diff --git a/Application/Admin/Controller/ArticleController.class.php b/Application/Admin/Controller/ArticleController.class.php index f1fc5d94d..037e1d643 100644 --- a/Application/Admin/Controller/ArticleController.class.php +++ b/Application/Admin/Controller/ArticleController.class.php @@ -862,6 +862,92 @@ class ArticleController extends AdminController { $this->ajaxReturn(['status'=>0,'info'=>'请求有误'],'json'); } } - + + public function pop_rules($row = 10, $type = '', $tag = '', $p = 1) + { + $map = []; + $map['_string'] = " 1=1 "; + if (isset($_GET['time-start'])) { + $map['_string'] .= " and operate_time >= " . strtotime($_GET['time-start']); + } + if (isset($_GET['time-end'])) { + $map['_string'] .= " and operate_time < " . (strtotime($_GET['time-end']) + 86400); + } + if (isset($type)) { + $map['type'] = $type; + } + if (!empty($_GET['title'])) { + $map['title'] = ['like', "%{$_GET['title']}%"]; + } + $list = M('document_pop_rules')->where($map)->page($p, $row)->select(); + $count = M('document_pop_rules')->where($map)->count(); + if (!empty($list)) { + $weekDes = ["一", "二", '三', '四', '五', '六', '日']; + $statusDes = ['1'=>'执行完成', '2'=>'下架', '3'=>'待执行']; + foreach ($list as &$item) { + switch ($item['type']) { + case '1': + $item['time_desc'] = date("Y-m-d", $item['pop_time']); + break; + case '2': + $item['time_desc'] = "每周".$weekDes[$item['pop_time']]; + break; + } + } + } + $page = set_pagination($count, $row); + if ($page) { + $this->assign('_page', $page); + } + $this->assign('list_data', $list); + $this->display('pop_rules'); + } + + public function pop_rule_edit($id=0) + { + if (IS_POST) { + if (empty($_POST['title']) || empty($_POST['desc']) || !isset($_POST['sort']) || empty($_POST['content'])) { + return $this->error("请填写完整的内容"); + } + if (!is_numeric($_POST['sort'])) { + return $this->error("权重值需为数字"); + } + if (!empty($_POST['type']) && empty($_POST['pop_time'])) { + return $this->error("请选择弹窗时间"); + } + if ($_POST['type'] == 1 ) { + $_POST['pop_time'] = strtotime($_POST['pop_time']); + } + if ($id) { + $pop_rules_model = M('document_pop_rules');//M('$this->$model_name','tab_'); + $res = $pop_rules_model->where(['id'=>$id])->save($_POST); + return $res ? $this->success("更新成功") : $this->error("更新失败"); + + } else { + $pop_rules_model = M('document_pop_rules');//M('$this->$model_name','tab_'); + $data = $_POST; + $data['operate_time'] = time(); + $data['operater_id'] = is_login(); + $data['status'] = 1; + $res = $pop_rules_model->add($data); + return $res ? $this->success("新增完成") : $this->error("新增失败"); + } + } else { + if($id) { + if ($_GET['delete']) { + $pop_rules_model = M('document_pop_rules');//M('$this->$model_name','tab_'); + $res = $pop_rules_model->where(['id'=>$id])->delete(); + return $res ? $this->success("删除成功") : $this->error("删除失败"); + } + $rule = M('document_pop_rules')->where(['id'=>$id])->find(); + if (!$rule) { + return $this->error('记录不存在'); + } + $rule['pop_time'] = date("Y-m-d", ($rule['pop_time'] <= 10 ? time() : $rule['pop_time'])); + $this->assign('rule', $rule); + } + } + $this->display('pop_rule_edit'); + } } diff --git a/Application/Admin/View/Article/pop_rule_edit.html b/Application/Admin/View/Article/pop_rule_edit.html new file mode 100644 index 000000000..6c906281b --- /dev/null +++ b/Application/Admin/View/Article/pop_rule_edit.html @@ -0,0 +1,90 @@ + + + +
+
编辑平台规则
+
    + +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
  • +
  • + + + + {:hook('adminArticleEdit', array('name'=>'content','value'=>$rule['content']))} + +
  • +
  • + +
  • +
+
+ + + +
+ + + if(C('COLOR_STYLE')=='blue_color') echo ' + + '; + + + + + + + + \ No newline at end of file diff --git a/Application/Admin/View/Article/pop_rules.html b/Application/Admin/View/Article/pop_rules.html new file mode 100644 index 000000000..b3798c942 --- /dev/null +++ b/Application/Admin/View/Article/pop_rules.html @@ -0,0 +1,238 @@ + + + + + + + + + + + + +
+ + +
+
+ +
+
+ +  -  + +
+
+ +
+ +
+ +
+ + +
+
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ID标题描述时间操作
aOh! 暂时还没有内容!
{$data.id}{$data.title}{$data.desc}{$data.time_desc} + 编辑 + 删除 +
+
+
+
+ {$_page|default=''} +
+ +
+ + + + if(C('COLOR_STYLE')=='blue_color') echo ' + + '; + + + + + + + +