Commit 669e0628 by jenny

Merge branch 'zjx' into 'master'

Zjx

See merge request iot-project-js/doorlock!7
parents d66ebf1a 8ceb76ba
......@@ -39,7 +39,7 @@
"forgetPassword": "忘记密码",
"device": "U智锁",
"opendoorRecord": "开门记录",
"alarmInfo": "报警信息",
"alarmInfo": "报警记录",
"remoteOpendoor": "远程开门",
"hijackRecord": "劫持记录",
"doorlockManage": "门锁管理",
......
......@@ -39,7 +39,7 @@
"forgetPassword": "忘记密码",
"device": "U智锁",
"opendoorRecord": "开门记录",
"alarmInfo": "报警信息",
"alarmInfo": "报警记录",
"remoteOpendoor": "远程开门",
"hijackRecord": "劫持记录",
"doorlockManage": "门锁管理",
......
......@@ -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(() => {
uPublic.recalc();
});
......@@ -147,15 +186,20 @@ iot.navigator.trigger = function (element, eventType, eventData) {
};
iot.navigator.closeAllBesidesItself = function () {
setTimeout(function () {
var wvs = plus.webview.all();
var curWb = plus.webview.currentWebview();
for (var i = 0; i < wvs.length-1; i++) {
if (wvs[i].id != curWb.id) {
wvs[i].close();
var page = plus.webview.currentWebview();
for (var i = 0; i < wvs.length; i++) {
if (wvs[i].id != page.id && wvs[i]) {
// wvs[i].close();
plus.webview.close(wvs[i],"none",0,{});
}
}
var wvs = plus.webview.all();
}, 500);
}
iot.navigator.closeAll = function (){
var wvs = plus.webview.all();
var curWb = plus.webview.currentWebview();
......@@ -165,9 +209,13 @@ iot.navigator.closeAll = 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;
mui.back = function(){
......@@ -223,20 +271,22 @@ mui.back = function(){
}
}
iot.navigator.getCurrentWebView = function (){
return plus.webview.currentWebview();
}
function requestsend(url, opts, i){
opts.success(i);
}
function clearTime(interval, timeout){
window.clearInterval(interval);
window.clearTimeout(timeout);
}
//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){
// var handle = null;
// var time = null;
......@@ -246,7 +296,22 @@ function clearTime(interval, timeout){
// var intervalcb = interval.opts;
// var flag = true;
// var i = 0;
//
// time = setTimeout(function(){
// clearTime(handle, time);
// intervalcb.error('timeout');
// fincb.error('timeout');
// },timeout);
// //一开始执行一次,发送一次请求
// requestsend(url, {
// data: {},
// success: (response) => {
// intervalcb.success(response);
// if(stopcondition(response)){
// //首次请求结果符合条件的话,结束整个方法
// fincb.success(response);
// clearTime(handle, time);
// }else{
// //首次请求结果不符合条件的话,每隔intervalTime时间发送请求
// handle = setInterval(() => {
// i++;
// console.log(i);
......@@ -263,20 +328,32 @@ function clearTime(interval, timeout){
// flag = true;
// },
// error: (error) => {
// intervalcb.success(response);
// fincb.success(error);
// intervalcb.error(error);
// fincb.error(error);
// clearTime(handle, time);
// },
// complete: {}
// }, i);
// }
// },intervalTime);
//
// time = setTimeout(function(){
// }
// },
// error: (error) => {
// intervalcb.error(error);
// fincb.error(error);
// clearTime(handle, time);
// },timeout);
// },
// complete: {}
// }, 0);
//
//}
//
////传递的参数依次是:
////1.request: 请求参数(数据类型: map,包括:url、header等);
////2.timeout: 整个方法的超时时间;
////3.interval: 发送请求的间隔时间、callback;
////4.fincb: 整个方法的callback;
////5.stopcondition: 请求停止所要符合的条件
//uComponents.loop({url:'getLockInfo',opts: {
// success: (response) => {
// console.log(response);
......@@ -284,14 +361,14 @@ function clearTime(interval, timeout){
// error: (error) => {
// console.log(error);
// }
//}}, 10000, {
//}}, 8000, {
// delay: 1000,
// opts: {
// success: (response) => {
// console.log('intervalcbSuccess:'+response);
// },
// error: (error) => {
// console.log(error);
// console.log('intervalcbSuccess:'+error);
// }
// }
//}, {
......@@ -299,10 +376,10 @@ function clearTime(interval, timeout){
// console.log('fincbSuccess:'+response);
// },
// error: (error) => {
// console.log(error);
// console.log('fincbError'+error);
// }
//}, (response) => {
// if(response == 5){
// if(response == 1){
// return true;
// }else{
// return false;
......
......@@ -3,12 +3,19 @@
* unotify
*/
class unotify{
//在一个周期内获取cid
static async getCid(successCallback, errorCallback){
var a = null;
var cid = null;
try{
a = await this.getCidPeriotic(3);
//利用promise,直到执行完代码再获取cid
cid = await this.getCidPeriotic(3);
//获取后,在缓存中存储cid
if(typeof successCallback == 'function'){
successCallback(a);
iot.storage.setMap('clientId', cid, (res) => {
console.log("已成功保存cid"+cid);
successCallback(cid);
}, () => {
});
}
}
catch (err){
......@@ -18,6 +25,7 @@ class unotify{
}
}
}
//周期性获取cid,周期可调整
static getCidPeriotic(times){
var self = this;
return new Promise(function(resolve, reject){
......@@ -26,14 +34,16 @@ class unotify{
var handle = null;
i++;
cid = self.getCidOnce(i);
if(cid != null || i >= times){
console.log("第"+i+"次"+"获取的cid为"+cid);
if(cid != null && cid != 'null' || i >= times){
window.clearInterval(handle);
resolve(cid);
}else{
handle = setInterval(function(){
i++;
cid = self.getCidOnce(i);
if(cid != null || i >= times){
console.log("第"+i+"次"+"获取的cid为"+cid);
if(cid != null && cid != 'null' || i >= times){
window.clearInterval(handle);
resolve(cid);
}
......@@ -41,13 +51,51 @@ class unotify{
}
});
}
//单次获取cid
static getCidOnce(i){
var clientInfo = plus.push.getClientInfo();
if(clientInfo && clientInfo.hasOwnProperty('clientid') && clientInfo.clientid){
// if(i == 6){
return(clientInfo.clientid);
// }else{
// return(null);
// }
}else{
return(null);
}
}
//长期不断循环获取cid,并更新cid
// static async getCid(successCallback, errorCallback){
// var cid = null;
// var oldCid = null;
// try{
// cid = await this.getCidPeriotic(9);
// if(cid != null && cid != oldCid){
// successCallback('cid updateSuccess');
// iot.business.api.send('user/updateCid',{
// data: {
// clienId: cid
// },
// success: (response) => {
// if(typeof successCallback == 'function'){
// uccessCallback('cid updateSuccess');
// }
// },
// error: (error) => {
// console.log(error);
// errorCallback(error);
// }
// }, true, false);
// }else{
// successCallback('cid not updated');
// }
// }
// catch (err){
// console.log(err);
// if(typeof errorCallback == 'function'){
// errorCallback(err);
// }
// }
// }
}
export default unotify;
\ No newline at end of file
......@@ -13,6 +13,7 @@ iot.ready(init);
function init() {
//通用 list、dialog、loading组件
uPublic.componentsInit(['u-list','u-dialog','u-loading']);
uPublic.closeSlideBack();
const app = new Vue({
data:{
//配置组件
......
......@@ -13,6 +13,7 @@ iot.ready(init);
function init() {
//通用 dialog、loading组件
uPublic.componentsInit(['u-dialog','u-loading']);
uPublic.closeSlideBack();
const app = new Vue({
data:{
//配置组件
......
......@@ -14,6 +14,7 @@ function init() {
console.log("init" + new Date().getTime());
//通用 dialog、loading组件
uPublic.componentsInit(['u-dialog','u-loading']);
uPublic.closeSlideBack();
const app = new Vue({
data:{
//配置组件
......
......@@ -135,7 +135,7 @@ function passwordChange(self,text){
console.log('passwordChange: ' + self.textPassword);
}
iot.navigator.aback = function(){
mui.back = function(){
iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{ });
iot.navigator.back();
}
......
......@@ -13,6 +13,7 @@ iot.ready(init);
function init() {
//通用 按钮、dialog、loading组件
uPublic.componentsInit(['u-button','u-dialog','u-loading']);
uPublic.closeSlideBack();
const app = new Vue({
data:{
//配置组件
......
......@@ -149,7 +149,7 @@ function backTap(){
iot.navigator.aback();
}
iot.navigator.aback = function(){
mui.back = function(){
iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{});
console.log("fire");
iot.navigator.back();
......
......@@ -170,7 +170,7 @@ function backTap(){
iot.navigator.aback();
}
iot.navigator.aback = function(){
mui.back = function(){
iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{});
console.log("fire");
iot.navigator.back();
......
......@@ -15,9 +15,12 @@ import {iot, uPublic, uComponents} from '../../public/public.js';
iot.ready(init);
function init() {
uPublic.closeSlideBack();
//通用 图片轮播、跑马灯、开关、按钮、dialog、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({
data:{
//开门记录
......@@ -101,9 +104,9 @@ function init() {
remoteTime: null
},
mounted(){
uComponents.showLoading(this);
notificationListener(this);
let self = this;
iot.navigator.closeAllBesidesItself();
//获取设备信息
getDevices(this);
//注册监听上报
......@@ -482,6 +485,7 @@ function getDevices(self){
self.hijackAlarmFlag = false;
self.setRemoteOpendoorDisabledFlag(true);
self.setValueRemoteOpendoor(0);
uComponents.hideLoading(self);
}
},
error: (error) => {
......@@ -493,7 +497,8 @@ function getDevices(self){
iotDebug.upload(iot,'获取设备信息');
}
uPublic.openRequestErrorAlert(self);
}
},
complete: () => {}
});
}
......@@ -714,6 +719,7 @@ function getLockInfo(self){
console.log(error);
},
complete: () => {
uComponents.hideLoading(self);
}
});
}
......
......@@ -107,7 +107,7 @@ function backTap(){
iot.navigator.aback();
}
iot.navigator.aback = function(){
mui.back = function(){
iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{});
console.log("fire");
iot.navigator.back();
......
......@@ -262,7 +262,7 @@ function backTap(){
iot.navigator.aback();
}
iot.navigator.aback = function(){
mui.back = function(){
iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{});
console.log("fire");
iot.navigator.back();
......
......@@ -14,6 +14,7 @@ iot.ready(init);
function init() {
//通用 按钮、dialog、loading组件
uPublic.componentsInit(['u-button','u-dialog','u-loading']);
uPublic.closeSlideBack();
const app = new Vue({
data:{
//配置组件
......
......@@ -290,7 +290,7 @@ function sleep(time){
})
}
iot.navigator.aback = function(){
mui.back = function(){
iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{});
iot.navigator.back();
}
......
......@@ -292,7 +292,7 @@ function setUserInfo(self, data){
self.setUnbindShowFlag(data.user_id ? true : false);
}
iot.navigator.aback = function(){
mui.back = function(){
let opener = plus.webview.currentWebview().opener();
if(opener.id == 'addUser'){
opener.close();
......
......@@ -209,7 +209,7 @@ function backTap(){
iot.navigator.aback();
}
iot.navigator.aback = function(){
mui.back = function(){
iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{});
console.log("fire");
iot.navigator.back();
......
......@@ -77,8 +77,12 @@ function initComponentsConfig() {
//tap <
function backTap(){
iot.navigator.aback();
}
mui.back = function(){
iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{});
console.log('returnPage');
console.log("fire");
iot.navigator.back();
}
......
......@@ -13,6 +13,7 @@ iot.ready(init);
function init() {
//通用 input、按钮、dialog、loading组件
uPublic.componentsInit(['u-text','u-button','u-dialog','u-loading']);
uPublic.closeSlideBack();
const app = new Vue({
data:{
numberTel: null,
......
......@@ -15,6 +15,10 @@ function init() {
//通用 dialog、loading组件
uPublic.componentsInit(['u-dialog','u-loading','u-button']);
uPublic.closeSlideBack();
//是否需要关闭其他页面
if(iot.navigator.getExtras().needClose){
iot.navigator.closeAllBesidesItself();
}
const app = new Vue({
data:{
//配置组件
......@@ -193,7 +197,10 @@ function cloudsLogin(self, id){
iot.business.websql.setMaps(infoArray, () =>{
iot.navigator.openWindow({
url: '../device/index.html',
id: 'device'
id: 'device',
extras: {
needClose: true
}
});
}, (error) => {
console.log(error);
......
......@@ -13,6 +13,7 @@ iot.ready(init);
function init() {
//通用 input、按钮、dialog、loading组件
uPublic.componentsInit(['u-text','u-button','u-dialog','u-loading']);
uPublic.closeSlideBack();
const app = new Vue({
data:{
numberTel: null,
......
......@@ -13,6 +13,7 @@ iot.ready(init);
function init() {
//通用 input、按钮、dialog、loading组件
uPublic.componentsInit(['u-text','u-button','u-dialog','u-loading']);
uPublic.closeSlideBack();
const app = new Vue({
data:{
numberTel: null,
......
......@@ -108,7 +108,7 @@ function saveTap(self){
}
}
iot.navigator.aback = function(){
mui.back = function(){
iot.navigator.fire(plus.webview.currentWebview().opener(),'returnPage',{ });
iot.navigator.back();
}
......
......@@ -13,6 +13,7 @@ iot.ready(init);
function init() {
//通用 dialog、loading组件
uPublic.componentsInit(['u-dialog','u-loading','u-text']);
uPublic.closeSlideBack();
const app = new Vue({
data:{
//配置组件
......
......@@ -108,12 +108,6 @@ function getInfo(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: () => {}
......@@ -125,49 +119,55 @@ function logoutButtonTap(self){
uComponents.openConfirm(self, Vue.t('myInfo.logoutDialogTip'),
{text: Vue.t('dialog.cancel'), 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({
data: {
sds: true
},
data: {},
success: (response) => {
console.log("sdsLogout:"+response);
let sdsResponse = 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) => {
console.log(error);
// if(window.iotDebug){
// iotDebug.push('end: 清除tocken失败'+JSON.stringify(error));
// }
// if (window.iotDebug) {
// iotDebug.upload(iot,'清除tocken失败');
// }
uPublic.openRequestErrorAlert(self);
});
iot.storage.delMaps(['notifyTime','alarmTime','openTime'], (response) => {
console.log(response);
}, () => {
});
iot.navigator.openWindow({
url: '../login/index.html',
id: 'login'
}, (error) => {
console.log(error);
uPublic.openRequestErrorAlert(self);
});
let wvs = plus.webview.all();
for (var i = 0; i < wvs.length-1; i++) {
plus.webview.close(wvs[i]);
}
},
error: (error) => {
console.log(error);
if(window.iotDebug){
iotDebug.push('end: 退出登陆失败'+JSON.stringify(error));
}
if (window.iotDebug) {
iotDebug.upload(iot,'退出登陆失败');
}
uPublic.openRequestErrorAlert(self);
},
complete: () => {
console.log("complete");
}
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