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
felix
DoorLock
Commits
6049e46b
Commit
6049e46b
authored
Dec 21, 2017
by
朱建香
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2017/12/21
1.优化首页代码 2.用新的轮询方法获取开门记录
parent
a01869c1
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
73 additions
and
218 deletions
+73
-218
dev/src/public/loop.js
+18
-9
dev/src/public/public.js
+33
-188
dev/src/view/device/v_alarmInfo.js
+6
-5
dev/src/view/device/v_hijackRecord.js
+7
-6
dev/src/view/device/v_index.js
+0
-0
dev/src/view/device/v_opendoorRecord.js
+6
-5
dev/src/view/doorlockManage/v_index.js
+3
-3
web/lib/js/UIOT.js
+0
-2
No files found.
dev/src/public/loop.js
View file @
6049e46b
...
...
@@ -39,18 +39,21 @@ class Loop{
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
;
var
needAuth
=
this
.
opts
.
needAuth
!==
undefined
?
this
.
opts
.
needAuth
:
true
;
var
isDebug
=
this
.
opts
.
isDebug
!==
undefined
?
this
.
opts
.
isDebug
:
false
;
var
withoutUgen
=
this
.
opts
.
withoutUgen
!==
undefined
?
this
.
opts
.
withoutUgen
:
false
;
// iot.business.api.send(this.url, {
// iot.business.api.sendCustom(this.url, {
try
{
let
response
=
await
iot
.
business
.
api
.
send
(
this
.
url
,
{
var
urlParams
=
{
type
:
this
.
opts
.
type
,
data
:
this
.
opts
.
data
},
needAuth
,
false
,
isDebug
);
if
(
this
.
intervalcb
!=
null
){
this
.
intervalcb
.
success
(
response
);
};
try
{
var
response
=
null
;
if
(
withoutUgen
){
response
=
await
iot
.
network
.
send
(
this
.
url
,
urlParams
);
}
else
{
response
=
await
iot
.
business
.
api
.
send
(
this
.
url
,
urlParams
,
needAuth
,
false
,
isDebug
);
}
if
(
await
this
.
stopcondition
(
response
)){
if
(
this
.
fincb
!=
null
){
...
...
@@ -60,6 +63,9 @@ class Loop{
this
.
clearTime
();
this
.
canSend
=
false
;
}
else
{
if
(
this
.
intervalcb
!=
null
){
this
.
intervalcb
.
success
(
response
);
}
this
.
canSend
=
true
;
}
}
...
...
@@ -90,11 +96,14 @@ class Loop{
this
.
intervalcb
=
null
;
this
.
fincb
=
null
;
},
this
.
timeout
);
console
.
log
(
"第"
+
this
.
i
+
"次发送了请求"
);
console
.
log
(
"发送时间"
+
new
Date
().
getTime
());
this
.
i
++
;
this
.
sendRequest
();
this
.
watcher
=
setInterval
(()
=>
{
if
(
this
.
canSend
&&
this
.
canDo
){
this
.
canDo
=
false
;
console
.
log
(
"发送了请求"
);
console
.
log
(
"
第"
+
this
.
i
+
"次
发送了请求"
);
console
.
log
(
"发送时间"
+
new
Date
().
getTime
());
this
.
i
++
;
this
.
sendRequest
();
...
...
dev/src/public/public.js
View file @
6049e46b
...
...
@@ -19,11 +19,11 @@ const iot = new UIOT({
cloud
:
{
// url: 'http://wx.iotface.com'
//96环境
//
url: 'http://192.168.2.96:20000'
url
:
'http://192.168.2.96:20000'
//96外网
// url: 'http://jycinema.u-gen.net'
//正式
url
:
'https://cloud.iot.u-gen.net/'
//
url: 'https://cloud.iot.u-gen.net/'
//正式测试
// url: 'https://cloud.iot.u-gen.net/test-openapi/'
},
...
...
@@ -147,6 +147,37 @@ uPublic.logout = function(opts){
});
}
uPublic
.
upDateRead
=
async
function
(
key
){
let
oldHistory
=
{
alarm
:
{
time
:
null
,
isReadFlag
:
true
},
notify
:
{
time
:
null
,
isReadFlag
:
true
},
open
:
{
time
:
null
,
isReadFlag
:
true
}
};
try
{
oldHistory
=
await
iot
.
storage
.
getMap
(
'history'
);
console
.
log
(
oldHistory
);
}
catch
(
error
){
console
.
log
(
error
);
}
let
newHistory
=
oldHistory
;
newHistory
[
key
].
isReadFlag
=
true
;
iot
.
storage
.
setMap
(
'history'
,
newHistory
,
(
response
)
=>
{
console
.
log
(
res
);
},
()
=>
{
});
}
iot
.
ready
(()
=>
{
uPublic
.
recalc
();
});
...
...
@@ -275,189 +306,4 @@ iot.navigator.getCurrentWebView = function (){
return
plus
.
webview
.
currentWebview
();
}
//function requestsend(url, opts, needAuth, isPublic, i){
// let data = [0,1,1,0,0,1,0,1,0,0,0];
// console.log("请求时间"+i+'-'+new Date().getTime());
// setTimeout(function(){
// console.log("返回时间"+i+'-'+new Date().getTime());
// opts.success(data[i]);
// },1000);
//
//}
//
//function clearTime(interval, intervalTwo, timeout){
// window.clearInterval(interval);
// window.clearInterval(intervalTwo);
// window.clearTimeout(timeout);
//}
//
//function sendRequest(url, params, fincb, intervalcb, handle, watcher, time, canSend, stopcondition, i){
// canSend(false);
// requestsend(url, {
// type: 'post',
// data: params.data,
// success: (response) => {
// intervalcb.success(response);
// if(stopcondition(response)){
// fincb.success(response);
// clearTime(handle, watcher, time);
// canSend(false);
// }else{
// canSend(true);
// }
// },
// error: (error) => {
// intervalcb.error(error);
// if(intervalcb.error(error)){
// canSend(true);
// }else{
// fincb.error(error);
// clearTime(handle, watcher, time);
// }
// },
// complete: () => {}
// }, true, false, i);
//
//}
//
//
//uComponents.loop = function(request, timeout, interval, fincb, stopcondition){
// var handle = null;
// var watcher = null;
// var time = null;
// var url = request.url;
// var opts = request.opts;
// var intervalTime = interval.delay;
// var intervalcb = interval.opts;
// var flag = true;
// var canSend = true;
// var canDo = true;
// var i = 0;
// console.log("开始");
// time = setTimeout(function(){
// clearTime(handle, watcher, time);
// canDo = false;
// fincb.error('timeout');
// console.log("超时");
// intervalcb.success = function(){
// return;
// };
// },timeout);
// sendRequest(url, opts, fincb, intervalcb, handle, watcher, time, function(res){
// canSend = res;
// if(canSend){
// watcher = setInterval(function(){
// if(canSend && canDo){
// canDo = false;
// console.log("发送了请求");
// console.log("发送时间"+new Date().getTime());
// i++;
// sendRequest(url, opts, fincb, intervalcb, handle, watcher, time, function(res){
// canSend = res;
// }, stopcondition, i);
// }
// },1000);
// }
// }, stopcondition, i);
// handle = setInterval(function(){
// canDo = true;
// },1000);
//// //一开始执行一次,发送一次请求
//// requestsend(url, {
//// data: {},
//// 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);
//}
//
////传递的参数依次是:
////1.request: 请求参数(数据类型: map,包括:url、header等);
////2.timeout: 整个方法的超时时间;
////3.interval: 发送请求的间隔时间、callback;
////4.fincb: 整个方法的callback;
////5.stopcondition: 请求停止所要符合的条件
//function sendloop(){
// uComponents.loop({url:'getLockInfo',opts: {
// success: (response) => {
// console.log(response);
// },
// error: (error) => {
// console.log(error);
// }
// }},6000, {
// delay: 1000,
// opts: {
// success: (response) => {
// console.log('intervalcbSuccess:'+response);
// },
// error: (error) => {
// console.log('intervalcbSuccess:'+error);
// }
// }
// }, {
// success: (response) => {
// console.log('fincbSuccess:'+response);
// },
// error: (error) => {
// console.log('fincbError'+error);
// }
// }, (response) => {
// if(response == 1){
// return true;
// }else{
// return false;
// }
// });
//}
//sendloop();
//setTimeout(function(){
// sendloop();
// setTimeout(function(){
// sendloop();
// },3000)
//
//},1000)
export
{
iot
,
uPublic
,
uComponents
}
\ No newline at end of file
dev/src/view/device/v_alarmInfo.js
View file @
6049e46b
...
...
@@ -99,11 +99,12 @@ function initComponentsConfig() {
let
data
=
uPublic
.
checkResponseData
(
response
.
data
);
if
(
data
&&
data
.
record
.
length
>
0
){
let
record
=
data
.
record
;
iot
.
storage
.
setMap
(
'notifyTime'
,
moment
(
record
[
0
].
time
).
unix
(),
(
res
)
=>
{
console
.
log
(
res
);
self
.
flag
=
false
;
},
()
=>
{
});
// iot.storage.setMap('notifyTime', moment(record[0].time).unix(), (res) => {
// console.log(res);
// self.flag = false;
// }, () => {
// });
uPublic
.
upDateRead
(
'notify'
);
}
}
let
data
=
uPublic
.
checkResponseData
(
response
.
data
);
...
...
dev/src/view/device/v_hijackRecord.js
View file @
6049e46b
...
...
@@ -101,16 +101,17 @@ function initComponentsConfig() {
start_id
:
self
.
getStartId
(),
page_size
:
PAGE_SIZE
},
success
:
(
response
)
=>
{
success
:
async
(
response
)
=>
{
if
(
self
.
flag
){
let
data
=
uPublic
.
checkResponseData
(
response
.
data
);
if
(
data
&&
data
.
record
.
length
>
0
){
let
record
=
data
.
record
;
iot
.
storage
.
setMap
(
'alarmTime'
,
moment
(
record
[
0
].
time
).
unix
(),
(
res
)
=>
{
console
.
log
(
res
);
self
.
flag
=
false
;
},
()
=>
{
});
// iot.storage.setMap('alarmTime', moment(record[0].time).unix(), (res) => {
// console.log(res);
// self.flag = false;
// }, () => {
// });
uPublic
.
upDateRead
(
'alarm'
);
}
}
let
data
=
uPublic
.
checkResponseData
(
response
.
data
);
...
...
dev/src/view/device/v_index.js
View file @
6049e46b
This diff is collapsed.
Click to expand it.
dev/src/view/device/v_opendoorRecord.js
View file @
6049e46b
...
...
@@ -133,11 +133,12 @@ function getHistoryRecord(self){
let
data
=
uPublic
.
checkResponseData
(
response
.
data
);
if
(
data
&&
data
.
record
.
length
>
0
){
let
record
=
data
.
record
;
iot
.
storage
.
setMap
(
'openTime'
,
moment
(
record
[
0
].
time
).
unix
(),
(
res
)
=>
{
console
.
log
(
res
);
self
.
flag
=
false
;
},
()
=>
{
});
// iot.storage.setMap('openTime', moment(record[0].time).unix(), (res) => {
// console.log(res);
// self.flag = false;
// }, () => {
// });
uPublic
.
upDateRead
(
'open'
);
}
}
},
...
...
dev/src/view/doorlockManage/v_index.js
View file @
6049e46b
...
...
@@ -32,11 +32,11 @@ function init() {
extras
:
{},
unbindSucceess
:
false
,
//门铃消息推送
valueDoorbell
:
iot
.
navigator
.
getExtras
().
lockInfo
.
options
[
0
]
,
valueDoorbell
:
iot
.
navigator
.
getExtras
().
lockInfo
.
options
.
ring
,
//报警消息推送
valueAlarm
:
iot
.
navigator
.
getExtras
().
lockInfo
.
options
[
1
]
,
valueAlarm
:
iot
.
navigator
.
getExtras
().
lockInfo
.
options
.
alarm
,
//开发消息推送
valueOpendoor
:
iot
.
navigator
.
getExtras
().
lockInfo
.
options
[
2
]
,
valueOpendoor
:
iot
.
navigator
.
getExtras
().
lockInfo
.
options
.
open
,
role
:
null
,
valueIsClear
:
true
,
unbindShowDialog
:
false
...
...
web/lib/js/UIOT.js
View file @
6049e46b
...
...
@@ -2158,9 +2158,7 @@ NetWork.send = function (url, params) {
if
(
params
.
error
)
params
.
error
(
err
);
if
(
params
.
complete
)
params
.
complete
();
});
console
.
log
(
"callback"
);
}
else
{
console
.
log
(
"promise"
);
return
fetchPromise
;
}
};
...
...
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