From aac0011daf2363792781aa36cd85ad6da5cad3a8 Mon Sep 17 00:00:00 2001 From: zeyan <258785420@qq.com> Date: Sat, 2 Aug 2025 10:49:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- niucloud/app/api/controller/Dashboard.php | 599 ++++++++++++++++++ niucloud/app/api/route/route.php | 3 + .../api/apiService/ResourceSharingService.php | 2 +- .../components/dashboard/DashboardLoading.vue | 73 +++ .../components/dashboard/DashboardWebView.vue | 318 ++++++++++ uniapp/pages-market/clue/index.vue | 13 +- uniapp/pages.json | 9 + uniapp/pages/common/dashboard/webview.vue | 280 ++++++++ uniapp/pages/common/home/index.vue | 27 +- 9 files changed, 1315 insertions(+), 9 deletions(-) create mode 100644 niucloud/app/api/controller/Dashboard.php create mode 100644 uniapp/components/dashboard/DashboardLoading.vue create mode 100644 uniapp/components/dashboard/DashboardWebView.vue create mode 100644 uniapp/pages/common/dashboard/webview.vue diff --git a/niucloud/app/api/controller/Dashboard.php b/niucloud/app/api/controller/Dashboard.php new file mode 100644 index 00000000..2b992317 --- /dev/null +++ b/niucloud/app/api/controller/Dashboard.php @@ -0,0 +1,599 @@ +request->get('type', 'my_data'); // 页面类型 + $token = $this->request->get('token', ''); // 用户token + $platform = $this->request->get('platform', 'web'); // 平台标识 + + // 验证token和获取用户信息 + if (empty($token)) { + return $this->renderErrorPage('缺少用户认证信息'); + } + + try { + // 这里应该验证token,暂时跳过验证用于测试 + $userInfo = $this->getMockUserInfo($type); + + // 根据页面类型渲染不同内容 + $htmlContent = $this->renderDashboardPage($type, $userInfo, $platform); + + // 输出HTML内容 + return response($htmlContent)->header([ + 'Content-Type' => 'text/html; charset=utf-8', + 'Cache-Control' => 'no-cache, no-store, must-revalidate', + 'Pragma' => 'no-cache', + 'Expires' => '0' + ]); + + } catch (\Exception $e) { + return $this->renderErrorPage('页面加载失败: ' . $e->getMessage()); + } + } + + /** + * 渲染Dashboard页面 + */ + private function renderDashboardPage($type, $userInfo, $platform) + { + // 获取页面数据 + $pageData = $this->getPageData($type, $userInfo); + + // 页面标题映射 + $titleMap = [ + 'my_data' => '我的数据', + 'dept_data' => '部门数据', + 'campus_data' => '校区数据' + ]; + + $pageTitle = $titleMap[$type] ?? '数据统计'; + + // 生成HTML内容 + return $this->generateHTML($pageTitle, $pageData, $platform); + } + + /** + * 获取页面数据 + */ + private function getPageData($type, $userInfo) + { + switch ($type) { + case 'my_data': + return $this->getMyData($userInfo); + case 'dept_data': + return $this->getDeptData($userInfo); + case 'campus_data': + return $this->getCampusData($userInfo); + default: + return []; + } + } + + /** + * 获取我的数据 + */ + private function getMyData($userInfo) + { + return [ + 'stats' => [ + ['label' => '本月签约客户', 'value' => 12, 'unit' => '人', 'trend' => '+15%'], + ['label' => '本月完成业绩', 'value' => 85000, 'unit' => '元', 'trend' => '+8%'], + ['label' => '跟进客户数', 'value' => 45, 'unit' => '人', 'trend' => '+5%'], + ['label' => '转化率', 'value' => 26.7, 'unit' => '%', 'trend' => '+2.3%'] + ], + 'charts' => [ + 'monthly_trend' => [ + 'title' => '月度业绩趋势', + 'data' => [65000, 72000, 68000, 75000, 82000, 85000] + ], + 'customer_source' => [ + 'title' => '客户来源分布', + 'data' => [ + ['name' => '线上推广', 'value' => 35], + ['name' => '转介绍', 'value' => 28], + ['name' => '电话营销', 'value' => 22], + ['name' => '其他', 'value' => 15] + ] + ] + ] + ]; + } + + /** + * 获取部门数据 + */ + private function getDeptData($userInfo) + { + return [ + 'stats' => [ + ['label' => '部门总业绩', 'value' => 520000, 'unit' => '元', 'trend' => '+12%'], + ['label' => '团队人数', 'value' => 8, 'unit' => '人', 'trend' => '0%'], + ['label' => '平均业绩', 'value' => 65000, 'unit' => '元', 'trend' => '+12%'], + ['label' => '部门排名', 'value' => 2, 'unit' => '名', 'trend' => '+1'] + ], + 'charts' => [ + 'team_performance' => [ + 'title' => '团队成员业绩排行', + 'data' => [ + ['name' => '张三', 'value' => 85000], + ['name' => '李四', 'value' => 72000], + ['name' => '王五', 'value' => 68000], + ['name' => '赵六', 'value' => 65000] + ] + ] + ] + ]; + } + + /** + * 获取校区数据 + */ + private function getCampusData($userInfo) + { + return [ + 'stats' => [ + ['label' => '校区总业绩', 'value' => 1200000, 'unit' => '元', 'trend' => '+18%'], + ['label' => '部门数量', 'value' => 5, 'unit' => '个', 'trend' => '0%'], + ['label' => '员工总数', 'value' => 32, 'unit' => '人', 'trend' => '+3'], + ['label' => '客户总数', 'value' => 245, 'unit' => '人', 'trend' => '+25'] + ], + 'charts' => [ + 'dept_performance' => [ + 'title' => '部门业绩对比', + 'data' => [ + ['name' => '销售一部', 'value' => 320000], + ['name' => '销售二部', 'value' => 280000], + ['name' => '销售三部', 'value' => 260000], + ['name' => '客服部', 'value' => 180000], + ['name' => '行政部', 'value' => 160000] + ] + ] + ] + ]; + } + + /** + * 获取模拟用户信息 + */ + private function getMockUserInfo($type) + { + return [ + 'id' => 1, + 'name' => '测试员工', + 'department' => '销售部', + 'campus' => '总校区', + 'role' => 'staff' + ]; + } + + /** + * 生成HTML内容 + */ + private function generateHTML($title, $data, $platform) + { + $statsHtml = ''; + if (!empty($data['stats'])) { + foreach ($data['stats'] as $stat) { + $trendColor = strpos($stat['trend'], '+') === 0 ? '#4CAF50' : '#FF5722'; + $statsHtml .= " +