device_operate_frm.html
22.6 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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
<!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"/>
<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
<meta name="referrer" content="no-referrer">
<title>操作命令_frm</title>
<link rel="stylesheet" type="text/css" href="http://iot.uccc.cc:9090/app/css/api.css"/>
<link rel="stylesheet" type="text/css" href="http://iot.uccc.cc:9090/app/css/aui.css"/>
<link rel="stylesheet" type="text/css" href="http://iot.uccc.cc:9090/app/css/home.css"/>
<link rel="stylesheet" type="text/css" href="http://iot.uccc.cc:9090/app/css/element.css"/>
<link rel="stylesheet" type="text/css" href="http://iot.uccc.cc:9090/app/css/style.css"/>
<style>
html,
body{
background-color: #F4F6F9;
}
.el-collapse-item__wrap{
height: auto;
}
</style>
</head>
<body>
<div id="app" ontouchstart="" οnmοuseοver="">
<template>
<div class="store01001-operate-param-title" style="height: auto;">
<div style="margin-left:15px;margin-right:15.5px;">
<div class="aui-row aui-row-flex store01001-operate-top-14">
<div class="aui-col aui-col-span-1" style="margin-top: 1rem;">
<div class="store01001-operate-title-sign"></div>
</div>
<div class="aui-col aui-col-span-23">
<span class="store01001-operate-device-name" id="device_imei">设备编号:{{ api.pageParam.imei }}</span>
</div>
</div>
</div>
</div>
<div v-if="opener===1" class="store01001-operate-info-panel">
<div class="store01001-operate-info-inside-panel">
<!-- 报警总开关 -->
<div>
<div class="aui-row aui-row-flex store01001-operate-padding-top-21" @click="showWarnList(3,'rw_alarm_pattern')">
<div class="aui-col aui-col-span-15 aui-row-flex-start">
<span class="store01001-operate-param-obj">报警总开关</span>
</div>
<div class="aui-col aui-col-span-7 aui-row-flex-end">
<span style="height:1.26rem;margin-right:-0.2rem;text-align:right;font-family:DINPro-Medium;font-weight:500;color:rgba(91,127,248,1);font-size:16px;"> {{ di3_str | switchFilter }} </span>
</div>
<div class="aui-col aui-col-span-2 aui-row-flex-end">
<i style="border-left: 5px solid transparent;border-right: 5px solid transparent;border-top: 5px solid #999;margin-top: 0.5rem;"></i>
</div>
</div>
<div class="panel-line store01001-operate-margin-top-21" style="margin-top: 30px;"></div>
</div>
<!-- 使能 -->
<div v-for="(list, i) in snParamList">
<div v-if="list.show">
<div class="aui-row aui-row-flex store01001-operate-padding-top-21">
<div class="aui-col aui-col-span-15 aui-row-flex-start">
<span class="store01001-operate-param-obj">{{ list.paramTitle }}</span>
</div>
<div class="aui-col aui-col-span-9 aui-row-flex-end">
<div class="aui-list-item-input" @click="switchChange(list)">
<input :id="'select_'+ list.order" v-if="list.status" type="checkbox" class="aui-switch" checked >
<input :id="'select_'+ list.order" v-else type="checkbox" class="aui-switch" >
</div>
</div>
</div>
<div class="panel-line store01001-operate-margin-top-21" style="margin-top: 30px;"></div>
</div>
</div>
<!-- 设置 -->
<div v-for="(list, i) in setParamList">
<div class="aui-row aui-row-flex store01001-operate-padding-top-21" @click="showAmount(list)">
<div class="aui-col aui-col-span-15 aui-row-flex-start">
<span class="store01001-operate-param-obj">{{ list.paramTitle }}</span>
</div>
<div class="aui-col aui-col-span-5 aui-row-flex-end">
<span style="height:1.26rem;margin-right:-0.2rem;text-align:right;font-family:DINPro-Medium;font-weight:500;color:rgba(91,127,248,1);font-size:16px;">{{ list.paramValue }}</span>
</div>
<div class="aui-col aui-col-span-3 aui-row-flex-start">
<span v-if="!list.doing" class="store01001-operate-num-value store01001-operate-num-unit">{{ list.paramUnit }}</span>
<span v-else class="store01001-operate-num-value store01001-operate-num-unit aui-loading"></span>
</div>
<div class="aui-col aui-col-span-1 aui-row-flex-end">
<i v-if="!list.doing" class="aui-iconfont aui-icon-right icon-right" style="color:#AEB8CE;margin-top: 0.1rem;"></i>
</div>
</div>
<div class="panel-line store01001-operate-margin-top-21"></div>
</div>
<!-- 温度报警模式 -->
<div>
<div class="aui-row aui-row-flex store01001-operate-padding-top-21" @click="showWarnList(1,'rw_temp_pattern')">
<div class="aui-col aui-col-span-15 aui-row-flex-start">
<span class="store01001-operate-param-obj">温度报警模式</span>
</div>
<div class="aui-col aui-col-span-7 aui-row-flex-end">
<span style="height:1.26rem;margin-right:-0.2rem;text-align:right;font-family:DINPro-Medium;font-weight:500;color:rgba(91,127,248,1);font-size:16px;"> {{ di1_str | diFilter }} </span>
</div>
<div class="aui-col aui-col-span-2 aui-row-flex-end">
<i style="border-left: 5px solid transparent;border-right: 5px solid transparent;border-top: 5px solid #999;margin-top: 0.5rem;"></i>
</div>
</div>
<div class="panel-line store01001-operate-margin-top-21"></div>
</div>
<!-- 湿度报警模式 -->
<div>
<div class="aui-row aui-row-flex store01001-operate-padding-top-21" @click="showWarnList(2,'rw_humidity_pattern')">
<div class="aui-col aui-col-span-15 aui-row-flex-start">
<span class="store01001-operate-param-obj">湿度报警模式</span>
</div>
<div class="aui-col aui-col-span-7 aui-row-flex-end">
<span style="height:1.26rem;margin-right:-0.2rem;text-align:right;font-family:DINPro-Medium;font-weight:500;color:rgba(91,127,248,1);font-size:16px;"> {{ di2_str | diFilter }} </span>
</div>
<div class="aui-col aui-col-span-2 aui-row-flex-end">
<i style="border-left: 5px solid transparent;border-right: 5px solid transparent;border-top: 5px solid #999;margin-top: 0.5rem;"></i>
</div>
</div>
<div class="panel-line store01001-operate-margin-top-21" style="margin-top: 30px;"></div>
</div>
</div>
</div>
<div style="height: 20px;"></div>
</template>
</div>
</body>
<script type="text/javascript" src="http://iot.uccc.cc:9090/app/js/api.js"></script>
<script type="text/javascript" src="http://iot.uccc.cc:9090/app/js/aui-tab.js"></script>
<script type="text/javascript" src="http://iot.uccc.cc:9090/app/js/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="http://iot.uccc.cc:9090/app/js/vue.min.js"></script>
<script type="text/javascript" src="http://iot.uccc.cc:9090/app/js/element.js"></script>
<script type="text/javascript" src="http://iot.uccc.cc:9090/app/js/fastclick.js"></script>
<script type="text/javascript" src="http://iot.uccc.cc:9090/app/js/moment.min.js"></script>
<script type="text/javascript" src="../../../script/common.js"></script>
<script type="text/javascript" src="../../../script/ctrl.js"></script>
<script type="text/javascript">
var vm,
that;
var tabTypeList = {
"first": 1,
}
var di_s = {
'0': '高报警',
'1': '低报警',
}
var switch_s = {
'0': '关闭',
'1': '保持',
'2': '自动恢复'
}
apiready = function(){
api.parseTapmode();
//---------初始化vue
vm = new Vue({
el: '#app',
data: {
imei: api.pageParam.imei,
productId: api.pageParam.productId,
user_id: api.getPrefs({sync: true,key: 'userID'}),
userId: api.getPrefs({sync: true,key: 'userID'}),
token: api.getPrefs({sync: true,key: 'userToken'}),
opener: 1,
setParamList: [
{paramSign: "rw_temp_val", paramTitle: "温度报警值", paramValue: "", paramUnit: "℃", min: -40, max: 100, closable: false, doing: false},
{paramSign: "rw_humidity_val", paramTitle: "湿度报警值", paramValue: "", paramUnit: "%", min: 0, max: 100, closable: false, doing: false},
{paramSign: "rw_temp_time", paramTitle: "温度报警时间", paramValue: "", paramUnit: "s", min: 1, max: 100, closable: false, doing: false},
{paramSign: "rw_humidity_time", paramTitle: "湿度报警时间", paramValue: "", paramUnit: "s", min: 1, max: 100, closable: false, doing: false},
],
snParamList: [
{paramTitle: "温度报警使能",paramSign: 'rw_temp_switch',status: false,order: 0, show: true, show2: false},
{paramTitle: "湿度报警使能",paramSign: 'rw_humidity_switch',status: false,order: 1, show: true, show2: false}
],
di1_str: '0',
di2_str: '0',
di3_str: '0',
value: true,
infoTemp_ : null,
},
filters: {
diFilter(v) {
return di_s[v]
},
switchFilter(v) {
return switch_s[v]
},
},
created() {
that = this
this.initFirstPage()
api.addEventListener({
name: 'pageDownEvent'
}, function(ret, err){
setTimeout(() => {
api.pageDown(function(ret, err) {
if (!ret.scrolled) {
}
});
}, 500);
});
},
methods: {
handleClick(tab, event) {
this.opener = tabTypeList[tab.name]
switch (this.opener) {
case 1:
this.initFirstPage()
break;
default:
break;
}
},
async initFirstPage() {
let params = {
imei: this.imei,
userId: this.userId,
token: this.token
}
let lastInfoRes = await get_device_infos_by_imei(params)
let lastInfo = lastInfoRes.data.device.store06001
this.infoTemp_ = lastInfo
for (var v1 in lastInfo) {
this.setParamList.forEach(d => {
if (v1 === d.paramSign) {
d.paramValue = lastInfo[v1]
}
});
}
this.di1_str = lastInfo.rw_temp_pattern
this.di2_str = lastInfo.rw_humidity_pattern
this.di3_str = lastInfo.rw_alarm_pattern
for (var v2 in lastInfo) {
this.snParamList.forEach(d => {
if (v2 === d.paramSign) {
let paramV = lastInfo[v2]
paramV === "0" ? d.status = false : d.status = true
}
});
}
},
async showAmount(list) {
if (list.doing) {
api.alert({
title: '系统繁忙',
msg: '正在操作'+ list.paramTitle +',请稍后再试!'
});
return;
}
let closeTitle = ''
if (list.closable) {
closeTitle = ' 0关闭'
}
var dialogBox = api.require('dialogBox');
dialogBox.amount({
texts: {
title: list.paramTitle + '(参数范围:' + list.min + '~' + list.max + list.paramUnit + closeTitle + ')' ,
default: list.paramValue,
leftBtnTitle: '取消',
rightBtnTitle: '完成'
},
tapClose: true,
styles: {
bg: '#fff',
corner: 6,
w: 300,
h: 200,
title: {
marginT: 20,
size: 14,
color: '#000'
},
input: {
w: 150,
h: 44,
marginT: 15,
size: 14,
color: '#000'
},
dividingLine: {
marginT: 10,
width: 0.5,
color: '#696969'
},
left: {
marginB: 7,
marginL: 20,
w: 130,
h: 35,
corner: 10,
bg: '#5B7FF8',
color: '#FFFFFF',
size: 12
},
right: {
marginB: 7,
marginL: 10,
w: 130,
h: 35,
corner: 10,
bg: '#5B7FF8',
color: '#FFFFFF',
size: 12
}
}
},async function(ret) {
var dialogBox = api.require('dialogBox');
if (ret.eventType == 'left') {
dialogBox.close({dialogName: 'amount'});
}else if (ret.eventType == 'right') {
let value_ = Number(ret.amount)
//可关闭但未
if (list.closable && value_ != 0 && (value_ < list.min || value_ > list.max)) {
api.alert({title: '提示',msg: '参数有误!'});
return;
}
if (!list.closable && (value_ < list.min || value_ > list.max)) {
api.alert({title: '提示',msg: '参数有误!'});
return;
}
let json_ = {}
eval('json_.'+list.paramSign+'=' + value_)
let params = {
user_id: that.user_id,
imei: that.imei,
type: that.productId,
command: 'set',
// control_name: ''
request_body: json_
}
dialogBox.close({dialogName: 'amount'});
that.setParamList.forEach((d,i) => { //锁定设置操作
if (d.paramSign === list.paramSign) {
d.doing = true
}
});
let setCmdReq = await post_normal_set_device(params,that.token)
console.log(JSON.stringify(params));
that.setParamList.forEach((d,i) => { //解锁设置操作
if (d.paramSign === list.paramSign) {
d.doing = false
}
});
if (setCmdReq.data.upRet) {
let upRet = JSON.parse(setCmdReq.data.upRet)
if (setCmdReq.code == 0 && setCmdReq.msg == '操作成功' && upRet.rescode == 200) {
api.toast({msg: '设置' + list.paramTitle + '成功',duration: 2000,location: 'bottom'});
}else {
api.toast({msg: '设置' + list.paramTitle + '失败',duration: 2000,location: 'bottom'});
}
}
// 射完立马get一下
params.command = 'get'
eval('params.request_body = ["' + list.paramSign + '"]')
console.log(JSON.stringify(params));
let getCmdReq = await post_normal_set_device(params,that.token)
console.log(JSON.stringify(getCmdReq));
that.initFirstPage()
}
});
},
showWarnList(v,sign) {
let title_ = '';
let buttonV = [];
let buttons = [];
if (v === 1) {
title_ = '温度报警模式'
buttonV = ['0','1']
buttons = ['高报警', '低报警']
}else if (v === 2) {
title_ = '湿度报警模式'
buttonV = ['0','1']
buttons = ['高报警', '低报警']
}else if (v === 3) {
title_ = '报警总开关'
buttonV = ['0','1','2']
buttons = ['关闭', '保持', '自动恢复']
}
let body_ = {}
eval("body_ = {" + sign + ":" + "''" + "}")
let params = {
user_id: this.user_id,
imei: this.imei,
type: this.productId,
command: 'set',
request_body: body_
}
api.actionSheet({
title: title_,
cancelTitle: '取消',
buttons: buttons
},async function(ret, err) {
var index = ret.buttonIndex;
let oldDi1 = that.di1_str
let oldDi2 = that.di2_str
let oldDi3 = that.di3_str
if (index<=buttons.length) { //取消按钮忽略
if (v === 1) {
that.di1_str = buttonV[index-1]
params.request_body.rw_temp_pattern = that.di1_str
}else if (v === 2) {
that.di2_str = buttonV[index-1]
params.request_body.rw_humidity_pattern = that.di2_str
}else if (v === 3) {
that.di3_str = buttonV[index-1]
params.request_body.rw_alarm_pattern = that.di3_str
}
console.log(JSON.stringify(params));
let setCmdReq = await post_normal_set_device(params,that.token)
console.log(JSON.stringify(setCmdReq));
if (setCmdReq.data.upRet) {
let upRet = JSON.parse(setCmdReq.data.upRet)
if (setCmdReq.code == 0 && setCmdReq.msg == '操作成功' && upRet.rescode === 200) {
api.toast({msg: '设置成功',duration: 2000,location: 'bottom'});
}else {
that.di1_str = oldDi1
that.di2_str = oldDi2
that.di3_str = oldDi3
api.toast({msg: '设置失败',duration: 2000,location: 'bottom'});
}
}
// 射完立马get一下
params.command = 'get'
params.request_body = [sign]
let getCmdReq = await post_normal_set_device(params,that.token)
that.initFirstPage()
}
});
},
async switchChange(list) {
let snValue_ = ''
let result_ = ''
if($api.byId('select_' + list.order).checked){
console.log(list.paramTitle + '---选中');
list.status = true
}else {
console.log(list.paramTitle + '---未选中');
list.status = false
}
result_ = list.status ? '开启' : '关闭'
let singleV_ = list.status ? '1' : '0'
eval("body_ = {" + list.paramSign + ": " + singleV_ + "}")
let params = {
user_id: this.user_id,
imei: this.imei,
type: this.productId,
command: 'set',
request_body: body_
}
api.showProgress({
style: 'default',
animationType: 'fade',
title: '加载中...',
text: '',
modal: true
});
let setCmdReq = await post_normal_set_device(params,that.token)
if (setCmdReq.data.upRet) {
let upRet = JSON.parse(setCmdReq.data.upRet)
if (setCmdReq.code == 0 && setCmdReq.msg == '操作成功' && upRet.rescode == 200) {
api.toast({msg: '控制' + list.paramTitle + result_ + '成功',duration: 2000,location: 'bottom'});
}else {
// that.di1_str = oldDi1
// that.di2_str = oldDi2
api.toast({msg: '控制' + list.paramTitle + result_ + '失败',duration: 2000,location: 'bottom'});
}
}
// 射完立马get一下
params.command = 'get'
params.request_body = [list.paramSign]
console.log(JSON.stringify(params));
let getCmdReq = await post_normal_set_device(params,that.token)
console.log(JSON.stringify(getCmdReq));
api.hideProgress();
that.initFirstPage()
},
}
})
};
</script>
</html>