Commit 95faa338 by 朱建香

2017/12/18

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