APP
YYC
2026-02-12 57233e23e69d04672f9721def4d00c2905922d25
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
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 {
                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+'</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.tags + '</div></div></div>';
            html += '<div class="cd"><div class="con loc"><div class="tit">时间</div>'
            html += '<div class="txt">' +item.snapTime + '</div></div></div></div></div></li>'
        })
    } else {
        html += '<li><div class="item"><div class="top">'
        html += '<div class="text"> ----- </div><div class="r-btn r-warn1"  id = "0">查看照片</div></div>';
        html += '<div class="top-tit"><div class="text">抓拍设备:----- </div></div>';
        html += '<div class="cards"><div class="cd"><div class="con user">'
        html += '<div class="tit">标签</div><div class="txt">--,--</div></div></div>';
        html += '<div class="cd"><div class="con loc"><div class="tit">时间</div>'
        html += '<div class="txt">'+dateTime+'</div></div></div></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();
});