- 按 docs/renew-code-comment.md 将 PHP 文件头改为带边框的 Author 注释\n- 注释中的 crmeb.com 替换为 uj345.cn(代码字符串中的外链未改)\n- 新增 docs/renew-code-comment.md 说明 Made-with: Cursor
67 lines
1.6 KiB
PHP
67 lines
1.6 KiB
PHP
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | Author: ScottPan Team
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\controller\api\pc;
|
|
|
|
use app\services\pc\LoginServices;
|
|
use crmeb\services\CacheService;
|
|
use think\annotation\Inject;
|
|
|
|
class Login
|
|
{
|
|
/**
|
|
* @var LoginServices
|
|
*/
|
|
#[Inject]
|
|
protected LoginServices $services;
|
|
|
|
/**
|
|
* 获取扫码登陆KEY
|
|
* @return mixed
|
|
*/
|
|
public function getLoginKey()
|
|
{
|
|
$key = md5(time() . uniqid());
|
|
$time = time() + 600;
|
|
CacheService::set($key, 1, 600);
|
|
return app('json')->success(['key' => $key, 'time' => $time]);
|
|
}
|
|
|
|
/**
|
|
* 扫码登陆
|
|
* @param string $key
|
|
* @return mixed
|
|
* @throws \Psr\SimpleCache\InvalidArgumentException
|
|
*/
|
|
public function scanLogin(string $key)
|
|
{
|
|
return app('json')->success($this->services->scanLogin($key));
|
|
}
|
|
|
|
/**
|
|
* 开放平台扫码登录
|
|
* @return mixed
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
*/
|
|
public function wechatAuth()
|
|
{
|
|
return app('json')->success($this->services->wechatAuth());
|
|
}
|
|
|
|
/**
|
|
* 获取公众平台id
|
|
* @return mixed
|
|
*/
|
|
public function getAppid()
|
|
{
|
|
return app('json')->success([
|
|
'appid' => sys_config('wechat_open_app_id'),
|
|
'version' => get_crmeb_version()
|
|
]);
|
|
}
|
|
}
|