<?php
/**
 *  Guojiz网址导航系统
 *	www.guojiz.com
 *  作者：梦雨
 *  @ QQ50361804
 */
namespace app\admin\controller;
use think\Controller;
use think\Db;
class Shiming extends Common
{
    
	
	public function index()
    {
		$shiming=Db::name('shiming');
		$ks=input('ks');
		$tptc=$shiming->order('id desc')->where('title','like','%'.$ks.'%')->paginate(15,false,$config = ['query'=>array('ks'=>$ks)]);
        $this->assign('tptc',$tptc);
		return view();
    }

	public function changestatus(){
        if(request()->isAjax()){
			$change=input('change');
          
			$status=db('shiming')->field('status')->where('id',$change)->find();
			$status=$status['status'];
			if($status==1){
                Db::name('member')->alias('m')->join('shiming s', 's.uid=m.userid')->where('s.id',$change)->setField('sm',0);
				db('shiming')->where('id',$change)->update(['status'=>0]);
				echo 1;
			}else{
                Db::name('member')->alias('m')->join('shiming s', 's.uid=m.userid')->where('s.id',$change)->setField('sm',1);
				db('shiming')->where('id',$change)->update(['status'=>1]);
				echo 2;
			}
		}else{
            $this->error('非法操作');
		}
    }

}
