62 lines
1.7 KiB
PHP
Executable File
62 lines
1.7 KiB
PHP
Executable File
<?php
|
||
/**
|
||
* VR票务插件 - C端首页/票夹控制器
|
||
*
|
||
* 路由机制(PluginsService::PluginsControlCall):
|
||
* URL: ?s=plugins/index&pluginsname=vr_ticket&pluginscontrol=index&pluginsaction=wallet
|
||
* → pluginsname=vr_ticket, pluginscontrol=index, pluginsaction=wallet
|
||
* → class = \app\plugins\vr_ticket\index\Index (ucfirst('index') = 'Index')
|
||
* → method = ucfirst('wallet') = 'Wallet'
|
||
* → app/plugins/vr_ticket/index/Index.php::Wallet() ✓
|
||
*
|
||
* @package vr_ticket\index
|
||
*/
|
||
|
||
namespace app\plugins\vr_ticket\index;
|
||
|
||
use app\service\UserService;
|
||
|
||
class Index
|
||
{
|
||
/**
|
||
* 构造方法
|
||
*/
|
||
public function __construct()
|
||
{
|
||
// 初始化检查
|
||
}
|
||
|
||
/**
|
||
* 默认首页(重定向到用户中心或票夹)
|
||
*/
|
||
public function index()
|
||
{
|
||
return $this->wallet();
|
||
}
|
||
|
||
/**
|
||
* 票夹页面
|
||
*
|
||
* URL: ?s=plugins/index&pluginsname=vr_ticket&pluginscontrol=index&pluginsaction=wallet
|
||
*
|
||
* @return string
|
||
*/
|
||
public function wallet()
|
||
{
|
||
// 用 ShopXO 标准方式获取登录用户(session key = 'user_login_info')
|
||
$user = UserService::LoginUserInfo();
|
||
if (empty($user)) {
|
||
// 未登录,重定向到登录页
|
||
return redirect(MyUrl('index/user/logininfo'));
|
||
}
|
||
|
||
// 渲染票夹页面
|
||
// 注意:插件不继承 index/Common,故 $public_host 不会自动赋值
|
||
// 使用 Config('shopxo.host_url') 或显式传递均可,这里用 Config() 保持一致
|
||
return MyView('../../../plugins/vr_ticket/view/goods/ticket_wallet', [
|
||
'user' => $user,
|
||
'public_host' => \think\facade\Config::get('shopxo.host_url'),
|
||
]);
|
||
}
|
||
}
|