Commit 98765389 by 朱建香

2017/12/18

1.修改退出登陆时关闭页面动画闪动bug
2.重写需要刷新页面的mui.back方法
3.cid的条件之中增加不等于‘null’
parent 95faa338
...@@ -108,6 +108,45 @@ uPublic.closeSlideBack = function (){ ...@@ -108,6 +108,45 @@ uPublic.closeSlideBack = function (){
}); });
} }
//logout退出
uPublic.logout = function(opts){
iot.business.user.logout({
data: opts.data,
success: (response) => {
console.log("sdsLogout:"+response);
var sdsResponse = response;
iot.business.api.send('user/logout',{
data: {
key: ['clienId']
},
success: (response) => {
console.log("logout"+response)
iot.business.websql.delMaps(['utoken', 'userinfo'], (response) => {
iot.storage.delMaps(['notifyTime','alarmTime','openTime'], (response) => {
console.log("clearMap"+response);
opts.success(sdsResponse);
}, (error) => {
opts.error(error);
});
}, (error) => {
opts.error(error);
});
},
error: (error) => {
opts.error(error);
},
complete: () => {
opts.complete();
}
}, true, false);
},
error: (error) => {
opts.error(error);
},
complete: () => {}
});
}
iot.ready(() => { iot.ready(() => {
uPublic.recalc(); uPublic.recalc();
}); });
...@@ -147,15 +186,20 @@ iot.navigator.trigger = function (element, eventType, eventData) { ...@@ -147,15 +186,20 @@ iot.navigator.trigger = function (element, eventType, eventData) {
}; };
iot.navigator.closeAllBesidesItself = function () { iot.navigator.closeAllBesidesItself = function () {
setTimeout(function () {
var wvs = plus.webview.all(); var wvs = plus.webview.all();
var curWb = plus.webview.currentWebview(); var page = plus.webview.currentWebview();
for (var i = 0; i < wvs.length-1; i++) { for (var i = 0; i < wvs.length; i++) {
if (wvs[i].id != curWb.id) { if (wvs[i].id != page.id && wvs[i]) {
wvs[i].close(); // wvs[i].close();
plus.webview.close(wvs[i],"none",0,{});
} }
} }
var wvs = plus.webview.all();
}, 500);
} }
iot.navigator.closeAll = function (){ iot.navigator.closeAll = function (){
var wvs = plus.webview.all(); var wvs = plus.webview.all();
var curWb = plus.webview.currentWebview(); var curWb = plus.webview.currentWebview();
...@@ -165,9 +209,13 @@ iot.navigator.closeAll = function (){ ...@@ -165,9 +209,13 @@ iot.navigator.closeAll = function (){
} }
iot.ready(function(){ iot.ready(function(){
// plus.key.addEventListener('backbutton',iot.navigator.aback,false); plus.key.addEventListener('backbutton',iot.navigator.aback,false);
}) })
iot.navigator.aback = function(){
mui.back();
}
var __back__first = null; var __back__first = null;
mui.back = function(){ mui.back = function(){
...@@ -223,118 +271,119 @@ mui.back = function(){ ...@@ -223,118 +271,119 @@ mui.back = function(){
} }
} }
iot.navigator.getCurrentWebView = function (){ iot.navigator.getCurrentWebView = function (){
return plus.webview.currentWebview(); return plus.webview.currentWebview();
} }
function requestsend(url, opts, i){
let data = [0,0,0,0,0,0,0,1,0,0,0];
opts.success(data[i]);
}
function clearTime(interval, timeout){
window.clearInterval(interval);
window.clearTimeout(timeout);
}
uComponents.loop = function(request, timeout, interval, fincb, stopcondition){ //function requestsend(url, opts, i){
var handle = null; // let data = [0,0,0,0,0,0,0,1,0,0,0];
var time = null; // opts.success(data[i]);
var url = request.url; //}
var opts = request.opts; //
var intervalTime = interval.delay; //function clearTime(interval, timeout){
var intervalcb = interval.opts; // window.clearInterval(interval);
var flag = true; // window.clearTimeout(timeout);
var i = 0; //}
time = setTimeout(function(){ //
clearTime(handle, time); //uComponents.loop = function(request, timeout, interval, fincb, stopcondition){
intervalcb.error('timeout'); // var handle = null;
fincb.error('timeout'); // var time = null;
},timeout); // var url = request.url;
//一开始执行一次,发送一次请求 // var opts = request.opts;
requestsend(url, { // var intervalTime = interval.delay;
data: {}, // var intervalcb = interval.opts;
success: (response) => { // var flag = true;
intervalcb.success(response); // var i = 0;
if(stopcondition(response)){ // time = setTimeout(function(){
//首次请求结果符合条件的话,结束整个方法 // clearTime(handle, time);
fincb.success(response); // intervalcb.error('timeout');
clearTime(handle, time); // fincb.error('timeout');
}else{ // },timeout);
//首次请求结果不符合条件的话,每隔intervalTime时间发送请求 // //一开始执行一次,发送一次请求
handle = setInterval(() => { // requestsend(url, {
i++; // data: {},
console.log(i); // success: (response) => {
if(flag){ // intervalcb.success(response);
flag = false; // if(stopcondition(response)){
requestsend(url, { // //首次请求结果符合条件的话,结束整个方法
data: {}, // fincb.success(response);
success: (response) => { // clearTime(handle, time);
intervalcb.success(response); // }else{
if(stopcondition(response)){ // //首次请求结果不符合条件的话,每隔intervalTime时间发送请求
fincb.success(response); // handle = setInterval(() => {
clearTime(handle, time); // i++;
} // console.log(i);
flag = true; // if(flag){
}, // flag = false;
error: (error) => { // requestsend(url, {
intervalcb.error(error); // data: {},
fincb.error(error); // success: (response) => {
clearTime(handle, time); // intervalcb.success(response);
}, // if(stopcondition(response)){
complete: {} // fincb.success(response);
}, i); // clearTime(handle, time);
} // }
},intervalTime); // flag = true;
} // },
}, // error: (error) => {
error: (error) => { // intervalcb.error(error);
intervalcb.error(error); // fincb.error(error);
fincb.error(error); // clearTime(handle, time);
clearTime(handle, time); // },
}, // complete: {}
complete: {} // }, i);
}, 0); // }
// },intervalTime);
} // }
// },
//传递的参数依次是: // error: (error) => {
//1.request: 请求参数(数据类型: map,包括:url、header等); // intervalcb.error(error);
//2.timeout: 整个方法的超时时间; // fincb.error(error);
//3.interval: 发送请求的间隔时间、callback; // clearTime(handle, time);
//4.fincb: 整个方法的callback; // },
//5.stopcondition: 请求停止所要符合的条件 // complete: {}
uComponents.loop({url:'getLockInfo',opts: { // }, 0);
success: (response) => { //
console.log(response); //}
}, //
error: (error) => { ////传递的参数依次是:
console.log(error); ////1.request: 请求参数(数据类型: map,包括:url、header等);
} ////2.timeout: 整个方法的超时时间;
}}, 8000, { ////3.interval: 发送请求的间隔时间、callback;
delay: 1000, ////4.fincb: 整个方法的callback;
opts: { ////5.stopcondition: 请求停止所要符合的条件
success: (response) => { //uComponents.loop({url:'getLockInfo',opts: {
console.log('intervalcbSuccess:'+response); // success: (response) => {
}, // console.log(response);
error: (error) => { // },
console.log('intervalcbSuccess:'+error); // error: (error) => {
} // console.log(error);
} // }
}, { //}}, 8000, {
success: (response) => { // delay: 1000,
console.log('fincbSuccess:'+response); // opts: {
}, // success: (response) => {
error: (error) => { // console.log('intervalcbSuccess:'+response);
console.log('fincbError'+error); // },
} // error: (error) => {
}, (response) => { // console.log('intervalcbSuccess:'+error);
if(response == 1){ // }
return true; // }
}else{ //}, {
return false; // success: (response) => {
} // console.log('fincbSuccess:'+response);
}); // },
// error: (error) => {
// console.log('fincbError'+error);
// }
//}, (response) => {
// if(response == 1){
// return true;
// }else{
// return false;
// }
//});
export {iot, uPublic, uComponents} export {iot, uPublic, uComponents}
\ No newline at end of file
...@@ -35,7 +35,7 @@ class unotify{ ...@@ -35,7 +35,7 @@ class unotify{
i++; i++;
cid = self.getCidOnce(i); cid = self.getCidOnce(i);
console.log("第"+i+"次"+"获取的cid为"+cid); console.log("第"+i+"次"+"获取的cid为"+cid);
if(cid != null || i >= times){ if(cid != null && cid != 'null' || i >= times){
window.clearInterval(handle); window.clearInterval(handle);
resolve(cid); resolve(cid);
}else{ }else{
...@@ -43,7 +43,7 @@ class unotify{ ...@@ -43,7 +43,7 @@ class unotify{
i++; i++;
cid = self.getCidOnce(i); cid = self.getCidOnce(i);
console.log("第"+i+"次"+"获取的cid为"+cid); console.log("第"+i+"次"+"获取的cid为"+cid);
if(cid != null || i >= times){ if(cid != null && cid != 'null' || i >= times){
window.clearInterval(handle); window.clearInterval(handle);
resolve(cid); resolve(cid);
} }
...@@ -65,48 +65,37 @@ class unotify{ ...@@ -65,48 +65,37 @@ class unotify{
} }
} }
//长期不断循环获取cid,并更新cid //长期不断循环获取cid,并更新cid
static updateCid(successCallback, errorCallback){ // static async getCid(successCallback, errorCallback){
var cid = null; // var cid = null;
var oldCid = null; // var oldCid = null;
iot.storage.getMap('clientId',async (res) => { // try{
oldCid = res; // cid = await this.getCidPeriotic(9);
console.log("原来的cid为"+oldCid); // if(cid != null && cid != oldCid){
try{ // successCallback('cid updateSuccess');
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',{ // iot.business.api.send('user/updateCid',{
// data: { // data: {
// clientId: cid // clienId: cid
// }, // },
// success: (response) => { // success: (response) => {
// console.log(response); // if(typeof successCallback == 'function'){
// uccessCallback('cid updateSuccess');
// }
// }, // },
// error: (error) => { // error: (error) => {
// console.log(error); // console.log(error);
// errorCallback(error);
// }
// }, true, false);
// }else{
// successCallback('cid not updated');
// }
// }
// catch (err){
// console.log(err);
// if(typeof errorCallback == 'function'){
// errorCallback(err);
// }
// }
// } // }
// }, false);
}, () => {
});
}
}else{
successCallback('cid未更新');
}
}
catch (err){
console.log(err);
if(typeof errorCallback == 'function'){
errorCallback(a);
}
}
}, (err) => {
console.log(err);
});
}
} }
export default unotify; export default unotify;
\ No newline at end of file
...@@ -135,7 +135,7 @@ function passwordChange(self,text){ ...@@ -135,7 +135,7 @@ function passwordChange(self,text){
console.log('passwordChange: ' + self.textPassword); console.log('passwordChange: ' + self.textPassword);
} }
iot.navigator.aback = function(){ mui.back = function(){
iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{ }); iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{ });
iot.navigator.back(); iot.navigator.back();
} }
......
...@@ -149,7 +149,7 @@ function backTap(){ ...@@ -149,7 +149,7 @@ function backTap(){
iot.navigator.aback(); iot.navigator.aback();
} }
iot.navigator.aback = function(){ mui.back = function(){
iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{}); iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{});
console.log("fire"); console.log("fire");
iot.navigator.back(); iot.navigator.back();
......
...@@ -170,7 +170,7 @@ function backTap(){ ...@@ -170,7 +170,7 @@ function backTap(){
iot.navigator.aback(); iot.navigator.aback();
} }
iot.navigator.aback = function(){ mui.back = function(){
iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{}); iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{});
console.log("fire"); console.log("fire");
iot.navigator.back(); iot.navigator.back();
......
...@@ -18,6 +18,9 @@ function init() { ...@@ -18,6 +18,9 @@ function init() {
uPublic.closeSlideBack(); uPublic.closeSlideBack();
//通用 图片轮播、跑马灯、开关、按钮、dialog、loading组件 //通用 图片轮播、跑马灯、开关、按钮、dialog、loading组件
uPublic.componentsInit(['u-carousel','u-marquee','u-switch','u-button','u-dialog','u-loading','u-text','u-comm-loading']); uPublic.componentsInit(['u-carousel','u-marquee','u-switch','u-button','u-dialog','u-loading','u-text','u-comm-loading']);
if(iot.navigator.getExtras().needClose){
iot.navigator.closeAllBesidesItself();
}
const app = new Vue({ const app = new Vue({
data:{ data:{
//开门记录 //开门记录
...@@ -101,9 +104,9 @@ function init() { ...@@ -101,9 +104,9 @@ function init() {
remoteTime: null remoteTime: null
}, },
mounted(){ mounted(){
uComponents.showLoading(this);
notificationListener(this); notificationListener(this);
let self = this; let self = this;
iot.navigator.closeAllBesidesItself();
//获取设备信息 //获取设备信息
getDevices(this); getDevices(this);
//注册监听上报 //注册监听上报
...@@ -482,6 +485,7 @@ function getDevices(self){ ...@@ -482,6 +485,7 @@ function getDevices(self){
self.hijackAlarmFlag = false; self.hijackAlarmFlag = false;
self.setRemoteOpendoorDisabledFlag(true); self.setRemoteOpendoorDisabledFlag(true);
self.setValueRemoteOpendoor(0); self.setValueRemoteOpendoor(0);
uComponents.hideLoading(self);
} }
}, },
error: (error) => { error: (error) => {
...@@ -493,7 +497,8 @@ function getDevices(self){ ...@@ -493,7 +497,8 @@ function getDevices(self){
iotDebug.upload(iot,'获取设备信息'); iotDebug.upload(iot,'获取设备信息');
} }
uPublic.openRequestErrorAlert(self); uPublic.openRequestErrorAlert(self);
} },
complete: () => {}
}); });
} }
...@@ -714,6 +719,7 @@ function getLockInfo(self){ ...@@ -714,6 +719,7 @@ function getLockInfo(self){
console.log(error); console.log(error);
}, },
complete: () => { complete: () => {
uComponents.hideLoading(self);
} }
}); });
} }
......
...@@ -107,7 +107,7 @@ function backTap(){ ...@@ -107,7 +107,7 @@ function backTap(){
iot.navigator.aback(); iot.navigator.aback();
} }
iot.navigator.aback = function(){ mui.back = function(){
iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{}); iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{});
console.log("fire"); console.log("fire");
iot.navigator.back(); iot.navigator.back();
......
...@@ -262,7 +262,7 @@ function backTap(){ ...@@ -262,7 +262,7 @@ function backTap(){
iot.navigator.aback(); iot.navigator.aback();
} }
iot.navigator.aback = function(){ mui.back = function(){
iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{}); iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{});
console.log("fire"); console.log("fire");
iot.navigator.back(); iot.navigator.back();
......
...@@ -290,7 +290,7 @@ function sleep(time){ ...@@ -290,7 +290,7 @@ function sleep(time){
}) })
} }
iot.navigator.aback = function(){ mui.back = function(){
iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{}); iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{});
iot.navigator.back(); iot.navigator.back();
} }
......
...@@ -292,7 +292,7 @@ function setUserInfo(self, data){ ...@@ -292,7 +292,7 @@ function setUserInfo(self, data){
self.setUnbindShowFlag(data.user_id ? true : false); self.setUnbindShowFlag(data.user_id ? true : false);
} }
iot.navigator.aback = function(){ mui.back = function(){
let opener = plus.webview.currentWebview().opener(); let opener = plus.webview.currentWebview().opener();
if(opener.id == 'addUser'){ if(opener.id == 'addUser'){
opener.close(); opener.close();
......
...@@ -209,7 +209,7 @@ function backTap(){ ...@@ -209,7 +209,7 @@ function backTap(){
iot.navigator.aback(); iot.navigator.aback();
} }
iot.navigator.aback = function(){ mui.back = function(){
iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{}); iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{});
console.log("fire"); console.log("fire");
iot.navigator.back(); iot.navigator.back();
......
...@@ -77,8 +77,12 @@ function initComponentsConfig() { ...@@ -77,8 +77,12 @@ function initComponentsConfig() {
//tap < //tap <
function backTap(){ function backTap(){
iot.navigator.aback();
}
mui.back = function(){
iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{}); iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{});
console.log('returnPage'); console.log("fire");
iot.navigator.back(); iot.navigator.back();
} }
......
...@@ -15,6 +15,10 @@ function init() { ...@@ -15,6 +15,10 @@ function init() {
//通用 dialog、loading组件 //通用 dialog、loading组件
uPublic.componentsInit(['u-dialog','u-loading','u-button']); uPublic.componentsInit(['u-dialog','u-loading','u-button']);
uPublic.closeSlideBack(); uPublic.closeSlideBack();
//是否需要关闭其他页面
if(iot.navigator.getExtras().needClose){
iot.navigator.closeAllBesidesItself();
}
const app = new Vue({ const app = new Vue({
data:{ data:{
//配置组件 //配置组件
...@@ -193,7 +197,10 @@ function cloudsLogin(self, id){ ...@@ -193,7 +197,10 @@ function cloudsLogin(self, id){
iot.business.websql.setMaps(infoArray, () =>{ iot.business.websql.setMaps(infoArray, () =>{
iot.navigator.openWindow({ iot.navigator.openWindow({
url: '../device/index.html', url: '../device/index.html',
id: 'device' id: 'device',
extras: {
needClose: true
}
}); });
}, (error) => { }, (error) => {
console.log(error); console.log(error);
......
...@@ -108,7 +108,7 @@ function saveTap(self){ ...@@ -108,7 +108,7 @@ function saveTap(self){
} }
} }
iot.navigator.aback = function(){ mui.back() = function(){
iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{ }); iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{ });
iot.navigator.back(); iot.navigator.back();
} }
......
...@@ -108,12 +108,6 @@ function getInfo(self){ ...@@ -108,12 +108,6 @@ function getInfo(self){
}, },
error: (error) => { error: (error) => {
console.log(error); console.log(error);
// if(window.iotDebug){
// iotDebug.push('end: 获取用户信息'+JSON.stringify(error));
// }
// if (window.iotDebug) {
// iotDebug.upload(iot,'获取用户信息');
// }
uPublic.openRequestErrorAlert(self); uPublic.openRequestErrorAlert(self);
}, },
complete: () => {} complete: () => {}
...@@ -125,49 +119,55 @@ function logoutButtonTap(self){ ...@@ -125,49 +119,55 @@ function logoutButtonTap(self){
uComponents.openConfirm(self, Vue.t('myInfo.logoutDialogTip'), uComponents.openConfirm(self, Vue.t('myInfo.logoutDialogTip'),
{text: Vue.t('dialog.cancel'), callback: function () {}}, {text: Vue.t('dialog.cancel'), callback: function () {}},
{text: Vue.t('dialog.confirm'), callback: function () { {text: Vue.t('dialog.confirm'), callback: function () {
// uPublic.logout({
// data: {
// sds: true
// },
// success: (response) => {
// console.log(response);
// iot.navigator.openWindow({
// url: '../login/index.html',
// id: 'login',
// extras: {
// needClose: true
// }
// });
// },
// error: (error) => {
// console.log(error);
// },
// complete: () => {}
// });
iot.business.user.logout({ iot.business.user.logout({
data: { data: {},
sds: true
},
success: (response) => { success: (response) => {
console.log("sdsLogout:"+response);
let sdsResponse = response;
iot.business.websql.delMaps(['utoken', 'userinfo'], (response) => { iot.business.websql.delMaps(['utoken', 'userinfo'], (response) => {
console.log(response); iot.storage.delMaps(['notifyTime','alarmTime','openTime'], (response) => {
console.log("clearMap"+response);
//打开首页
iot.navigator.openWindow({
url: '../login/index.html',
id: 'login',
extras: {
needClose: true
}
});
}, (error) => { }, (error) => {
console.log(error); console.log(error);
// if(window.iotDebug){
// iotDebug.push('end: 清除tocken失败'+JSON.stringify(error));
// }
// if (window.iotDebug) {
// iotDebug.upload(iot,'清除tocken失败');
// }
uPublic.openRequestErrorAlert(self); uPublic.openRequestErrorAlert(self);
}); });
iot.storage.delMaps(['notifyTime','alarmTime','openTime'], (response) => { }, (error) => {
console.log(response); console.log(error);
}, () => { uPublic.openRequestErrorAlert(self);
});
iot.navigator.openWindow({
url: '../login/index.html',
id: 'login'
}); });
let wvs = plus.webview.all();
for (var i = 0; i < wvs.length-1; i++) {
plus.webview.close(wvs[i]);
}
}, },
error: (error) => { error: (error) => {
console.log(error); console.log(error);
if(window.iotDebug){
iotDebug.push('end: 退出登陆失败'+JSON.stringify(error));
}
if (window.iotDebug) {
iotDebug.upload(iot,'退出登陆失败');
}
uPublic.openRequestErrorAlert(self); uPublic.openRequestErrorAlert(self);
}, },
complete: () => { complete: () => {}
console.log("complete");
}
}); });
}} }}
); );
......
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