Files
YwxAppThink/app/member/controller/Index.php
T

204 lines
8.0 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
// +----------------------------------------------------------------------
// | YwxApp [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2026-2036 http://ywxapp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: ywxapp<admin@ywxapp.cn>
// +----------------------------------------------------------------------
declare (strict_types = 1);
namespace app\member\controller;
use ywxapp\controller\MemberBase;
/**
* Index 类
*
* @author ywxapp <admin@ywxapp.cn>
*/
class Index extends MemberBase
{
/**
* Summary of needLogin
* @var array
*/
protected $noNeedLogin = [];
/**
* Summary of needRight
* @var array
*/
protected $noNeedVerify = ['*'];
/**
* 控制器初始化 initialize
* @return void
*/
protected function initialize(){}
/**
* 显示资源列表
*
* @return \think\Response
*/
public function index()
{
// 会员中心主框架为完整 iframe 页面,不需要套用全局 layoutcommon/layout
$this->view->layout(false);
$arrayVar = [
"logo" => [
"title" => "Wxapp Mmember",
"src" => "static/images/logo.png",
],
"menu" => [
"url" => "/user/index/menu",
],
"tabs" => [
"home" => [
"id" => "1",
"href" => "console/index",
"name" => "console:index",
"title" => "首页",
],
],
'container' => 'WXapp', // 容器 ID
'entry' => 'index', // 默认视图文件名
'route_prefix' => '/user/views/',
'engine' => 'html', // 视图文件后缀名
'name' => 'AdminUI', // 系统名称
'theme' => [
'color' => [
['main' => '#20222A', 'selected' => '#16baaa', 'alias' => 'default'],
['main' => '#03152A', 'selected' => '#3B91FF', 'alias' => 'dark-blue'],
['main' => '#2E241B', 'selected' => '#A48566', 'alias' => 'coffee'],
['main' => '#50314F', 'selected' => '#7A4D7B', 'alias' => 'purple-red'],
['main' => '#344058', 'logo' => '#1E9FFF', 'selected' => '#1E9FFF', 'alias' => 'ocean'],
['main' => '#3A3D49', 'logo' => '#2F9688', 'selected' => '#16b777', 'alias' => 'green'],
['main' => '#20222A', 'logo' => '#F78400', 'selected' => '#F78400', 'alias' => 'red'],
['main' => '#28333E', 'logo' => '#AA3130', 'selected' => '#AA3130', 'alias' => 'fashion-red'],
['main' => '#24262F', 'logo' => '#3A3D49', 'selected' => '#16baaa', 'alias' => 'classic-black'],
['logo' => '#226A62', 'header' => '#2F9688', 'alias' => 'green-header'],
['main' => '#344058', 'logo' => '#0085E8', 'selected' => '#1E9FFF', 'header' => '#1E9FFF', 'alias' => 'ocean-header'],
['header' => '#393D49', 'alias' => 'classic-black-header'],
['main' => '#50314F', 'logo' => '#50314F', 'selected' => '#7A4D7B', 'header' => '#50314F', 'alias' => 'purple-red-header'],
['main' => '#28333E', 'logo' => '#28333E', 'selected' => '#AA3130', 'header' => '#AA3130', 'alias' => 'fashion-red-header'],
['main' => '#28333E', 'logo' => '#16baaa', 'selected' => '#16baaa', 'header' => '#16baaa', 'alias' => 'green-header'],
['main' => '#393D49', 'logo' => '#393D49', 'selected' => '#16baaa', 'header' => '#23262E', 'alias' => 'Classic-style1'],
['main' => '#001529', 'logo' => '#001529', 'selected' => '#1890FF', 'header' => '#1890FF', 'alias' => 'Classic-style2'],
['main' => '#25282A', 'logo' => '#25282A', 'selected' => '#35BDB2', 'header' => '#35BDB2', 'alias' => 'Classic-style3'],
],
'initColorIndex' => 3, // 初始颜色索引
],
"other" => ["keepLoad" => "1200", "autoHead" => false, "footer" => false],
];
$this->view->assign($arrayVar);
// 注入当前登录用户,供右上角头像/昵称显示
// 未登录时 $this->auth->model 为 null,需整体降级,避免 null->avatar 致命错误
$authUser = $this->auth->model;
$this->view->assign('member', [
'nickname' => $authUser->nickname ?? '会员',
'avatar' => $authUser->avatar ?? '/static/common/images/avatar.jpg',
'account' => $authUser->account ?? '',
]);
return $this->view->fetch();
}
/**
* 菜单数据
*
* 会员中心菜单:仅指向会员端真实可用页面(避免后台路由导致 403)。
* 结构使用 child 键,供前端 buildSideMenu 递归渲染;route 为 iframe 内打开的地址。
*/
public function menu()
{
$tree = [
[
'name' => 'console',
'title' => '控制台',
'icon' => 'layui-icon-home',
'route' => '/static/member/views/console/index.html',
'child' => [],
],
[
'name' => 'task',
'title' => '任务中心',
'icon' => 'layui-icon-rate',
'route' => '/user/task/index',
'child' => [],
],
[
'name' => 'myprop',
'title' => '我的道具',
'icon' => 'layui-icon-gift',
'route' => '/user/task/myProp',
'child' => [],
],
[
'name' => 'mymedal',
'title' => '我的勋章',
'icon' => 'layui-icon-trophy',
'route' => '/user/medal/index',
'child' => [],
],
[
'name' => 'payment',
'title' => '充值中心',
'icon' => 'layui-icon-rmb',
'route' => '#',
'spread' => false,
'child' => [
[
'name' => 'recharge',
'title' => '套餐充值',
'icon' => '',
'route' => '/user/payment/index',
'child' => [],
],
[
'name' => 'card',
'title' => '卡密充值',
'icon' => '',
'route' => '/user/card/exchange',
'child' => [],
],
[
'name' => 'cardrecord',
'title' => '兑换记录',
'icon' => '',
'route' => '/user/card/records',
'child' => [],
],
],
],
[
'name' => 'forum',
'title' => '社区中心',
'icon' => 'layui-icon-release',
'route' => '#',
'spread' => false,
'child' => [
[
'name' => 'post',
'title' => '我要发帖',
'icon' => '',
'route' => '/forum/member/forum/post',
'child' => [],
],
[
'name' => 'mytopics',
'title' => '我的帖子',
'icon' => '',
'route' => '/forum/member/forum/mytopics',
'child' => [],
],
],
],
];
$this->result->success($tree);
}
}