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
c605af96
Commit
c605af96
authored
Dec 25, 2017
by
朱建香
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
20171225
parent
314b404f
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
181 additions
and
142 deletions
+181
-142
dev/src/public/loop.js
+5
-18
dev/src/public/unotify.js
+37
-50
dev/src/view/device/v_index.js
+17
-9
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
+95
-42
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,25 +5,11 @@
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
);
},
()
=>
{
});
}
}
catch
(
err
){
console
.
log
(
err
);
if
(
typeof
errorCallback
==
'function'
){
errorCallback
(
a
);
}
}
UpdateCid
((
response
)
=>
{
successCallback
(
response
);
},
(
error
)
=>
{
errorCallback
(
error
);
});
}
//周期性获取cid,周期可调整
static
getCidPeriotic
(
times
){
...
...
@@ -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
:
{
type
:
'post'
,
data
:
{
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
){
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
.
fire
(
plus
.
webview
.
currentWebview
().
opener
(),
'returnPage'
,{});
console
.
log
(
'returnPage'
);
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
...
...
@@ -6144,22 +6144,25 @@ var SDSUser = function (_User) {
var
_this3
=
this
;
var
sds
=
params
.
data
.
sds
===
true
;
var
opts
=
{
success
:
params
.
success
,
error
:
params
.
error
,
complete
:
params
.
complete
};
var
SDSLogout
=
function
SDSLogout
()
{
_this3
.
business
.
sds
.
logout
({
success
:
params
.
success
,
success
:
function
success
(
ret
)
{
if
(
sds
===
true
)
{
params
.
success
(
ret
);
}
else
{
_get
(
SDSUser
.
prototype
.
__proto__
||
Object
.
getPrototypeOf
(
SDSUser
.
prototype
),
'logout'
,
_this3
).
call
(
_this3
,
opts
);
}
},
error
:
params
.
error
,
complete
:
params
.
complete
});
};
if
(
sds
)
{
SDSLogout
();
}
else
{
var
opts
=
{
success
:
SDSLogout
,
error
:
params
.
error
};
_get
(
SDSUser
.
prototype
.
__proto__
||
Object
.
getPrototypeOf
(
SDSUser
.
prototype
),
'logout'
,
this
).
call
(
this
,
opts
);
}
SDSLogout
();
}
}]);
...
...
@@ -6626,7 +6629,7 @@ var User = function () {
_createClass
(
User
,
[{
key
:
'reg'
,
value
:
function
reg
(
params
)
{
var
_this
=
this
;
var
_this
2
=
this
;
var
data
=
{
username
:
params
.
data
.
username
,
...
...
@@ -6648,10 +6651,10 @@ var User = function () {
}
_context
.
next
=
4
;
return
_regenerator2
.
default
.
awrap
(
_this
.
business
.
websql
.
setMap
(
keys
.
uToken
,
ret
.
data
.
utoken
));
return
_regenerator2
.
default
.
awrap
(
_this
2
.
business
.
websql
.
setMap
(
keys
.
uToken
,
ret
.
data
.
utoken
));
case
4
:
_this
.
business
.
setToken
(
ret
.
data
.
utoken
);
_this
2
.
business
.
setToken
(
ret
.
data
.
utoken
);
params
.
success
(
ret
);
_context
.
next
=
9
;
break
;
...
...
@@ -6674,7 +6677,7 @@ var User = function () {
return
_context
.
stop
();
}
}
},
null
,
_this
,
[[
0
,
11
]]);
},
null
,
_this
2
,
[[
0
,
11
]]);
},
error
:
params
.
error
,
complete
:
params
.
complete
...
...
@@ -6687,7 +6690,7 @@ var User = function () {
},
{
key
:
'login'
,
value
:
function
login
(
params
)
{
var
_this
2
=
this
;
var
_this
3
=
this
;
var
data
=
{
username
:
params
.
data
.
username
,
...
...
@@ -6696,7 +6699,7 @@ var User = function () {
var
opts
=
{
data
:
data
,
success
:
function
success
(
ret
)
{
_this
2
.
handleLoginSuccess
(
params
,
ret
);
_this
3
.
handleLoginSuccess
(
params
,
ret
);
},
error
:
params
.
error
,
complete
:
params
.
complete
...
...
@@ -6706,7 +6709,7 @@ var User = function () {
},
{
key
:
'thirdLogin'
,
value
:
function
thirdLogin
(
params
)
{
var
_this
3
=
this
;
var
_this
4
=
this
;
var
opts
=
{
data
:
params
.
data
,
...
...
@@ -6715,14 +6718,14 @@ var User = function () {
while
(
1
)
{
switch
(
_context2
.
prev
=
_context2
.
next
)
{
case
0
:
_this
3
.
handleLoginSuccess
(
params
,
ret
);
_this
4
.
handleLoginSuccess
(
params
,
ret
);
case
1
:
case
'end'
:
return
_context2
.
stop
();
}
}
},
null
,
_this
3
);
},
null
,
_this
4
);
},
error
:
params
.
error
,
complete
:
params
.
complete
...
...
@@ -6732,12 +6735,12 @@ var User = function () {
},
{
key
:
'simpleLogin'
,
value
:
function
simpleLogin
(
params
)
{
var
_this
4
=
this
;
var
_this
5
=
this
;
var
opts
=
{
data
:
params
.
data
,
success
:
function
success
(
ret
)
{
_this
4
.
handleLoginSuccess
(
params
,
ret
);
_this
5
.
handleLoginSuccess
(
params
,
ret
);
},
error
:
params
.
error
,
complete
:
params
.
complete
...
...
@@ -6750,7 +6753,7 @@ var User = function () {
},
{
key
:
'autoLogin'
,
value
:
function
autoLogin
(
params
)
{
var
_this
5
=
this
;
var
_this
6
=
this
;
var
data
=
{};
var
opts
=
{
...
...
@@ -6768,10 +6771,10 @@ var User = function () {
}
_context3
.
next
=
4
;
return
_regenerator2
.
default
.
awrap
(
_this
5
.
business
.
websql
.
setMap
(
keys
.
uToken
,
ret
.
data
.
utoken
));
return
_regenerator2
.
default
.
awrap
(
_this
6
.
business
.
websql
.
setMap
(
keys
.
uToken
,
ret
.
data
.
utoken
));
case
4
:
_this
5
.
business
.
setToken
(
ret
.
data
.
utoken
);
_this
6
.
business
.
setToken
(
ret
.
data
.
utoken
);
params
.
success
(
ret
);
_context3
.
next
=
9
;
break
;
...
...
@@ -6794,7 +6797,7 @@ var User = function () {
return
_context3
.
stop
();
}
}
},
null
,
_this
5
,
[[
0
,
11
]]);
},
null
,
_this
6
,
[[
0
,
11
]]);
},
error
:
params
.
error
,
complete
:
params
.
complete
...
...
@@ -6877,26 +6880,61 @@ var User = function () {
},
{
key
:
'logout'
,
value
:
function
logout
(
params
)
{
this
.
business
.
websql
.
delMaps
([
keys
.
uToken
,
keys
.
USER_INFO
],
function
()
{
params
.
success
();
},
function
(
error
)
{
console
.
log
(
error
);
params
.
error
(
'logout error'
);
});
var
_this7
=
this
;
var
data
=
{};
var
_this
=
this
;
var
opts
=
{
data
:
data
,
success
:
function
success
(
ret
)
{
return
_regenerator2
.
default
.
async
(
function
success$
(
_context4
)
{
while
(
1
)
{
switch
(
_context4
.
prev
=
_context4
.
next
)
{
case
0
:
_context4
.
prev
=
0
;
_context4
.
next
=
3
;
return
_regenerator2
.
default
.
awrap
(
_this7
.
business
.
websql
.
delMaps
([
keys
.
uToken
,
keys
.
USER_INFO
]));
case
3
:
params
.
success
(
ret
);
_context4
.
next
=
9
;
break
;
case
6
:
_context4
.
prev
=
6
;
_context4
.
t0
=
_context4
[
'catch'
](
0
);
params
.
error
(
_context4
.
t0
);
case
9
:
case
'end'
:
return
_context4
.
stop
();
}
}
},
null
,
_this7
,
[[
0
,
6
]]);
},
error
:
function
error
(
err
)
{
params
.
error
(
err
);
},
complete
:
function
complete
()
{
params
.
complete
();
}
};
this
.
business
.
api
.
logout
(
opts
);
}
},
{
key
:
'handleLoginSuccess'
,
value
:
function
handleLoginSuccess
(
params
,
response
)
{
var
data
,
infoArray
;
return
_regenerator2
.
default
.
async
(
function
handleLoginSuccess$
(
_context
4
)
{
return
_regenerator2
.
default
.
async
(
function
handleLoginSuccess$
(
_context
5
)
{
while
(
1
)
{
switch
(
_context
4
.
prev
=
_context4
.
next
)
{
switch
(
_context
5
.
prev
=
_context5
.
next
)
{
case
0
:
_context
4
.
prev
=
0
;
_context
5
.
prev
=
0
;
data
=
response
.
data
;
if
(
!
(
data
.
utoken
.
length
!==
0
))
{
_context
4
.
next
=
12
;
_context
5
.
next
=
12
;
break
;
}
...
...
@@ -6904,31 +6942,31 @@ var User = function () {
infoArray
.
push
([
keys
.
uToken
,
data
.
utoken
]);
infoArray
.
push
([
keys
.
USER_INFO
,
data
]);
_context
4
.
next
=
8
;
_context
5
.
next
=
8
;
return
_regenerator2
.
default
.
awrap
(
this
.
business
.
websql
.
setMaps
(
infoArray
));
case
8
:
this
.
business
.
setToken
(
data
.
utoken
);
params
.
success
(
response
);
_context
4
.
next
=
13
;
_context
5
.
next
=
13
;
break
;
case
12
:
params
.
error
();
case
13
:
_context
4
.
next
=
18
;
_context
5
.
next
=
18
;
break
;
case
15
:
_context
4
.
prev
=
15
;
_context
4
.
t0
=
_context4
[
'catch'
](
0
);
_context
5
.
prev
=
15
;
_context
5
.
t0
=
_context5
[
'catch'
](
0
);
params
.
error
(
_context
4
.
t0
);
params
.
error
(
_context
5
.
t0
);
case
18
:
case
'end'
:
return
_context
4
.
stop
();
return
_context
5
.
stop
();
}
}
},
null
,
this
,
[[
0
,
15
]]);
...
...
@@ -7060,6 +7098,21 @@ var CloudAPI = function () {
};
this
.
send
(
'user/login'
,
opts
,
false
);
}
//退出登陆
},
{
key
:
'logout'
,
value
:
function
logout
(
params
)
{
var
opts
=
{
type
:
'post'
,
data
:
params
.
data
,
success
:
params
.
success
,
error
:
params
.
error
,
complete
:
params
.
complete
};
this
.
send
(
'user/logout'
,
opts
);
}
},
{
key
:
'thirdLogin'
,
value
:
function
thirdLogin
(
params
)
{
...
...
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