Commit fd29a166 by 朱建香

1208

parent de3d8ca3
...@@ -46,6 +46,6 @@ export default { ...@@ -46,6 +46,6 @@ export default {
"ringBell_timeout": 300, "ringBell_timeout": 300,
"intervalTime": 3, "intervalTime": 3,
"getHistoryTime": 10, "getHistoryTime": 10,
// "audioUrl": "../../resources/audio/tipSound.mp3" "audioUrl": "../../resources/audio/tipSound.mp3"
"audioUrl": "_www/resources/audio/tipSound.mp3" // "audioUrl": "_www/resources/audio/tipSound.mp3"
} }
\ No newline at end of file
...@@ -23,6 +23,7 @@ function init() { ...@@ -23,6 +23,7 @@ function init() {
list:[], list:[],
startId: 0, startId: 0,
deviceId: null, deviceId: null,
flag: true
}, },
mounted(){ mounted(){
resolve(this); resolve(this);
...@@ -94,6 +95,17 @@ function initComponentsConfig() { ...@@ -94,6 +95,17 @@ function initComponentsConfig() {
}, },
success: (response) => { success: (response) => {
console.log(response); console.log(response);
if(self.flag){
let data = uPublic.checkResponseData(response.data);
if(data && data.record.length > 0){
let record = data.record;
iot.storage.setMap('notifyTime', moment(record[0].time).toISOString(), (res) => {
console.log(res);
self.flag = false;
}, () => {
});
}
}
let data = uPublic.checkResponseData(response.data); let data = uPublic.checkResponseData(response.data);
if(data){ if(data){
let list = []; let list = [];
......
...@@ -24,7 +24,8 @@ function init() { ...@@ -24,7 +24,8 @@ function init() {
list: [], list: [],
startId: 0, startId: 0,
deviceId: null, deviceId: null,
userInfo: [] userInfo: [],
flag: true
}, },
mounted(){ mounted(){
resolve(this); resolve(this);
...@@ -101,6 +102,17 @@ function initComponentsConfig() { ...@@ -101,6 +102,17 @@ function initComponentsConfig() {
page_size: PAGE_SIZE page_size: PAGE_SIZE
}, },
success: (response) => { success: (response) => {
if(self.flag){
let data = uPublic.checkResponseData(response.data);
if(data && data.record.length > 0){
let record = data.record;
iot.storage.setMap('alarmTime', moment(record[0].time).toISOString(), (res) => {
console.log(res);
self.flag = false;
}, () => {
});
}
}
let data = uPublic.checkResponseData(response.data); let data = uPublic.checkResponseData(response.data);
if(data){ if(data){
console.log(data); console.log(data);
......
...@@ -510,8 +510,10 @@ function registerPushListener(self){ ...@@ -510,8 +510,10 @@ function registerPushListener(self){
success: (response) => { success: (response) => {
console.log("registerPushListener"); console.log("registerPushListener");
console.log(response); console.log(response);
let data = response.data; let data = uPublic.checkResponseData(response.data.params.data);
setDevceInfo(self, data.params.data); if(data){
sdsDataPorcessing(self, data);
}
}, },
error: (error) => { error: (error) => {
console.log(error); console.log(error);
...@@ -548,22 +550,22 @@ async function getRecordTime(self, data){ ...@@ -548,22 +550,22 @@ async function getRecordTime(self, data){
let newNotifyTime = moment(data.notify_time); let newNotifyTime = moment(data.notify_time);
let newAlarmTime = moment(data.alarm_time); let newAlarmTime = moment(data.alarm_time);
let newOpenTime = moment(data.open_time); let newOpenTime = moment(data.open_time);
console.log("newNotifyTime"+newNotifyTime); // console.log("newNotifyTime:"+newNotifyTime.format('YYYY-MM-DD hh:mm:ss'));
console.log("newAlarmTime"+newAlarmTime); // console.log("newAlarmTime:"+newAlarmTime.format('YYYY-MM-DD hh:mm:ss'));
console.log("newOpenTime"+newOpenTime); // console.log("newOpenTime:"+newOpenTime.format('YYYY-MM-DD hh:mm:ss'));
console.log("notifyTime"+self.notifyTime); // console.log("notifyTime:"+moment(self.notifyTime,moment.ISO_8601).format('YYYY-MM-DD hh:mm:ss'));
console.log("alarmTime"+self.alarmTime); // console.log("alarmTime:"+moment(self.alarmTime,moment.ISO_8601).format('YYYY-MM-DD hh:mm:ss'));
console.log("openTime"+self.openTime); // console.log("openTime:"+moment(self.openTime,moment.ISO_8601).format('YYYY-MM-DD hh:mm:ss'));
let now = moment(); let now = moment(new Date(), "YYYY-MM-DD hh:mm:ss");
if(self.notifyTime){ if(self.notifyTime){
console.log("notifyTime"+newNotifyTime.diff(self.notifyTime, 'seconds')); // console.log("notifyTime"+newNotifyTime.diff(self.notifyTime, 'seconds'));
self.notifyTime = moment(self.notifyTime,moment.ISO_8601); self.notifyTime = moment(self.notifyTime,moment.ISO_8601);
if(newNotifyTime != null && newNotifyTime.diff(self.notifyTime, 'seconds') >= 0){ if(newNotifyTime != null && newNotifyTime.diff(self.notifyTime, 'seconds') > 0){
self.securityAlarmFlag = true; self.securityAlarmFlag = true;
self.notifyTime = newNotifyTime; self.notifyTime = newNotifyTime;
} }
}else{ }else{
console.log("notifyTime"+now.diff(newNotifyTime, 'hours')); // console.log("notifyTime"+now.diff(newNotifyTime, 'hours'));
if(newNotifyTime != null && now.diff(newNotifyTime, 'hours') < 1){ if(newNotifyTime != null && now.diff(newNotifyTime, 'hours') < 1){
self.securityAlarmFlag = true; self.securityAlarmFlag = true;
self.notifyTime = newNotifyTime; self.notifyTime = newNotifyTime;
...@@ -571,13 +573,13 @@ async function getRecordTime(self, data){ ...@@ -571,13 +573,13 @@ async function getRecordTime(self, data){
} }
if(self.alarmTime){ if(self.alarmTime){
self.alarmTime = moment(self.alarmTime,moment.ISO_8601); self.alarmTime = moment(self.alarmTime,moment.ISO_8601);
console.log("Alarm"+newAlarmTime.diff(self.alarmTime, 'seconds')); // console.log("Alarm"+newAlarmTime.diff(self.alarmTime, 'seconds'));
if(newAlarmTime != null && newAlarmTime.diff(self.alarmTime, 'seconds') >= 0){ if(newAlarmTime != null && newAlarmTime.diff(self.alarmTime, 'seconds') > 0){
self.hijackAlarmFlag = true; self.hijackAlarmFlag = true;
self.alarmTime = newAlarmTime; self.alarmTime = newAlarmTime;
} }
}else{ }else{
console.log("Alarm"+now.diff(newAlarmTime, 'hours')); // console.log("Alarm"+now.diff(newAlarmTime, 'hours'));
if(newAlarmTime != null && now.diff(newAlarmTime, 'hours') < 1){ if(newAlarmTime != null && now.diff(newAlarmTime, 'hours') < 1){
self.hijackAlarmFlag = true; self.hijackAlarmFlag = true;
self.alarmTime = newAlarmTime; self.alarmTime = newAlarmTime;
...@@ -585,35 +587,27 @@ async function getRecordTime(self, data){ ...@@ -585,35 +587,27 @@ async function getRecordTime(self, data){
} }
if(self.openTime){ if(self.openTime){
self.openTime = moment(self.openTime,moment.ISO_8601); self.openTime = moment(self.openTime,moment.ISO_8601);
console.log("openTime"+newOpenTime.diff(self.openTime, 'seconds')); // console.log("openTime"+newOpenTime.diff(self.openTime, 'seconds'));
if(newOpenTime != null && newOpenTime.diff(self.openTime, 'seconds') >= 0){ if(newOpenTime != null && newOpenTime.diff(self.openTime, 'seconds') > 0){
self.opendoorRecordFlag = true; self.opendoorRecordFlag = true;
self.openTime = newOpenTime; self.openTime = newOpenTime;
} }
}else{ }else{
console.log("openTime"+now.diff(newOpenTime, 'hours')); // console.log("openTime"+now.diff(newOpenTime, 'hours'));
if(newOpenTime != null && now.diff(newOpenTime, 'hours') < 1){ if(newOpenTime != null && now.diff(newOpenTime, 'hours') < 1){
self.opendoorRecordFlag = true; self.opendoorRecordFlag = true;
console.log(newOpenTime);
self.openTime = newOpenTime; self.openTime = newOpenTime;
} }
} }
} }
function setRecordTime(timeKey, time){
console.log(time);
iot.storage.setMap(timeKey, time, (res) => {
console.log(res);
}, () => {
});
}
//获取websql上的firstLogin //获取websql上的firstLogin
function getRecordTimeMap(time) { function getRecordTimeMap(time) {
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
console.log(time); // console.log(time);
iot.storage.getMap(time, (res) => { iot.storage.getMap(time, (res) => {
if (res) { if (res) {
// console.log('获取时间:'+moment(res).format('YYYY-MM-DD hh:mm:ss'));
resolve(res); resolve(res);
} else { } else {
reject(res); reject(res);
...@@ -644,9 +638,10 @@ function getDeviceStatus(self){ ...@@ -644,9 +638,10 @@ function getDeviceStatus(self){
}, },
success: (response) => { success: (response) => {
console.log(response); console.log(response);
let data = response.data; let data = uPublic.checkResponseData(response.data);
console.log("getStatus"); if(data){
setDevceInfo(self, data); setBatteryPercentAndIcon(self, data.BatteryPercentage.value);
}
}, },
error: (error) => { error: (error) => {
console.log(error); console.log(error);
...@@ -665,212 +660,288 @@ function getLockInfo(self){ ...@@ -665,212 +660,288 @@ function getLockInfo(self){
console.log("getLockInfo"); console.log("getLockInfo");
iot.business.api.sendCustom('lock/getLockInfo',{ iot.business.api.sendCustom('lock/getLockInfo',{
data: { data: {
device_id: self.deviceId, device_id: self.deviceId
// product_id: self.model,
// userinfo: self.userInfo
}, },
success: (response) => { success: (response) => {
console.log(response); console.log(response);
// alert(JSON.stringify(response));
let data = uPublic.checkResponseData(response.data); let data = uPublic.checkResponseData(response.data);
if(data){ if(data){
getRecordTime(self, data); getLockInfoSuccess(self, data);
// getRecordTime(self, data);
// //判断云端是否绑定
// if(data.lock_id){
// setValueOfSwitch(self, false);
// self.setLockInfo(data);
// self.setLockId(data.lock_id);
// self.setRole(data.role);
// if(self.isFirstGetLockInfo){
// getDeviceStatus(self);
// self.setIsFirstGetLockInfo(false);
// }
// if(data.info && data.info.length){
// self.newMsg = [];
// for(let i=0; i< data.info.length; i++){
// let msg = '';
// if(data.info[i].nickname == null){
// msg = ' ID:' + data.info[i].openId;
// }else{
// msg = data.info[i].nickname;
// }
// self.newMsg.push(moment(data.info[i].time).format("YY.MM.DD HH:mm") + msg + Vue.t('opendoorRecord.'+config.openDoorMode[data.info[i].mode]+''));
//// }
// }
// uComponents.changeMarqueeText(self, self.newMsg);
// if(self.newMsg.length >= 2){
// self.activeFlag = true;
// }else{
// self.activeFlag = false;
// }
// }else{
// uComponents.changeMarqueeText(self, [Vue.t('device.noNewMsg')]);
// self.activeFlag = false;
// }
// }else{
// uComponents.changeMarqueeText(self, [Vue.t('device.defaultNewMsg')]);
// self.activeFlag = false;
// }
}else{
setValueOfSwitch(self, true);
self.setLockId(null);
self.mac = null;
self.deviceId = null;
self.uuid = null;
uComponents.changeMarqueeText(self, [Vue.t('device.defaultNewMsg')]);
self.activeFlag = false;
self.opendoorRecordFlag = false;
self.securityAlarmFlag = false;
self.hijackAlarmFlag = false;
}
},
error: (error) => {
uPublic.openRequestErrorAlert(self);
console.log(error);
},
complete: () => {
}
});
}
function getLockInfoSuccess(self, data){
//判断云端是否绑定 //判断云端是否绑定
if(data.lock_id){ if(data.lock_id){
//获取‘未读’小红点状态
getRecordTime(self, data);
//更改按钮为‘可点击’样式
setValueOfSwitch(self, false); setValueOfSwitch(self, false);
//设置门锁信息
self.setLockInfo(data); self.setLockInfo(data);
self.setLockId(data.lock_id); self.setLockId(data.lock_id);
self.setRole(data.role); self.setRole(data.role);
//判断是否第一次获取门锁信息
if(self.isFirstGetLockInfo){ if(self.isFirstGetLockInfo){
getDeviceStatus(self); getDeviceStatus(self);
self.setIsFirstGetLockInfo(false); self.setIsFirstGetLockInfo(false);
} }
//拼接首页滚动的三条记录
if(data.info && data.info.length){ if(data.info && data.info.length){
self.newMsg = []; self.newMsg = [];
for(let i=0; i< data.info.length; i++){ for(let i=0; i< data.info.length; i++){
// let now = moment();
// let time = moment(data.info[i].time);
// if(now.diff(time,'hours') < 24){
let msg = ''; let msg = '';
if(data.info[i].nickname == null){ if(data.info[i].nickname == null){
msg = ' ID:' + data.info[i].openId; msg = ' ID:' + data.info[i].openId;
// self.newMsg.push(moment(data.info[i].time).format("YY.MM.DD HH:mm") + ' ID:' + data.info[i].openId + Vue.t('opendoorRecord.'+config.openDoorMode[data.info[i].mode]+''));
}else{ }else{
msg = data.info[i].nickname; msg = data.info[i].nickname;
// self.newMsg.push(moment(data.info[i].time).format("YY.MM.DD HH:mm") + data.info[i].nickname + Vue.t('opendoorRecord.'+config.openDoorMode[data.info[i].mode]+''));
} }
self.newMsg.push(moment(data.info[i].time).format("YY.MM.DD HH:mm") + msg + Vue.t('opendoorRecord.'+config.openDoorMode[data.info[i].mode]+'')); self.newMsg.push(moment(data.info[i].time).format("YY.MM.DD HH:mm") + msg + Vue.t('opendoorRecord.'+config.openDoorMode[data.info[i].mode]+''));
// }
} }
// if(data.info[0].nickname == null){
// self.newMsg.push(moment(data.info[0].time).format("YY.MM.DD HH:mm") + ' ID:' + data.info[0].openId + Vue.t('opendoorRecord.'+config.openDoorMode[data.info[0].mode]+''));
// }else{
// self.newMsg.push(moment(data.info[0].time).format("YY.MM.DD HH:mm") + data.info[0].nickname + Vue.t('opendoorRecord.'+config.openDoorMode[data.info[0].mode]+''));
// }
uComponents.changeMarqueeText(self, self.newMsg); uComponents.changeMarqueeText(self, self.newMsg);
if(self.newMsg.length >= 2){ if(self.newMsg.length >= 2){
// console.log("滚");
self.activeFlag = true; self.activeFlag = true;
}else{ }else{
// console.log("不滚");
self.activeFlag = false; self.activeFlag = false;
} }
}else{ }else{
uComponents.changeMarqueeText(self, [Vue.t('device.noNewMsg')]); uComponents.changeMarqueeText(self, [Vue.t('device.noNewMsg')]);
// console.log("不滚");
self.activeFlag = false; self.activeFlag = false;
// self.setRingingTime(null);
} }
}else{ }else{
uComponents.changeMarqueeText(self, [Vue.t('device.defaultNewMsg')]); uComponents.changeMarqueeText(self, [Vue.t('device.defaultNewMsg')]);
// console.log("不滚");
self.activeFlag = false;
}
}else{
setValueOfSwitch(self, true);
self.setLockId(null);
self.mac = null;
self.deviceId = null;
self.uuid = null;
uComponents.changeMarqueeText(self, [Vue.t('device.defaultNewMsg')]);
// console.log("不滚");
self.activeFlag = false; self.activeFlag = false;
self.opendoorRecordFlag = false;
self.securityAlarmFlag = false;
self.hijackAlarmFlag = false;
} }
}, }
error: (error) => {
uPublic.openRequestErrorAlert(self); ////设置设备信息
console.log(error); //function setDevceInfo(self, data) {
// if(window.iotDebug){ // console.log(data);
// iotDebug.push('end: 获取门锁详情失败'+JSON.stringify(error)); // let notifyMode = ['1','2','3'];
// console.log(notifyMode.indexOf(data.notify_type.value));
// if(data.BatteryPercentage){
// self.setBatteryPercent(data.BatteryPercentage.value);
// if(data.BatteryPercentage.value >= 10){
// //向上取整
// self.setBatteryState(config.powerIcon[Math.ceil(data.BatteryPercentage.value/20)]);
// }else{
// self.setBatteryState(config.powerIcon[Math.round(data.BatteryPercentage.value/20)]);
// } // }
// if (window.iotDebug) {
// iotDebug.upload(iot,'获取门锁详情失败');
// } // }
}, // if(data.action.value == 'notify'){
complete: () => { // if(data.notify_type.value == 104){
// //门铃响了
// let now = moment(new Date(), "YYYY-MM-DD hh:mm:ss");
// let time = moment(data.time.value, "YY-MM-DD-hh-mm-ss");
//// console.log('门铃时间差'+now.diff(time,'seconds')+'timeout'+config.ringBell_timeout);
// if(now.diff(time,'seconds') < config.ringBell_timeout && now.diff(time,'seconds') > 0){
// self.setRingingTime(time.format("HH:mm"));
// ringBell(self);
// }
// }else if(data.notify_type.value == 5){
// //请求远程开门
//// self.setRemoteOpendoorFlag(true);
// let now = moment(new Date(), "YYYY-MM-DD hh:mm:ss");
// let time = moment(data.time.value, "YY-MM-DD-hh-mm-ss");
//// console.log(now.diff(time,'seconds'));
// if(now.diff(time,'seconds') < config.remote_timeout && now.diff(time,'seconds') > 0){
// self.setValueRemoteOpendoor(true);
// self.setRemoteOpendoorDisabledFlag(false);
// setTimeout(function(){
// self.setValueRemoteOpendoor(false);
// self.setRemoteOpendoorDisabledFlag(true);
// },(300-now.diff(time,'seconds'))*1000);
// }
//
// }else if(notifyMode.indexOf(data.notify_type.value) != -1){
// loopGetLockInfo(self, config.intervalTime, config.getHistoryTime);
// }
// }
// if(data.action.value == 'lock_log' && (data.lock_action.value == '1' || data.lock_action.value == '4')){
// //开门或远程开门成功
// loopGetLockInfo(self, config.intervalTime, config.getHistoryTime);
// if(data.lock_action.value == '4'){
// uComponents.changeCommLoadingStatusAndText(self, 1, Vue.t('remoteOpendoor.openDoorSuccess'));
// uComponents.changeCommButtonText(self, Vue.t('btn.confirm'));
// self.setValueRemoteOpendoor(false);
// self.setRemoteOpendoorDisabledFlag(true);
// self.setStatus(1);
// }
// }
// if(data.ErrorCode.value == 1){
// //远程开门失败
// uComponents.changeCommLoadingStatusAndText(self, 2, Vue.t('remoteOpendoor.openDoorFailure'));
// uComponents.changeCommButtonText(self, Vue.t('remoteOpendoor.remoteOpendoorAgain'));
// self.setStatus(2);
// }
//}
//sds消息处理方法
function sdsDataPorcessing(self, data){
console.log(data);
//设置电量百分比和icon
setBatteryPercentAndIcon(self, data.BatteryPercentage.value);
switch(data.action.value){
case 'notify':
switch(data.notify_type.value){
case '104':
//门铃
setBellRing(self, moment(new Date(), "YYYY-MM-DD hh:mm:ss"));
break;
case '5':
//远程开门请求
setRemoteOpendoor(self, moment(new Date(), "YYYY-MM-DD hh:mm:ss"));
break;
case '1':
case '2':
case '3':
//防撬、试错、欠电报警
//轮循获取最新的历史记录
console.log('欠电报警');
loopGetLockInfo(self, config.intervalTime, config.getHistoryTime);
break;
}
break;
case 'lock_log':
switch(data.lock_action.value){
case '4':
//切换轮循loading样式
setRemoteOpenDoorLoading(self, 1, Vue.t('remoteOpendoor.openDoorSuccess'), Vue.t('btn.confirm'));
case '1':
//轮循获取最新的历史记录
loopGetLockInfo(self, config.intervalTime, config.getHistoryTime);
break;
}
break;
}
if(data.ErrorCode.value == 1){
//远程开门失败
setRemoteOpenDoorLoading(self, 2, Vue.t('remoteOpendoor.openDoorFailure'), Vue.t('remoteOpendoor.remoteOpendoorAgain'));
} }
});
} }
//设置设备信息 //设置电量百分比、电量icon
function setDevceInfo(self, data) { function setBatteryPercentAndIcon(self, value){
console.log(data); console.log('setBatteryPercentAndIcon'+value);
let notifyMode = ['1','2','3']; self.setBatteryPercent(value);
console.log(notifyMode.indexOf(data.notify_type.value)); let state = 0;
if(data.BatteryPercentage){ if(value >= 10){
self.setBatteryPercent(data.BatteryPercentage.value);
if(data.BatteryPercentage.value >= 10){
//向上取整 //向上取整
self.setBatteryState(config.powerIcon[Math.ceil(data.BatteryPercentage.value/20)]); state = config.powerIcon[Math.ceil(value/20)];
}else{ }else{
self.setBatteryState(config.powerIcon[Math.round(data.BatteryPercentage.value/20)]); state = config.powerIcon[Math.round(value/20)];
}
} }
if(data.action.value == 'notify'){ self.setBatteryState(state);
if(data.notify_type.value == 104){ }
//门铃响了
let now = moment(); //设置门铃
let time = moment(data.time.value, "YY-MM-DD-hh-mm-ss"); function setBellRing(self, time){
console.log('门铃时间差'+now.diff(time,'seconds')+'timeout'+config.ringBell_timeout); let now = moment(new Date(), "YYYY-MM-DD hh:mm:ss");
if(now.diff(time,'seconds') < config.ringBell_timeout && now.diff(time,'seconds') > 0){ time = moment(time, "YY-MM-DD-hh-mm-ss");
self.setRingingTime(time.format("HH:mm")); console.log(now.diff(time,'seconds'));
if(now.diff(time,'seconds') < config.ringBell_timeout && now.diff(time,'seconds') >= 0){
self.setRingingTime(now.format("HH:mm"));
ringBell(self); ringBell(self);
} }
}else if(data.notify_type.value == 5){ }
//请求远程开门
// self.setRemoteOpendoorFlag(true); //设置远程开门
let now = moment(); function setRemoteOpendoor(self, time){
let time = moment(data.time.value, "YY-MM-DD-hh-mm-ss"); let now = moment(new Date(), "YYYY-MM-DD hh:mm:ss");
time = moment(time, "YY-MM-DD-hh-mm-ss");
console.log(now.diff(time,'seconds')); console.log(now.diff(time,'seconds'));
if(now.diff(time,'seconds') < config.remote_timeout && now.diff(time,'seconds') > 0){ if(now.diff(time,'seconds') < config.remote_timeout && now.diff(time,'seconds') >= 0){
self.setValueRemoteOpendoor(true); self.setValueRemoteOpendoor(true);
self.setRemoteOpendoorDisabledFlag(false); self.setRemoteOpendoorDisabledFlag(false);
setTimeout(function(){ setTimeout(function(){
self.setValueRemoteOpendoor(false); self.setValueRemoteOpendoor(false);
self.setRemoteOpendoorDisabledFlag(true); self.setRemoteOpendoorDisabledFlag(true);
},(300-now.diff(time,'seconds'))*1000); },(config.remote_timeout-now.diff(time,'seconds'))*1000);
} }
}
}else if(notifyMode.indexOf(data.notify_type.value) != -1){ //设置远程开门样式
loopGetLockInfo(self, config.intervalTime, config.getHistoryTime); function setRemoteOpenDoorLoading(self, status, text, buttonText){
} switch(status){
} case 1:
if(data.action.value == 'lock_log' && (data.lock_action.value == '1' || data.lock_action.value == '4')){
//开门或远程开门成功
loopGetLockInfo(self, config.intervalTime, config.getHistoryTime);
if(data.lock_action.value == '4'){
uComponents.changeCommLoadingStatusAndText(self, 1, Vue.t('remoteOpendoor.openDoorSuccess'));
uComponents.changeCommButtonText(self, Vue.t('btn.confirm'));
self.setValueRemoteOpendoor(false); self.setValueRemoteOpendoor(false);
self.setRemoteOpendoorDisabledFlag(true); self.setRemoteOpendoorDisabledFlag(true);
self.setStatus(1); case 2:
} case 0:
} self.setStatus(status);
if(data.ErrorCode.value == 1){ uComponents.changeCommLoadingStatusAndText(self, status, text);
//远程开门失败 uComponents.changeCommButtonText(self, buttonText);
uComponents.changeCommLoadingStatusAndText(self, 2, Vue.t('remoteOpendoor.openDoorFailure')); break;
uComponents.changeCommButtonText(self, Vue.t('remoteOpendoor.remoteOpendoorAgain'));
self.setStatus(2);
} }
} }
////sds消息处理方法 //响铃动画和铃声设置
//function notifyDataProcessing(self, data){
// //
// if(data.BatteryPercentage){
// //设置门铃电量
// }
// switch(data.action.value){
// case 'notify':
// switch(data.notify_type.value){
// case '104':
// //门铃
// break;
// case '5':
// //远程开门请求
// break;
// case '1' || '2' || '3':
// //防撬、试错、欠电报警
// //轮循获取最新的历史记录
// break;
// }
// break;
// case 'lock_log':
// switch(data.lock_action.value){
// case '4':
// //切换轮循loading样式
//
// case '1':
// //轮循获取最新的历史记录
//
// break;
// }
// break;
// }
// if(data.ErrorCode.value == 1){
// //远程开门失败
// }
//}
function ringBell(self){ function ringBell(self){
window.clearInterval(self.time); window.clearInterval(self.time);
window.clearTimeout(self.timeout); window.clearTimeout(self.timeout);
let intervalTime = 10000;
let i = 0; let i = 0;
simpleRingBell(self,i); simpleRingBell(self,i);
self.setRingTime(config.ring_time); self.setRingTime(config.ring_time);
self.time = setInterval(function(){ self.time = setInterval(function(){
i++; i++;
simpleRingBell(self,i); simpleRingBell(self,i);
// if(self.getRingTime() == 0){
// window.clearInterval(self.time);
// window.clearTimeout(self.timeout);
// }
},config.await_time*2); },config.await_time*2);
} }
function simpleRingBell(self,i){ function simpleRingBell(self,i){
...@@ -912,59 +983,62 @@ function pushAction(self, msg) { ...@@ -912,59 +983,62 @@ function pushAction(self, msg) {
if (typeof payload == 'string') { if (typeof payload == 'string') {
payload = JSON.parse(msg.payload); payload = JSON.parse(msg.payload);
} }
if(payload.type == "open"){ notifyDataProcessing(self, payload);
//开门推送 // if(payload.type == "open"){
getLockInfo(self); // //开门推送
}else if(payload.type == "notify"){ // getLockInfo(self);
//安全报警 // }else if(payload.type == "notify"){
getLockInfo(self); // //安全报警
}else if(payload.type == "alarm"){ // getLockInfo(self);
//劫持报警 // }else if(payload.type == "alarm"){
// //劫持报警
// getLockInfo(self);
// }else if(payload.type == "ring"){
// //门铃
// let now = moment(new Date(), "YYYY-MM-DD hh:mm:ss");
// let time = moment(payload.time, "YYYY-MM-DD hh:mm:ss");
// console.log(now.diff(time,'seconds'));
// if(now.diff(time,'seconds') < config.ringBell_timeout && now.diff(time,'seconds') > 0){
// if(!self.getRingTime()){
// self.setRingingTime(time.format("HH:mm"));
// ringBell(self);
// }
// }
// }else if(payload.type == "remoteOpen"){
// //远程开门通知
// let now = moment(new Date(), "YYYY-MM-DD hh:mm:ss");
// let time = moment(payload.time, "YYYY-MM-DD hh:mm:ss");
// console.log(now.diff(time,'seconds'));
// if(now.diff(time,'seconds') < config.remote_timeout && now.diff(time,'seconds') > 0){
// self.setValueRemoteOpendoor(true);
// self.setRemoteOpendoorDisabledFlag(false);
// setTimeout(function(){
// self.setValueRemoteOpendoor(false);
// self.setRemoteOpendoorDisabledFlag(true);
// },(300-now.diff(time,'seconds'))*1000);
// }
// }
}
//推送消息处理方法
function notifyDataProcessing(self, payload){
switch(payload.type){
case 'open' || 'notify' || 'alarm':
//开门推送、安全报警、劫持报警
//历史记录信息只拿一遍,不需要轮询
getLockInfo(self); getLockInfo(self);
}else if(payload.type == "ring"){ break;
case 'ring':
//门铃 //门铃
let now = moment(new Date(), "YYYY-MM-DD hh:mm:ss"); setBellRing(self, payload.time);
let time = moment(payload.time, "YYYY-MM-DD hh:mm:ss"); break;
console.log(now.diff(time,'seconds')); case 'remoteOpen':
if(now.diff(time,'seconds') < config.ringBell_timeout && now.diff(time,'seconds') > 0){ //远程开门
if(!self.getRingTime()){ setRemoteOpendoor(self, payload.time);
self.setRingingTime(time.format("HH:mm")); break;
ringBell(self);
}
}
}else if(payload.type == "remoteOpen"){
//远程开门通知
let now = moment(new Date(), "YYYY-MM-DD hh:mm:ss");
let time = moment(payload.time, "YYYY-MM-DD hh:mm:ss");
console.log(now.diff(time,'seconds'));
if(now.diff(time,'seconds') < config.remote_timeout && now.diff(time,'seconds') > 0){
self.setValueRemoteOpendoor(true);
self.setRemoteOpendoorDisabledFlag(false);
setTimeout(function(){
self.setValueRemoteOpendoor(false);
self.setRemoteOpendoorDisabledFlag(true);
},(300-now.diff(time,'seconds'))*1000);
}
} }
} }
////推送消息处理方法
//function notifyDataProcessing(self, msgType){
// switch(msgType){
// case 'open' || 'notify' || 'alarm':
// //开门推送、安全报警、劫持报警
// //历史记录信息只拿一遍,不需要轮询
// getLockInfo(self);
// break;
// case 'ring':
// //门铃
// break;
// case 'remoteOpen':
// //远程开门
// break;
// }
//}
function notificationListener(self) { function notificationListener(self) {
if (plus.os.name == 'Android') { if (plus.os.name == 'Android') {
setInterval(function () { setInterval(function () {
...@@ -1032,13 +1106,15 @@ function doorlockManageTap(self){ ...@@ -1032,13 +1106,15 @@ function doorlockManageTap(self){
//tap 开门记录 //tap 开门记录
function opendoorRecordTap(self){ function opendoorRecordTap(self){
let now = moment(new Date());
if(self.valueOpendoorRecord){ if(self.valueOpendoorRecord){
if(self.hijackAlarmFlag){ if(self.opendoorRecordFlag){
console.log("停止所以interval");
window.clearInterval(self.handle); window.clearInterval(self.handle);
} }
self.opendoorRecordFlag = false; self.opendoorRecordFlag = false;
setRecordTime('openTime', now.toISOString()); // let now = moment(new Date(), "YYYY-MM-DD hh:mm:ss");
// setRecordTime('openTime', self.openTime.toISOString());
iot.navigator.openWindow({ iot.navigator.openWindow({
url: './opendoorRecord.html', url: './opendoorRecord.html',
id: 'opendoorRecord', id: 'opendoorRecord',
...@@ -1051,14 +1127,14 @@ function opendoorRecordTap(self){ ...@@ -1051,14 +1127,14 @@ function opendoorRecordTap(self){
//tap 安全报警 //tap 安全报警
function securityAlarmTap(self){ function securityAlarmTap(self){
let now = moment(new Date());
if(self.valueSecurityAlarm){ if(self.valueSecurityAlarm){
if(self.notifyTime != null){ if(self.notifyTime != null){
if(self.hijackAlarmFlag){ if(self.securityAlarmFlag){
window.clearInterval(self.handle); window.clearInterval(self.handle);
} }
self.securityAlarmFlag = false; self.securityAlarmFlag = false;
setRecordTime('notifyTime', now.toISOString()); // let now = moment(new Date(), "YYYY-MM-DD hh:mm:ss");
// setRecordTime('notifyTime', self.notifyTime);
} }
iot.navigator.openWindow({ iot.navigator.openWindow({
url: './alarmInfo.html', url: './alarmInfo.html',
...@@ -1108,7 +1184,7 @@ function remoteOpendoorTap(self){ ...@@ -1108,7 +1184,7 @@ function remoteOpendoorTap(self){
//tap 劫持报警 //tap 劫持报警
function hijackAlarmTap(self){ function hijackAlarmTap(self){
let now = moment(new Date());
if(self.valueHijackAlarm){ if(self.valueHijackAlarm){
console.log(self.alarmTime); console.log(self.alarmTime);
if(self.alarmTime != null){ if(self.alarmTime != null){
...@@ -1116,7 +1192,8 @@ function hijackAlarmTap(self){ ...@@ -1116,7 +1192,8 @@ function hijackAlarmTap(self){
window.clearInterval(self.handle); window.clearInterval(self.handle);
} }
self.hijackAlarmFlag = false; self.hijackAlarmFlag = false;
setRecordTime('alarmTime', now.toISOString()); // let now = moment(new Date(), "YYYY-MM-DD hh:mm:ss");
// setRecordTime('alarmTime', self.alarmTime.toISOString());
} }
iot.navigator.openWindow({ iot.navigator.openWindow({
url: './hijackRecord.html', url: './hijackRecord.html',
...@@ -1182,10 +1259,7 @@ function confirmButtonTap(self){ ...@@ -1182,10 +1259,7 @@ function confirmButtonTap(self){
success: (response) => { success: (response) => {
//密码下发成功 //密码下发成功
console.log(response); console.log(response);
// uComponents.showCommLoading(self);
self.getStatus(0); self.getStatus(0);
// uComponents.changeCommLoadingStatusAndText(self, 1, Vue.t('remoteOpendoor.openDoorSuccess'));
// uComponents.changeCommButtonText(self, Vue.t('btn.confirm'));
}, },
error: (error) => { error: (error) => {
console.log(error); console.log(error);
...@@ -1218,7 +1292,6 @@ function confirmButtonTap(self){ ...@@ -1218,7 +1292,6 @@ function confirmButtonTap(self){
function commLoadingButtonTap(self){ function commLoadingButtonTap(self){
if(self.getStatus() == 1){ if(self.getStatus() == 1){
//绑定成功 //绑定成功
console.log("1111");
uComponents.hideCommLoading(self); uComponents.hideCommLoading(self);
self.setRemoteOpendoorShowFlag(false); self.setRemoteOpendoorShowFlag(false);
}else if(self.getStatus() == 2){ }else if(self.getStatus() == 2){
......
...@@ -23,7 +23,8 @@ function init() { ...@@ -23,7 +23,8 @@ function init() {
list: [], list: [],
startId: 0, startId: 0,
deviceId: null, deviceId: null,
userInfo: [] userInfo: [],
flag: true
}, },
mounted(){ mounted(){
resolve(this); resolve(this);
...@@ -128,6 +129,17 @@ function getHistoryRecord(self){ ...@@ -128,6 +129,17 @@ function getHistoryRecord(self){
}, },
success: (response) => { success: (response) => {
setListData(self, response); setListData(self, response);
if(self.flag){
let data = uPublic.checkResponseData(response.data);
if(data && data.record.length > 0){
let record = data.record;
iot.storage.setMap('openTime', moment(record[0].time).toISOString(), (res) => {
console.log(res);
self.flag = false;
}, () => {
});
}
}
}, },
error: (error) => { error: (error) => {
console.log(error); console.log(error);
......
...@@ -196,7 +196,7 @@ function setUserData(self, data){ ...@@ -196,7 +196,7 @@ function setUserData(self, data){
role: data[i].role, role: data[i].role,
image: data[i].role == 0 ? '../../resources/image/green_admin_icon.png' : data[i].user_id == null ? '../../resources/image/gray_unbindHead_icon.png' : '../../resources/image/green_bindHead_icon.png', image: data[i].role == 0 ? '../../resources/image/green_admin_icon.png' : data[i].user_id == null ? '../../resources/image/gray_unbindHead_icon.png' : '../../resources/image/green_bindHead_icon.png',
title: data[i].nickname, title: data[i].nickname,
subtitle: data[i].username ? Vue.t('userList.binded'):Vue.t('userList.unbind') subtitle: data[i].hasOwnProperty('username') ? Vue.t('userList.binded'):Vue.t('userList.unbind')
} }
} }
console.log(data); console.log(data);
......
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