Commit ca597bec by 朱建香

2017/12/26

#1.轮询方法完善(已完成)
2.整理less
#4.getCid用通用方法调用(已完成)
parent c605af96
...@@ -12,7 +12,7 @@ class Loop{ ...@@ -12,7 +12,7 @@ class Loop{
// this.url = params.request.url; // this.url = params.request.url;
// this.opts = params.request.opts; // this.opts = params.request.opts;
this.loopContent = params.loopContent; this.loopContent = params.loopContent;
this.timeout = params.timeout | 30; this.timeout = params.timeout || 10;
this.fincb = params.fincb; this.fincb = params.fincb;
this.intervalTime = params.interval.delay; this.intervalTime = params.interval.delay;
this.intervalcb = params.interval.cb; this.intervalcb = params.interval.cb;
...@@ -74,15 +74,15 @@ class Loop{ ...@@ -74,15 +74,15 @@ class Loop{
start(){ start(){
console.log("开始"); console.log("开始");
this.time = setTimeout(() => { // this.time = setTimeout(() => {
this.clearTime(); // this.clearTime();
this.canDo = false; // this.canDo = false;
this.fincb.error('timeout'); // this.fincb.error('timeout');
this.fincb.complete(); // this.fincb.complete();
console.log("超时"); // console.log("超时");
this.intervalcb = null; // this.intervalcb = null;
this.fincb = null; // this.fincb = null;
},this.timeout); // },this.timeout);
console.log("第"+this.i+"次发送了请求"); console.log("第"+this.i+"次发送了请求");
console.log("发送时间"+new Date().getTime()); console.log("发送时间"+new Date().getTime());
this.i++; this.i++;
...@@ -96,9 +96,22 @@ class Loop{ ...@@ -96,9 +96,22 @@ class Loop{
this.sendRequest(); this.sendRequest();
} }
},1000); },1000);
let times = 1;
this.handle = setInterval(() => { this.handle = setInterval(() => {
times++;
console.log('times'+times);
if(times > this.timeout){
this.clearTime();
this.canDo = false;
this.fincb.error('timeout');
this.fincb.complete();
this.intervalcb = null;
this.fincb = null;
}else{
this.canDo = true; this.canDo = true;
},3000); }
},this.intervalTime);
} }
} }
......
...@@ -2,10 +2,12 @@ ...@@ -2,10 +2,12 @@
* @class * @class
* unotify * unotify
*/ */
import uloop from './uloop';
class unotify{ class unotify{
//在一个周期内获取cid //在一个周期内获取cid
static async getCid(successCallback, errorCallback){ static getCid(successCallback, errorCallback){
UpdateCid((response) => { this.UpdateCid((response) => {
successCallback(response); successCallback(response);
}, (error) => { }, (error) => {
errorCallback(error); errorCallback(error);
...@@ -13,28 +15,76 @@ class unotify{ ...@@ -13,28 +15,76 @@ class unotify{
} }
//周期性获取cid,周期可调整 //周期性获取cid,周期可调整
static getCidPeriotic(times){ static getCidPeriotic(times){
// var self = this;
// return new Promise(function(resolve, reject){
// var i = 0;
// var cid = null;
// var handle = null;
// i++;
// cid = self.getCidOnce(i);
// 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);
// console.log("第"+i+"次"+"获取的cid为"+cid);
// if(cid != null && cid != 'null' || i >= times){
// window.clearInterval(handle);
// resolve(cid);
// }
// },1000);
// }
// });
var self = this; var self = this;
return new Promise(function(resolve, reject){ return new Promise(function(resolve, reject){
var i = 0; new uloop({
var cid = null; loopContent: () => {
var handle = null; // var urlParams = {
i++; // type: 'get',
cid = self.getCidOnce(i); // data: {},
console.log("第"+i+"次"+"获取的cid为"+cid); // };
if(cid != null && cid != 'null' || i >= times){ // return iot.network.send('http://192.168.2.75:3000/get', urlParams);
window.clearInterval(handle); console.log(self.getCidOnce());
resolve(cid); return self.getCidOnce();
}else{ },
handle = setInterval(function(){ timeout: times,
i++; interval:{
cid = self.getCidOnce(i); delay: 1000,
console.log("第"+i+"次"+"获取的cid为"+cid); cb: {
if(cid != null && cid != 'null' || i >= times){ success: (response) => {
window.clearInterval(handle); console.log('intervalcbSuccess:'+JSON.stringify(response));
resolve(cid); },
error: (error) => {
console.log('intervalcbError:'+JSON.stringify(error));
}
}
},
fincb: {
success: (response) => {
console.log('fincbSuccess:'+JSON.stringify(response));
resolve(response);
},
error: (error) => {
console.log('fincbSuccess:'+JSON.stringify(error));
if(error == 'timeout'){
resolve(null);
}
},
complete: () => {}
},
stopcondition: async (response) => {
// if(response.data.msg == 5){
// return true;
// }
if(response != null && response != 'null' ){
return true;
} }
},1000);
} }
}).start();
}); });
} }
//单次获取cid //单次获取cid
......
...@@ -12,7 +12,8 @@ import moment from 'moment'; ...@@ -12,7 +12,8 @@ import moment from 'moment';
import crypto from '../../public/crypto.js'; import crypto from '../../public/crypto.js';
import config from '../../public/config.js'; import config from '../../public/config.js';
import {iot, uPublic, uComponents} from '../../public/public.js'; import {iot, uPublic, uComponents} from '../../public/public.js';
import Loop from '../../public/loop.js'; import uloop from '../../public/uloop.js';
import unotify from '../../public/unotify.js';
iot.ready(init); iot.ready(init);
function init() { function init() {
...@@ -112,6 +113,11 @@ function init() { ...@@ -112,6 +113,11 @@ function init() {
getDevices(this); getDevices(this);
//注册监听上报 //注册监听上报
registerPushListener(this); registerPushListener(this);
unotify.getCid((response) => {
console.log(response);
},(error) => {
console.log(error);
});
let self = this; let self = this;
window.addEventListener('returnPage',function(event){ window.addEventListener('returnPage',function(event){
console.log('returnPage'); console.log('returnPage');
...@@ -500,6 +506,7 @@ function getLockInfo(self){ ...@@ -500,6 +506,7 @@ function getLockInfo(self){
}, },
error: (error) => { error: (error) => {
uPublic.openRequestErrorAlert(self); uPublic.openRequestErrorAlert(self);
initDeviceInfo(self);
console.log(error); console.log(error);
}, },
complete: () => { complete: () => {
...@@ -670,7 +677,7 @@ async function loopGetLockInfo(self, delay, timeout){ ...@@ -670,7 +677,7 @@ async function loopGetLockInfo(self, delay, timeout){
console.log(error); console.log(error);
} }
console.log(oldHistoryId); console.log(oldHistoryId);
new Loop({ new uloop({
loopContent: () => { loopContent: () => {
var urlParams = { var urlParams = {
type: 'post', type: 'post',
...@@ -682,7 +689,7 @@ async function loopGetLockInfo(self, delay, timeout){ ...@@ -682,7 +689,7 @@ async function loopGetLockInfo(self, delay, timeout){
return iot.business.api.send('lock/getNewInfo', urlParams, true, false); return iot.business.api.send('lock/getNewInfo', urlParams, true, false);
// return plus.push.getClientInfo().clientid; // return plus.push.getClientInfo().clientid;
}, },
timeout: config.getHistoryTime*1000, timeout: 3,
interval:{ interval:{
delay: config.intervalTime*1000, delay: config.intervalTime*1000,
cb: { cb: {
......
...@@ -77,14 +77,6 @@ function init() { ...@@ -77,14 +77,6 @@ function init() {
setRole(role){ setRole(role){
this.role = role; this.role = role;
}, },
//
// onSwipeLeftRow(index){
// swipeLeftRow(this, index);
// },
// onSwipeRightRow(){
// swipeRightRow(this);
// },
//
onTapLoad(){ onTapLoad(){
// tapLoad(); // tapLoad();
}, },
...@@ -132,12 +124,6 @@ function getUserList(self){ ...@@ -132,12 +124,6 @@ function getUserList(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: () => {
...@@ -146,7 +132,6 @@ function getUserList(self){ ...@@ -146,7 +132,6 @@ function getUserList(self){
}); });
} }
//
function sortRule(a,b){ function sortRule(a,b){
return a.role - b.role; return a.role - b.role;
} }
...@@ -228,16 +213,7 @@ function addUserTap(self){ ...@@ -228,16 +213,7 @@ function addUserTap(self){
} }
}); });
} }
//
//// 向左滑动用户列表,修改用户列表下标
//function swipeLeftRow(self, index) {
// self.userListIndex = index;
//}
//// 向右滑动用户列表,修改用户列表下标
//function swipeRightRow(self) {
// self.userListIndex = null;
//}
//
// 点击组件列表 通知事件和当前点击列表下标 // 点击组件列表 通知事件和当前点击列表下标
function onTapUserList(self, listIndex) { function onTapUserList(self, listIndex) {
iot.navigator.openWindow({ iot.navigator.openWindow({
...@@ -291,12 +267,6 @@ function deleteUser(self, index){ ...@@ -291,12 +267,6 @@ function deleteUser(self, index){
}, },
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,'删除用户失败');
// }
uComponents.openAlert(self, Vue.t('doorlockUser.deleteFailure'), { uComponents.openAlert(self, Vue.t('doorlockUser.deleteFailure'), {
text: Vue.t('btn.confirm'), callback: function () { text: Vue.t('btn.confirm'), callback: function () {
} }
......
...@@ -98,6 +98,30 @@ function qrcodeButtonTap(self){ ...@@ -98,6 +98,30 @@ function qrcodeButtonTap(self){
let data = uPublic.checkResponseData(response.data); let data = uPublic.checkResponseData(response.data);
if(data){ if(data){
let qrKey = response.data.qrKey; let qrKey = response.data.qrKey;
createQrcode(self, qrKey);
}else{}
},
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);
}
});
setTimeout(() => {
self.setQrCodeDisabled(true);
},config.qrcode_timeout)
}
function createQrcode(self, qrKey){
let data = { let data = {
qrKey: qrKey, qrKey: qrKey,
lockId: self.extras.lockId, lockId: self.extras.lockId,
...@@ -113,7 +137,6 @@ function qrcodeButtonTap(self){ ...@@ -113,7 +137,6 @@ function qrcodeButtonTap(self){
console.log(error) console.log(error)
} else { } else {
console.log('success'); console.log('success');
uComponents.hideLoading(self);
qr.style.width = "5.333rem"; qr.style.width = "5.333rem";
qr.style.height = "5.333rem"; qr.style.height = "5.333rem";
console.log(qr.style); console.log(qr.style);
...@@ -122,21 +145,4 @@ function qrcodeButtonTap(self){ ...@@ -122,21 +145,4 @@ function qrcodeButtonTap(self){
},qrcode_timeout); },qrcode_timeout);
} }
}); });
}else{}
},
error: (error) => {
console.log(error);
if(window.iotDebug){
iotDebug.push('end: 生成二维码失败'+JSON.stringify(error));
}
if (window.iotDebug) {
iotDebug.upload(iot,'生成二维码失败');
}
//请求失败
uPublic.openRequestErrorAlert(self);
}
});
setTimeout(() => {
self.setQrCodeDisabled(true);
},config.qrcode_timeout)
} }
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
*/ */
import {iot, uPublic, uComponents} from '../../public/public.js'; import {iot, uPublic, uComponents} from '../../public/public.js';
import unotify from '../../public/unotify.js';
iot.ready(init); iot.ready(init);
function init() { function init() {
...@@ -31,9 +31,6 @@ function init() { ...@@ -31,9 +31,6 @@ function init() {
iotDebug.push('start: Debug'); iotDebug.push('start: Debug');
} }
var self = this; var self = this;
// unotify.getCid(function(ret){
// console.log(ret);
// self.setClientId(ret);
if (plus.os.name == 'Android') { if (plus.os.name == 'Android') {
iot.permission.checkPermission(['READ_EXTERNAL_STORAGE'], function (res) { iot.permission.checkPermission(['READ_EXTERNAL_STORAGE'], function (res) {
console.log('success', res); console.log('success', res);
...@@ -44,10 +41,6 @@ function init() { ...@@ -44,10 +41,6 @@ function init() {
}else{ }else{
loginButtonTap(self); loginButtonTap(self);
} }
// },function(err){
// console.log(err);
// })
console.log('innnnnnn');
}, },
methods:{ methods:{
getShowLoginButtonFlag(){ getShowLoginButtonFlag(){
...@@ -93,23 +86,8 @@ function initComponentsConfig() { ...@@ -93,23 +86,8 @@ function initComponentsConfig() {
} }
} }
//sds登陆
function loginButtonTap(self){ function loginButtonTap(self){
// if(window.iotDebug){
// iotDebug.push('start: initSDSLogin');
// }
// window.SDSPlugin.login({},(res)=>{
// console.log(res);
//// alert(res);
// var data = uPublic.checkResponseData(res.data);
// if(data){
//// alert("sds登陆成功");
// cloudsLogin(self, data.UserID);
// }
// },(err)=>{
// alert(error);
// console.log(err);
// })
console.log("loginButton");
iot.business.sds.checkSDSInit({ iot.business.sds.checkSDSInit({
data: {}, data: {},
success: (response) => { success: (response) => {
...@@ -168,9 +146,9 @@ console.log("loginButton"); ...@@ -168,9 +146,9 @@ console.log("loginButton");
}, },
complete: () => {} complete: () => {}
}); });
} }
//云端登陆
function cloudsLogin(self, id){ function cloudsLogin(self, id){
uComponents.showLoading(self); uComponents.showLoading(self);
if(window.iotDebug){ if(window.iotDebug){
...@@ -179,8 +157,8 @@ function cloudsLogin(self, id){ ...@@ -179,8 +157,8 @@ function cloudsLogin(self, id){
iot.business.api.send('user/sds_login',{ iot.business.api.send('user/sds_login',{
data: { data: {
username: id, username: id,
clienId: self.getClientId() // clienId: self.getClientId()
// clienId: null clienId: null
}, },
success: (response) => { success: (response) => {
if(window.iotDebug){ if(window.iotDebug){
......
...@@ -119,26 +119,6 @@ function logoutButtonTap(self){ ...@@ -119,26 +119,6 @@ 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: () => {}
// });
console.log("logout");
iot.business.user.logout({ iot.business.user.logout({
data: { data: {
// sds: false // sds: false
......
...@@ -187,6 +187,7 @@ ...@@ -187,6 +187,7 @@
.custom-comm-loading(); .custom-comm-loading();
//
.scanContent { .scanContent {
position: fixed; position: fixed;
top: 1.173rem; top: 1.173rem;
......
...@@ -469,3 +469,14 @@ ...@@ -469,3 +469,14 @@
.remoteOpendoorPage{ .remoteOpendoorPage{
.mask(1051,@BODY-BG-COLOR); .mask(1051,@BODY-BG-COLOR);
} }
//
.custom-marquee .u-marquee-text {
display: block;
line-height: 0.96rem;
}
.active .u-marquee-text {
-webkit-animation: none;
animation: none;
}
\ No newline at end of file
...@@ -220,6 +220,11 @@ ...@@ -220,6 +220,11 @@
} }
} }
//
.nameDisabled:before{
display: none;
}
.custom-isClearSwitch-switch { .custom-isClearSwitch-switch {
width: 5.333rem; width: 5.333rem;
height: auto; height: auto;
......
...@@ -329,3 +329,8 @@ ...@@ -329,3 +329,8 @@
} }
.mediaPosition(true); .mediaPosition(true);
//
.userInfo-title-disabled:after {
display: none;
}
\ No newline at end of file
...@@ -224,14 +224,14 @@ ...@@ -224,14 +224,14 @@
&.u-switch-on .u-switch-handle{ &.u-switch-on .u-switch-handle{
background-color: transparent; background-color: transparent;
&:before{ &:before{
content: '\e6a9'; content: '\e6aa';
left: 0; left: 0;
} }
} }
&.u-switch-off .u-switch-handle{ &.u-switch-off .u-switch-handle{
background-color: transparent; background-color: transparent;
&:before{ &:before{
content: '\e6aa'; content: '\e6a9';
left: 0; left: 0;
} }
} }
......
...@@ -1199,7 +1199,7 @@ p { ...@@ -1199,7 +1199,7 @@ p {
} }
.u-marquee .u-marquee-text { .u-marquee .u-marquee-text {
/*display: inline-block;*/ display: inline-block;
line-height: 0.667rem; line-height: 0.667rem;
} }
...@@ -1212,6 +1212,7 @@ p { ...@@ -1212,6 +1212,7 @@ p {
.custom-marquee .u-marquee-text { .custom-marquee .u-marquee-text {
line-height: 0.96rem; line-height: 0.96rem;
display: block;
} }
.custom-marquee:before { .custom-marquee:before {
...@@ -1248,7 +1249,7 @@ p { ...@@ -1248,7 +1249,7 @@ p {
color: #91929a; color: #91929a;
} }
/*.active .u-marquee-text { .active .u-marquee-text {
-webkit-animation: marquee 5s linear infinite; -webkit-animation: marquee 5s linear infinite;
animation: marquee 5s linear infinite; animation: marquee 5s linear infinite;
} }
...@@ -1263,9 +1264,9 @@ p { ...@@ -1263,9 +1264,9 @@ p {
-webkit-transform: translate(0,-100%); -webkit-transform: translate(0,-100%);
transform: translate(0,-100%); transform: translate(0,-100%);
} }
}*/ }
/*@keyframes marquee { @keyframes marquee {
from { from {
-webkit-transform: translate(0,0.533rem); -webkit-transform: translate(0,0.533rem);
transform: translate(0,0.533rem); transform: translate(0,0.533rem);
...@@ -1275,7 +1276,7 @@ p { ...@@ -1275,7 +1276,7 @@ p {
-webkit-transform: translate(0,-100%); -webkit-transform: translate(0,-100%);
transform: translate(0,-100%); transform: translate(0,-100%);
} }
}*/ }
.deviceHandle { .deviceHandle {
position: absolute; position: absolute;
...@@ -1621,3 +1622,13 @@ p { ...@@ -1621,3 +1622,13 @@ p {
z-index: 1051; z-index: 1051;
background-color: #242635; background-color: #242635;
} }
.custom-marquee .u-marquee-text {
display: block;
line-height: 0.96rem;
}
.active .u-marquee-text {
-webkit-animation: none;
animation: none;
}
\ No newline at end of file
...@@ -849,10 +849,6 @@ p { ...@@ -849,10 +849,6 @@ p {
line-height: 1; line-height: 1;
} }
.nameDisabled:before{
display: none;
}
.doorlockManage li:after { .doorlockManage li:after {
content: ''; content: '';
position: absolute; position: absolute;
...@@ -958,47 +954,8 @@ p { ...@@ -958,47 +954,8 @@ p {
left: 0; left: 0;
} }
.unbindState-dialog { .nameDisabled:before {
position: fixed; display: none;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1051;
background-color: rgba(36, 38, 53, 0.9);
}
.unbindState-dialog div {
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
width: 8.933rem;
height: 5.68rem;
display: -webkit-box;
display: -webkit-flex;
display: flex;
-webkit-box-orient: vertical;
-webkit-flex-direction: column;
flex-direction: column;
-webkit-box-pack: center;
-webkit-justify-content: center;
justify-content: center;
-webkit-box-align: center;
-webkit-align-items: center;
align-items: center;
color: #00ffff;
font-size: 0.427rem;
border: 1px solid;
border-radius: 0.133rem;
}
.unbindState-dialog div img {
display: block;
width: 1.733rem;
height: 1.733rem;
margin-bottom: 0.373rem;
} }
.custom-isClearSwitch-switch { .custom-isClearSwitch-switch {
...@@ -1061,3 +1018,46 @@ p { ...@@ -1061,3 +1018,46 @@ p {
content: '\e6a9'; content: '\e6a9';
left: 0; left: 0;
} }
.unbindState-dialog {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1051;
background-color: rgba(36, 38, 53, 0.9);
}
.unbindState-dialog div {
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
width: 8.933rem;
height: 5.68rem;
display: -webkit-box;
display: -webkit-flex;
display: flex;
-webkit-box-orient: vertical;
-webkit-flex-direction: column;
flex-direction: column;
-webkit-box-pack: center;
-webkit-justify-content: center;
justify-content: center;
-webkit-box-align: center;
-webkit-align-items: center;
align-items: center;
color: #00ffff;
font-size: 0.427rem;
border: 1px solid;
border-radius: 0.133rem;
}
.unbindState-dialog div img {
display: block;
width: 1.733rem;
height: 1.733rem;
margin-bottom: 0.373rem;
}
\ No newline at end of file
...@@ -723,10 +723,6 @@ p { ...@@ -723,10 +723,6 @@ p {
line-height: 1; line-height: 1;
} }
.userInfo-title-disabled:after {
display: none;
}
.userInfoLink li.userInfo .userInfo-subtitle { .userInfoLink li.userInfo .userInfo-subtitle {
position: relative; position: relative;
} }
...@@ -1099,3 +1095,7 @@ p { ...@@ -1099,3 +1095,7 @@ p {
bottom: 1.2rem; bottom: 1.2rem;
} }
} }
.userInfo-title-disabled:after {
display: none;
}
\ No newline at end of file
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