deviceDetails_frm.html
10.2 KB
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
<title>设备信息_frm</title>
<link rel="stylesheet" type="text/css" href="../../css/api.css"/>
<link rel="stylesheet" type="text/css" href="../../css/aui.css"/>
<link rel="stylesheet" type="text/css" href="../../css/deviceDetails/deviceDetails.css"/>
<style>
html,
body{
background-color: #F4F6F9;
}
</style>
</head>
<body>
<div class="device-title">
<div style="margin-left:15px;margin-right:15.5px;">
<div class="aui-row aui-row-flex top-14">
<div class="aui-col aui-col-span-1" style="margin-top: 1rem;">
<div class="title-sign"></div>
</div>
<div class="aui-col aui-col-span-15">
<span class="device-name" id="device_imei">设备编号:000000000000000</span>
</div>
<div class="aui-col aui-col-span-8 aui-row-flex-end">
</div>
</div>
</div>
</div>
<div class="info-panel">
<div class="info-inside-panel">
<div class="aui-row aui-row-flex padding-top-21">
<div class="aui-col aui-col-span-8 aui-row-flex-start">
<span class="device-obj" style="font-weight:bold;color:rgba(129,130,149,1);">设备终端信息</span>
</div>
<div class="aui-col aui-col-span-16 aui-row-flex-end">
<span class="num-value" style="font-size:12px;font-weight:500;color:rgba(129,130,149,1);" id="update_time"></span>
</div>
</div>
<div class="panel-line margin-top-21" style="background:rgba(217,229,255,1);"></div>
<div class="aui-row aui-row-flex margin-top-21">
<div class="aui-col aui-col-span-3 aui-row-flex-start">
<img src="../../image/deviceDetails/macInfo-icon-1.png" style="width:22px;height:22px;" />
</div>
<div class="aui-col aui-col-span-10 aui-row-flex-start">
<span class="device-obj" style="margin-left:-0.4rem;">设备状态</span>
</div>
<div class="aui-col aui-col-span-11 aui-row-flex-end chooseStatus1">
<img src="../../image/deviceDetails/icon-red.png" style="width:12px;height:12px;margin-top: 0.25rem;"/>
<span class="num-value" id="status1">在线</span>
</div>
</div>
<div class="panel-line margin-top-21"></div>
<div class="aui-row aui-row-flex margin-top-21">
<div class="aui-col aui-col-span-3 aui-row-flex-start">
<img src="../../image/deviceDetails/macInfo-icon-2.png" style="width:22px;height:22px;" />
</div>
<div class="aui-col aui-col-span-10 aui-row-flex-start">
<span class="device-obj" style="margin-left:-0.4rem;">开关状态</span>
</div>
<div class="aui-col aui-col-span-11 aui-row-flex-end chooseStatus2">
<img src="../../image/deviceDetails/icon-red.png" style="width:12px;height:12px;margin-top: 0.25rem;"/>
<span class="num-value" id="status2">合闸</span>
</div>
</div>
<div class="panel-line margin-top-21"></div>
<div class="aui-row aui-row-flex margin-top-21">
<div class="aui-col aui-col-span-3 aui-row-flex-start">
<img src="../../image/deviceDetails/macInfo-icon-3.png" style="width:22px;height:22px;" />
</div>
<div class="aui-col aui-col-span-10 aui-row-flex-start">
<span class="device-obj" style="margin-left:-0.4rem;">设备位置</span>
</div>
<div class="aui-col aui-col-span-11 aui-row-flex-end" style="margin-right:-0.2rem;">
<span class="num-value" style="color:rgba(55,57,78,1);text-align:right;" id="device_position">无</span>
</div>
</div>
<div class="panel-line margin-top-21"></div>
<div class="aui-row aui-row-flex margin-top-21" tapmode onclick="changeDeviceName();">
<div class="aui-col aui-col-span-3 aui-row-flex-start">
<img src="../../image/deviceDetails/macInfo-icon-4.png" style="width:22px;height:22px;" />
</div>
<div class="aui-col aui-col-span-6 aui-row-flex-start">
<span class="device-obj" style="margin-left:-0.4rem;">设备名称</span>
</div>
<div class="aui-col aui-col-span-13 aui-row-flex-end">
<span class="num-value" style="color:rgba(55,57,78,1);" id="device_name"></span>
</div>
<div class="aui-col aui-col-span-2 aui-row-flex-end">
<i class="aui-iconfont aui-icon-right icon-right" style="color:#AEB8CE;"></i>
</div>
</div>
<div style="height:21px;"></div>
</div>
</div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript" src="../../script/jquery-3.3.1.min.js"></script>
<script type="text/javascript">
var defaultImei;
var token;
var userId;
apiready = function(){
api.parseTapmode();
defaultImei = $api.getStorage('defaultDevice');
token = $api.getStorage('userToken');
userId = $api.getStorage('userID');
$api.html($api.byId("device_imei"), '设备编号:'+ defaultImei);
/** 下拉刷新 */
api.setRefreshHeaderInfo({
loadingImg:'../../image/alpha0.png',
bgColor: '#5B7FF8',
textColor: 'rgba(255,255,255,0.5)',
textDown: '刷新设备信息...',
textUp: '松开刷新...'
}, function(ret, err) {
getDeviceInfo();
});
getDeviceInfo();
};
function getDeviceInfo() {
//当前单个设备的所有信息
$.ajax({
url: HOST + '/iot_api/v1/app/device?imei='+defaultImei + '&user_id=' + userId,
type: 'GET',
dataType: 'json',
headers: {
'Content-Type': 'application/json;charset=utf-8',
'token': token
},
complete: function() {
api.refreshHeaderLoadDone();
},
success: function(ret) {
if (ret.code == 0) {
var info = ret.data.device;
var choose1Doms = $api.domAll('.chooseStatus1');
var status1Span = $api.byId('status1');
var choose2Doms = $api.domAll('.chooseStatus2');
var status2Span = $api.byId('status2');
if (info.online) {
for (var j = 0; j < choose1Doms.length; j++) {
((choose1Doms[j].childNodes)[1]).src = '../../image/deviceDetails/icon-green.png';
}
status1Span.style.color = '#70C248';
$api.html(status1Span, '在线');
}else {
for (var j = 0; j < choose1Doms.length; j++) {
((choose1Doms[j].childNodes)[1]).src = '../../image/deviceDetails/icon-red.png';
}
status1Span.style.color = '#FA5251';
$api.html(status1Span, '离线');
}
if (info.gate_status != '1') {
for (var j = 0; j < choose2Doms.length; j++) {
((choose2Doms[j].childNodes)[1]).src = '../../image/deviceDetails/icon-green.png';
}
status2Span.style.color = '#70C248';
$api.html(status2Span, '分闸');
}else {
for (var j = 0; j < choose2Doms.length; j++) {
((choose2Doms[j].childNodes)[1]).src = '../../image/deviceDetails/icon-red.png';
}
status2Span.style.color = '#FA5251';
$api.html(status2Span, '合闸');
}
$api.html($api.byId("update_time"), parseTime(info.updatedAt,'{y}-{m}-{d} {h}:{i}:{s}')+' 更新');
if (info.bind.address && info.bind.address != null) {
$api.html($api.byId("device_position"), info.bind.address);
}
if (info.bind.storename && info.bind.storename != null) {
$api.html($api.byId("device_name"), info.bind.storename);
}
}else {
api.toast({msg: '参数请求失败',duration: 2000,location: 'bottom'});
}
},
error: function() {
api.toast({msg: ERR_MSG,duration: 2000,location: 'bottom'});
}
});
}
//修改设备名称
function changeDeviceName() {
var deviceName_ = $api.html($api.byId('device_name'));
api.prompt({
title: '修改设备名称',
text: deviceName_,
buttons: ['取消', '确定']
}, function(ret, err) {
var index = ret.buttonIndex;
var text = ret.text;
if (index == 2) {
if (text.length <= 15 && text != '') {
$.ajax({
url: HOST + '/iot_api/v1/app/device',
type: 'POST',
dataType: 'json',
headers:{
'Content-Type':'application/json;charset=utf-8',
'token': token
},
data: JSON.stringify({
imei:defaultImei,
user_id:userId,
store_name: text
}),
complete: function() {
api.hideProgress();
},
success: function(ret) {
if (ret.code == 0) {
api.toast({msg: '修改成功'});
getDeviceInfo();
api.sendEvent({
name: 'change_device',
});
}
},
error: function() {
api.toast({msg: ERR_MSG,duration: 2000,location: 'bottom'});
}
});
}else if (text == '') {
api.toast({msg: '设备名称不可为空'});
}else if (text.length > 15) {
api.toast({msg: '设备名称最多15个字符!'});
}
}
});
}
</script>
</html>