var BASE = "https://ykdz.yundazhou.com/api";
var player;
var markers = [];
var groupType = undefined;
function getList(tag) {
$.ajax({
url: BASE + "/waterLoggingPoints/list",
type: "GET",
// data: JSON.stringify(param),
data: { groupType },
async: false,
dataType: "json",
contentType: "application/json; charset=UTF-8",
success: function (data) {
if (data.c === 200) {
// console.log(data);
$(".videoList").empty();
$(`.videoList1`).empty();
$(`.videoList2`).empty();
if (tag === 1) {
data.d.map((item) => {
//创建一个 Marker 实例:
const marker = new AMap.Marker({
icon: "https://a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png",
position: new AMap.LngLat(item.longitude, item.latitude), //经纬度对象,也可以是经纬度构成的一维数组[116.39, 39.9]
anchor: "bottom-center",
title: item.name,
});
// 设置鼠标划过点标记显示的文字提示
marker.setTitle(item.name);
// 设置label标签
// label默认蓝框白底左上角显示,样式className为:amap-marker-label
marker.setLabel({
direction: "top",
offset: new AMap.Pixel(10, 0), //设置文本标注偏移量
content: "
" + item.name + "
", //设置文本标注内容
});
marker.on("click", () => {
location.href = `detail.html?id=${item.id}`;
});
map.add(marker);
markers.push(marker);
});
} else {
let data1 = data.d.filter((item) => item.groupType === 1);
let data2 = data.d.filter((item) => item.groupType === 2);
if (data1.length > 0) {
appendListDom(data1);
}
if (data2.length > 0) {
appendListDom(data2);
}
}
}
},
});
}
function appendListDom(data) {
// let title =
// '' + data[0].groupType === 1
// ? "城市道路积水"
// : "河道水情观测" + "
";
// $(".videoList").append(title);
let type = data[0].groupType;
let title =
type === 1
? '城市道路积水
'
: '河道水情观测
';
$(`.videoList${type}`).prepend(title);
console.log(1);
data.map((item) => {
let local =
(localStorage.getItem("local") &&
localStorage.getItem("local").split(",")) ||
"0,0";
let dis = AMap.GeometryUtil.distance(local, [
item.longitude,
item.latitude,
]);
let bg = item.groupType === 1 ? "bg1" : "bg2";
let status = item.num2 > item.num1 ? "异常" : "正常";
let statusClass = status === "异常" ? "err" : "";
let str =
'" +
'
' +
'
' +
status +
"" +
'

' +
"
" +
"
" +
item.name +
"
" +
'
' +
Math.round(dis / 1000) +
"km
" +
"
";
$(`.videoList${type}> .videoList`).append(str);
console.log(2);
});
}
function handleDetail(id) {
console.log(id);
window.location.href = `detail.html?id=${id}`;
}
function getInfo(id) {
$.ajax({
url: BASE + "/waterLoggingPoints/info",
type: "GET",
// data: JSON.stringify(param),
async: false,
dataType: "json",
data: { id },
contentType: "application/json; charset=UTF-8",
success: function (data) {
document.title = data.d.name;
if (data.d.mark === 1) {
$(".videoBox").append('');
}
$(".content").empty();
// let str = `点位信息网络问题可能导致视频加载失败,请重新进入
//
//
${data.d.name}
//
正常
//
// 易涝点共查共查数据每2小时更新一次
//
//
该点位是否能正常通行?
//
${data.d.numAll}已参与
//
//
//

//
${data.d.numProportion1}
//
//
//

//
${data.d.numProportion2}
//
//
//
`;
let status = data.d.num2 > data.d.num1 ? "异常" : "正常";
let statusClass = status === "异常" ? "err" : "";
let str = `
${data.d.name}
${status}
如果监控长时间未成功播放,请刷新重试。
该点位是否正常通行?
${data.d.numAll}人已参与
是
${data.d.numProportion1}
否
${data.d.numProportion2}
共查数据每2小时更新一次
`;
$(".content").append(str);
if (data.c === 200) {
console.log(data);
player.src({
src: data.d.playUrl,
type: "application/x-mpegURL",
});
player.play();
// var hls;
// var video = document.getElementById("myVideo");
// $(".status").text(Hls.isSupported(),document.getElementById("myVideo"));
// var hls = new Hls();
// hls.loadSource(data.d.playUrl);
// hls.attachMedia(video);
// hls.on(Hls.Events.MANIFEST_PARSED, function () {
// video.play();
// });
// $(video).attr('src',data.d.playUrl)
// data.d.map((item, index) => {
// // if (index !== 1) {
// $("#source_video" + index).attr("src", item);
// videojs("video" + index);
// // }
// });
}
},
});
}
function refresh() {
location.reload();
}
function commit(tag) {
let payload = {
id: parameterValue,
isNormal: tag ? true : false,
};
$.ajax({
url: BASE + "/waterLoggingPoints/dataCommit",
type: "POST",
// data: JSON.stringify(param),
async: false,
dataType: "json",
data: JSON.stringify(payload),
contentType: "application/json; charset=UTF-8",
success: function (data) {
// alert("提交成功!");
msg.info("提交成功!");
getInfo(parameterValue);
},
});
}
function handleGroupTypeChange() {
console.log($("#groupType").val());
groupType = $("#groupType").val();
getList();
}