CodeController.php 3.8 KB
<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2018 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 老猫 <thinkcmf@126.com>
// +----------------------------------------------------------------------
namespace app\portal\controller;

use app\portal\model\BankModel;
use app\portal\model\NewModel;
use cmf\controller\AdminBaseController;
use think\Db;
use think\Request;
use think\Loader;

class CodeController extends AdminBaseController
{
    /**
     * 列表(暂无用)
     * @adminMenu(
     *     'name'   => '文章管理',
     *     'parent' => 'portal/AdminIndex/default',
     *     'display'=> true,
     *     'hasView'=> true,
     *     'order'  => 10000,
     *     'icon'   => '',
     *     'remark' => '文章列表',
     *     'param'  => ''
     * )
     */
    public function index(Request $request)
    {
        $where_coo['status'] = 1;
//        $where_coo = array();
        $search = $request->param();
        $arr = array();
        if($search){
            if(!empty($search['start_time'])){
                $arr['start_time'] = $search['start_time'];
                $start = strtotime($search['start_time']);
                if(!empty($search['end_time'])){
                    $arr['end_time'] = $search['end_time'];
                    $end = strtotime($search['end_time']);
                }else{
                    $end = time();
                }
                $where_coo['n.update_time'] = array('between',"$start,$end");
                $this->assign('start_time',date('Y-m-d H:i',$start));
                $this->assign('end_time',date('Y-m-d H:i',$end));
            }else{
                if(!empty($search['end_time'])){
                    $arr['end_time'] = $search['end_time'];
                    $end = strtotime($search['end_time']);
                    $where_coo['n.update_time'] = array('elt',$end);
                    $this->assign('end_time',date('Y-m-d H:i',$end));
                }
            }
            if(!empty($search['keyword'])){
                $arr['keyword'] = $search['keyword'];
                $where_coo['tel'] = array('like',"%".$search['keyword']."%");
                $this->assign('keyword',$search['keyword']);
            }
            if(!empty($search['type'])){
                $arr['type'] = $search['type'];
                $where_coo['type'] = $search['type'];
                $this->assign('type',$search['type']);
            }

        }
        $type = empty($search['type'])?0:$search['type'];
        $this->assign('type',$type);
        $coo_list = Db::name('Code')->where($where_coo)->order('create_time desc')->paginate(10,false,['query'=>$arr]);
        $page = $coo_list->render();
        $this->assign('page',$page);
        $this->assign('list',$coo_list);
        return $this->fetch();
    }




//  删除
    public function del(Request $request){
        $ids = $this->request->post();
        $id = $request->param('id');
        if($ids){
            $where_del['id'] = array('in',$ids['ids']);
        }else if($id){
            $where_del['id'] = $request->param('id');
        }else{
            $this->error('删除失败');
        }
        $add_del['status'] = 9;
        $add_del['update_time'] = time();
//        $model = new NewModel();
        $del = Db::name('Code')->where($where_del)->update($add_del);
        if($del){
            $this->success('删除成功',url('index'));
        }else{
            $this->error('删除失败');
        }
    }

}