<?php
namespace app\admin\controller;
use think\App;
use think\facade\Session;
use think\facade\View;
use think\facade\Request;
 
class user extends Base{

	//User首页
    public function index(){
		$tdata=Request::param();
		$info['pid']=$tdata['pid'];
		
		if(isset($tdata['limit'])){
			$limit=$tdata['limit'];
		}else{
			$limit=Session::get('limit');
		}

		$auto_page=tq_value(1,'auto_page','system');
		$auto_page_num=tq_value(1,'page_num','system');
		$syltem_page_list=tq_value(1,'page_list','system');
		if($auto_page==2 and isset($tdata['limit'])==''){
			$limit=$auto_page_num;
		}else{
			$limit=$limit;
		}
		
		
		$strtime=isset($tdata['strtime'])?$tdata['strtime']:'';
		$endtime=isset($tdata['endtime'])?$tdata['endtime']:'';
		$keyword=isset($tdata['keyword'])?$tdata['keyword']:'';
		
		$list=\app\admin\model\User::list_data($limit);
		
		$limits=Session::get('limit');
		$count=$list['total'];
		View::assign([
			'strtime'=>$strtime,
			'endtime'=>$endtime,
			'keyword'=>$keyword,
			'info'=>$info,
			'table'=>$table,
			'field'=>$field,
			'limit'=>$limit,
			'limits'=>$limits,
			'count'=>$count,
			'view'=>$view,
			'syltem_page_list'=>$syltem_page_list,
			'curr'=>$list['current_page'],
			'list'=>$list['data']]
		);
		return View::fetch();
    }

    public function edit(){
		$tdata=Request::param();
		$info=\app\admin\model\User::withoutField('password')->find($tdata['id']);
		View::assign(['info'=>$info]);
		return View::fetch();
	}

    public function update(){
		$tdata=Request::param();
		$user=\app\index\model\User::strict(false)->update($tdata);
		$data =['type' =>1,'ss'=>$info,'msg' =>'修改成功'];
		return json($data);
    }	

}
