auth->get_menus(); $permissions = $this->auth->get_permissions(); $rs = [ 'user' => $this->auth->getUserInfo(), 'permissions' => $permissions, 'menus' => $menus, ]; // dump($rs);exit; $this->success(1,$rs); } //员工账号+密码登录 public function login() { $username = input('username'); $password = input('password'); if (!$username || !$password) { $this->error(__('Invalid parameters')); } PcAdminLog::setTitle(__('Login')); //找员工 $ret = $this->auth->login($username, $password); if ($ret) { $data = $this->auth->getUserInfo_simple(); $this->success('登录成功', $data); } else { $msg = $this->auth->getError(); $msg = $msg ? $msg : __('Username or password is incorrect'); $this->error($msg); } } //大屏幕 public function dashboard(){ //左侧上面条状 $list = Db::name('user_company')->field('id,projectname,starttime,endtime,longitude,latitude')->where('company_id',$this->auth->company_id)->order('endtime asc')->select(); if(!empty($list)){ foreach($list as $key => $val){ //总月份 $total_month = intval(ceil(($val['endtime'] - $val['starttime']) / 2592000)); $total_month = $total_month < 0 ? 0 : $total_month; //剩余月份 $end_month = intval(ceil(($val['endtime'] - time()) / 2592000)); $end_month = $end_month < 0 ? 0 : $end_month; //比例 $bili = 100; if($total_month > 0 && $total_month > $end_month){ $bili = bcdiv(($total_month - $end_month) * 100 , $total_month,0); } //追加数据 $list[$key]['total_month'] = $total_month; $list[$key]['bili'] = $bili; $list[$key]['end_month'] = $end_month; } } //左侧下面扇形 $wancheng = Db::name('maintain')->where('company_id',$this->auth->company_id)->where('status',100)->count(); $weiwancheng = Db::name('maintain')->where('company_id',$this->auth->company_id)->where('status',2)->count(); $jinxingzhong = Db::name('maintain')->where('company_id',$this->auth->company_id)->where('status','NOTIN',[2,100])->count(); $shanxing = [ ['name'=>'完成数','value'=>$wancheng,'itemStyle'=>['color'=>'#FABA26']], ['name'=>'未完成数','value'=>$weiwancheng,'itemStyle'=>['color'=>'#15DB92']], ['name'=>'进行中','value'=>$jinxingzhong,'itemStyle'=>['color'=>'#2AA1FF']], ]; $shanxing_number = $wancheng + $weiwancheng + $jinxingzhong; //中间地图 $map_data = []; if(!empty($list)){ foreach($list as $key => $val){ // $map_data[$val['projectname']] = [$val['longitude'],$val['latitude']]; $map_data[] = [ 'name' => $val['projectname'], 'value'=> [$val['longitude'],$val['latitude'],9], ]; } } //中间底部 $maintainlist = Db::name('maintain')->field('id,DATE(FROM_UNIXTIME(createtime)) as createdate')->where('company_id',$this->auth->company_id)/*->whereTime('createtime','week')*/->select(); $maindate = array_column($maintainlist,'createdate'); $maindate = array_count_values($maindate); $maindate = [ 'date' => array_keys($maindate), 'value'=> array_values($maindate), ]; // dump($maindate); //导航 $menus = $this->auth->get_menus_simple(); //结果 $week = [ 1 => '星期一', 2 => '星期二', 3 => '星期三', 4 => '星期四', 5 => '星期五', 6 => '星期六', 0 => '星期天', ]; $rs = [ 'date' => date('Y.m.d'), 'week' => $week[date('w')], 'time' => date('H:i:s'), 'project' => $list, 'map_data'=> $map_data, 'shanxing' => $shanxing, 'shanxing_number' => $shanxing_number, 'maindate' => $maindate, 'menus' => $menus, ]; $this->success(1,$rs); } /** * 退出登录 * @ApiMethod (POST) */ public function logout() { PcAdminLog::setTitle('退出登录'); if (!$this->request->isPost()) { $this->error(__('Invalid parameters')); } $this->auth->logout(); $this->success('退出成功'); } //用户详细资料 public function getUserinfo(){ PcAdminLog::setTitle('获取信息'); $info = $this->auth->getUserInfo(); $this->success(__('success'),$info); } ///////////////////////////下面没用到//////////////////////////////// //用户申请资料 public function getUserapplyinfo(){ $field = [ 'company_name', 'company_code', 'company_registerdate', 'company_address', 'company_image', 'truename', 'idcard', 'idcard_images', 'bank_name', 'bank_branchname', 'bank_account', 'bank_card', ]; $info = Db::name('company')->field($field)->where('id',$this->auth->id)->find(); $info = info_domain_image($info,['company_image','idcard_images']); $this->success(1,$info); } /** * 修改会员个人信息 * * @ApiMethod (POST) * @param string $avatar 头像地址 * @param string $username 用户名 * @param string $nickname 昵称 * @param string $bio 个人简介 */ public function profile() { //检查 $check = Db::name('company')->where('id',$this->auth->id)->find(); if($check['status'] == 1){ $this->success('资料审核通过后需联系客服修改'); } $field = [ 'company_name', 'company_code', 'company_registerdate', 'company_address', 'company_image', 'truename', 'idcard', 'idcard_images', 'bank_name', 'bank_branchname', 'bank_account', 'bank_card', ]; $data = request_post_hub($field); $data['status'] = 0; $update_rs = Db::name('company')->where('id',$this->auth->id)->update($data); $this->success('资料更新完成'); } }