123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315 |
- <?php
- declare (strict_types = 1);
- namespace app\admin\controller;
- use app\common\controller\Backend;
- use app\common\model\Notice;
- use app\common\model\Problem;
- use think\facade\Db;
- use think\facade\Request;
- use think\facade\View;
- class Contents extends Backend
- {
- // todo 内容管理
- //轮播图
- public function index()
- {
- if (Request::isPost()){
- $page=input("page")?:1;
- $limit=input("limit")?:10;
- $url="http://".$_SERVER['HTTP_HOST'];
- $list=Db::name("banner")->order("id desc")->paginate(['list_rows' => $limit, 'page' => $page])->each(function ($item) use (&$url){
- $item["url"]=$url;
- return $item;
- })->toArray();
- return $result = ['code' => 0, 'msg' => lang('get info success'), 'data' => $list['data']?:[], 'count' => $list['total']?:0];
- }
- return View::fetch();
- }
- // 添加轮播图
- public function addbanner()
- {
- $name=input("text");
- $img=input("img")?:"";
- $text=input("text")?:"";
- $id=input("id");
- $add["text"]=$name;
- $add["image"]=$img;
- $add["text"]=$text;
- // $add["centos"]=$centos;
- if ($id){
- $where["id"]=$id;
- $res=Db::name("banner")->where($where)->update($add);
- }else{
- $res=Db::name("banner")->insert($add);
- }
- if ($res){
- json_result(1,"添加成功");
- }
- json_result(2,"添加失败");
- }
- public function add()
- {
- $id=input("id");
- $info=[];
- if ($id){
- $where["id"]=$id;
- $info=Db::name("banner")->where($where)->find();
- }else{
- $info["text"]='';
- $info["img"]='';
- }
- $view = [
- 'info' => $info,
- 'title' => lang('add'),
- ];
- View::assign($view);
- return View::fetch();
- }
- // 删除轮播图
- public function del_banner()
- {
- $id=input("id");
- $where["id"]=$id;
- Db::name("banner")->where($where)->delete();
- json_result(1,"删除成功");
- }
- //
- //关于我们
- public function about()
- {
- if (Request::isPost()){
- $centos=input("text");
- $add["text"]=$centos;
- $ehere["id"]=1;
- Db::name("about")->where($ehere)->update($add);
- json_result(1,"修改成功");
- }
- $data=Db::name("about")->where(["id"=>1])->value("text");
- $view = [
- 'info' => $data,
- 'title' => lang('add'),
- ];
- View::assign($view);
- return View::fetch();
- }
- //
- //意见反馈
- public function feedback()
- {
- if (Request::isPost()){
- $name=input("name");
- $page=input("page")?:1;
- $limit=input("limit")?:10;
- $where=[];
- // if ($name){
- // $where["name"]=["like","% $name %"];
- // }
- $list=Db::name("feedback")->order("id desc")->where($where)->paginate(["list_row"=>$limit,"page"=>$page])->each(function ($item){
- $user=\app\common\model\User::where(["id"=>$item["user_id"]])->field("name")->find();
- $item["name"]=$user->name;
- if ($item["image"]){
- $item["image"]=explode(",",$item["image"]);
- }else{
- $item["image"]="";
- }
- return $item;
- })->toArray();
- return $result = ['code' => 0, 'msg' => lang('get info success'), 'data' => $list['data']?:[], 'count' => $list['total']?:0];
- }
- return View::fetch();
- }
- //
- public function hlep()
- {
- if (Request::isPost()){
- $name=input("name");
- $page=input("page")?:1;
- $limit=input("limit")?:10;
- $where=[];
- $list=Db::name("problem")->order("id desc")->where($where)->paginate(["list_row"=>$limit,"page"=>$page])->each(function ($item){
- return $item;
- })->toArray();
- return $result = ['code' => 0, 'msg' => lang('get info success'), 'data' => $list['data']?:[], 'count' => $list['total']?:0];
- }
- return View::fetch();
- }
- // 删除常见问题
- public function del_hlep()
- {
- $id=input("id");
- Problem::where(["id"=>$id])->delete();
- json_result(200,"删除成功");
- }
- // 添加修改
- public function addhlep()
- {
- if (Request::isPost()){
- $id=input("id");
- $add["name"]=input("name");
- $add["text"]=input("text");
- if ($id){
- Problem::update($add,["id"=>$id]);
- }else{
- Problem::create($add);
- }
- json_result(200,"操作成功");
- }else{
- $id=input("id");
- if ($id){
- $da=Problem::where(["id"=>$id])->find();
- $info["name"]=$da->name;
- $info["text"]=$da->text;
- $info["id"]=$id;
- }else{
- $info["name"]="";
- $info["text"]="";
- $info["id"]=0;
- }
- $view = [
- 'info' => $info,
- 'title' => lang('add'),
- ];
- View::assign($view);
- return View::fetch();
- }
- }
- // 收款信息
- public function push()
- {
- if (Request::isPost()){
- $data = Request::post();
- foreach ($data as $k=>$v){
- $res = Db::name('system')->where('name',$k)->update(['value'=>$v]);
- }
- json_result(200,"修改成功",$data);
- }
- $list = Db::name('system')
- ->where(["type"=>"shouk"])
- ->field('name,value')
- ->column('value','name');
- View::assign('config',json_encode($list));
- $view = [
- 'info' => $list,
- 'title' => lang('add'),
- ];
- View::assign($view);
- return View::fetch();
- }
- //系统消息管理
- public function sysmsg()
- {
- if (Request::isPost()){
- $name=input("name");
- $page=input("page")?:1;
- $limit=input("limit")?:10;
- $where=[];
- $list=Db::name("notice")->order("id desc")->where($where)->paginate(["list_row"=>$limit,"page"=>$page])->each(function ($item){
- return $item;
- })->toArray();
- return $result = ['code' => 0, 'msg' => lang('get info success'), 'data' => $list['data']?:[], 'count' => $list['total']?:0];
- }
- return View::fetch();
- }
- // 更新是否显示消息
- public function update_nocice_status()
- {
- $id=input("id");
- $status=input("status")?:0;
- Notice::update(["status"=>$status],["id"=>$id]);
- json_result(200,"操作成功");
- }
- public function del_msg()
- {
- $id=input("id");
- Notice::where(["id"=>$id])->delete();
- json_result(200,"删除成功");
- }
- // 添加消息
- public function addmsg()
- {
- if (Request::isPost()){
- $id=input("id");
- $add["name"]=input("name");
- $add["text"]=input("text");
- if ($id){
- Notice::update($add,["id"=>$id]);
- }else{
- Notice::create($add);
- }
- json_result(200,"操作成功");
- }else{
- $id=input("id");
- if ($id){
- $da=Problem::where(["id"=>$id])->find();
- $info["name"]=$da->name;
- $info["text"]=$da->text;
- $info["id"]=$id;
- }else{
- $info["name"]="";
- $info["text"]="";
- $info["id"]=0;
- }
- $view = [
- 'info' => $info,
- 'title' => lang('add'),
- ];
- View::assign($view);
- return View::fetch();
- }
- }
- }
|