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,36 +55,46 @@ class unotify{ ...@@ -55,36 +55,46 @@ 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) => {
console.log(err);
});
try{ try{
cid = await this.getCidPeriotic(9); cid = await this.getCidPeriotic(9);
if(cid !== oldCid){ if(cid != null && cid != oldCid){
//发送请求更新clientId //更新缓存并发送请求更新clientId
if(typeof successCallback == 'function'){ if(typeof successCallback == 'function'){
iot.storage.setMap('clientId', cid, (res) => { iot.storage.setMap('clientId', cid, (res) => {
console.log("更新后的cid为"+cid); console.log("更新后的cid为"+cid);
successCallback('success'); successCallback('cid updateSuccess');
// iot.business.api.send('user/updateCid',{
// data: {
// clientId: cid
// },
// success: (response) => {
// console.log(response);
// },
// error: (error) => {
// console.log(error);
// }
// }, false);
}, () => { }, () => {
}); });
} }
}else{
successCallback('cid未更新');
} }
} }
catch (err){ catch (err){
...@@ -93,6 +103,10 @@ class unotify{ ...@@ -93,6 +103,10 @@ class unotify{
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