89 行
2.9 KiB
PHP
可执行文件
89 行
2.9 KiB
PHP
可执行文件
<?php
|
|
namespace Admin\Controller;
|
|
use Think\Controller;
|
|
//[1.1.96]
|
|
class ContactController extends BaseController{
|
|
public function index(){
|
|
$arr = array(
|
|
'add' => '/index.php/Admin/Contact/add', //修改插件状态
|
|
'update' => '/index.php/Admin/Contact/update', //修改插件状态
|
|
'del' => '/index.php/Admin/Contact/del', //修改插件状态
|
|
);
|
|
$authArr = checkFunction($arr);
|
|
$this->assign('authArr', $authArr);
|
|
$this->display();
|
|
}
|
|
public function add(){
|
|
$this->display();
|
|
}
|
|
public function update(){
|
|
$id = $_GET['id'];
|
|
$list = M("retail_contact")->where("id=".$id)->find();
|
|
$this->assign('list',$list);
|
|
$this->display();
|
|
}
|
|
//添加数据
|
|
public function adds(){
|
|
$data['pid'] = session('admin_userinfo')['pid'];
|
|
$data['name'] = I('post.name');
|
|
$data['tell'] = I('post.tell');
|
|
$data['qq'] = I('post.qq');
|
|
$data['time'] = time();
|
|
$list = M("retail_contact")->add($data);
|
|
if ($list > 0){
|
|
$res['status'] = 1;
|
|
$res['msg'] = "添加成功";
|
|
}else{
|
|
$res['status'] = 0;
|
|
$res['msg'] = "添加失败";
|
|
}
|
|
$this->ajaxReturn($res);
|
|
}
|
|
//删除数据
|
|
public function del(){
|
|
$id = I('post.id');
|
|
$list = M("retail_contact")->where('id ='.$id)->delete();
|
|
if ($list){
|
|
$res['status'] = 1;
|
|
$res['msg'] = "删除成功";
|
|
}else{
|
|
$res['status'] = 0;
|
|
$res['msg'] = "删除失败";
|
|
}
|
|
$this->ajaxReturn($res);
|
|
}
|
|
//修改数据
|
|
public function updates(){
|
|
$update['id'] = I('post.id');
|
|
$update['pid'] = session('admin_userinfo')['pid'];
|
|
$data['name'] = I('post.name');
|
|
$data['tell'] = I('post.tell');
|
|
$data['qq'] = I('post.qq');
|
|
$list = M("retail_contact")->where($update)->save($data);
|
|
if ($list){
|
|
$res['status'] = 1;
|
|
$res['msg'] = "修改成功";
|
|
}else{
|
|
$res['status'] = 0;
|
|
$res['msg'] = "修改失败";
|
|
}
|
|
$this->ajaxReturn($res);
|
|
}
|
|
/**
|
|
* 获取表单数据
|
|
*/
|
|
public function getData(){
|
|
$user = session('admin_userinfo');
|
|
$news['pid'] = $user['pid'];
|
|
$list = M("retail_contact")->where($news)->page($_POST['page'],$_POST['limit'])->select();
|
|
$count = M("retail_contact")->where($news)->count();
|
|
foreach ($list as $k => &$v){
|
|
$v['time'] = date('Y-m-d H:I:s',$v['time']);
|
|
}
|
|
$res['code'] = 0;
|
|
$res['msg'] = '';
|
|
$res['data'] = $list;
|
|
$res['count'] = $count;
|
|
$this->ajaxReturn($res);
|
|
}
|
|
} |