106 lines
3.0 KiB
PHP
106 lines
3.0 KiB
PHP
<?php
|
|
namespace app\admin\controller;
|
|
use think\Db;
|
|
|
|
class Webpage extends AdminBase
|
|
{
|
|
|
|
//哆拉猫动态页面的
|
|
|
|
public function lists(){
|
|
if ($this->request->isAjax()) {
|
|
$lists=Db::name('pageweb')->select();
|
|
foreach($lists as &$list){
|
|
$list['times'] = date('Y-m-d H:i:s',$list['time']);
|
|
}
|
|
$this->_success('',$lists);
|
|
}
|
|
return $this->fetch();
|
|
}
|
|
|
|
// 增加动态页面
|
|
|
|
public function add(){
|
|
if ($this->request->isAjax()) {
|
|
$post = $this->request->post();
|
|
$img = $post['img'];
|
|
$url = $post['url'];
|
|
|
|
$service = [];
|
|
if(!empty($img) && !empty($url)){
|
|
foreach ($img as$k=>$v){
|
|
if(empty($v) || empty($url[$k])) continue;
|
|
$service[] = [
|
|
'img'=>$v,
|
|
'url'=>$url[$k]
|
|
];
|
|
}
|
|
}
|
|
|
|
$service = json_encode($service);
|
|
|
|
|
|
$data = [
|
|
'name' => $post['name'],
|
|
'service' => $service,
|
|
'time' => time(),
|
|
];
|
|
|
|
|
|
$inser=Db::name('pageweb')->data($data)->insert();
|
|
$this->_success('增加成功');
|
|
}
|
|
|
|
return $this->fetch();
|
|
}
|
|
//修改页面
|
|
public function edit($id){
|
|
|
|
if ($this->request->isAjax()) {
|
|
$post = $this->request->post();
|
|
$img = $post['img'];
|
|
$url = $post['url'];
|
|
|
|
$service = [];
|
|
if(!empty($img) && !empty($url)){
|
|
foreach ($img as$k=>$v){
|
|
if(empty($v) || empty($url[$k])) continue;
|
|
$service[] = [
|
|
'img'=>$v,
|
|
'url'=>$url[$k]
|
|
];
|
|
}
|
|
}
|
|
|
|
$service = json_encode($service);
|
|
$data=Db::name('pageweb')->where('id',$post['id'])->update(['name'=>$post['name'],'service'=>$service]);
|
|
$this->_success('修改数据成功');
|
|
}
|
|
|
|
$info=Db::name('pageweb')->where('id',$id)->find();
|
|
try{
|
|
$info['service'] = json_decode($info['service'],true);
|
|
}catch(Exception $e){
|
|
$info['service'] = '';
|
|
}
|
|
|
|
$this->assign('info',$info);
|
|
return $this->fetch();
|
|
}
|
|
|
|
public function del($id){
|
|
$info=Db::name('pageweb')->where('id',$id)->delete();
|
|
$this->_success('删除成功');
|
|
}
|
|
|
|
public function suspend($id){
|
|
$info=Db::name('pageweb')->where('id',$id)->update(['status'=>1]);
|
|
$this->_success('暂停成功');
|
|
}
|
|
public function cancellation($id){
|
|
$info=Db::name('pageweb')->where('id',$id)->update(['status'=>0]);
|
|
$this->_success('启动成功');
|
|
}
|
|
|
|
|
|
} |