0) {$extend['game_id']=$_REQUEST['game_id'];} $this->m_title = '系统公告'; $this->m_url = 'Notice/lists'; $this->assign('commonset',M('Kuaijieicon')->where(['url'=>'Merchandise/lists','status'=>1])->find()); $extend['status'] = 1; parent::lists(self::model_name,$_GET['p'],$extend); } /** * 添加系统公告 * @author 鹿文学 */ public function add() { if(IS_POST) { $notice = D(self::model_name); if(!empty($_POST['start_time']) && !empty($_POST['end_time'])) { if(strtotime($_POST['start_time'])>strtotime($_POST['end_time'])) { $this->error('开始时间必须小于等于结束时间'); } } !empty($_POST['start_time']) || $_POST['start_time'] = date('Y-m-d'); empty($_POST['game_name']) && $_POST['game_name'] = get_game_name($_POST['game_id']); if($notice->update($_POST)) { $this->success('新增成功',U('lists')); } else { $this->error($notice->getError()); } } else { $this->meta_title = '新增系统公告'; $this->m_title = '系统公告'; $this->m_url = 'Notice/lists'; $this->assign('commonset',M('Kuaijieicon')->where(['url'=>'Notice/lists','status'=>1])->find()); $this->display(); } } /** * 编辑系统公告 * @author 鹿文学 */ public function edit() { if(IS_POST) { $notice = D(self::model_name); if(!empty($_POST['start_time']) && !empty($_POST['end_time'])) { if(strtotime($_POST['start_time'])>strtotime($_POST['end_time'])) { $this->error('开始时间必须小于等于结束时间'); } } if(empty($_POST['start_time'])) { $this->error('开始时间不能为空'); } empty($_POST['game_name']) && $_POST['game_name'] = get_game_name($_POST['game_id']); if($notice->update($_POST)) { $this->success('编辑成功',U('lists')); } else { $this->error($notice->getError()); } } else { $map['id'] = $_REQUEST['id']; $data = D(self::model_name)->where($map)->find(); $this->assign('data',$data); $this->meta_title = '编辑系统公告'; $this->m_title = '系统公告'; $this->m_url = 'Notice/lists'; $this->assign('commonset',M('Kuaijieicon')->where(['url'=>'Notice/lists','status'=>1])->find()); $this->display(); } } /** * 删除系统公告 * @param array/integer $ids 要删除的系统公告编号 * @author 鹿文学 */ public function del($ids=null){ $model = M('Model')->getByName(self::model_name); /*通过Model名称获取Model完整信息*/ parent::del($model["id"],$ids); } /** * 更改系统公告优先级 * @param integer $id 系统公告编号 * @param integer $value 优先级数值 * @author 鹿文学 */ public function change_value($id,$value) { if(IS_POST) { if(!is_numeric($id) || $id<1) {$this->ajaxReturn(['status'=>0,'info'=>'数据有误'],'json');} if(!is_numeric($value) || $value<1) {$this->ajaxReturn(['status'=>0,'info'=>'请输入正整数'],'json');} $result = D(self::model_name)->where(['id'=>$id])->setField('level',$value); if($result) { $this->ajaxReturn(['status'=>1,'info'=>'优先级修改成功'],'json'); } else { $this->ajaxReturn(['status'=>0,'info'=>'优先级修改失败'],'json'); } } else { $this->ajaxReturn(['status'=>0,'info'=>'请求有误'],'json'); } } }