Commit 1b901a46 authored by 冯超鹏's avatar 冯超鹏

登入模块

parent 78c0e7c3
Pipeline #51 failed with stages
<?php
namespace App\Http\Controllers;
use App\Http\Resources\PermissionResource;
use App\Http\Requests\UsersRequest;
use App\Http\Resources\UserResource;
use App\Laravue\JsonResponse;
use App\Laravue\Models\Device;
use App\Laravue\Models\Users;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\ResourceCollection;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Redis;
use Validator;
class HomepageController extends Controller
{
//返回用户数量 设备数量, 报警数量 ,
public function homepagecount()
{
$usercount = Users::count();
$devicecount = Device::count();
$devicepolice = Device::where('devicepolice', '>', '1')->count();
$t = time();//当前时间
$start = mktime(0,0,0,date("m",$t),date("d",$t),date("Y",$t));//今天的开始
$end = mktime(23,59,59,date("m",$t),date("d",$t),date("Y",$t));//今天的结束
$timedevicepolice = DB::table('reportpolice')->where('status', '=', '1')->whereBetween('starttime',[$start,$end])->count();
return $this->jsonSuccessData(['usercount' => $usercount, 'devicecount' => $devicecount, 'devicepolice' => $devicepolice,'timedevicepolice'=>$timedevicepolice]);
}
//返回一年当前月份
public function devicemonthcount(){
$year_start=strtotime(date("Y")."-01-01"); // 获取当前的1月份的时间戳
$endThismonth = mktime(23, 59, 59, date('m'), date('t'), date('Y')); //获取当月的时间戳
$devicedata = Device::whereBetween('deviceaddtime',[$year_start,$endThismonth])
->selectRaw('from_unixtime(deviceaddtime,"%Y-%m") as date,COUNT(id) as value')
->groupBy('date')
->get()
->toArray();
$policedata = Users::whereBetween('add_time',[$year_start,$endThismonth])
->selectRaw('from_unixtime(add_time,"%Y-%m") as date,COUNT(id) as value')
->groupBy('date')
->get()
->toArray();
$devicepolice = Device::whereBetween('deviceaddtime',[$year_start,$endThismonth])
->where('devicepolice','>',1)
->selectRaw('from_unixtime(deviceaddtime,"%Y-%m") as date,COUNT(id) as value')
->groupBy('date')
->get()
->toArray();
return $this->jsonSuccessData(['devicedata'=>$this->datamonth($devicedata),'policedata'=>$this->datamonth($policedata),'devicepolice'=>$this->datamonth($devicepolice)]);
}
private function datamonth($monthdata = []) :array{
$year = date('Y',time());
$month = date('m',time());
$data = [];
foreach ($monthdata as $value) {
$data[$value['date']] = $value['value'];
}
$out = [];
for ($i = 1; $i <= $month; $i++) {
$mont = $i < 10 ? "0{$i}" : $i;
$val = isset($data["{$year}-{$mont}"]) ? $data["{$year}-{$mont}"] : 0;
array_push($out, $val);
}
return $out;
}
}
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>地图模式</title>
<link rel="stylesheet" type="text/css" href="npmcss/zzsc.css">
<link rel="stylesheet" type="text/css" href="npmcss/style.css">
<style>
html,
body {
margin: 0;
padding: 0;
overflow: hidden;
height: 100%;
}
#mapContainer {
position: relative;
height: 100%;
width: 100%;
}
</style>
</head>
<script src="npmcss/jquery.js"></script>
<script charset="utf-8" src="https://map.qq.com/api/gljs?v=1.exp&key=OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77"></script>
<body onload="init(1)">
<div id='mapContainer'>
<div class="container" style="z-index: 9999999;position:fixed;left: 1233px;top: -31px;">
<!-- <div class="switch-box is-info">
<input id="info" class="switch-box-input" type="checkbox" checked />
<label for="info" class="switch-box-slider" onclick="init(2)"></label>
<label for="info" class="switch-box-label">切换设备</label>
</div> -->
</div>
</div>
<script>
var map;
function init(id) {
var type = getUrlParams('type');
if(type == '' || type == null){
alert('违规操作');
window.opener = null;
window.open('', '_self');
window.close();
return;
}
if(type != 'permit'){
alert('type值不对重新打开');
window.opener = null;
window.open('', '_self');
window.close();
return;
}
if(id == 1){ //用户设备
$.ajax({
type: "GET",
url: "api/user/userLocation",
data: {},
success: function(data) {
var data = JSON.parse(data);
nmp(data.data,1);
}
});
}else{
$.ajax({
type: "GET",
url: "api/devices/deviceLocation",
data: {},
success: function(data) {
var data = JSON.parse(data);
nmp(data.data,2);
}
});
}
}
function getUrlParams(name) {
var url = window.location.search;
if (url.indexOf('?') == 1) {
return false;
}
url = url.substr(1);
url = url.split('&');
var name = name || '';
var nameres;
// 获取全部参数及其值
for (var i = 0; i < url.length; i++) {
var info = url[i].split('=');
var obj = {};
obj[info[0]] = info[1];
url[i] = obj;
}
// 如果传入一个参数名称,就匹配其值
if (name) {
for (var i = 0; i < url.length; i++) {
for (const key in url[i]) {
if (key == name) {
nameres = url[i][key];
}
}
}
} else {
nameres = url;
}
// 返回结果
return uncompileStr(nameres);
}
function uncompileStr(code) {
code = unescape(code);
var c = String.fromCharCode(code.charCodeAt(0) - code.length);
for (var i = 1; i < code.length; i++) {
c += String.fromCharCode(code.charCodeAt(i) - c.charCodeAt(i - 1));
}
return c;
}
function nmp(data,type) {
var LatLng = [];
if(type == 2){
console.log(LatLng);
data.forEach((item, index, array) => {
if (item.devicecoord != null && item.mapcenter != '') {
console.log(item);
let x = item.devicecoord.split(',')[0];
let y = item.devicecoord.split(',')[1];
if (x > 0 && y > 0) {
let position = new TMap.LatLng(x, y);
let tmpP = {
position: position
};
LatLng.push(tmpP);
}
}
});
}else{
data.forEach((item, index, array) => {
if (item.mapcenter != null && item.mapcenter != '') {
let x = item.mapcenter.split(',')[0];
let y = item.mapcenter.split(',')[1];
if (x > 0 && y > 0) {
let position = new TMap.LatLng(x, y);
let tmpP = {
position: position,
};
LatLng.push(tmpP);
}
}
});
}
var drawContainer = document.getElementById('mapContainer');
var center = new TMap.LatLng(38.230596, 114.216328); //设置中心点坐标
map = new TMap.Map(drawContainer, {
zoom: 12,
pitch: 40,
center: center,
draggable: true,
scrollable: true,
mapStyleId: "style1"
});
// 创建点聚合实例
var markerCluster = new TMap.MarkerCluster({
id: 'cluster',
map: map,
enableDefaultStyle: true, // 启用默认样式
minimumClusterSize: 2, // 形成聚合簇的最小个数
geometries: [{
"id": "1", //点标记唯一标识,后续如果有删除、修改位置等操作,都需要此id
"styleId": 'myStyle', //指定样式id
"position": new TMap.LatLng(39.954104, 116.357503), //点标记坐标位置
"properties": {//自定义属性
"title": "marker1"
}
}, {//第二个点标记
"id": "2",
"styleId": 'marker',
"position": new TMap.LatLng(39.994104, 116.287503),
"properties": {
"title": "marker2"
}
}
],
zoomOnClick: true, // 点击簇时放大至簇内点分离
gridSize: 60, // 聚合算法的可聚合距离
averageCenter: false, // 每个聚和簇的中心是否应该是聚类中所有标记的平均值
maxZoom: true // 采用聚合策略的最大缩放级别
});
}
</script>
</body>
</html>
This diff is collapsed.
.switch-box {
display: block;
margin-top: 24px;
}
.switch-box .switch-box-slider {
position: relative;
display: inline-block;
height: 8px;
width: 32px;
background: #d5d5d5;
border-radius: 8px;
cursor: pointer;
-webkit-transition: all 0.2s ease;
transition: all 0.2s ease;
}
.switch-box .switch-box-slider:after {
position: absolute;
left: -8px;
top: -8px;
display: block;
width: 24px;
height: 24px;
border-radius: 50%;
background: #eeeeee;
box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.2);
content: '';
-webkit-transition: all 0.2s ease;
transition: all 0.2s ease;
}
.switch-box .switch-box-input {
display: none;
}
.switch-box .switch-box-input ~ .switch-box-label {
margin-left: 8px;
}
.switch-box .switch-box-input:checked ~ .switch-box-slider:after {
left: 16px;
}
.switch-box .switch-box-input:disabled ~ .switch-box-slider {
background: #e2e2e2;
cursor: default;
}
.switch-box .switch-box-input:disabled ~ .switch-box-slider:after {
background: #d5d5d5;
}
.switch-box.is-primary .switch-box-input:checked:not(:disabled) ~ .switch-box-slider {
background: #28e1bd;
}
.switch-box.is-primary .switch-box-input:checked:not(:disabled) ~ .switch-box-slider:after {
background: #1abc9c;
}
.switch-box.is-info .switch-box-input:checked:not(:disabled) ~ .switch-box-slider {
background: #5faee3;
}
.switch-box.is-info .switch-box-input:checked:not(:disabled) ~ .switch-box-slider:after {
background: #3498db;
}
.switch-box.is-success .switch-box-input:checked:not(:disabled) ~ .switch-box-slider {
background: #54d98c;
}
.switch-box.is-success .switch-box-input:checked:not(:disabled) ~ .switch-box-slider:after {
background: #2ecc71;
}
.switch-box.is-danger .switch-box-input:checked:not(:disabled) ~ .switch-box-slider {
background: #ed7669;
}
.switch-box.is-danger .switch-box-input:checked:not(:disabled) ~ .switch-box-slider:after {
background: #e74c3c;
}
.switch-box.is-warning .switch-box-input:checked:not(:disabled) ~ .switch-box-slider {
background: #eb9950;
}
.switch-box.is-warning .switch-box-input:checked:not(:disabled) ~ .switch-box-slider:after {
background: #e67e22;
}
.container{
width: 200px;
margin: 30px auto;
}
body{
background: #494A5F;
color: #D5D6E2;
font-weight: 500;
font-size: 1.05em;
font-family: "Microsoft YaHei","宋体","Segoe UI", "Lucida Grande", Helvetica, Arial,sans-serif, FreeSans, Arimo;
}
a{ color: rgba(255, 255, 255, 0.6);outline: none;text-decoration: none;-webkit-transition: 0.2s;transition: 0.2s;}
a:hover,a:focus{color:#74777b;text-decoration: none;}
\ No newline at end of file
const baseURL = 'ws://127.0.0.1:9502';
const mapkey = '2719fe261fee06a08dcb4980990879da';
const mapurl = 'https://webapi.amap.com/maps?v=1.4.15&key=';
export default {
baseURL,
mapkey,
mapurl,
};
import request from '@/utils/request';
export function homepagecount() { // 设备类型
return request({
url: 'homepagecount/homepagecount',
method: 'get',
});
}
export function getcount() { // 设备类型
return request({
url: 'homepagecount/devicemonthcount',
method: 'get',
});
}
import request from '@/utils/request';
export function getmap(key) {
return request({
url: 'https://webapi.amap.com/maps?v=1.4.15&key=' + key + '&callback=onLoad',
method: 'get',
});
}
<!-- <template>
<a href="https://github.com/tuandm/laravue" target="_blank" class="github-corner" aria-label="View source on Github">
<svg
width="80"
height="80"
viewBox="0 0 250 250"
style="fill:#40c9c6; color:#fff;"
aria-hidden="true"
>
<path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z" />
<path
d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
fill="currentColor"
style="transform-origin: 130px 106px;"
class="octo-arm"
/>
<path
d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
fill="currentColor"
class="octo-body"
/>
</svg>
</a>
</template> -->
<style scoped>
.github-corner:hover .octo-arm {
animation: octocat-wave 560ms ease-in-out
}
@keyframes octocat-wave {
0%,
100% {
transform: rotate(0)
}
20%,
60% {
transform: rotate(-25deg)
}
40%,
80% {
transform: rotate(10deg)
}
}
@media (max-width:500px) {
.github-corner:hover .octo-arm {
animation: none
}
.github-corner .octo-arm {
animation: octocat-wave 560ms ease-in-out
}
}
</style>
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1589854256367" class="icon" viewBox="0 0 1088 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1990" data-spm-anchor-id="a313x.7781069.0.i1" xmlns:xlink="http://www.w3.org/1999/xlink" width="212.5" height="200"><defs><style type="text/css"></style></defs><path d="M1084.710172 1019.718325h-132.460079c0-2.514635 0-4.893343-0.407778 0a272.532024 272.532024 0 0 0-271.852393-271.852393c-150.130484 0-203.889294 122.809318-203.889294 271.852393-0.543705-4.893343-0.543705-2.514635-0.407779 0H340.174431a462.149067 462.149067 0 0 1 119.139311-314.533218 159.373465 159.373465 0 0 0-156.85883-90.322958C163.878155 609.017323 136.285137 688.058406 136.285137 815.82903c-0.407779-4.213712-0.407779-2.106856 0 0H0.35894v-0.407778-1.291299a319.426561 319.426561 0 0 1 302.028009-334.106591 295.503551 295.503551 0 0 1 252.890688 152.577156 314.397292 314.397292 0 0 1 139.800093-32.690251A391.263556 391.263556 0 0 1 1087.768511 989.746599c0 10.262428-2.242782 19.913188-3.058339 29.971726zM951.842315 1019.718325h0.407778c-0.407779 2.582598-0.407779 5.233159-0.407778 0z m-476.149466 0H476.100628c0 5.233159 0 2.582598-0.407779 0zM340.174431 1019.718325c0 10.262428-0.815557-65.312537 0 0z m-203.889294-203.889295c0 4.485564 0 2.174819 0 0z m-135.926197-0.407778c0 3.126303-0.475742-5.776863 0 0zM689.776608 543.976638a262.473485 262.473485 0 0 1-247.113825-184.247959 171.33497 171.33497 0 0 1-131.780447 63.341607 181.461472 181.461472 0 0 1 0-362.651092 172.898122 172.898122 0 0 1 147.819738 85.361652 260.366629 260.366629 0 0 1 231.074534-145.780846 271.988319 271.988319 0 0 1 0 543.976638zM340.174431 204.161147H272.211333v67.963098h67.963098V204.161147z m339.815491-67.963098a135.926196 135.926196 0 1 0 135.926196 135.926196 135.926196 135.926196 0 0 0-135.926196-135.926196z" p-id="1991" fill="#409EFF" data-spm-anchor-id="a313x.7781069.0.i0" class=""></path></svg>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Hello world!</title>
<style type="text/css">
#container{
/*地图(容器)显示大小*/
width:1200px;
height:400px;
}
</style>
<!--引入Javascript API GL,参数说明参见下文-->
<script src="https://map.qq.com/api/gljs?v=1.exp&key=JW7BZ-NN2KD-ODD4Y-PCH4X-J76HQ-EEF2Q"></script>
<script>
//地图初始化函数,本例取名为init,开发者可根据实际情况定义
function initMap() {
//定义地图中心点坐标
var center = new TMap.LatLng(39.984120, 116.307484)
//定义map变量,调用 TMap.Map() 构造函数创建地图
var map = new TMap.Map(document.getElementById('container'), {
center: center,//设置地图中心点坐标
zoom: 17.2, //设置地图缩放级别
pitch: 43.5, //设置俯仰角
rotation: 45 //设置地图旋转角度
});
}
</script>
</head>
<!-- 页面载入后,调用init函数 -->
<body onload="initMap()">
<!-- 定义地图显示容器 -->
<div id="container"></div>
</body>
</html>
<template>
<div></div>
</template>
<script>
</script>
<style>
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment