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
c605af96
Commit
c605af96
authored
Dec 25, 2017
by
朱建香
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
20171225
parent
314b404f
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
83 additions
and
97 deletions
+83
-97
dev/src/public/loop.js
+5
-18
dev/src/public/unotify.js
+36
-49
dev/src/view/device/v_index.js
+15
-7
dev/src/view/doorlockManage/v_editName.js
+8
-8
dev/src/view/doorlockManage/v_index.js
+8
-7
dev/src/view/login/v_index.js
+7
-7
dev/src/view/myInfo/v_index.js
+4
-1
web/lib/js/UIOT.js
+0
-0
No files found.
dev/src/public/loop.js
View file @
c605af96
...
...
@@ -9,8 +9,9 @@ class Loop{
this
.
handle
=
null
;
this
.
watcher
=
null
;
this
.
time
=
null
;
this
.
url
=
params
.
request
.
url
;
this
.
opts
=
params
.
request
.
opts
;
// this.url = params.request.url;
// this.opts = params.request.opts;
this
.
loopContent
=
params
.
loopContent
;
this
.
timeout
=
params
.
timeout
|
30
;
this
.
fincb
=
params
.
fincb
;
this
.
intervalTime
=
params
.
interval
.
delay
;
...
...
@@ -28,7 +29,6 @@ class Loop{
console
.
log
(
"返回时间"
+
this
.
i
+
'-'
+
new
Date
().
getTime
());
opts
.
success
(
data
[
this
.
i
]);
},
100
);
}
clearTime
(){
...
...
@@ -39,22 +39,10 @@ class Loop{
async
sendRequest
(){
this
.
canSend
=
false
;
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, {
var
urlParams
=
{
type
:
this
.
opts
.
type
,
data
:
this
.
opts
.
data
};
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
);
}
response
=
await
this
.
loopContent
();
console
.
log
(
response
);
if
(
await
this
.
stopcondition
(
response
)){
if
(
this
.
fincb
!=
null
){
this
.
fincb
.
success
(
response
);
...
...
@@ -84,7 +72,6 @@ class Loop{
}
}
start
(){
console
.
log
(
"开始"
);
this
.
time
=
setTimeout
(()
=>
{
...
...
dev/src/public/unotify.js
View file @
c605af96
...
...
@@ -5,26 +5,12 @@
class
unotify
{
//在一个周期内获取cid
static
async
getCid
(
successCallback
,
errorCallback
){
var
cid
=
null
;
try
{
//利用promise,直到执行完代码再获取cid
cid
=
await
this
.
getCidPeriotic
(
3
);
//获取后,在缓存中存储cid
if
(
typeof
successCallback
==
'function'
){
iot
.
storage
.
setMap
(
'clientId'
,
cid
,
(
res
)
=>
{
console
.
log
(
"已成功保存cid"
+
cid
);
successCallback
(
cid
);
},
()
=>
{
UpdateCid
((
response
)
=>
{
successCallback
(
response
);
},
(
error
)
=>
{
errorCallback
(
error
);
});
}
}
catch
(
err
){
console
.
log
(
err
);
if
(
typeof
errorCallback
==
'function'
){
errorCallback
(
a
);
}
}
}
//周期性获取cid,周期可调整
static
getCidPeriotic
(
times
){
var
self
=
this
;
...
...
@@ -65,36 +51,36 @@ class unotify{
}
}
//长期不断循环获取cid,并更新cid
// static async get
Cid(successCallback, errorCallback){
//
var cid = null;
//
var oldCid = null;
//
try{
//
cid = await this.getCidPeriotic(9);
//
if(cid != null && cid != oldCid){
//
iot.business.api.send('user/updateCid',{
//
data: {
//
clienId: cid
//
},
//
success: (response) => {
//
if(typeof successCallback == 'function'){
//
successCallback('cid updateSuccess');
//
}
//
},
//
error: (error) => {
//
console.log(error);
//
errorCallback(error);
//
}
//
}, true, false);
//
}else{
//
successCallback('cid not updated');
//
}
//
}
//
catch (err){
//
console.log(err);
//
if(typeof errorCallback == 'function'){
//
errorCallback(err);
//
}
//
}
//
}
static
async
Update
Cid
(
successCallback
,
errorCallback
){
var
cid
=
null
;
var
oldCid
=
null
;
try
{
cid
=
await
this
.
getCidPeriotic
(
9
);
if
(
cid
!=
null
&&
cid
!=
oldCid
){
iot
.
business
.
api
.
send
(
'user/updateCid'
,{
data
:
{
clienId
:
cid
},
success
:
(
response
)
=>
{
if
(
typeof
successCallback
==
'function'
){
successCallback
(
'cid updateSuccess'
);
}
},
error
:
(
error
)
=>
{
console
.
log
(
error
);
errorCallback
(
error
);
}
},
true
,
false
);
}
else
{
successCallback
(
'cid not updated'
);
}
}
catch
(
err
){
console
.
log
(
err
);
if
(
typeof
errorCallback
==
'function'
){
errorCallback
(
err
);
}
}
}
}
export
default
unotify
;
\ No newline at end of file
dev/src/view/device/v_index.js
View file @
c605af96
...
...
@@ -114,12 +114,13 @@ function init() {
registerPushListener
(
this
);
let
self
=
this
;
window
.
addEventListener
(
'returnPage'
,
function
(
event
){
console
.
log
(
'returnPage'
);
//获取设备信息
getDevices
(
self
);
//注册监听上报
registerPushListener
(
self
);
iot
.
navigator
.
closeAllBesidesItself
();
});
},
methods
:{
setValueRemoteOpendoor
(
value
){
...
...
@@ -522,7 +523,8 @@ function getLockInfoSuccess(self, data){
self
.
setIsFirstGetLockInfo
(
false
);
}
//存储最后一条历史记录的ID
let
historyId
=
data
.
info
.
historyId
;
let
historyId
=
null
historyId
=
data
.
info
.
historyId
?
data
.
info
.
historyId
:
null
;
iot
.
storage
.
setMap
(
'historyId'
,
historyId
,
(
res
)
=>
{
console
.
log
(
res
);
},
()
=>
{
...
...
@@ -656,23 +658,29 @@ function initDeviceInfo(self){
}
async
function
loopGetLockInfo
(
self
,
delay
,
timeout
){
let
oldHistoryId
=
null
;
try
{
oldHistoryId
=
await
iot
.
storage
.
getMap
(
'historyId'
);
let
historyId
=
await
iot
.
storage
.
getMap
(
'historyId'
);
if
(
historyId
){
oldHistoryId
=
historyId
;
}
}
catch
(
error
){
console
.
log
(
error
);
}
console
.
log
(
oldHistoryId
);
new
Loop
({
request
:
{
url
:
'lock/getNewInfo'
,
opts
:
{
loopContent
:
()
=>
{
var
urlParams
=
{
type
:
'post'
,
data
:
{
history_id
:
oldHistoryId
,
device_id
:
self
.
deviceId
}
}
};
return
iot
.
business
.
api
.
send
(
'lock/getNewInfo'
,
urlParams
,
true
,
false
);
// return plus.push.getClientInfo().clientid;
},
timeout
:
config
.
getHistoryTime
*
1000
,
interval
:{
...
...
dev/src/view/doorlockManage/v_editName.js
View file @
c605af96
...
...
@@ -93,12 +93,12 @@ function backTap(){
iot
.
navigator
.
back
();
}
//重写mui.back
mui
.
back
=
function
(){
iot
.
navigator
.
fire
(
plus
.
webview
.
currentWebview
().
opener
(),
'returnPage'
,{});
console
.
log
(
"fire"
);
iot
.
navigator
.
back
();
}
//
//
重写mui.back
//
mui.back = function(){
//
iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{});
//
console.log("fire");
//
iot.navigator.back();
//
}
//tap 保存
function
saveTap
(
self
){
...
...
@@ -115,10 +115,10 @@ function saveTap(self){
console
.
log
(
response
);
let
data
=
uPublic
.
checkResponseData
(
response
.
data
);
if
(
data
){
uComponents
.
openAlert
(
self
,
Vue
.
t
(
'editName.editNameSuccess'
),
{
text
:
Vue
.
t
(
'btn.confirm'
),
callback
:
function
()
{
iot
.
navigator
.
fire
(
plus
.
webview
.
currentWebview
().
opener
(),
'returnPage'
,{});
console
.
log
(
'returnPage'
);
uComponents
.
openAlert
(
self
,
Vue
.
t
(
'editName.editNameSuccess'
),
{
text
:
Vue
.
t
(
'btn.confirm'
),
callback
:
function
()
{
iot
.
navigator
.
back
();
}
});
...
...
dev/src/view/doorlockManage/v_index.js
View file @
c605af96
...
...
@@ -287,6 +287,7 @@ function unbind(self){
self
.
setStateShowFlag
(
true
);
self
.
setShowMsg
(
Vue
.
t
(
'doorlockManage.unbindSuccess'
));
self
.
setUnbindSucceess
(
true
);
iot
.
navigator
.
fire
(
plus
.
webview
.
currentWebview
().
opener
(),
'returnPage'
,{});
},
error
:
(
error
)
=>
{
console
.
log
(
error
);
...
...
@@ -311,12 +312,12 @@ function backTap(){
iot
.
navigator
.
aback
();
}
//重写mui.back
mui
.
back
=
function
(){
iot
.
navigator
.
fire
(
plus
.
webview
.
currentWebview
().
opener
(),
'returnPage'
,{});
console
.
log
(
"fire"
);
iot
.
navigator
.
back
();
}
//
//
重写mui.back
//
mui.back = function(){
//
iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{});
//
console.log("fire");
//
iot.navigator.back();
//
}
// 选择: 是否接收门铃消息推送
function
doorbellSwitchTap
(
self
,
value
){
...
...
@@ -347,6 +348,7 @@ function setOption(self){
opt_open
:
self
.
getValueOpendoor
()
},
success
:
(
response
)
=>
{
iot
.
navigator
.
fire
(
plus
.
webview
.
currentWebview
().
opener
(),
'returnPage'
,{});
console
.
log
();
},
error
:
(
error
)
=>
{
...
...
@@ -366,7 +368,6 @@ function cancelTap(self){
//tap 绑定成功弹框提示-->回到首页
function
unbindStateDialogTap
(
self
){
self
.
setStateShowFlag
(
false
);
iot
.
navigator
.
fire
(
plus
.
webview
.
currentWebview
().
opener
(),
'returnPage'
,{});
if
(
self
.
getUnbindSucceess
){
iot
.
navigator
.
openWindow
({
url
:
'../device/index.html'
,
...
...
dev/src/view/login/v_index.js
View file @
c605af96
...
...
@@ -31,9 +31,9 @@ function init() {
iotDebug
.
push
(
'start: Debug'
);
}
var
self
=
this
;
unotify
.
getCid
(
function
(
ret
){
console
.
log
(
ret
);
self
.
setClientId
(
ret
);
//
unotify.getCid(function(ret){
//
console.log(ret);
//
self.setClientId(ret);
if
(
plus
.
os
.
name
==
'Android'
)
{
iot
.
permission
.
checkPermission
([
'READ_EXTERNAL_STORAGE'
],
function
(
res
)
{
console
.
log
(
'success'
,
res
);
...
...
@@ -44,9 +44,9 @@ function init() {
}
else
{
loginButtonTap
(
self
);
}
},
function
(
err
){
console
.
log
(
err
);
})
//
},function(err){
//
console.log(err);
//
})
console
.
log
(
'innnnnnn'
);
},
methods
:{
...
...
@@ -212,7 +212,7 @@ function cloudsLogin(self, id){
error
:
(
error
)
=>
{
console
.
log
(
error
);
if
(
window
.
iotDebug
){
iotDebug
.
push
(
'end: 云端登陆失败'
+
JSON
.
stringify
(
error
));
iotDebug
.
push
(
'end: 云端
登陆失败'
+
JSON
.
stringify
(
error
));
}
if
(
window
.
iotDebug
)
{
iotDebug
.
upload
(
iot
,
'云端登陆失败'
);
...
...
dev/src/view/myInfo/v_index.js
View file @
c605af96
...
...
@@ -138,8 +138,11 @@ function logoutButtonTap(self){
// },
// complete: () => {}
// });
console
.
log
(
"logout"
);
iot
.
business
.
user
.
logout
({
data
:
{},
data
:
{
// sds: false
},
success
:
(
response
)
=>
{
console
.
log
(
"sdsLogout:"
+
response
);
let
sdsResponse
=
response
;
...
...
web/lib/js/UIOT.js
View file @
c605af96
This diff is collapsed.
Click to expand it.
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