diff --git a/app/Admin/Controllers/HomeController.php b/app/Admin/Controllers/HomeController.php
index d576f3af..6c387cd2 100644
--- a/app/Admin/Controllers/HomeController.php
+++ b/app/Admin/Controllers/HomeController.php
@@ -2,8 +2,15 @@
namespace App\Admin\Controllers;
+use App\Admin\Metrics\Dashboard;
+use App\Admin\Metrics\NewUsers;
+use App\Admin\Metrics\Orders;
+use App\Admin\Metrics\StatisticsTotal;
+use App\Admin\Metrics\Users;
use App\Http\Controllers\Controller;
+use Dcat\Admin\Layout\Column;
use Dcat\Admin\Layout\Content;
+use Dcat\Admin\Layout\Row;
class HomeController extends Controller
{
@@ -11,6 +18,18 @@ class HomeController extends Controller
{
return $content
->header('首页')
- ->description('开发中...');
+ ->description('开发中...')
+ ->body(function (Row $row) {
+ $row->column(6, function (Column $column) {
+ $column->row(Dashboard::title());
+ $column->row(new StatisticsTotal());
+ });
+
+ $row->column(6, function (Column $column) {
+ $column->row(new NewUsers());
+ $column->row(new Orders());
+ $column->row(new Users());
+ });
+ });
}
}
diff --git a/app/Admin/Forms/Settings/App.php b/app/Admin/Forms/Settings/App.php
index 8c9d3318..9a61481d 100644
--- a/app/Admin/Forms/Settings/App.php
+++ b/app/Admin/Forms/Settings/App.php
@@ -60,5 +60,6 @@ class App extends Form
$this->text('article_about_us', '关于我们文章指定(链接)')->value($appSettings['article_about_us'] ?? '');
$this->text('article_user_promotion_agreement', '服务协议文章指定(链接)')->value($appSettings['article_user_promotion_agreement'] ?? '');
$this->text('article_user_hide_agreement', '隐私协议文章指定(链接)')->value($appSettings['article_user_hide_agreement'] ?? '');
+ $this->text('article_user_agent_agreement', '升级规则文章指定(链接)')->value($appSettings['article_user_agent_agreement'] ?? '');
}
}
diff --git a/app/Admin/Metrics/Dashboard.php b/app/Admin/Metrics/Dashboard.php
new file mode 100644
index 00000000..53e32e71
--- /dev/null
+++ b/app/Admin/Metrics/Dashboard.php
@@ -0,0 +1,11 @@
+title('新注册');
+ $this->dropdown([
+ '7' => '最近7天',
+ '30' => '最近30天',
+ '90' => '最近3个月',
+ ]);
+ }
+
+ /**
+ * 处理请求
+ *
+ * @param Request $request
+ *
+ * @return mixed|void
+ */
+ public function handle(Request $request)
+ {
+ $generator = function ($len, $min = 10, $max = 300) {
+ for ($i = 0; $i <= $len; $i++) {
+ yield mt_rand($min, $max);
+ }
+ };
+
+ switch ($request->get('option')) {
+ case '365':
+ // 卡片内容
+ $this->withContent(mt_rand(1000, 5000).'k');
+ // 图表数据
+ $this->withChart(collect($generator(30))->toArray());
+ break;
+ case '30':
+ // 卡片内容
+ $this->withContent(mt_rand(400, 1000).'k');
+ // 图表数据
+ $this->withChart(collect($generator(30))->toArray());
+ break;
+ case '28':
+ // 卡片内容
+ $this->withContent(mt_rand(400, 1000).'k');
+ // 图表数据
+ $this->withChart(collect($generator(28))->toArray());
+ break;
+ case '7':
+ default:
+ // 卡片内容
+ $this->withContent('89.2k');
+ // 图表数据
+ $this->withChart([28, 40, 36, 52, 38, 60, 55]);
+ }
+ }
+
+ /**
+ * 设置图表数据.
+ *
+ * @param array $data
+ *
+ * @return $this
+ */
+ public function withChart(array $data)
+ {
+ return $this->chart([
+ 'series' => [
+ [
+ 'name' => $this->title,
+ 'data' => $data,
+ ],
+ ],
+ ]);
+ }
+
+ /**
+ * 设置卡片内容.
+ *
+ * @param string $content
+ *
+ * @return $this
+ */
+ public function withContent($content)
+ {
+ return $this->content(
+ <<
+
{$content}
+ {$this->title}
+
+HTML
+ );
+ }
+}
diff --git a/app/Admin/Metrics/Orders.php b/app/Admin/Metrics/Orders.php
new file mode 100644
index 00000000..4fdad338
--- /dev/null
+++ b/app/Admin/Metrics/Orders.php
@@ -0,0 +1,116 @@
+dark35();
+
+ // 卡片内容宽度
+ $this->contentWidth(5, 7);
+ // 标题
+ $this->title('订单');
+ // 设置下拉选项
+ $this->dropdown([
+ '7' => '最近7天',
+ '28' => '最近30天',
+ ]);
+ // 设置图表颜色
+ $this->chartColors([
+ $dark35,
+ $dark35,
+ $dark35,
+ $dark35,
+ $dark35,
+ $dark35,
+ $color->primary(),
+ ]);
+ }
+
+ /**
+ * 处理请求
+ *
+ * @param Request $request
+ *
+ * @return mixed|void
+ */
+ public function handle(Request $request)
+ {
+ switch ($request->get('option')) {
+ case '7':
+ default:
+ // 卡片内容
+ $this->withContent('2.7k', '+5.2%');
+
+ // 图表数据
+ $this->withChart([
+ [
+ 'name' => 'Sessions',
+ 'data' => [75, 125, 225, 250, 125, 75, 25],
+ ],
+ ]);
+ }
+ }
+
+ /**
+ * 设置图表数据.
+ *
+ * @param array $data
+ *
+ * @return $this
+ */
+ public function withChart(array $data)
+ {
+ return $this->chart([
+ 'series' => $data,
+ ]);
+ }
+
+ /**
+ * 设置卡片内容.
+ *
+ * @param string $title
+ * @param string $value
+ * @param string $style
+ *
+ * @return $this
+ */
+ public function withContent($title, $value, $style = 'success')
+ {
+ // 根据选项显示
+ $label = strtolower(
+ $this->dropdown[request()->option] ?? 'last 7 days'
+ );
+
+ $minHeight = '183px';
+
+ return $this->content(
+ <<
+
+
{$title}
+
+
+
+ 查看详情
+
+HTML
+ );
+ }
+}
diff --git a/app/Admin/Metrics/StatisticsTotal.php b/app/Admin/Metrics/StatisticsTotal.php
new file mode 100644
index 00000000..68226b92
--- /dev/null
+++ b/app/Admin/Metrics/StatisticsTotal.php
@@ -0,0 +1,124 @@
+title('统计预览');
+ $this->height(400);
+ $this->contentWidth(12, 0);
+
+ // $this->chartLabels('Completed Tickets');
+ // $this->dropdown([
+ // '7' => 'Last 7 Days',
+ // '28' => 'Last 28 Days',
+ // '30' => 'Last Month',
+ // '365' => 'Last Year',
+ // ]);
+ }
+
+ /**
+ * 处理请求
+ *
+ * @param Request $request
+ *
+ * @return mixed|void
+ */
+ public function handle(Request $request)
+ {
+ // 卡片内容
+ $this->withContent([
+ 'total_points'=> 999999999,
+ 'total_wallet'=> 999999999.99,
+ 'total_balance'=> 999999999.99,
+ 'total_distribution'=> 999999999.99,
+ 'total_quota_v2' => 999999999.99,
+ 'total_quota_v1' => 999999999.99,
+ ]);
+ }
+
+ /**
+ * 卡片内容
+ *
+ * @param string $content
+ *
+ * @return $this
+ */
+ public function withContent($content)
+ {
+ return $this->content(
+ <<
+
+
+
{$content['total_distribution']}
+ 当前预收益
+
+
+
{$content['total_wallet']}
+ 总可提
+
+
+
{$content['total_balance']}
+ 总余额
+
+
+
+
+
{$content['total_points']}
+ 总积分
+
+
+
{$content['total_quota_v2']}
+ 新配额
+
+
+
{$content['total_quota_v1']}
+ 老配额
+
+
+HTML
+ );
+ }
+
+ /**
+ * 卡片底部内容.
+ *
+ * @param string $new
+ * @param string $open
+ * @param string $response
+ *
+ * @return $this
+ */
+ public function withFooter($new, $open, $response)
+ {
+ return $this->footer(
+ <<
+
+
+
Open Tickets
+
{$open}
+
+
+
Response Time
+
{$response}
+
+
+HTML
+ );
+ }
+}
diff --git a/app/Admin/Metrics/Users.php b/app/Admin/Metrics/Users.php
new file mode 100644
index 00000000..8e40deca
--- /dev/null
+++ b/app/Admin/Metrics/Users.php
@@ -0,0 +1,163 @@
+title('累计会员');
+ $this->contentWidth(4, 8);
+ $this->chartLabels(UserInfo::$agentLevelTexts);
+ $this->chartHeight(300);
+ $this->chartOption('chart.width', '300');
+ $this->chart->style('float: none;');
+ }
+
+ /**
+ * 处理请求
+ *
+ * @param Request $request
+ *
+ * @return mixed|void
+ */
+ public function handle(Request $request)
+ {
+ switch ($request->get('option')) {
+ case '365':
+ case '30':
+ case '28':
+ case '7':
+ default:
+ // 卡片内容
+ $this->withContent(23043, 14658, 4758);
+
+ // 图表数据
+ $this->withChart([70, 52, 26]);
+
+ // 总数
+ $this->chartTotal('Total', 344);
+ }
+ }
+
+ /**
+ * 设置图表数据.
+ *
+ * @param array $data
+ *
+ * @return $this
+ */
+ public function withChart(array $data)
+ {
+ return $this->chart([
+ 'series' => $data,
+ ]);
+ }
+
+ /**
+ * 卡片内容.
+ *
+ * @param int $finished
+ * @param int $pending
+ * @param int $rejected
+ * @param int $finished
+ * @param int $pending
+ * @param int $rejected
+ * @param int $rejected
+ *
+ * @return $this
+ */
+ public function withContent($finished, $pending, $rejected)
+ {
+ return $this->content(
+ <<
+
+
+
+ 粉丝
+
+
+ {$finished}
+
+
+
+
+
+
+ 店铺
+
+
+ {$pending}
+
+
+
+
+
+ 社区
+
+
+ {$rejected}
+
+
+
+
+
+ 区级
+
+
+ {$finished}
+
+
+
+
+
+
+ 市级
+
+
+ {$pending}
+
+
+
+
+
+
+ 省级
+
+
+ {$rejected}
+
+
+
+
+
+ 分公司
+
+
+ {$rejected}
+
+
+
+
+
+ 董事
+
+
+ {$rejected}
+
+
+
+HTML
+ );
+ }
+}
diff --git a/database/seeders/AppSettingSeeder.php b/database/seeders/AppSettingSeeder.php
index 3149d38e..91443198 100644
--- a/database/seeders/AppSettingSeeder.php
+++ b/database/seeders/AppSettingSeeder.php
@@ -31,6 +31,7 @@ class AppSettingSeeder extends Seeder
'article_about_us' => env('APP_URL', '').'/h5/articles/1',
'article_user_promotion_agreement' => env('APP_URL', '').'/h5/articles/2',
'article_user_hide_agreement' => env('APP_URL', '').'/h5/articles/3',
+ 'article_user_agent_agreement' => env('APP_URL', '').'/h5/articles/4',
'invite_uri' => '',
'search_hot_keys' => '搜索热词,分词1,分词2,分词3',
],
diff --git a/resources/views/admin/metrics/dashboard.blade.php b/resources/views/admin/metrics/dashboard.blade.php
new file mode 100644
index 00000000..1563606d
--- /dev/null
+++ b/resources/views/admin/metrics/dashboard.blade.php
@@ -0,0 +1,74 @@
+
+
+
+
+
+
 }})
+
+
+
{{ config('admin.name') }}
+
+
+
+
+