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 .= " +
+
{$stat['label']}
+
{$stat['value']}{$stat['unit']}
+
{$stat['trend']}
+
+ "; + } + } + + // 生成图表数据的JavaScript + $chartsScript = ''; + if (!empty($data['charts'])) { + foreach ($data['charts'] as $chartId => $chart) { + $chartData = json_encode($chart['data']); + $chartsScript .= " + renderChart('{$chartId}', '{$chart['title']}', {$chartData}); + "; + } + } + + return " + + + + + + {$title} + + + + +
+

{$title}

+ +
+ {$statsHtml} +
+ +
+
+ + + + + +"; + } + + /** + * 渲染错误页面 + */ + private function renderErrorPage($message) + { + return response(" + + + + + + 页面错误 + + + +
+
⚠️
+
页面加载失败
+
{$message}
+
+ +")->header([ + 'Content-Type' => 'text/html; charset=utf-8' + ]); + } +} \ No newline at end of file diff --git a/niucloud/app/api/route/route.php b/niucloud/app/api/route/route.php index 39ee8bca..2854497b 100644 --- a/niucloud/app/api/route/route.php +++ b/niucloud/app/api/route/route.php @@ -185,6 +185,9 @@ Route::group(function () { //获取微信小程序openid Route::post('common/getMiniWxOpenId', 'apiController.Common/getMiniWxOpenId'); + //Dashboard WebView 页面 + Route::get('dashboard/webview', 'Dashboard/webview'); + //公共端-获取全部课程列表 Route::get('common/getCourseAll', 'apiController.Common/getCourseAll'); //公共端-获取全部班级列表 diff --git a/niucloud/app/service/api/apiService/ResourceSharingService.php b/niucloud/app/service/api/apiService/ResourceSharingService.php index 21094c89..1ef17d58 100644 --- a/niucloud/app/service/api/apiService/ResourceSharingService.php +++ b/niucloud/app/service/api/apiService/ResourceSharingService.php @@ -386,7 +386,7 @@ class ResourceSharingService extends BaseApiService $item['customerResource']['second_visit_status'] = $visit_info[$resource_id]['second_visit_status'] ?? '未到'; // 添加开单状态 - $item['customerResource']['order_status'] = $order_status[$resource_id] ?? '未开单'; + $item['customerResource']['order_status'] = $order_status[$resource_id] ?? '未报名'; } // 添加分配人员信息 diff --git a/uniapp/components/dashboard/DashboardLoading.vue b/uniapp/components/dashboard/DashboardLoading.vue new file mode 100644 index 00000000..6a75396e --- /dev/null +++ b/uniapp/components/dashboard/DashboardLoading.vue @@ -0,0 +1,73 @@ + + + + + \ No newline at end of file diff --git a/uniapp/components/dashboard/DashboardWebView.vue b/uniapp/components/dashboard/DashboardWebView.vue new file mode 100644 index 00000000..73fb607b --- /dev/null +++ b/uniapp/components/dashboard/DashboardWebView.vue @@ -0,0 +1,318 @@ + + + + + \ No newline at end of file diff --git a/uniapp/pages-market/clue/index.vue b/uniapp/pages-market/clue/index.vue index fb85a40d..83e86b8d 100644 --- a/uniapp/pages-market/clue/index.vue +++ b/uniapp/pages-market/clue/index.vue @@ -33,26 +33,31 @@ 来源:{{ v.customerResource.source }} - + 来源渠道:{{ v.customerResource.source_channel }} + + 到访备注:{{ v.sixSpeed.consultation_remark || '' }} + - {{ v.customerResource.order_status || '未开单' }} + {{ v.customerResource.order_status || '未报名' }} 一访{{ v.customerResource.first_visit_status || '未到' }} - + 二访{{ v.customerResource.second_visit_status || '未到' }} - + diff --git a/uniapp/pages.json b/uniapp/pages.json index a574ad03..27b7f241 100644 --- a/uniapp/pages.json +++ b/uniapp/pages.json @@ -42,6 +42,15 @@ "navigationBarTextStyle": "white" } }, + { + "path": "pages/common/dashboard/webview", + "style": { + "navigationBarTitleText": "数据统计", + "navigationStyle": "custom", + "navigationBarBackgroundColor": "#181A20", + "navigationBarTextStyle": "white" + } + }, { "path": "pages/student/profile/index", "style": { diff --git a/uniapp/pages/common/dashboard/webview.vue b/uniapp/pages/common/dashboard/webview.vue new file mode 100644 index 00000000..811c99df --- /dev/null +++ b/uniapp/pages/common/dashboard/webview.vue @@ -0,0 +1,280 @@ + + + + + \ No newline at end of file diff --git a/uniapp/pages/common/home/index.vue b/uniapp/pages/common/home/index.vue index 399d523f..f15ad2de 100644 --- a/uniapp/pages/common/home/index.vue +++ b/uniapp/pages/common/home/index.vue @@ -74,17 +74,20 @@ { title: '我的数据', icon: 'bars', - path: '/pages-market/my/my_data' + path: '/pages/common/dashboard/webview', + params: { type: 'my_data' } }, { title: '部门数据', icon: 'staff', - path: '/pages-market/my/dept_data' + path: '/pages/common/dashboard/webview', + params: { type: 'dept_data' } }, { title: '校区数据', icon: 'location-filled', - path: '/pages-market/my/campus_data' + path: '/pages/common/dashboard/webview', + params: { type: 'campus_data' } }, { title: '我的消息', @@ -117,8 +120,24 @@ }, handleGridClick(item) { console.log('点击功能按钮:', item.title, item.path); + + // 构建跳转URL,如果有参数则附加到URL中 + let url = item.path; + if (item.params) { + // 手动构建参数字符串,兼容小程序环境 + const paramStrings = []; + for (const key in item.params) { + if (item.params.hasOwnProperty(key)) { + paramStrings.push(`${encodeURIComponent(key)}=${encodeURIComponent(item.params[key])}`); + } + } + if (paramStrings.length > 0) { + url = `${item.path}?${paramStrings.join('&')}`; + } + } + uni.navigateTo({ - url: item.path, + url: url, fail: (err) => { console.error('页面跳转失败:', err); uni.showToast({