Is_Login(); // 权限校验 $this->Is_Power(); //要执行的表 $this->table = M('activity_vote'); } /** * [Index 列表] * @author Devil * @blog http://gong.gg/ * @version 0.0.1 * @datetime 2016-12-06T21:31:53+0800 */ public function Index() { $where = array(); $listRows = I('listRows') ? I('listRows') : 100; $keyword = I("keyword", "", "trim"); $keyword && $where['uid'] = array('like', '%' . $keyword . '%'); if (isset($keyword) && !empty($keyword)) { $this->assign('keyword', $keyword); } $page = I('p') ? I('p') : 1; $this->assign('p', $page); $list = D('Admin/Vote')->get_vote_list($where, $page, $listRows, $count); $mengbaos = M('activity_mengbao')->getField('id,name',true); $Page = new \Think\Page($count, $listRows); $Page->parameter .= "&p=[PAGE]"; $Page->parameter .= "&listRows=" . $listRows; $Page->parameter .= "&keyword=" .$keyword; $Page = $this->page_config($Page); $show = $Page->show(); $this->assign('page', $show); $this->assign('List', $list); $this->assign('Mengbaos', $mengbaos); $this->display('Index'); } /** * [SaveInfo 文章添加/编辑页面] * @author Devil * @blog http://gong.gg/ * @version 0.0.1 * @datetime 2016-12-14T21:37:02+0800 */ public function SaveInfo() { // 文章信息 if (empty($_REQUEST['id'])) { $data = array(); } else { $data = $this->table->find(I('id')); if (empty($data)) { $data = array('id' => I('id')); } } $this->assign('data', $data); $this->display('SaveInfo'); } /** * [Save 文章添加/编辑] * @author Devil * @blog http://gong.gg/ * @version 0.0.1 * @datetime 2016-12-14T21:37:02+0800 */ public function Save() { // 是否ajax请求 if (!IS_AJAX) { $this->error(L('common_unauthorized_access')); } // 添加 if (empty($_POST['id'])) { $this->Add(); // 编辑 } else { $this->Edit(); } } /** * [Add 文章添加] * @author Devil * @blog http://gong.gg/ * @version 0.0.1 * @datetime 2016-12-18T16:20:59+0800 */ private function Add() { $data['uid'] = I('uid'); $data['num'] = I('num'); $data['act_id'] = I('act_id'); $data['date'] = I('date'); $data['created_at'] = I('created_at'); // 数据添加 if ($this->table->add($data)) { $this->ajaxReturn(L('common_operation_add_success')); } else { $this->ajaxReturn(L('common_operation_add_error'), -100); } } /** * [Edit 文章编辑] * @author Devil * @blog http://gong.gg/ * @version 0.0.1 * @datetime 2016-12-17T22:13:40+0800 */ private function Edit() { $id = I('id'); $data = array(); $data['uid'] = I('uid'); $data['num'] = I('num'); $data['act_id'] = I('act_id'); $data['date'] = I('date'); $data['created_at'] = I('created_at'); // 数据更新 if (false !== $this->table->where(array('id' => $id))->save($data)) { $this->ajaxReturn(L('common_operation_edit_success')); } else { $this->ajaxReturn(L('common_operation_edit_error'), -100); } } /** * [Delete 删除] * @author Devil * @blog http://gong.gg/ * @version 0.0.1 * @datetime 2016-12-15T11:03:30+0800 */ public function Delete() { // 是否ajax请求 if (!IS_AJAX) { $this->error(L('common_unauthorized_access')); } // 删除数据 if (!empty($_POST['id'])) { // 更新 if ($this->table->delete(I('id'))) { $this->ajaxReturn(L('common_operation_delete_success')); } else { $this->ajaxReturn(L('common_operation_delete_error'), -100); } } else { $this->ajaxReturn(L('common_param_error'), -1); } } }