You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
2.3 KiB
62 lines
2.3 KiB
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
|
|
// +----------------------------------------------------------------------
|
|
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
|
|
// +----------------------------------------------------------------------
|
|
// | Author: rainfer <81818832@qq.com>
|
|
// +----------------------------------------------------------------------
|
|
namespace app\admin\controller;
|
|
|
|
use think\Db;
|
|
use think\Request;
|
|
|
|
class Page extends Base{
|
|
public function index(){
|
|
$kind=input('kind');
|
|
$this->assign('kind',$kind);
|
|
|
|
if (request()->isAjax()){
|
|
$id=input('id');
|
|
$jumpParam=['kind'=>$kind];
|
|
$jump=url('index',$jumpParam);
|
|
|
|
$n_order=input('sort','','intval');
|
|
$sl_data=array(
|
|
'title'=>input('title'),
|
|
'status'=>input('status',0),
|
|
'infor'=>input('infor',''),
|
|
'content'=>htmlspecialchars_decode(input('content')),
|
|
'uid'=>session('admin_auth.aid'),
|
|
'create_time'=>time(),
|
|
'sort'=>$n_order,
|
|
);
|
|
if($kind)$sl_data['kind']=$kind;
|
|
if($id){
|
|
unset($sl_data["create_time"]);
|
|
$rst=Db::name("page")->where(['id'=>$id])->update($sl_data);
|
|
if($rst!==false){
|
|
$this->success('修改成功',$jump);
|
|
}else{
|
|
$this->error('修改失败',$jump);
|
|
}
|
|
}else{
|
|
$rst=Db::name("page")->insert($sl_data);
|
|
if($rst){
|
|
if(empty($n_order)||$n_order==50){
|
|
$lastId=Db::name("page")->getLastInsID();
|
|
Db::name("page")->where(['id'=>$lastId])->update(['sort'=>$lastId]);
|
|
}
|
|
$this->success('添加成功',$jump);
|
|
}else{
|
|
$this->error('添加失败',$jump);
|
|
}
|
|
}
|
|
}else{
|
|
$page=Db::name("page")->where(['kind'=>$kind])->find();
|
|
$this->assign('page',$page);
|
|
}
|
|
|
|
return $this->fetch();
|
|
}
|
|
}
|