58 lines
1.7 KiB
PHP
58 lines
1.7 KiB
PHP
<?php
|
|
namespace app\admin\controller;
|
|
use app\common\controller\Admin;
|
|
use think\Request;
|
|
use think\Loader;
|
|
use think\Db;
|
|
// 智能推送
|
|
class Smartpush extends Admin{
|
|
|
|
public function index(){
|
|
$list = db('smartpush')->order('id asc')->select();
|
|
$status = db('smartpush')->where('id',1)->value('status');
|
|
$this->assign('status',$status);
|
|
$this->assign('list',$list);
|
|
$this->setMeta('推送列表');
|
|
return $this->fetch();
|
|
}
|
|
|
|
// open
|
|
public function open(){
|
|
$status = input('status');
|
|
if($status){
|
|
$res = db('smartpush')->where('id',1)->update(['status'=>$status]);
|
|
if($res){
|
|
if($status==1){
|
|
exit(json_encode(array('status'=>1,'reg'=>'开启成功')));
|
|
}else{
|
|
exit(json_encode(array('status'=>1,'reg'=>'关闭成功')));
|
|
}
|
|
}else{
|
|
exit(json_encode(array('status'=>2,'reg'=>'失败')));
|
|
}
|
|
}
|
|
}
|
|
|
|
// 编辑客服图文消息
|
|
public function edit(){
|
|
$id = input('id');
|
|
$data = input('');
|
|
if(isset($data['url'])){
|
|
$id = $data['id'];
|
|
unset($data['id']);
|
|
$res = db('smartpush')->where('id',$id)->update($data);
|
|
if($res){
|
|
exit(json_encode(array('status'=>1,'reg'=>'成功')));
|
|
}else{
|
|
exit(json_encode(array('status'=>2,'reg'=>'没有值修改')));
|
|
}
|
|
}else{
|
|
$data = db('smartpush')->where('id',$id)->find();
|
|
$this->assign('data',$data);
|
|
$this->setMeta('编辑客服图文消息');
|
|
return $this->fetch();
|
|
}
|
|
}
|
|
|
|
|
|
} |