var url = null;
|
var uploadUrl = null;
|
var PatrolList = null;
|
var ImgFile = null;
|
var dateTime;
|
var deptId;
|
//抓拍记录列表
|
var data = {
|
"interfaceId": "5108",
|
"outId": "10108",
|
"reqDateTime": new Date(),
|
"tokenAuth": "",
|
"data": {
|
"deptId": "",
|
"dateTime": "",
|
}
|
};
|
//抓拍照片查看
|
var data1 = {
|
"interfaceId": "5109",
|
"outId": "10109",
|
"reqDateTime": new Date(),
|
"tokenAuth": "",
|
"data": {
|
"id": "",
|
}
|
};
|
|
function init() {
|
var user = JSON.parse(localStorage.getItem('user'));
|
var selectDeptId = JSON.parse(localStorage.getItem('selectDeptId'));
|
url = user.url + "/api/phone/v1/gateway";
|
data.tokenAuth = user.tokenAuth;
|
data1.tokenAuth = user.tokenAuth;
|
data1.data.userName = user.cname;
|
deptId = selectDeptId;
|
if(deptId == null){
|
deptId = user.deptId
|
}
|
data.data.deptId = deptId;
|
data1.data.deptId = deptId;
|
dateTime = getDate(new Date())
|
document.getElementById("date").value = dateTime;
|
//获取巡更记录
|
getPatrolList()
|
|
}
|
|
//默认获取当前日期(yyyy-MM-dd)
|
function getDate(date) {
|
var year = date.getFullYear();
|
var month, day;
|
month = date.getMonth() + 1;
|
if (month > 0 && month <= 9) {
|
month = "0" + month;
|
}
|
day = date.getDate();
|
if (day > 0 && day <= 9) {
|
day = "0" + day;
|
}
|
return year + "-" + month + "-" + day
|
}
|
//加减天数
|
function addAndReduceMonth(tag) {
|
|
var date = new Date(dateTime);
|
date = date.setDate(date.getDate() + tag);
|
date = new Date(date);
|
dateTime = getDate(date);
|
document.getElementById("date").value = dateTime;
|
//获取巡更记录
|
getPatrolList()
|
}
|
|
//选择日期
|
function chooseDate() {
|
var dtpicker = new mui.DtPicker({
|
type: "date", //设置日历初始视图模式
|
// beginDate: new Date(2015, 04, 25), //设置开始日期
|
// endDate: new Date(2016, 04, 25), //设置结束日期
|
value: dateTime
|
})
|
var time = dateTime;
|
dtpicker.show(function(e) {
|
dateTime = e.value;
|
document.getElementById("date").value = e.value
|
if (time != dateTime) {
|
getPatrolList();
|
}
|
})
|
}
|
//获取巡更记录
|
function getPatrolList() {
|
//赋值参数的日期
|
data.data.dateTime = dateTime;
|
console.log(JSON.stringify(data.data), "地磅抓拍", "security-patrol")
|
mui.ajax(url, {
|
type: "POST",
|
dataType: "json",
|
crossDomain: true,
|
contentType: "application/json;charset=utf-8",
|
data: JSON.stringify(data),
|
success: function(result) {
|
if (result.code == "0000") {
|
PatrolList = result.data;
|
renderPatrol();
|
} else {
|
PatrolList = ''
|
renderPatrol();
|
mui.toast(result.msg);
|
// console.log(JSON.stringify(result))
|
}
|
},
|
error: function() {
|
mui.alert("系统繁忙,请重试!", "提示", ["确定"], function() {}, "div")
|
}
|
})
|
|
}
|
|
function renderPatrol() {
|
var html = '';
|
if (PatrolList && PatrolList.length > 0) {
|
$.each(PatrolList, function(index, item) {
|
html += '<li><div class="item"><div class="top">'
|
html += '<div class="text">'+ (item.deptName == null?"--":item.deptName) +'</div><div class="r-btn r-warn1" id = "' + item.id +'">查看照片</div></div>';
|
html += '<div class="top-tit"><div class="text">抓拍设备:'+item.cameraId+'</div></div>';
|
html += '<div class="cards"><div class="cd"><div class="con user">'
|
html += '<div class="tit">重量</div><div class="txt">' + item.weight + ' KG</div></div></div>';
|
html += '<div class="cd"><div class="con loc"><div class="tit">时间</div>'
|
html += '<div class="txt">' +(item.time == null?"--":item.time)+ '</div></div></div></div></div></li>'
|
})
|
} else {
|
html +=
|
'<li><div class="item"><div style="text-align: center;font-size: 20px;color:#dd524d;padding-top: 16px;">暂无地磅抓拍信息</div></div></li>';
|
}
|
$("#recordList").html(html)
|
}
|
|
mui('.mui-scroll-wrapper').scroll({
|
indicators: true, //是否显示滚动条
|
deceleration: 0.0006, //阻尼系数,系数越小滑动越灵敏
|
bounce: false, //是否启用回弹
|
deceleration: 0.0005 //flick 减速系数,系数越大,滚动速度越慢,滚动距离越小,默认值0.0006
|
});
|
|
mui(".mui-content").on("tap", ".g-date_box .prev", function() {
|
var curDate = document.getElementById("date").value;
|
addAndReduceMonth(-1)
|
// document.getElementById("date").value = e.value
|
});
|
mui(".mui-content").on("tap", ".g-date_box .next", function() {
|
var curDate = document.getElementById("date").value;
|
addAndReduceMonth(1)
|
// document.getElementById("date").value = e.value
|
});
|
|
//查看照片
|
mui(".mui-content").on("tap", ".ul-cardb1 li .r-btn", function() {
|
var id = this.getAttribute('id');
|
data1.data.id = id;
|
console.log(JSON.stringify(data1))
|
mui.ajax(url, {
|
type: "POST",
|
dataType: "json",
|
crossDomain: true,
|
contentType: "application/json;charset=utf-8",
|
data: JSON.stringify(data1),
|
success: function(result) {
|
if (result.code == "0000") {
|
ImgFile = result.data;
|
var html = '<img src="' + ImgFile.imgName + '" alt="" class="img" />';
|
$('#viewerImg').html(html);
|
} else {
|
// var html = '<img src="" alt="" class="img" />';
|
// $('#viewerImg').html(html);
|
mui.toast(result.msg);
|
}
|
},
|
error: function() {
|
mui.alert("系统繁忙,请重试!", "提示", ["确定"], function() {}, "div")
|
}
|
})
|
$('.m-pop').css('display', 'flex');
|
});
|
//关闭照片
|
$('.pop-bg,.m-pop .close').click(function(e) {
|
e.stopPropagation();
|
$('.m-pop').fadeOut();
|
});
|