| 
									
										
										
										
											2021-11-18 17:57:04 +08:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace app\controller\manager; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | use app\model\AccountRecord; | 
					
						
							|  |  |  | use app\model\Overview; | 
					
						
							|  |  |  | use app\model\AccountRole; | 
					
						
							|  |  |  | use app\model\Appointment; | 
					
						
							|  |  |  | use app\model\Account; | 
					
						
							|  |  |  | use app\repository\CmsRepository; | 
					
						
							|  |  |  | use Exception; | 
					
						
							|  |  |  | use think\db\exception\DataNotFoundException; | 
					
						
							|  |  |  | use think\db\exception\DbException; | 
					
						
							|  |  |  | use think\db\exception\ModelNotFoundException; | 
					
						
							|  |  |  | use think\response\Json; | 
					
						
							|  |  |  | use think\response\View; | 
					
						
							|  |  |  | use app\model\Member; | 
					
						
							|  |  |  | use app\model\Menu; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class Index extends Base | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     //TODO 权限未完善
 | 
					
						
							|  |  |  |     protected $noNeedLogin = ['index', 'init']; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * 后台初始页面 随后进入dashboard页面 | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return View | 
					
						
							|  |  |  |      * @throws DataNotFoundException | 
					
						
							|  |  |  |      * @throws DbException | 
					
						
							|  |  |  |      * @throws ModelNotFoundException | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function index(): View | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $auth               = session('auth'); | 
					
						
							|  |  |  |         $this->data['user'] = Member::findById($auth['user_id'] ?? 0, ['id', 'username', 'nickname', 'mobile']); | 
					
						
							|  |  |  |         return $this->view(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * 控制台 | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return Json|View | 
					
						
							|  |  |  |      * @throws Exception | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function dashboard() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return $this->view(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * 菜单初始化 | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return Json | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function init(): Json | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $res             = []; | 
					
						
							|  |  |  |         $res['homeInfo'] = ['title' => '控制台', 'href' => "manager/index/dashboard"]; | 
					
						
							| 
									
										
										
										
											2021-12-08 10:25:31 +08:00
										 |  |  |         $res['logoInfo'] = ['title' => '优惠券', 'href' => "", 'image' => '/static/manager/image/logo.png']; | 
					
						
							| 
									
										
										
										
											2021-11-18 17:57:04 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-01 16:53:44 +08:00
										 |  |  |         $menus           = CmsRepository::getInstance()->getMenuList(Menu::TYPE_MENU, Menu::SHOW_YES)->toArray(); | 
					
						
							|  |  |  |         $userId          = $this->auth['user_id'] ?? 0; | 
					
						
							|  |  |  |         $menus           = CmsRepository::getInstance()->handMenuRule($userId, $menus); | 
					
						
							|  |  |  |         $menus           = CmsRepository::getInstance()->buildMenuChild(0, $menus, 'child'); | 
					
						
							| 
									
										
										
										
											2021-11-18 17:57:04 +08:00
										 |  |  |         $res['menuInfo'] = $menus; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return json($res); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * 缓存清理 | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return Json | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function clear(): Json | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $res = ['code' => 1, 'msg' => '服务端清理缓存成功']; | 
					
						
							|  |  |  |         sleep(2); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return json($res); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } |