var url = null; var uploadUrl = null; var quantityList = null; var ImgFile = null; var dateTime1; var length; var currentImageIndex; //电子巡更记录 var data = { "interfaceId": "5207", "outId": "10207", "reqdateTime1": new Date(), "tokenAuth": "", "data": { "deptId": "", "dateTime1": "", } }; //巡更照片查看 var data2 = { "interfaceId": "5208", "outId": "10208", "reqdateTime1": 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; data2.tokenAuth = user.tokenAuth; data.data.deptId = selectDeptId; dateTime1 = getDate(new Date()) document.getElementById("date").value = dateTime1; //获取数量检测列表 getQuantityList() } //默认获取当前日期(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; } return year + "-" + month } //加减天数 function addAndReduceMonth(tag) { var date = new Date(dateTime1); date = date.setMonth(date.getMonth() + tag); date = new Date(date); dateTime1 = getDate(date); document.getElementById("date").value = dateTime1; //获取数量检测列表 getQuantityList() } //选择日期 function chooseDate() { var dtpicker = new mui.DtPicker({ type: "month", //设置日历初始视图模式 // beginDate: new Date(2015, 04, 25), //设置开始日期 // endDate: new Date(2016, 04, 25), //设置结束日期 value: dateTime1 }) var time = dateTime1; dtpicker.show(function(e) { dateTime1 = e.value; document.getElementById("date").value = e.value if (time != dateTime1) { getQuantityList(); } }) } //获取数量检测列表 function getQuantityList() { //赋值参数的日期 data.data.dateTime1 = dateTime1; console.log(JSON.stringify(data.data), "数量检测", "grain-quantity") 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") { quantityList = result.data; renderPatrol(); } else { quantityList = '' renderPatrol(); mui.toast(result.msg); console.log(JSON.stringify(result)) } }, error: function() { mui.alert("系统繁忙,请重试!", "提示", ["确定"], function() {}, "div") } }) } function renderPatrol() { var html = ''; if (quantityList && quantityList.length > 0) { $.each(quantityList, function(index, item) { html += '
  • '+(item.deptName == null?"--":item.deptName)+'
    过程抓拍
    ' html += '
    '+(item.remark == null?"--":item.remark)+'
    '; html += '
    检测重量
    '+(item.weight == null?"--":item.weight)+' KG
    ' html += '
    时间
    '+(item.receiveDate == null?"--":item.receiveDate)+'
  • '; }) } else { html += '
  • 暂无数量监测信息
  • '; } $("#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'); data2.data.id = id; mui.ajax(url, { type: "POST", dataType: "json", crossDomain: true, contentType: "application/json;charset=utf-8", data: JSON.stringify(data2), success: function(result) { if (result.code == "0000") { ImgFile = result.data; length = ImgFile.length; currentImageIndex = 0; // 获取图片元素 const imgElement = document.getElementById('viewerImg'); // 更换src imgElement.src = ImgFile[currentImageIndex].base64Img; } else { 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(); }); // 左右箭头事件 $('.left-arrow').on('click', showPrevImage(-1)); $('.right-arrow').on('click', showNextImage(1)); // 显示上一张图片 function showPrevImage(index) { if(index>0){ currentImageIndex = (currentImageIndex + 1)%length; }else{ currentImageIndex = (currentImageIndex - 1)%length; } if(currentImageIndex<0){ currentImageIndex = length-1; } const imgElement = document.getElementById('viewerImg'); // 更换src imgElement.src = ImgFile[currentImageIndex].base64Img; } //数量检测 function patrolClock() { console.log(latitude) console.log(longitude) data1.data.latitude = latitude; data1.data.longitude = longitude 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") { // mui.toast(result.msg); setInterval(getQuantityList(), 500) } else { mui.toast(result.msg); } }, error: function() { mui.alert("系统繁忙,请重试!", "提示", ["确定"], function() {}, "div") } }) }