68 lines
2.7 KiB
PHP
68 lines
2.7 KiB
PHP
<?php
|
|
namespace app\deal\controller;
|
|
use think\Controller;
|
|
use think\Db;
|
|
use think\Request;
|
|
use think\Session;
|
|
class Scan extends Controller{
|
|
public function create_online_token($user){
|
|
//$ip = getIP();
|
|
//$time = time();
|
|
return md5($user['encrypt'].$user['password']);
|
|
}
|
|
|
|
public function index(){
|
|
// 用户信息
|
|
$user_info = Session::get('user_info');
|
|
$user = Db::name('user_controller')->where(array('id' => $user_info['id']))->find();
|
|
if(!$user) exit('用户不存在');
|
|
// 验证token
|
|
$online_token = $this->create_online_token($user);
|
|
$r = Db::name('user_controller')->where(array('id' => $user_info['id']))->update(array('login_token' => $online_token));
|
|
// 获取桌子信息
|
|
$table = Db::name('table')->where(array('id' => $user_info['table_id']))->find();
|
|
|
|
// 渲染参数和模板
|
|
$this->assign('online_token',$online_token);
|
|
$this->assign('table',$table);
|
|
$this->assign('user',$user);
|
|
$this->assign('websocketUrl',$table['websocket_url']);
|
|
return $this->fetch();
|
|
}
|
|
|
|
public function nn_index(){
|
|
// 用户信息
|
|
$user_info = Session::get('user_info');
|
|
$user = Db::name('user_controller')->where(array('id' => $user_info['id']))->find();
|
|
if(!$user) exit('用户不存在');
|
|
// 验证token
|
|
$online_token = $this->create_online_token($user);
|
|
$r = Db::name('user_controller')->where(array('id' => $user_info['id']))->update(array('login_token' => $online_token));
|
|
// 获取桌子信息
|
|
$table = Db::name('table')->where(array('id' => $user_info['table_id']))->find();
|
|
|
|
// 渲染参数和模板
|
|
$this->assign('online_token',$online_token);
|
|
$this->assign('table',$table);
|
|
$this->assign('user',$user);
|
|
$this->assign('websocketUrl',$table['websocket_url']);
|
|
return $this->fetch();
|
|
}
|
|
public function tc_index(){
|
|
// 用户信息
|
|
$user_info = Session::get('user_info');
|
|
$user = Db::name('user_controller')->where(array('id' => $user_info['id']))->find();
|
|
if(!$user) exit('用户不存在');
|
|
// 验证token
|
|
$online_token = $this->create_online_token($user);
|
|
$r = Db::name('user_controller')->where(array('id' => $user_info['id']))->update(array('login_token' => $online_token));
|
|
// 获取桌子信息
|
|
$table = Db::name('table')->where(array('id' => $user_info['table_id']))->find();
|
|
// 渲染参数和模板
|
|
$this->assign('online_token',$online_token);
|
|
$this->assign('table',$table);
|
|
$this->assign('user',$user);
|
|
$this->assign('websocketUrl',$table['websocket_url']);
|
|
return $this->fetch();
|
|
}
|
|
} |