123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- <?php
- declare (strict_types = 1);
- namespace app\admin\controller;
- use app\common\controller\Backend;
- 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")?:"";
- $id=input("id");
- $add["text"]=$name;
- $add["img"]=$img;
- // $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");
- // var_dump(date("Y-m-d",time()));
- $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){
- if ($item["create_time"]){
- // var_dump($item["create_time"]);
- // $date=date('Y-m-s h:i:s',$item["create_time"]);
- // $item["create_time"]=$date;
- }
- return $item;
- })->toArray();
- return $result = ['code' => 0, 'msg' => lang('get info success'), 'data' => $list['data']?:[], 'count' => $list['total']?:0];
- }
- return View::fetch();
- }
- }
|