Commit 95faa338 by 朱建香

2017/12/18

1.新增更新cid方法
2.修改轮询方法
3.修改多语言“报警信息”为“报警记录”
parent 11f3e717
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
"forgetPassword": "忘记密码", "forgetPassword": "忘记密码",
"device": "U智锁", "device": "U智锁",
"opendoorRecord": "开门记录", "opendoorRecord": "开门记录",
"alarmInfo": "报警信息", "alarmInfo": "报警记录",
"remoteOpendoor": "远程开门", "remoteOpendoor": "远程开门",
"hijackRecord": "劫持记录", "hijackRecord": "劫持记录",
"doorlockManage": "门锁管理", "doorlockManage": "门锁管理",
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
"forgetPassword": "忘记密码", "forgetPassword": "忘记密码",
"device": "U智锁", "device": "U智锁",
"opendoorRecord": "开门记录", "opendoorRecord": "开门记录",
"alarmInfo": "报警信息", "alarmInfo": "报警记录",
"remoteOpendoor": "远程开门", "remoteOpendoor": "远程开门",
"hijackRecord": "劫持记录", "hijackRecord": "劫持记录",
"doorlockManage": "门锁管理", "doorlockManage": "门锁管理",
......
...@@ -247,6 +247,11 @@ uComponents.loop = function(request, timeout, interval, fincb, stopcondition){ ...@@ -247,6 +247,11 @@ uComponents.loop = function(request, timeout, interval, fincb, stopcondition){
var intervalcb = interval.opts; var intervalcb = interval.opts;
var flag = true; var flag = true;
var i = 0; var i = 0;
time = setTimeout(function(){
clearTime(handle, time);
intervalcb.error('timeout');
fincb.error('timeout');
},timeout);
//一开始执行一次,发送一次请求 //一开始执行一次,发送一次请求
requestsend(url, { requestsend(url, {
data: {}, data: {},
...@@ -274,7 +279,7 @@ uComponents.loop = function(request, timeout, interval, fincb, stopcondition){ ...@@ -274,7 +279,7 @@ uComponents.loop = function(request, timeout, interval, fincb, stopcondition){
flag = true; flag = true;
}, },
error: (error) => { error: (error) => {
intervalcb.error(response); intervalcb.error(error);
fincb.error(error); fincb.error(error);
clearTime(handle, time); clearTime(handle, time);
}, },
...@@ -285,18 +290,13 @@ uComponents.loop = function(request, timeout, interval, fincb, stopcondition){ ...@@ -285,18 +290,13 @@ uComponents.loop = function(request, timeout, interval, fincb, stopcondition){
} }
}, },
error: (error) => { error: (error) => {
intervalcb.error(response); intervalcb.error(error);
fincb.error(error); fincb.error(error);
clearTime(handle, time); clearTime(handle, time);
}, },
complete: {} complete: {}
}, 0); }, 0);
time = setTimeout(function(){
clearTime(handle, time);
intervalcb.error('timeout');
fincb.error('timeout');
},timeout);
} }
//传递的参数依次是: //传递的参数依次是:
...@@ -312,7 +312,7 @@ uComponents.loop({url:'getLockInfo',opts: { ...@@ -312,7 +312,7 @@ uComponents.loop({url:'getLockInfo',opts: {
error: (error) => { error: (error) => {
console.log(error); console.log(error);
} }
}}, 7000, { }}, 8000, {
delay: 1000, delay: 1000,
opts: { opts: {
success: (response) => { success: (response) => {
......
...@@ -55,44 +55,58 @@ class unotify{ ...@@ -55,44 +55,58 @@ class unotify{
static getCidOnce(i){ static getCidOnce(i){
var clientInfo = plus.push.getClientInfo(); var clientInfo = plus.push.getClientInfo();
if(clientInfo && clientInfo.hasOwnProperty('clientid') && clientInfo.clientid){ if(clientInfo && clientInfo.hasOwnProperty('clientid') && clientInfo.clientid){
if(i == 6){ // if(i == 6){
return(clientInfo.clientid); return(clientInfo.clientid);
}else{ // }else{
return(null); // return(null);
} // }
}else{ }else{
return(null); return(null);
} }
} }
//长期不断循环获取cid,并更新cid //长期不断循环获取cid,并更新cid
static async updateCid(successCallback, errorCallback){ static updateCid(successCallback, errorCallback){
var cid = null; var cid = null;
var oldCid = null; var oldCid = null;
iot.storage.getMap('clientId',(res) => { iot.storage.getMap('clientId',async (res) => {
oldCid = res; oldCid = res;
console.log("原来的cid为"+oldCid); console.log("原来的cid为"+oldCid);
}, (err) => { try{
console.log(err); cid = await this.getCidPeriotic(9);
}); if(cid != null && cid != oldCid){
try{ //更新缓存并发送请求更新clientId
cid = await this.getCidPeriotic(9); if(typeof successCallback == 'function'){
if(cid !== oldCid){ iot.storage.setMap('clientId', cid, (res) => {
//发送请求更新clientId console.log("更新后的cid为"+cid);
if(typeof successCallback == 'function'){ successCallback('cid updateSuccess');
iot.storage.setMap('clientId', cid, (res) => { // iot.business.api.send('user/updateCid',{
console.log("更新后的cid为"+cid); // data: {
successCallback('success'); // clientId: cid
}, () => { // },
}); // success: (response) => {
// console.log(response);
// },
// error: (error) => {
// console.log(error);
// }
// }, false);
}, () => {
});
}
}else{
successCallback('cid未更新');
} }
} }
} catch (err){
catch (err){ console.log(err);
console.log(err); if(typeof errorCallback == 'function'){
if(typeof errorCallback == 'function'){ errorCallback(a);
errorCallback(a); }
} }
} }, (err) => {
console.log(err);
});
} }
} }
export default unotify; export default unotify;
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment