Dashboard.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <?php
  2. /**
  3. * ----------------------------------------------------------------------------
  4. * 行到水穷处,坐看云起时
  5. * 开发软件,找贵阳云起信息科技,官网地址:https://www.56q7.com/
  6. * ----------------------------------------------------------------------------
  7. * Author: 老成
  8. * email:85556713@qq.com
  9. */
  10. declare (strict_types = 1);
  11. namespace app\admin\controller;
  12. use app\common\model\Admin;
  13. use app\common\model\delivery\Text;
  14. use app\common\model\User;
  15. use app\common\model\Category;
  16. use app\common\model\Attachment;
  17. use app\common\library\Date;
  18. use app\common\controller\Backend;
  19. use think\annotation\route\Route;
  20. use think\facade\Db;
  21. /**
  22. * 控制台
  23. */
  24. class Dashboard extends Backend
  25. {
  26. public function _initialize()
  27. {
  28. parent::_initialize();
  29. }
  30. /**
  31. * 查看
  32. */
  33. #[Route('GET','dashboard/index')]
  34. public function index()
  35. {
  36. if($this->request->isAjax()){
  37. //模拟数据面板
  38. $panel=[
  39. rand(100,1000),
  40. rand(100,1000),
  41. rand(100,1000),
  42. rand(100,1000),
  43. ];
  44. //模拟折线图
  45. $line=[
  46. 'date'=>[],
  47. 'data'=>[]
  48. ];
  49. $time=time();
  50. for($i=0;$i<7;$i++){
  51. $line['date'][]=date('Y-m-d',$time-(7-$i)*24*3600);
  52. $line['data'][]=rand(100,1000);
  53. }
  54. //模拟表格
  55. $names=['张三','李四','老王','老成','黑娃'];
  56. $table=[];
  57. $total=rand(100,999);
  58. foreach ($names as $key=>$name){
  59. $table[]=[
  60. 'sort'=>$key+1,'name'=>$name,'total'=>$total,'money'=>$total*rand(10,20)
  61. ];
  62. $total-=rand(10,99);
  63. }
  64. //模拟柱状图
  65. $bar=[
  66. 'date'=>['周一','周二','周三','周四','周五','周六','周日'],
  67. 'name'=>['张三','李四','老王'],
  68. 'data'=>[
  69. [],
  70. [],
  71. []
  72. ]
  73. ];
  74. for($i=0;$i<3;$i++){
  75. foreach ($bar['date'] as $name){
  76. $bar['data'][$i][]=rand(100,999);
  77. }
  78. }
  79. //模拟饼状图
  80. $pie=[
  81. ['name'=>'张三','value'=>rand(100,999)],
  82. ['name'=>'李四','value'=>rand(100,999)],
  83. ['name'=>'老王','value'=>rand(100,999)],
  84. ['name'=>'黑娃','value'=>rand(100,999)],
  85. ];
  86. //模拟订单
  87. $count=rand(100,999);
  88. $today=rand(1000,9999);
  89. $yestoday=rand(1000,9999);
  90. $order=[
  91. 'count'=>$count,
  92. 'total'=>1000,
  93. 'today'=>$today.'.'.rand(10,99),
  94. 'yestoday'=>$yestoday.'.'.rand(10,99),
  95. 'percentage'=>[
  96. round($count/10),
  97. $yestoday>$today?round($today/$yestoday*100):100,
  98. ]
  99. ];
  100. $this->success('',compact('panel','line','table','bar','pie','order'));
  101. }
  102. return $this->fetch();
  103. }
  104. #[Route('GET','dashboard/platform1')]
  105. public function platform1()
  106. {
  107. return $this->fetch();
  108. }
  109. #[Route('GET','dashboard/platform2')]
  110. public function platform2()
  111. {
  112. return $this->fetch();
  113. }
  114. }