data['user'] = Member::findById($auth['user_id'] ?? 0, ['id', 'username', 'nickname', 'mobile']); return $this->view(); } /** * 控制台 * * @return Json|View * @throws Exception */ public function dashboard() { if ($this->request->isPost()) { $page = input('page/d', 1); $limit = input('size/d', 10); $items = Overview::findList([], [], $page, $limit, function ($q) { return $q->with(['staff', 'account'])->order('customer', 'desc') ->order('shares', 'desc')->order('views', 'desc')->order('asks', 'desc'); }); $items['list'] = $items['list']->each(function ($item) { $item->nickname = $item->account->nickname ?? ''; $item->real_name = $item->account->real_name ?? ''; $item->staff_name = $item->staff->name ?? ''; $item->phone = $item->account->mobile ?? ''; }); return $this->json(0, '操作成功', $items); } $count['order_placed'] = Order::where("status",Order::STATUS_ORDER_PLACED)->count(); $this->data['count'] = $count; return $this->view(); } /** * 菜单初始化 * * @return Json */ public function init(): Json { $res = []; $res['homeInfo'] = ['title' => '控制台', 'href' => "manager/index/dashboard"]; $res['logoInfo'] = ['title' => '商城', 'href' => "", 'image' => '/static/manager/image/logo.png']; $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'); $res['menuInfo'] = $menus; return json($res); } /** * 缓存清理 * * @return Json */ public function clear(): Json { $res = ['code' => 1, 'msg' => '服务端清理缓存成功']; sleep(2); return json($res); } }