Commit fd29a166 by 朱建香

1208

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