Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
DoorLock
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
朱建香
DoorLock
Commits
1df4b733
Commit
1df4b733
authored
Dec 20, 2017
by
朱建香
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2017/12/20
1.轮询方法修改结合
parent
57788686
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
378 additions
and
120 deletions
+378
-120
dev/src/public/loop.js
+148
-0
dev/src/public/public.js
+109
-82
dev/src/public/unotify.js
+1
-2
dev/src/view/device/v_alarmInfo.js
+1
-1
dev/src/view/device/v_hijackRecord.js
+1
-1
dev/src/view/device/v_index.js
+116
-33
dev/src/view/device/v_opendoorRecord.js
+1
-1
dev/src/view/login/v_index.js
+1
-0
web/lib/js/UIOT.js
+0
-0
No files found.
dev/src/public/loop.js
0 → 100644
View file @
1df4b733
/**
* @class
* loop
*/
class
Loop
{
constructor
(
params
)
{
this
.
handle
=
null
;
this
.
watcher
=
null
;
this
.
time
=
null
;
this
.
url
=
params
.
request
.
url
;
this
.
opts
=
params
.
request
.
opts
;
this
.
timeout
=
params
.
timeout
|
30
;
this
.
fincb
=
params
.
fincb
;
this
.
intervalTime
=
params
.
interval
.
delay
;
this
.
intervalcb
=
params
.
interval
.
cb
;
this
.
stopcondition
=
params
.
stopcondition
;
this
.
canSend
=
true
;
this
.
canDo
=
true
;
this
.
i
=
0
;
}
requestsend
(
url
,
opts
,
needAuth
,
isPublic
,
i
){
let
data
=
[
0
,
0
,
0
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
0
];
console
.
log
(
"请求时间"
+
this
.
i
+
'-'
+
new
Date
().
getTime
());
setTimeout
(()
=>
{
console
.
log
(
"返回时间"
+
this
.
i
+
'-'
+
new
Date
().
getTime
());
opts
.
success
(
data
[
this
.
i
]);
},
100
);
}
clearTime
(){
clearInterval
(
this
.
handle
);
clearInterval
(
this
.
watcher
);
clearTimeout
(
this
.
time
);
}
async
sendRequest
(){
this
.
canSend
=
false
;
var
needAuth
=
arguments
.
length
>
2
&&
arguments
[
2
]
!==
undefined
?
arguments
[
2
]
:
true
;
var
isDebug
=
arguments
.
length
>
3
&&
arguments
[
3
]
!==
undefined
?
arguments
[
3
]
:
false
;
// var send = this.opts.isCustom ? iot.business.api.sendCustom : iot.business.api.send;
// iot.business.api.send(this.url, {
// iot.business.api.sendCustom(this.url, {
try
{
let
response
=
await
iot
.
business
.
api
.
send
(
this
.
url
,
{
type
:
this
.
opts
.
type
,
data
:
this
.
opts
.
data
},
needAuth
,
false
,
isDebug
);
if
(
this
.
intervalcb
!=
null
){
this
.
intervalcb
.
success
(
response
);
}
if
(
await
this
.
stopcondition
(
response
)){
if
(
this
.
fincb
!=
null
){
this
.
fincb
.
success
(
response
);
this
.
fincb
.
complete
();
}
this
.
clearTime
();
this
.
canSend
=
false
;
}
else
{
this
.
canSend
=
true
;
}
}
catch
(
error
){
if
(
this
.
intervalcb
!=
null
){
if
(
this
.
intervalcb
.
error
(
error
)){
this
.
canSend
=
true
;
}
else
{
if
(
this
.
fincb
!=
null
){
this
.
fincb
.
error
(
error
);
this
.
fincb
.
complete
();
this
.
clearTime
();
}
}
}
}
}
start
(){
console
.
log
(
"开始"
);
this
.
time
=
setTimeout
(()
=>
{
this
.
clearTime
();
this
.
canDo
=
false
;
// this.fincb.error('timeout');
// this.fincb.complete();
console
.
log
(
"超时"
);
this
.
intervalcb
=
null
;
this
.
fincb
=
null
;
},
this
.
timeout
);
this
.
sendRequest
();
this
.
watcher
=
setInterval
(()
=>
{
if
(
this
.
canSend
&&
this
.
canDo
){
this
.
canDo
=
false
;
console
.
log
(
"发送了请求"
);
console
.
log
(
"发送时间"
+
new
Date
().
getTime
());
this
.
i
++
;
this
.
sendRequest
();
}
},
1000
);
this
.
handle
=
setInterval
(()
=>
{
this
.
canDo
=
true
;
},
3000
);
}
}
//new Loop({
// request: {
// url: 'http://www.baidu.com',
// opts: {
// type: 'post',
// data: {}
// }
// },
// timeout: 6000,
// interval:{
// delay: 1000,
// cb: {
// success: (response) => {
// console.log('intervalcbSuccess:'+response);
// },
// error: (error) => {
// console.log('intervalcbSuccess:'+error);
// }
// }
// },
// fincb: {
// success: (response) => {
// console.log('fincbSuccess:'+response);
// },
// error: (error) => {
// console.log('fincbError:'+error);
// },
// complete: () => {}
// },
// stopcondition: (response) => {
// if(response == 1){
// return true;
// }else{
// return false;
// }
// }
//}).start();
export
default
Loop
;
//module.exports = Loop;
\ No newline at end of file
dev/src/public/public.js
View file @
1df4b733
...
@@ -276,58 +276,55 @@ iot.navigator.getCurrentWebView = function (){
...
@@ -276,58 +276,55 @@ iot.navigator.getCurrentWebView = function (){
}
}
//function requestsend(url, opts, needAuth, isPublic, i){
//function requestsend(url, opts, i){
// let data = [0,1,1,0,0,1,0,1,0,0,0];
// let data = [0,0,0,0,0,0,0,1,0,0,0];
// console.log("请求时间"+i+'-'+new Date().getTime());
// setTimeout(function(){
// console.log("返回时间"+i+'-'+new Date().getTime());
// opts.success(data[i]);
// opts.success(data[i]);
// },1000);
//
//}
//}
//
//
//function clearTime(interval, timeout){
//function clearTime(interval,
intervalTwo,
timeout){
// window.clearInterval(interval);
// window.clearInterval(interval);
// window.clearInterval(intervalTwo);
// window.clearTimeout(timeout);
// window.clearTimeout(timeout);
//}
//}
//
//
//function sendRequest(url, params, canSend){
//function sendRequest(url, params, fincb, intervalcb, handle, watcher, time, canSend, stopcondition, i){
// var opts = {
// canSend(false);
// type: 'post',
// data: params.data,
// success: params.success,
// error: params.error,
// complete: params.complete
// };
// canSend = false;
// requestsend(url, {
// requestsend(url, {
// type: 'post',
// type: 'post',
// data: {
// data: params.data,
// params.data
// },
// success: (response) => {
// success: (response) => {
// intervalcb.success(response);
// intervalcb.success(response);
// if(stopcondition(response)){
// if(stopcondition(response)){
//
params
.success(response);
//
fincb
.success(response);
// clearTime(handle, time);
// clearTime(handle,
watcher,
time);
// canSend
= false
;
// canSend
(false)
;
// }else{
// }else{
// canSend
= true
;
// canSend
(true)
;
// }
// }
// },
// },
// error: (error) => {
// error: (error) => {
// intervalcb.error(error);
// intervalcb.error(error);
// //在intervalcb.error(error)中返回的如果是true则继续执行,否则结束轮询
// if(intervalcb.error(error)){
// if(intervalcb.error(error)){
// canSend
= true
;
// canSend
(true)
;
// }else{
// }else{
//
params
.error(error);
//
fincb
.error(error);
// clearTime(handle, time);
// clearTime(handle,
watcher,
time);
// }
// }
// },
// },
// complete: {}
// complete:
() =>
{}
// }, true, false);
// }, true, false
, i
);
//
return canSend;
//
//}
//}
//
//
//
//uComponents.loop = function(request, timeout, interval, fincb, stopcondition){
//uComponents.loop = function(request, timeout, interval, fincb, stopcondition){
// var handle = null;
// var handle = null;
// var watcher = null;
// var time = null;
// var time = null;
// var url = request.url;
// var url = request.url;
// var opts = request.opts;
// var opts = request.opts;
...
@@ -337,63 +334,82 @@ iot.navigator.getCurrentWebView = function (){
...
@@ -337,63 +334,82 @@ iot.navigator.getCurrentWebView = function (){
// var canSend = true;
// var canSend = true;
// var canDo = true;
// var canDo = true;
// var i = 0;
// var i = 0;
// console.log("开始");
// time = setTimeout(function(){
// time = setTimeout(function(){
// clearTime(handle, time);
// clearTime(handle, watcher, time);
// canDo = false;
// fincb.error('timeout');
// fincb.error('timeout');
// console.log("超时");
// intervalcb.success = function(){
// return;
// };
// },timeout);
// },timeout);
// var watcher = setInterval(function(){
// sendRequest(url, opts, fincb, intervalcb, handle, watcher, time, function(res){
// canSend = res;
// if(canSend){
// watcher = setInterval(function(){
// if(canSend && canDo){
// if(canSend && canDo){
// var send = sendRequest(url, opts, canSend, canDo);
// canDo = false;
// }
// console.log("发送了请求");
// },1000);
// console.log("发送时间"+new Date().getTime());
// //一开始执行一次,发送一次请求
// requestsend(url, {
// data: {},
// success: (response) => {
// intervalcb.success(response);
// if(stopcondition(response)){
// //首次请求结果符合条件的话,结束整个方法
// fincb.success(response);
// clearTime(handle, time);
// }else{
// //首次请求结果不符合条件的话,每隔intervalTime时间发送请求
// handle = setInterval(() => {
// i++;
// i++;
// console.log(i);
// sendRequest(url, opts, fincb, intervalcb, handle, watcher, time, function(res){
// if(flag){
// canSend = res;
// flag = false;
// }, stopcondition, i);
// requestsend(url, {
// data: {},
// success: (response) => {
// intervalcb.success(response);
// if(stopcondition(response)){
// fincb.success(response);
// clearTime(handle, time);
// }
// flag = true;
// },
// error: (error) => {
// if(intervalcb.error(error)){
// flag = false;
// }else{
// fincb.error(error);
// clearTime(handle, time);
// }
// },
// complete: {}
// }, i);
// }
// }
//
},intervalTime
);
//
},1000
);
// }
// }
// },
// }, stopcondition, i);
// error: (error) => {
// handle = setInterval(function(){
// intervalcb.error(error);
// canDo = true;
// fincb.error(error);
// },1000);
// clearTime(handle, time);
//// //一开始执行一次,发送一次请求
// },
//// requestsend(url, {
// complete: {}
//// data: {},
// }, 0);
//// success: (response) => {
//
//// intervalcb.success(response);
//// if(stopcondition(response)){
//// //首次请求结果符合条件的话,结束整个方法
//// fincb.success(response);
//// clearTime(handle, time);
//// }else{
//// //首次请求结果不符合条件的话,每隔intervalTime时间发送请求
//// handle = setInterval(() => {
//// i++;
//// console.log(i);
//// if(flag){
//// flag = false;
//// requestsend(url, {
//// data: {},
//// success: (response) => {
//// intervalcb.success(response);
//// if(stopcondition(response)){
//// fincb.success(response);
//// clearTime(handle, time);
//// }
//// flag = true;
//// },
//// error: (error) => {
//// if(intervalcb.error(error)){
//// flag = false;
//// }else{
//// fincb.error(error);
//// clearTime(handle, time);
//// }
//// },
//// complete: {}
//// }, i);
//// }
//// },intervalTime);
//// }
//// },
//// error: (error) => {
//// intervalcb.error(error);
//// fincb.error(error);
//// clearTime(handle, time);
//// },
//// complete: {}
//// }, 0);
//}
//}
//
//
////传递的参数依次是:
////传递的参数依次是:
...
@@ -402,14 +418,15 @@ iot.navigator.getCurrentWebView = function (){
...
@@ -402,14 +418,15 @@ iot.navigator.getCurrentWebView = function (){
////3.interval: 发送请求的间隔时间、callback;
////3.interval: 发送请求的间隔时间、callback;
////4.fincb: 整个方法的callback;
////4.fincb: 整个方法的callback;
////5.stopcondition: 请求停止所要符合的条件
////5.stopcondition: 请求停止所要符合的条件
//uComponents.loop({url:'getLockInfo',opts: {
//function sendloop(){
// uComponents.loop({url:'getLockInfo',opts: {
// success: (response) => {
// success: (response) => {
// console.log(response);
// console.log(response);
// },
// },
// error: (error) => {
// error: (error) => {
// console.log(error);
// console.log(error);
// }
// }
//
}}, 8
000, {
//
}},6
000, {
// delay: 1000,
// delay: 1000,
// opts: {
// opts: {
// success: (response) => {
// success: (response) => {
...
@@ -419,19 +436,28 @@ iot.navigator.getCurrentWebView = function (){
...
@@ -419,19 +436,28 @@ iot.navigator.getCurrentWebView = function (){
// console.log('intervalcbSuccess:'+error);
// console.log('intervalcbSuccess:'+error);
// }
// }
// }
// }
//}, {
//
}, {
// success: (response) => {
// success: (response) => {
// console.log('fincbSuccess:'+response);
// console.log('fincbSuccess:'+response);
// },
// },
// error: (error) => {
// error: (error) => {
// console.log('fincbError'+error);
// console.log('fincbError'+error);
// }
// }
//}, (response) => {
//
}, (response) => {
// if(response == 1){
// if(response == 1){
// return true;
// return true;
// }else{
// }else{
// return false;
// return false;
// }
// }
//});
// });
//}
//sendloop();
//setTimeout(function(){
// sendloop();
// setTimeout(function(){
// sendloop();
// },3000)
//
//},1000)
export
{
iot
,
uPublic
,
uComponents
}
export
{
iot
,
uPublic
,
uComponents
}
\ No newline at end of file
dev/src/public/unotify.js
View file @
1df4b733
...
@@ -71,14 +71,13 @@ class unotify{
...
@@ -71,14 +71,13 @@ class unotify{
// try{
// try{
// cid = await this.getCidPeriotic(9);
// cid = await this.getCidPeriotic(9);
// if(cid != null && cid != oldCid){
// if(cid != null && cid != oldCid){
// successCallback('cid updateSuccess');
// iot.business.api.send('user/updateCid',{
// iot.business.api.send('user/updateCid',{
// data: {
// data: {
// clienId: cid
// clienId: cid
// },
// },
// success: (response) => {
// success: (response) => {
// if(typeof successCallback == 'function'){
// if(typeof successCallback == 'function'){
// uccessCallback('cid updateSuccess');
//
s
uccessCallback('cid updateSuccess');
// }
// }
// },
// },
// error: (error) => {
// error: (error) => {
...
...
dev/src/view/device/v_alarmInfo.js
View file @
1df4b733
...
@@ -99,7 +99,7 @@ function initComponentsConfig() {
...
@@ -99,7 +99,7 @@ function initComponentsConfig() {
let
data
=
uPublic
.
checkResponseData
(
response
.
data
);
let
data
=
uPublic
.
checkResponseData
(
response
.
data
);
if
(
data
&&
data
.
record
.
length
>
0
){
if
(
data
&&
data
.
record
.
length
>
0
){
let
record
=
data
.
record
;
let
record
=
data
.
record
;
iot
.
storage
.
setMap
(
'notifyTime'
,
moment
(
record
[
0
].
time
).
toISOString
(),
(
res
)
=>
{
iot
.
storage
.
setMap
(
'notifyTime'
,
moment
(
record
[
0
].
time
).
unix
(),
(
res
)
=>
{
console
.
log
(
res
);
console
.
log
(
res
);
self
.
flag
=
false
;
self
.
flag
=
false
;
},
()
=>
{
},
()
=>
{
...
...
dev/src/view/device/v_hijackRecord.js
View file @
1df4b733
...
@@ -106,7 +106,7 @@ function initComponentsConfig() {
...
@@ -106,7 +106,7 @@ function initComponentsConfig() {
let
data
=
uPublic
.
checkResponseData
(
response
.
data
);
let
data
=
uPublic
.
checkResponseData
(
response
.
data
);
if
(
data
&&
data
.
record
.
length
>
0
){
if
(
data
&&
data
.
record
.
length
>
0
){
let
record
=
data
.
record
;
let
record
=
data
.
record
;
iot
.
storage
.
setMap
(
'alarmTime'
,
moment
(
record
[
0
].
time
).
toISOString
(),
(
res
)
=>
{
iot
.
storage
.
setMap
(
'alarmTime'
,
moment
(
record
[
0
].
time
).
unix
(),
(
res
)
=>
{
console
.
log
(
res
);
console
.
log
(
res
);
self
.
flag
=
false
;
self
.
flag
=
false
;
},
()
=>
{
},
()
=>
{
...
...
dev/src/view/device/v_index.js
View file @
1df4b733
...
@@ -12,6 +12,7 @@ import moment from 'moment';
...
@@ -12,6 +12,7 @@ import moment from 'moment';
import
crypto
from
'../../public/crypto.js'
;
import
crypto
from
'../../public/crypto.js'
;
import
config
from
'../../public/config.js'
;
import
config
from
'../../public/config.js'
;
import
{
iot
,
uPublic
,
uComponents
}
from
'../../public/public.js'
;
import
{
iot
,
uPublic
,
uComponents
}
from
'../../public/public.js'
;
import
Loop
from
'../../public/loop.js'
;
iot
.
ready
(
init
);
iot
.
ready
(
init
);
function
init
()
{
function
init
()
{
...
@@ -104,6 +105,7 @@ function init() {
...
@@ -104,6 +105,7 @@ function init() {
remoteTime
:
null
remoteTime
:
null
},
},
mounted
(){
mounted
(){
uComponents
.
showLoading
(
this
);
uComponents
.
showLoading
(
this
);
notificationListener
(
this
);
notificationListener
(
this
);
let
self
=
this
;
let
self
=
this
;
...
@@ -111,6 +113,7 @@ function init() {
...
@@ -111,6 +113,7 @@ function init() {
getDevices
(
this
);
getDevices
(
this
);
//注册监听上报
//注册监听上报
registerPushListener
(
this
);
registerPushListener
(
this
);
window
.
addEventListener
(
'returnPage'
,
function
(
event
){
window
.
addEventListener
(
'returnPage'
,
function
(
event
){
//获取设备信息
//获取设备信息
getDevices
(
self
);
getDevices
(
self
);
...
@@ -429,13 +432,94 @@ function initComponentsConfig() {
...
@@ -429,13 +432,94 @@ function initComponentsConfig() {
}
}
function
loopGetLockInfo
(
self
,
delay
,
timeout
){
function
loopGetLockInfo
(
self
,
delay
,
timeout
){
self
.
handle
=
setInterval
(
function
(){
// if(self.handle == null){
getLockInfo
(
self
);
// self.handle = setInterval(function(){
},
delay
*
1000
);
// getLockInfo(self);
let
time
=
setTimeout
(
function
()
{
// },delay*1000);
window
.
clearInterval
(
self
.
handle
);
// let time = setTimeout(function () {
window
.
clearTimeout
(
time
);
// window.clearInterval(self.handle);
},
timeout
*
1000
);
// window.clearTimeout(time);
// self.handle = null;
// }, timeout * 1000);
// }
new
Loop
({
request
:
{
url
:
'lock/getLockInfo'
,
opts
:
{
type
:
'post'
,
isCustom
:
true
,
data
:
{
device_id
:
self
.
deviceId
}
}
},
timeout
:
10000
,
interval
:{
delay
:
3000
,
cb
:
{
success
:
(
response
)
=>
{
console
.
log
(
'intervalcbSuccess:'
+
JSON
.
stringify
(
response
));
},
error
:
(
error
)
=>
{
console
.
log
(
'intervalcbError:'
+
JSON
.
stringify
(
error
));
}
}
},
fincb
:
{
success
:
(
response
)
=>
{
console
.
log
(
"insuccess"
);
console
.
log
(
response
);
let
data
=
uPublic
.
checkResponseData
(
response
.
data
);
if
(
data
){
getLockInfoSuccess
(
self
,
data
);
}
else
{
setValueOfSwitch
(
self
,
true
);
self
.
setLockId
(
null
);
self
.
mac
=
null
;
self
.
deviceId
=
null
;
self
.
uuid
=
null
;
uComponents
.
changeMarqueeText
(
self
,
[
Vue
.
t
(
'device.defaultNewMsg'
)]);
self
.
activeFlag
=
false
;
self
.
opendoorRecordFlag
=
false
;
self
.
securityAlarmFlag
=
false
;
self
.
hijackAlarmFlag
=
false
;
}
},
error
:
(
error
)
=>
{
// uPublic.openRequestErrorAlert(self);
console
.
log
(
error
);
},
complete
:
()
=>
{
uComponents
.
hideLoading
(
self
);
}
},
stopcondition
:
async
(
response
)
=>
{
let
data
=
response
.
data
;
console
.
log
(
data
.
open_time
);
var
notifyTime
=
null
;
var
alarmTime
=
null
;
var
openTime
=
null
;
try
{
notifyTime
=
await
iot
.
storage
.
getMap
(
'notifyTime'
);
alarmTime
=
await
iot
.
storage
.
getMap
(
'alarmTime'
);
openTime
=
await
iot
.
storage
.
getMap
(
'openTime'
);
}
catch
(
error
)
{
console
.
log
(
error
);
}
let
newNotifyTime
=
moment
(
data
.
notify_time
).
unix
();
let
newAlarmTime
=
moment
(
data
.
alarm_time
).
unix
();
let
newOpenTime
=
moment
(
data
.
open_time
).
unix
();
console
.
log
(
openTime
);
console
.
log
(
newOpenTime
);
if
(
notifyTime
!=
newNotifyTime
||
alarmTime
!=
newAlarmTime
||
openTime
!=
newOpenTime
){
console
.
log
(
"innnnnnn"
);
return
true
;
}
}
}).
start
();
}
}
function
getDevices
(
self
){
function
getDevices
(
self
){
...
@@ -527,73 +611,72 @@ function registerPushListener(self){
...
@@ -527,73 +611,72 @@ function registerPushListener(self){
async
function
getRecordTime
(
self
,
data
){
async
function
getRecordTime
(
self
,
data
){
try
{
try
{
self
.
notifyTime
=
await
getRecordTimeMap
(
'notifyTime'
);
self
.
notifyTime
=
await
iot
.
storage
.
getMap
(
'notifyTime'
);
}
self
.
alarmTime
=
await
iot
.
storage
.
getMap
(
'alarmTime'
);
catch
(
error
)
{
self
.
openTime
=
await
iot
.
storage
.
getMap
(
'openTime'
);
console
.
log
(
error
);
}
try
{
self
.
alarmTime
=
await
getRecordTimeMap
(
'alarmTime'
);
}
}
catch
(
error
)
{
catch
(
error
)
{
console
.
log
(
error
);
console
.
log
(
error
);
}
}
try
{
let
newNotifyTime
=
moment
(
data
.
notify_time
).
unix
();
self
.
openTime
=
await
getRecordTimeMap
(
'openTime'
);
let
newAlarmTime
=
moment
(
data
.
alarm_time
).
unix
();
}
let
newOpenTime
=
moment
(
data
.
open_time
).
unix
();
catch
(
error
)
{
console
.
log
(
error
);
}
let
newNotifyTime
=
moment
(
data
.
notify_time
);
let
newAlarmTime
=
moment
(
data
.
alarm_time
);
let
newOpenTime
=
moment
(
data
.
open_time
);
// console.log("newNotifyTime:"+newNotifyTime.format('YYYY-MM-DD hh:mm:ss'));
// console.log("newNotifyTime:"+newNotifyTime.format('YYYY-MM-DD hh:mm:ss'));
// console.log("newAlarmTime:"+newAlarmTime.format('YYYY-MM-DD hh:mm:ss'));
// console.log("newAlarmTime:"+newAlarmTime.format('YYYY-MM-DD hh:mm:ss'));
// console.log("newOpenTime:"+newOpenTime.format('YYYY-MM-DD hh:mm:ss'));
// console.log("newOpenTime:"+newOpenTime.format('YYYY-MM-DD hh:mm:ss'));
// console.log("notifyTime:"+moment(self.notifyTime,moment.ISO_8601).format('YYYY-MM-DD hh:mm:ss'));
// console.log("notifyTime:"+moment(self.notifyTime,moment.ISO_8601).format('YYYY-MM-DD hh:mm:ss'));
// console.log("alarmTime:"+moment(self.alarmTime,moment.ISO_8601).format('YYYY-MM-DD hh:mm:ss'));
// console.log("alarmTime:"+moment(self.alarmTime,moment.ISO_8601).format('YYYY-MM-DD hh:mm:ss'));
// console.log("openTime:"+moment(self.openTime,moment.ISO_8601).format('YYYY-MM-DD hh:mm:ss'));
// console.log("openTime:"+moment(self.openTime,moment.ISO_8601).format('YYYY-MM-DD hh:mm:ss'));
let
now
=
moment
(
new
Date
(),
"YYYY-MM-DD hh:mm:ss"
);
let
now
=
moment
(
new
Date
(),
"YYYY-MM-DD hh:mm:ss"
)
.
unix
()
;
if
(
self
.
notifyTime
){
if
(
self
.
notifyTime
){
// console.log("notifyTime"+newNotifyTime.diff(self.notifyTime, 'seconds'));
// console.log("notifyTime"+newNotifyTime.diff(self.notifyTime, 'seconds'));
self
.
notifyTime
=
moment
(
self
.
notifyTime
,
moment
.
ISO_8601
);
if
(
newNotifyTime
!=
null
&&
newNotifyTime
-
self
.
notifyTime
>
0
){
if
(
newNotifyTime
!=
null
&&
newNotifyTime
.
diff
(
self
.
notifyTime
,
'seconds'
)
>
0
){
self
.
securityAlarmFlag
=
true
;
self
.
securityAlarmFlag
=
true
;
self
.
notifyTime
=
newNotifyTime
;
self
.
notifyTime
=
newNotifyTime
;
}
else
{
self
.
securityAlarmFlag
=
false
;
}
}
}
else
{
}
else
{
// console.log("notifyTime"+now.diff(newNotifyTime, 'hours'));
// console.log("notifyTime"+now.diff(newNotifyTime, 'hours'));
if
(
newNotifyTime
!=
null
&&
now
.
diff
(
newNotifyTime
,
'hours'
)
<
1
){
if
(
newNotifyTime
!=
null
&&
now
-
newNotifyTime
<
3600
){
self
.
securityAlarmFlag
=
true
;
self
.
securityAlarmFlag
=
true
;
self
.
notifyTime
=
newNotifyTime
;
self
.
notifyTime
=
newNotifyTime
;
}
else
{
self
.
securityAlarmFlag
=
false
;
}
}
}
}
if
(
self
.
alarmTime
){
if
(
self
.
alarmTime
){
self
.
alarmTime
=
moment
(
self
.
alarmTime
,
moment
.
ISO_8601
);
// console.log("Alarm"+newAlarmTime.diff(self.alarmTime, 'seconds'));
// console.log("Alarm"+newAlarmTime.diff(self.alarmTime, 'seconds'));
if
(
newAlarmTime
!=
null
&&
newAlarmTime
.
diff
(
self
.
alarmTime
,
'seconds'
)
>
0
){
if
(
newAlarmTime
!=
null
&&
newAlarmTime
-
self
.
alarmTime
>
0
){
self
.
hijackAlarmFlag
=
true
;
self
.
hijackAlarmFlag
=
true
;
self
.
alarmTime
=
newAlarmTime
;
self
.
alarmTime
=
newAlarmTime
;
}
else
{
self
.
hijackAlarmFlag
=
false
;
}
}
}
else
{
}
else
{
// console.log("Alarm"+now.diff(newAlarmTime, 'hours'));
// console.log("Alarm"+now.diff(newAlarmTime, 'hours'));
if
(
newAlarmTime
!=
null
&&
now
.
diff
(
newAlarmTime
,
'hours'
)
<
1
){
if
(
newAlarmTime
!=
null
&&
now
-
newAlarmTime
<
3600
){
self
.
hijackAlarmFlag
=
true
;
self
.
hijackAlarmFlag
=
true
;
self
.
alarmTime
=
newAlarmTime
;
self
.
alarmTime
=
newAlarmTime
;
}
else
{
self
.
hijackAlarmFlag
=
false
;
}
}
}
}
if
(
self
.
openTime
){
if
(
self
.
openTime
){
self
.
openTime
=
moment
(
self
.
openTime
,
moment
.
ISO_8601
);
// console.log("openTime"+newOpenTime.diff(self.openTime, 'seconds'));
// console.log("openTime"+newOpenTime.diff(self.openTime, 'seconds'));
if
(
newOpenTime
!=
null
&&
newOpenTime
.
diff
(
self
.
openTime
,
'seconds'
)
>
0
){
if
(
newOpenTime
!=
null
&&
newOpenTime
-
self
.
openTime
>
0
){
self
.
opendoorRecordFlag
=
true
;
self
.
opendoorRecordFlag
=
true
;
self
.
openTime
=
newOpenTime
;
self
.
openTime
=
newOpenTime
;
}
else
{
self
.
opendoorRecordFlag
=
false
;
}
}
}
else
{
}
else
{
// console.log("openTime"+now.diff(newOpenTime, 'hours'));
// console.log("openTime"+now.diff(newOpenTime, 'hours'));
if
(
newOpenTime
!=
null
&&
now
.
diff
(
newOpenTime
,
'hours'
)
<
1
){
if
(
newOpenTime
!=
null
&&
now
.
diff
-
newOpenTime
<
3600
){
self
.
opendoorRecordFlag
=
true
;
self
.
opendoorRecordFlag
=
true
;
self
.
openTime
=
newOpenTime
;
self
.
openTime
=
newOpenTime
;
}
else
{
self
.
opendoorRecordFlag
=
false
;
}
}
}
}
}
}
...
...
dev/src/view/device/v_opendoorRecord.js
View file @
1df4b733
...
@@ -133,7 +133,7 @@ function getHistoryRecord(self){
...
@@ -133,7 +133,7 @@ function getHistoryRecord(self){
let
data
=
uPublic
.
checkResponseData
(
response
.
data
);
let
data
=
uPublic
.
checkResponseData
(
response
.
data
);
if
(
data
&&
data
.
record
.
length
>
0
){
if
(
data
&&
data
.
record
.
length
>
0
){
let
record
=
data
.
record
;
let
record
=
data
.
record
;
iot
.
storage
.
setMap
(
'openTime'
,
moment
(
record
[
0
].
time
).
toISOString
(),
(
res
)
=>
{
iot
.
storage
.
setMap
(
'openTime'
,
moment
(
record
[
0
].
time
).
unix
(),
(
res
)
=>
{
console
.
log
(
res
);
console
.
log
(
res
);
self
.
flag
=
false
;
self
.
flag
=
false
;
},
()
=>
{
},
()
=>
{
...
...
dev/src/view/login/v_index.js
View file @
1df4b733
...
@@ -180,6 +180,7 @@ function cloudsLogin(self, id){
...
@@ -180,6 +180,7 @@ function cloudsLogin(self, id){
data
:
{
data
:
{
username
:
id
,
username
:
id
,
clienId
:
self
.
getClientId
()
clienId
:
self
.
getClientId
()
// clienId: null
},
},
success
:
(
response
)
=>
{
success
:
(
response
)
=>
{
if
(
window
.
iotDebug
){
if
(
window
.
iotDebug
){
...
...
web/lib/js/UIOT.js
View file @
1df4b733
This source diff could not be displayed because it is too large. You can
view the blob
instead.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment