| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 | <?phpnamespace Task\Lib;use Dever;use Passport\Src\User;use Passport\Src\Login;class Base{	# 定义返回数据	protected $data;	public function __construct()	{		# 获取用户信息		$user = new User();		$this->user = $user->data();		$this->data['config'] = Dever::db('main/config')->one(1);		$this->data['time'] = time();		$this->data['uid'] = -1;		if ($this->user) {			$this->data['uid'] = $this->user['id'];		}	}	/**	 * 检测用户信息	 *	 * @return mixed	 */	protected function checkUser($state = false)	{		if ($this->data['uid'] <= 0) {			# 需要登录			$login = new Login();			$login->location();		}		$where['uid'] = $this->data['uid'];		# 获取用户积分		$this->data['user_score'] = Dever::db('task/user_score')->one($where);		if (!$this->data['user_score']) {			$this->data['user_score'] = array();        	$this->data['user_score']['score'] = 0;        	$this->data['user_score']['uid'] = $where['uid'];        	$this->data['user_score']['id'] = Dever::db('task/user_score')->insert($this->data['user_score']);        }		# 检测用户是否认证		$this->data['user_info'] = Dever::db('task/user_info')->one($where);		if ($this->data['user_info'] && $this->data['user_info']['status'] == 2) {			# 已认证			return true;		} else {			if ($state == true) {				# 未认证 code = 110 就是需要认证,需要跳转到认证页面				//Dever::alert('资料认证通过后才能领取任务', 110);			}			return false;		}	}	public function token($request = array())    {    	$request['uid'] = Dever::encode($this->data['uid']);        return http_build_query(Dever::token($request));    }    public function url($method, $request = array())    {        return Dever::proxy($method, $this->token($request));    }}
 |