Commit 314b404f by 朱建香

2017/12/22

1.首页代码规范优化
parent 6049e46b
......@@ -90,8 +90,8 @@ class Loop{
this.time = setTimeout(() => {
this.clearTime();
this.canDo = false;
// this.fincb.error('timeout');
// this.fincb.complete();
this.fincb.error('timeout');
this.fincb.complete();
console.log("超时");
this.intervalcb = null;
this.fincb = null;
......
......@@ -147,7 +147,8 @@ uPublic.logout = function(opts){
});
}
uPublic.upDateRead = async function(key){
// 更新缓存中history存储的isReadFlag 和 time
uPublic.upDateRead = async function(key, time){
let oldHistory = {
alarm: {
time: null,
......@@ -163,7 +164,8 @@ uPublic.upDateRead = async function(key){
}
};
try{
oldHistory = await iot.storage.getMap('history');
let history = await iot.storage.getMap('history');
oldHistory = history ? history : oldHistory;
console.log(oldHistory);
}
catch (error){
......@@ -172,12 +174,15 @@ uPublic.upDateRead = async function(key){
let newHistory = oldHistory;
newHistory[key].isReadFlag = true;
iot.storage.setMap('history', newHistory, (response) => {
console.log(res);
}, () => {
});
newHistory[key].time = time;
let flag = await iot.storage.setMap('history', newHistory);
if(flag){
return false;
}
}
iot.ready(() => {
uPublic.recalc();
});
......
......@@ -61,18 +61,11 @@ function backTap(){
//tap 扫描绑定设备
function scanAddTap(){
// iot.navigator.openWindow({
// url: './scanCodeAdd.html',
// id: 'scanCodeAdd'
// });
mui.openWindow({
iot.navigator.openWindow({
url: './scanCodeAdd.html',
id: 'scanCodeAdd',
show: {
aniShow: "none"
},
waiting: {
autoShow: false
}
});
}
......
......@@ -40,7 +40,7 @@ function init() {
setTextPassword(pwd){
this.textPassword = pwd;
},
gettTextErrorTip(){
getTextErrorTip(){
return this.textErrorTip;
},
setTextErrorTip(tip){
......@@ -110,12 +110,12 @@ function initComponentsConfig() {
}
}
//页面渲染后,获取wifi名称
function resolve(self){
iot.business.sds.getSSId({
success: (response) => {
console.log(response);
self.textWiFiName = response.data.ssid;
console.log(self.textWiFiName);
},
error: (error) => {
console.log(error);
......@@ -130,11 +130,13 @@ function resolve(self){
});
}
//设置wifi密码
function passwordChange(self,text){
self.textPassword = text;
console.log('passwordChange: ' + self.textPassword);
self.setTextPassword(text);
console.log('passwordChange: ' + self.getTextPassword());
}
//重新mui.back
mui.back = function(){
iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{ });
iot.navigator.back();
......@@ -147,8 +149,6 @@ function backTap(){
//tap 连接
function connectButtonTap(self){
// console.log(self.getTextWiFiName());
// console.log(self.getTextPassword());
if(self.getTextWiFiName() == null || self.getTextWiFiName().trim() == ''){
self.setTextErrorTip(Vue.t('wifiAdd.unbindWifiTip'));
}else if(self.getTextPassword() == null || self.getTextPassword().trim() == ''){
......@@ -189,10 +189,6 @@ function connectButtonTap(self){
}
//wifi连接成功,停止连接wifi
uComponents.changeCommLoadingStatusAndText(self, 0, Vue.t('wifiAdd.wifiBindSuccess'));
// iot.business.sds.stopFindWifi({
// success: (response) => {},
// error: (error) => {}
// });
}
},
error: (error) => {
......@@ -233,7 +229,6 @@ function connectButtonTap(self){
}
let deviceId = response.info.sn;
unbind(self, deviceId, productId);
// bind(self, deviceId, productId);
}else if(response.data == "fail"){
//连接失败
if(window.iotDebug){
......@@ -280,25 +275,7 @@ function connectButtonTap(self){
},config.wifi_add_timeout);
}
//tap loading button
function commLoadingButtonTap(self) {
if(self.getStatus() == 1){
//绑定成功
uComponents.hideCommLoading(self);
iot.navigator.fire(plus.webview.getWebviewById('device'),'returnPage',{});
iot.navigator.openWindow({
url: '../device/index.html',
id: 'device'
});
}else if(self.getStatus() == 2){
//绑定失败
uComponents.hideCommLoading(self);
self.setStatus(0);
uComponents.changeCommLoadingStatusAndText(self, 0, Vue.t('addDevice.loading'));
}
}
//云端绑定之前先解绑
function unbind(self, deviceId, productId){
console.log(deviceId);
iot.business.api.sendCustom('lock/unbindDevice',{
......@@ -332,6 +309,7 @@ function unbind(self, deviceId, productId){
});
}
//云端绑定
function bind(self, deviceId, productId){
iot.business.api.sendCustom('lock/bind',{
data: {
......@@ -370,3 +348,21 @@ function bind(self, deviceId, productId){
complete: () => {}
});
}
//tap loading button
function commLoadingButtonTap(self) {
if(self.getStatus() == 1){
//绑定成功
uComponents.hideCommLoading(self);
iot.navigator.fire(plus.webview.getWebviewById('device'),'returnPage',{});
iot.navigator.openWindow({
url: '../device/index.html',
id: 'device'
});
}else if(self.getStatus() == 2){
//绑定失败
uComponents.hideCommLoading(self);
self.setStatus(0);
uComponents.changeCommLoadingStatusAndText(self, 0, Vue.t('addDevice.loading'));
}
}
\ No newline at end of file
......@@ -79,15 +79,4 @@ function wifiAddButtonTap(){
url: './wifiAdd.html',
id: 'wifiAdd'
});
console.log("in");
// iot.business.sds.wifiDeviceConfig({
// success: function (response) {
// console.log('wifiDeviceConfig success');
// console.log(response);
// },
// error: function (error) {
// console.log('wifiDeviceConfig error');
// console.log(error);
// }
// });
}
\ No newline at end of file
......@@ -47,6 +47,7 @@ function init() {
setDeviceId(id){
this.deviceId = id;
},
//tap 点击加载更多
onListLoadTap(){
listLoadTap(this);
},
......@@ -82,7 +83,8 @@ function initComponentsConfig() {
}
}
function resolve(self) {
// 获取历史记录
function resolve(self) {
self.setDeviceId(iot.navigator.getExtras().deviceId);
uComponents.showLoading(self);
iot.business.api.sendCustom('lock/getHistoryRecord',
......@@ -93,18 +95,13 @@ function initComponentsConfig() {
start_id: self.getStartId(),
page_size: PAGE_SIZE
},
success: (response) => {
success: async (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).unix(), (res) => {
// console.log(res);
// self.flag = false;
// }, () => {
// });
uPublic.upDateRead('notify');
self.flag = await uPublic.upDateRead('notify', moment(record[0].time).unix());
}
}
let data = uPublic.checkResponseData(response.data);
......@@ -131,25 +128,20 @@ function initComponentsConfig() {
},
error: (error) => {
console.log(error);
// if(window.iotDebug){
// iotDebug.push('end: 获取报警信息失败'+JSON.stringify(error));
// }
// if (window.iotDebug) {
// iotDebug.upload(iot,'获取报警信息失败');
// }
uPublic.openRequestErrorAlert(self);
},
complete: () => {
uComponents.hideLoading(self);
}
});
}
}
//tap <
function backTap(){
iot.navigator.aback();
}
//重写mui.back
mui.back = function(){
iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{});
console.log("fire");
......
......@@ -106,12 +106,7 @@ function initComponentsConfig() {
let data = uPublic.checkResponseData(response.data);
if(data && data.record.length > 0){
let record = data.record;
// iot.storage.setMap('alarmTime', moment(record[0].time).unix(), (res) => {
// console.log(res);
// self.flag = false;
// }, () => {
// });
uPublic.upDateRead('alarm');
self.flag = await uPublic.upDateRead('alarm', moment(record[0].time).unix());
}
}
let data = uPublic.checkResponseData(response.data);
......@@ -152,12 +147,6 @@ function initComponentsConfig() {
},
error: (error) => {
console.log(error);
// if(window.iotDebug){
// iotDebug.push('end: 获取劫持报警信息'+JSON.stringify(error));
// }
// if (window.iotDebug) {
// iotDebug.upload(iot,'获取劫持报警信息');
// }
uPublic.openRequestErrorAlert(self);
},
complete: () => {
......@@ -171,6 +160,7 @@ function backTap(){
iot.navigator.aback();
}
//重写mui.back
mui.back = function(){
iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{});
console.log("fire");
......
......@@ -87,9 +87,6 @@ function init() {
opendoorRecordFlag: false,
securityAlarmFlag: false,
hijackAlarmFlag: false,
notifyTime: null,
alarmTime: null,
openTime: null,
//是否显示远程开门页面
remoteOpendoorShowFlag: false,
//远程开门密码
......@@ -99,19 +96,23 @@ function init() {
//当前状态
status: 0,
flag: true,
//门铃等待计时器
time: null,
//门铃总计时器
timeout: null,
//远程开门计时器
remoteTime: null
},
mounted(){
//显示loading
uComponents.showLoading(this);
//监听推送
notificationListener(this);
let self = this;
//获取设备信息
getDevices(this);
//注册监听上报
registerPushListener(this);
let self = this;
window.addEventListener('returnPage',function(event){
//获取设备信息
getDevices(self);
......@@ -435,6 +436,27 @@ function getDevices(self){
console.log(response);
let data = uPublic.checkResponseData(response.data);
if(data){
getDevicesSuccess(self, data);
}else{
initDeviceInfo(self);
uComponents.hideLoading(self);
}
},
error: (error) => {
console.log(error);
if(window.iotDebug){
iotDebug.push('end: 获取设备信息'+JSON.stringify(error));
}
if (window.iotDebug) {
iotDebug.upload(iot,'获取设备信息');
}
uPublic.openRequestErrorAlert(self);
},
complete: () => {}
});
}
function getDevicesSuccess(self, data){
self.mac = data[0].mac;
self.deviceId = data[0].sn;
self.uuid = data[0].uuid;
......@@ -458,26 +480,8 @@ function getDevices(self){
complete: () => {}
});
}
}else{
initDeviceInfo(self);
uComponents.hideLoading(self);
}
},
error: (error) => {
console.log(error);
if(window.iotDebug){
iotDebug.push('end: 获取设备信息'+JSON.stringify(error));
}
if (window.iotDebug) {
iotDebug.upload(iot,'获取设备信息');
}
uPublic.openRequestErrorAlert(self);
},
complete: () => {}
});
}
function getLockInfo(self){
console.log("getLockInfo");
iot.business.api.sendCustom('lock/getLockInfo',{
......@@ -506,8 +510,6 @@ function getLockInfo(self){
function getLockInfoSuccess(self, data){
//判断云端是否绑定
if(data.lock_id){
//获取‘未读’小红点状态
// getRecordTime(self, data);
//更改按钮为‘可点击’样式
setValueOfSwitch(self, false);
//设置门锁信息
......@@ -557,6 +559,32 @@ function getLockInfoSuccess(self, data){
}
}
//获取设备的初始状态
function getDeviceStatus(self){
iot.business.sds.getDeviceStatus({
data: {
uuid: self.uuid
},
success: (response) => {
console.log(response);
let data = uPublic.checkResponseData(response.data);
if(data){
setBatteryPercentAndIcon(self, data.BatteryPercentage.value);
}
},
error: (error) => {
console.log(error);
if(window.iotDebug){
iotDebug.push('end: 获取设备状态'+JSON.stringify(error));
}
if (window.iotDebug) {
iotDebug.upload(iot,'获取设备状态');
}
uPublic.openRequestErrorAlert(self);
}
});
}
async function updateHistoryMap(self, historyRecord){
let oldHistory = {
alarm: {
......@@ -573,28 +601,29 @@ async function updateHistoryMap(self, historyRecord){
}
};
try{
oldHistory = await iot.storage.getMap('history');
console.log(oldHistory);
let history = await iot.storage.getMap('history');
oldHistory = history ? history : oldHistory;
}
catch (error) {
console.log(error);
}
console.log(oldHistory.open.time);
let openHistory = historyRecord.open;
let newHistory = oldHistory;
console.log(historyRecord.hasOwnProperty('alarm') && oldHistory.alarm.time != moment(historyRecord.alarm).unix());
if(historyRecord.hasOwnProperty('alarm') && oldHistory.alarm.time != moment(historyRecord.alarm).unix()){
newHistory.alarm.time = moment(historyRecord.alarm).unix();
newHistory.alarm.isReadFlag = false;
}
if(openHistory.length && oldHistory.open.time != moment(openHistory[0].time).unix()){
let now = moment(new Date()).unix();
if(openHistory.length && oldHistory.open.time < moment(openHistory[0].time).unix() && now - moment(openHistory[0].time).unix() < 3600){
newHistory.open.time = moment(openHistory[0].time).unix();
newHistory.open.isReadFlag = false;
}
if(historyRecord.hasOwnProperty('notify') && oldHistory.notify.time != moment(historyRecord.notify).unix()){
newHistory.notify.time = moment(historyRecord.notify).unix()
newHistory.open.isReadFlag = false;
let historyType = ['alarm','notify'];
for(let i=0 ; i < historyType.length; i++){
if(historyRecord.hasOwnProperty(historyType[i]) && oldHistory[historyType[i]].time < moment(historyRecord[historyType[i]]).unix() && now - moment(historyRecord[historyType[i]]).unix() < 3600){
newHistory[historyType[i]].time = moment(historyRecord[historyType[i]]).unix()
newHistory[historyType[i]].isReadFlag = false;
}
}
iot.storage.setMap('history', newHistory, (response) => {
......@@ -610,55 +639,6 @@ async function updateHistoryMap(self, historyRecord){
});
}
function getDeviceStatus(self){
iot.business.sds.getDeviceStatus({
data: {
uuid: self.uuid
},
success: (response) => {
console.log(response);
let data = uPublic.checkResponseData(response.data);
if(data){
setBatteryPercentAndIcon(self, data.BatteryPercentage.value);
}
},
error: (error) => {
console.log(error);
if(window.iotDebug){
iotDebug.push('end: 获取设备状态'+JSON.stringify(error));
}
if (window.iotDebug) {
iotDebug.upload(iot,'获取设备状态');
}
uPublic.openRequestErrorAlert(self);
}
});
}
function getNewInfo(self){
console.log("getNewInfo");
iot.business.api.sendCustom('lock/getNewInfo',{
data: {
device_id: self.deviceId
},
success: (response) => {
console.log(response);
// let data = uPublic.checkResponseData(response.data);
// if(data){
// getLockInfoSuccess(self, data);
// }else{
// initDeviceInfo(self);
// }
},
error: (error) => {
uPublic.openRequestErrorAlert(self);
console.log(error);
},
complete: () => {
uComponents.hideLoading(self);
}
});
}
//云端获取设备信息失败
function initDeviceInfo(self){
setValueOfSwitch(self, true);
......@@ -675,7 +655,6 @@ function initDeviceInfo(self){
self.setValueRemoteOpendoor(0);
}
async function loopGetLockInfo(self, delay, timeout){
let oldHistoryId = null;
try{
......@@ -695,9 +674,9 @@ async function loopGetLockInfo(self, delay, timeout){
}
}
},
timeout: 20000,
timeout: config.getHistoryTime*1000,
interval:{
delay: 3000,
delay: config.intervalTime*1000,
cb: {
success: (response) => {
console.log('intervalcbSuccess:'+JSON.stringify(response));
......@@ -733,52 +712,10 @@ async function loopGetLockInfo(self, delay, timeout){
return true;
}
}
}
}).start();
}
async function getRecordTime(self, data){
console.log(getRecordTime);
try{
self.notifyTime = await iot.storage.getMap('notifyTime');
self.alarmTime = await iot.storage.getMap('alarmTime');
self.openTime = await iot.storage.getMap('openTime');
}
catch (error) {
console.log(error);
}
let newNotifyTime = data.notify_time == null? null : moment(data.notify_time).unix();
let newAlarmTime = data.alarm_time == null? null : moment(data.alarm_time).unix();
let newOpenTime = data.open_time == null? null : moment(data.open_time).unix();
self.securityAlarmFlag = showNewMessage(self.notifyTime, newNotifyTime);
self.hijackAlarmFlag = showNewMessage(self.alarmTime, newAlarmTime);
self.opendoorRecordFlag = showNewMessage(self.openTime, newOpenTime);
}
function showNewMessage(oldTime, newTime, flag){
let now = moment(new Date(), "YYYY-MM-DD hh:mm:ss").unix();
console.log(oldTime);
console.log(newTime);
if(oldTime){
if(newTime != null && newTime - oldTime > 0){
return true;
oldTime = newTime;
}else{
return false;
}
}else{
if(newTime != null && now - newTime < 3600){
return true;
oldTime = newTime;
}else{
return false;
}
}
}
function setValueOfSwitch(self, flag){
self.setOpendoorRecordDisabledFlag(flag);
self.setSecurityAlarmDisabledFlag(flag);
......@@ -906,10 +843,10 @@ function setRemoteOpenDoorLoading(self, status, text, buttonText){
self.setRemoteOpendoorDisabledFlag(true);
case 2:
window.clearTimeout(self.remoteTime);
uComponents.changeCommButtonText(self, buttonText);
case 0:
self.setStatus(status);
uComponents.changeCommLoadingStatusAndText(self, status, text);
uComponents.changeCommButtonText(self, buttonText);
break;
}
}
......@@ -927,6 +864,7 @@ function ringBell(self){
},config.await_time*2);
}
//铃声和动画循环一遍
function simpleRingBell(self,i){
window.clearTimeout(self.timeout);
self.setDoorbellRingingFlag(true);
......@@ -1036,9 +974,7 @@ function opendoorRecordTap(self){
//tap 安全报警
function securityAlarmTap(self){
if(self.valueSecurityAlarm){
if(self.notifyTime != null){
self.securityAlarmFlag = false;
}
iot.navigator.openWindow({
url: './alarmInfo.html',
id: 'alarmInfo',
......@@ -1052,10 +988,7 @@ function securityAlarmTap(self){
//tap 劫持报警
function hijackAlarmTap(self){
if(self.valueHijackAlarm){
console.log(self.alarmTime);
if(self.alarmTime != null){
self.hijackAlarmFlag = false;
}
iot.navigator.openWindow({
url: './hijackRecord.html',
id: 'hijackRecord',
......@@ -1141,9 +1074,7 @@ function confirmButtonTap(self){
self.setTextErrorTip(Vue.t('remoteOpendoor.error.noPasswordTip'));
}else{
uComponents.showCommLoading(self);
self.setStatus(0);
uComponents.changeCommLoadingStatusAndText(self, 0, Vue.t('remoteOpendoor.loading'));
// console.log(self.mac);
setRemoteOpenDoorLoading(self, 0, Vue.t('remoteOpendoor.loading'));
let keyIv = crypto.enkey(self.mac.replace(/:/g,''));
// console.log(keyIv);
let pwd = crypto.encode(self.getTextPassword(), keyIv);
......@@ -1165,7 +1096,6 @@ function confirmButtonTap(self){
success: (response) => {
//密码下发成功
console.log(response);
self.getStatus(0);
},
error: (error) => {
console.log(error);
......@@ -1182,13 +1112,8 @@ function confirmButtonTap(self){
});
}
self.remoteTime = setTimeout(function (){
console.log(self.getStatus());
if(self.getStatus() == 0){
//连接失败
uComponents.changeCommLoadingStatusAndText(self, 2, Vue.t('remoteOpendoor.remoteTimeout'));
uComponents.changeCommButtonText(self, Vue.t('remoteOpendoor.remoteOpendoorAgain'));
self.setStatus(2);
window.clearTimeout(self.remoteTime);
setRemoteOpenDoorLoading(self, 2, Vue.t('remoteOpendoor.remoteTimeout'), Vue.t('remoteOpendoor.remoteOpendoorAgain'));
}
},config.remote_opendoor_timeout);
}
......@@ -1197,11 +1122,8 @@ function confirmButtonTap(self){
function commLoadingButtonTap(self){
if(self.getStatus() == 1){
//远程开门成功
uComponents.hideCommLoading(self);
self.setRemoteOpendoorShowFlag(false);
}else if(self.getStatus() == 2){
//远程开门失败
uComponents.hideCommLoading(self);
}
uComponents.hideCommLoading(self);
}
......@@ -107,6 +107,7 @@ function backTap(){
iot.navigator.aback();
}
//重写mui.back
mui.back = function(){
iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{});
console.log("fire");
......@@ -118,6 +119,7 @@ function listLoadTap(self) {
resolve(self);
}
//获取历史记录(整个设备)
function getHistoryRecord(self){
iot.business.api.sendCustom('lock/getHistoryRecord',
{
......@@ -127,29 +129,18 @@ function getHistoryRecord(self){
start_id: self.getStartId(),
page_size: PAGE_SIZE
},
success: (response) => {
success: async (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).unix(), (res) => {
// console.log(res);
// self.flag = false;
// }, () => {
// });
uPublic.upDateRead('open');
self.flag = await uPublic.upDateRead('open', moment(record[0].time).unix());
}
}
},
error: (error) => {
console.log(error);
// if(window.iotDebug){
// iotDebug.push('end: 获取开门记录失败'+JSON.stringify(error));
// }
// if (window.iotDebug) {
// iotDebug.upload(iot,'获取开门记录失败');
// }
uPublic.openRequestErrorAlert(self);
},
complete: () => {
......@@ -158,6 +149,7 @@ function getHistoryRecord(self){
});
}
//获取个人历史记录
function getPersonalHistory(self, id){
iot.business.api.sendCustom('lock/getPersonalHistory',
{
......@@ -173,12 +165,6 @@ function getPersonalHistory(self, id){
},
error: (error) => {
console.log(error);
// if(window.iotDebug){
// iotDebug.push('end: 获取个人开门历史记录'+JSON.stringify(error));
// }
// if (window.iotDebug) {
// iotDebug.upload(iot,'获取个人开门历史记录');
// }
uPublic.openRequestErrorAlert(self);
},
complete: () => {
......@@ -187,6 +173,7 @@ function getPersonalHistory(self, id){
});
}
//设置历史记录渲染列表
function setListData(self, response){
let data = uPublic.checkResponseData(response.data);
if(data){
......
......@@ -82,10 +82,6 @@ function initComponentsConfig() {
}
}
function alert(){
alert('aaa');
}
function nameChange(self,text){
self.setTextName(text);
self.setTextErrorTip('');
......@@ -97,6 +93,13 @@ function backTap(){
iot.navigator.back();
}
//重写mui.back
mui.back = function(){
iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{});
console.log("fire");
iot.navigator.back();
}
//tap 保存
function saveTap(self){
if(self.getTextName() == null || self.getTextName().trim() == ''){
......@@ -123,12 +126,6 @@ function saveTap(self){
},
error: (error) => {
console.log(error);
// if(window.iotDebug){
// iotDebug.push('end: 修改设备名称失败'+JSON.stringify(error));
// }
// if (window.iotDebug) {
// iotDebug.upload(iot,'修改设备名称失败');
// }
uComponents.openAlert(self, Vue.t('editName.editNameFailue'), {
text: Vue.t('btn.confirm'), callback: function () {
let opener = plus.webview.currentWebview().opener();
......
......@@ -18,6 +18,7 @@ function init() {
//项目 list组件
uPublic.componentsExtend(['grid-list']);
uPublic.closeSlideBack();
console.log(iot.navigator.getExtras());
const app = new Vue({
data:{
//配置组件
......@@ -197,6 +198,7 @@ function initComponentsConfig() {
}
}
//获取设备信息
function getDoorlockInfo(self){
uComponents.showLoading(self);
let productId = config.model;
......@@ -216,57 +218,14 @@ function getDoorlockInfo(self){
},
error: (error) => {
console.log(error);
// if(window.iotDebug){
// iotDebug.push('end: 获取门锁信息失败'+JSON.stringify(error));
// }
// if (window.iotDebug) {
// iotDebug.upload(iot,'获取门锁信息失败');
// }
uPublic.openRequestErrorAlert(self);
},
complete: () => {
uComponents.hideLoading(self);
}
});
// iot.business.api.send('device/getList',{
// data: {
// sds: false,
// device_id: self.extras.deviceId,
// product_id: productId,
// parent_id: 0,
// start_id: 0,
// number: 10
// },
// success: (response) => {
// console.log(response);
// let data = uPublic.checkResponseData(response.data);
// if(data){
// self.setDoorlock(response.data[0]);
// self.setTextNickname(self.getDoorlock().nickname);
// console.log(self.getDoorlock());
// }
// },
// error: (error) => {
// //请求失败
// uPublic.openRequestErrorAlert(self);
// console.log(error);
// },
// complete: () => {
// uComponents.hideLoading(self);
// }
// },true);
}
//tap <
function backTap(){
iot.navigator.aback();
}
mui.back = function(){
iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{});
console.log("fire");
iot.navigator.back();
}
//tap 修改设备昵称
function editNameTap(self){
......@@ -282,44 +241,40 @@ function editNameTap(self){
}
}
//tap 解绑门锁
//tap ‘解绑门锁’ 显示解绑门锁弹框
function unbindDoorlockButtonTap(self){
self.setUnbindShowDialog(true);
//uComponents.openConfirm(self, Vue.t('doorlockManage.unbindDialogTip'),
// {text: Vue.t('dialog.cancel'), callback: function () {}},
// {text: Vue.t('dialog.unbind'), callback: function () {
// uComponents.showLoading(self);
// iot.business.sds.unbindDevice({
// data: {
// uuid: self.extras.uuid
// },
// success: (response) => {
// console.log(response);
// unbind(self);
// },
// error: (error) => {
// console.log(error)
// },
// complete: () => {
//
// }
// });
// }}
// );
}
//tap 隐藏提示框
function unbindStateDialogTap(self){
self.setStateShowFlag(false);
iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{});
if(self.getUnbindSucceess){
iot.navigator.openWindow({
url: '../device/index.html',
id: 'device'
});
//tap 确认解绑门锁
function confirmTap(self){
self.setUnbindShowDialog(false);
// sds解绑门锁
iot.business.sds.unbindDevice({
data: {
uuid: self.extras.uuid
},
success: (response) => {
console.log(response);
unbind(self);
},
error: (error) => {
console.log(error);
if(window.iotDebug){
iotDebug.push('end: sds解绑设备失败'+JSON.stringify(error));
}
if (window.iotDebug) {
iotDebug.upload(iot,'sds解绑设备失败');
}
uPublic.openRequestErrorAlert(self);
},
complete: () => {
}
});
}
// 云端解绑门锁
function unbind(self){
iot.business.api.sendCustom('lock/unbind',{
data: {
......@@ -335,12 +290,6 @@ function unbind(self){
},
error: (error) => {
console.log(error);
// if(window.iotDebug){
// iotDebug.push('end: 云端解绑失败'+JSON.stringify(error));
// }
// if (window.iotDebug) {
// iotDebug.upload(iot,'云端解绑失败');
// }
self.setStateShowFlag(false);
self.setShowMsg(Vue.t('doorlockManage.unbindFailue'));
self.setUnbindSucceess(false);
......@@ -351,46 +300,44 @@ function unbind(self){
});
}
//function unbindUser(self){
// iot.business.api.sendCustom('lock/unbindUser',{
// data: {
// rel_id: self.getDoorlock().id,
// device_id: self.getDoorlock().device_id,
// user_id: self.getDoorlock().user_device_id
// },
// success: (response) => {
// self.setStateShowFlag(true);
// self.setShowMsg(Vue.t('doorlockUser.unbindSuccess'));
// self.setUnbindSucceess(true);
// },
// error: (error) => {
// console.log(error);
// self.setStateShowFlag(false);
// self.setShowMsg(Vue.t('doorlockUser.unbindFailue'));
// self.setUnbindSucceess(false);
// },
// complete: () => {
// uComponents.hideLoading(self);
// }
// });
//}
//选择是否清除所有信息,默认选择为‘清除所有信息’
function isClearSwitchTap(self, value){
self.setValueIsClear(value);
console.log(self.getValueIsClear());
}
//tap <
function backTap(){
iot.navigator.aback();
}
//重写mui.back
mui.back = function(){
iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{});
console.log("fire");
iot.navigator.back();
}
// 选择: 是否接收门铃消息推送
function doorbellSwitchTap(self, value){
self.setValueDoorbell(value);
setOption(self);
}
// 选择: 是否接收报警消息推送
function alarmSwitchTap(self, value){
self.setValueAlarm(value);
setOption(self);
}
// 选择: 是否接收开门消息推送
function opendoorSwitchTap(self, value){
self.setValueOpendoor(value);
setOption(self);
}
// 调用设置推送接口
function setOption(self){
// uComponents.showLoading(self);
iot.business.api.sendCustom('lock/setPushOption',
{
data: {
......@@ -404,54 +351,26 @@ function setOption(self){
},
error: (error) => {
console.log(error);
// if(window.iotDebug){
// iotDebug.push('end: 设置推送失败'+JSON.stringify(error));
// }
// if (window.iotDebug) {
// iotDebug.upload(iot,'设置推送失败');
// }
uPublic.openRequestErrorAlert(self);
},
complete: () => {
// uComponents.hideLoading(self);
}
});
}
//tap 取消解绑门锁
function cancelTap(self){
self.setUnbindShowDialog(false);
}
function confirmTap(self){
self.setUnbindShowDialog(false);
iot.business.sds.unbindDevice({
data: {
uuid: self.extras.uuid
},
success: (response) => {
console.log(response);
unbind(self);
},
error: (error) => {
console.log(error);
if(window.iotDebug){
iotDebug.push('end: sds解绑设备失败'+JSON.stringify(error));
}
if (window.iotDebug) {
iotDebug.upload(iot,'sds解绑设备失败');
}
uPublic.openRequestErrorAlert(self);
},
complete: () => {
}
//tap 绑定成功弹框提示-->回到首页
function unbindStateDialogTap(self){
self.setStateShowFlag(false);
iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{});
if(self.getUnbindSucceess){
iot.navigator.openWindow({
url: '../device/index.html',
id: 'device'
});
// unbind(self);
}
function isClearSwitchTap(self, value){
self.setValueIsClear(value);
console.log(self.getValueIsClear());
}
}
......@@ -144,7 +144,7 @@ function logoutButtonTap(self){
console.log("sdsLogout:"+response);
let sdsResponse = response;
iot.business.websql.delMaps(['utoken', 'userinfo'], (response) => {
iot.storage.delMaps(['notifyTime','alarmTime','openTime'], (response) => {
iot.storage.delMaps(['historyId','history'], (response) => {
console.log("clearMap"+response);
//打开首页
iot.navigator.openWindow({
......
......@@ -4928,6 +4928,7 @@ var App = function (_Base) {
url: params.url,
id: params.id,
styles: params.styles || {},
show: params.show,
extras: { IOTData: params.extras },
waiting: params.waiting || { autoShow: false }
});
......
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