Index.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. namespace app\user\controller;
  3. use app\common\controller\Userend;
  4. use app\common\model\user\Log;
  5. use think\Config;
  6. use think\Hook;
  7. use think\Validate;
  8. /**
  9. * 会员中心入口文件
  10. */
  11. class Index extends Userend
  12. {
  13. protected $noNeedLogin = ['login'];
  14. protected $noNeedRight = ['index', 'logout'];
  15. protected $layout = '';
  16. public function _initialize()
  17. {
  18. parent::_initialize();
  19. if (!Config::get('fastadmin.usercenter')) {
  20. $this->error(__('User center already closed'));
  21. }
  22. }
  23. /**
  24. * 会员中心
  25. */
  26. public function index()
  27. {
  28. //左侧菜单
  29. list($menulist, $navlist, $fixedmenu, $referermenu) = $this->auth->getSidebar([
  30. 'dashboard' => 'hot',
  31. ], $this->view->site['fixedpage']);
  32. $action = $this->request->request('action');
  33. if ($this->request->isPost()) {
  34. if ($action == 'refreshmenu') {
  35. $this->success('', null, ['menulist' => $menulist, 'navlist' => $navlist]);
  36. }
  37. }
  38. $this->view->assign('menulist', $menulist);
  39. $this->view->assign('navlist', $navlist);
  40. $this->view->assign('fixedmenu', $fixedmenu);
  41. $this->view->assign('referermenu', $referermenu);
  42. $this->view->assign('title', __('User center'));
  43. return $this->view->fetch();
  44. }
  45. /**
  46. * 登录
  47. */
  48. public function login()
  49. {
  50. $this->redirect("index/user/login");
  51. }
  52. /**
  53. * 注销
  54. */
  55. public function logout()
  56. {
  57. //注销本站
  58. Log::setTitle(__('Logout'));
  59. $this->auth->logout();
  60. $synchtml = '';
  61. ////////////////同步到Ucenter////////////////
  62. if (defined('UC_STATUS') && UC_STATUS) {
  63. $uc = new \addons\ucenter\library\client\Client();
  64. $synchtml = $uc->uc_user_synlogout();
  65. }
  66. $this->success(__('Logout successful') . $synchtml, url('user/index/index'));
  67. }
  68. }