76 lines
2.0 KiB
PHP
76 lines
2.0 KiB
PHP
<?php
|
||
/**
|
||
* @Created by PhpStorm.
|
||
* @Author:Soar
|
||
* @Time:2023/11/16 13:46
|
||
*/
|
||
|
||
namespace app\index\controller;
|
||
|
||
use app\common\controller\Frontend;
|
||
use app\common\library\Token;
|
||
use app\index\service\ScreenService;
|
||
use fast\Random;
|
||
|
||
class Screen extends Frontend
|
||
{
|
||
|
||
protected $layout = 'defaults';
|
||
protected $noNeedLogin = ['getScreenList', 'verify_password'];
|
||
protected $noNeedRight = ['*'];
|
||
|
||
public function _initialize()
|
||
{
|
||
parent::_initialize();
|
||
$this->screenService = new ScreenService();
|
||
|
||
}
|
||
|
||
public function getScreenList()
|
||
{
|
||
// 解决跨域请求接口问题
|
||
header('Access-Control-Allow-Origin: *');
|
||
header('Access-Control-Allow-Credentials: true'); // 设置是否允许发送 cookies
|
||
header('Access-Control-Expose-Headers: *'); //服务器 headers 白名单,可以让客户端进行访问
|
||
header('Access-Control-Allow-Headers: *');
|
||
|
||
$match_id = $this->request->param('match_id');
|
||
if (empty($match_id)) {
|
||
$this->error("赛事id不可为空!");
|
||
}
|
||
$this->screenService->match_id = $match_id;
|
||
$screenList = $this->screenService->screenList($match_id);
|
||
|
||
if (!empty($screenList)) {
|
||
$res['code'] = 1;
|
||
$res['data'] = $screenList;
|
||
$res['msg'] = "获取成功";
|
||
} else {
|
||
$res['code'] = 0;
|
||
$res['data'] = [];
|
||
$res['msg'] = "数据为空";
|
||
}
|
||
|
||
return json($res);
|
||
}
|
||
|
||
public function verify_password()
|
||
{
|
||
$param['look_pwd'] = $this->request->param("password", "123456");
|
||
$param['match_id'] = $this->request->param("match_id", 0);
|
||
|
||
$res = $this->screenService->verifyScreen($param);
|
||
|
||
if ($res) {
|
||
$res['code'] = 1;
|
||
$res['data'] = [];
|
||
$res['msg'] = "验证成功";
|
||
} else {
|
||
$res['code'] = 0;
|
||
$res['data'] = [];
|
||
$res['msg'] = "验证失败";
|
||
}
|
||
|
||
return json($res);
|
||
}
|
||
} |