12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <?php
- // +----------------------------------------------------------------------
- // | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
- // +----------------------------------------------------------------------
- // | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
- // +----------------------------------------------------------------------
- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
- // +----------------------------------------------------------------------
- // | Author: 小夏 < 449134904@qq.com>
- // +----------------------------------------------------------------------
- namespace app\admin\controller;
- use app\admin\model\UserModel;
- use app\common\Fun;
- use app\love\model\UserAuthModel;
- use cmf\controller\AdminBaseController;
- use think\Db;
- class MainController extends AdminBaseController
- {
- /**
- * 后台欢迎页
- */
- public function index()
- {
- $auth = [
- 'total' => 0,
- 'man' => 0,
- 'woman' => 0,
- ];
- $auth_list = UserAuthModel::column('idcard');
- foreach ($auth_list as $v) {
- $auth['total']++;
- Fun::getSexByIdCard($v) == 1 ? $auth['man']++ : $auth['woman']++;
- }
- $user = [];
- $user_where = [
- ['user_type', '=', 2],
- ['is_complete', '=', 1],
- ];
- $user['total'] = UserModel::where($user_where)->count();
- $user['man'] = UserModel::where($user_where)->where('sex',1)->count();
- $user['woman'] = UserModel::where($user_where)->where('sex',2)->count();
- $config = Db::name('config')->find();
- $this->assign('auth',$auth);
- $this->assign('user',$user);
- $this->assign('config',$config);
- return $this->fetch();
- }
- public function dashboardWidget()
- {
- $dashboardWidgets = [];
- $widgets = $this->request->param('widgets/a');
- if (!empty($widgets)) {
- foreach ($widgets as $widget) {
- if ($widget['is_system']) {
- array_push($dashboardWidgets, ['name' => $widget['name'], 'is_system' => 1]);
- } else {
- array_push($dashboardWidgets, ['name' => $widget['name'], 'is_system' => 0]);
- }
- }
- }
- cmf_set_option('admin_dashboard_widgets', $dashboardWidgets, true);
- $this->success('更新成功!');
- }
- }
|