MainController.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: 小夏 < 449134904@qq.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\admin\controller;
  12. use app\admin\model\UserModel;
  13. use app\common\Fun;
  14. use app\love\model\UserAuthModel;
  15. use cmf\controller\AdminBaseController;
  16. use think\Db;
  17. class MainController extends AdminBaseController
  18. {
  19. /**
  20. * 后台欢迎页
  21. */
  22. public function index()
  23. {
  24. $auth = [
  25. 'total' => 0,
  26. 'man' => 0,
  27. 'woman' => 0,
  28. ];
  29. $auth_list = UserAuthModel::column('idcard');
  30. foreach ($auth_list as $v) {
  31. $auth['total']++;
  32. Fun::getSexByIdCard($v) == 1 ? $auth['man']++ : $auth['woman']++;
  33. }
  34. $user = [];
  35. $user_where = [
  36. ['user_type', '=', 2],
  37. ['is_complete', '=', 1],
  38. ];
  39. $user['total'] = UserModel::where($user_where)->count();
  40. $user['man'] = UserModel::where($user_where)->where('sex',1)->count();
  41. $user['woman'] = UserModel::where($user_where)->where('sex',2)->count();
  42. $config = Db::name('config')->find();
  43. $this->assign('auth',$auth);
  44. $this->assign('user',$user);
  45. $this->assign('config',$config);
  46. return $this->fetch();
  47. }
  48. public function dashboardWidget()
  49. {
  50. $dashboardWidgets = [];
  51. $widgets = $this->request->param('widgets/a');
  52. if (!empty($widgets)) {
  53. foreach ($widgets as $widget) {
  54. if ($widget['is_system']) {
  55. array_push($dashboardWidgets, ['name' => $widget['name'], 'is_system' => 1]);
  56. } else {
  57. array_push($dashboardWidgets, ['name' => $widget['name'], 'is_system' => 0]);
  58. }
  59. }
  60. }
  61. cmf_set_option('admin_dashboard_widgets', $dashboardWidgets, true);
  62. $this->success('更新成功!');
  63. }
  64. }