Commit 505e5da4 by 朱建香

1206

parent 7a4ccf81
......@@ -37,6 +37,7 @@ class I18NPackage{
}
apply(compiler){
langGroup = getAllLang(langPath,componentPath);
compiler.plugin("watch-run", (compilation, callback) => {
if(!this.watching){
this.watching = true;
......
......@@ -230,7 +230,9 @@
"userList":{
"name": "昵称:",
"noUserTip": "暂无用户",
"defaultName": "管理员"
"defaultName": "管理员",
"binded": "已绑定",
"unbind": "未绑定"
},
"addUser":{
"nameInputTip": "请输入您想添加的用户名",
......
......@@ -234,4 +234,32 @@ iot.navigator.getCurrentWebView = function (){
return plus.webview.currentWebview();
}
uPublic.loopUtils = function(func, opts, intervalTime, time){
var _this = this;
var params = _extends({}, opts);
var loop = function loop() {
var handle = setTimeout(function () {
_this.loopUtils(func, opts, intervalTime, time);
window.clearTimeout(handle);
}, intervalTime);
};
params.success = function (ret) {
if (opts.success(ret) === false) {
return;
}
loop();
};
params.error = function (err) {
if (opts.error(err) === false) {
return;
}
loop();
};
func();
var timeout = setTimeout(function (){
window.clearTimeout(handle);
window.clearTimeout(timeout);
}, time);
}
export {iot, uPublic, uComponents}
\ No newline at end of file
......@@ -67,6 +67,10 @@ function init() {
mac: null,
//设备uuid
uuid: null,
//设备model
model: null,
//sds设备用户信息
userInfo: null,
//门锁id
lockId: null,
//获取用户的身份
......@@ -89,7 +93,10 @@ function init() {
//远程开门错误提示
textErrorTip: null,
//当前状态
status: 0
status: 0,
flag: true,
time: null,
timeout: null
},
mounted(){
notificationListener(this);
......@@ -105,6 +112,17 @@ function init() {
//注册监听上报
registerPushListener(self);
});
// uPublic.loopUtils(function(){
// console.log('1233434');
// }, {
// success: (response) => {
// console.log('success');
// },
// error: (err) => {
// console.log(err);
// }
// }, 1, 30000);
// ringBell(this);sss
},
methods:{
setValueRemoteOpendoor(value){
......@@ -415,13 +433,50 @@ function initComponentsConfig() {
}
}
function loopGetLockInfo(self, delay, timeout, ){
var handle = setInterval(function(){
getLockInfo(self);
},delay*1000);
setTimeout(function () {
window.clearInterval(handle);
}, timeout * 1000);
}
function getDevices(self){
iot.business.sds.getDevicesByUser({
success: (response) => {
console.log(response);
// alert(JSON.stringify(response));
let data = uPublic.checkResponseData(response.data);
if(response.data == 'success'){
if(data){
self.mac = data[0].mac;
self.deviceId = data[0].sn;
self.uuid = data[0].uuid;
self.model = data[0].model;
if(self.uuid){
iot.business.device.getInfo({
data: {
sds: true,
uuid: self.uuid
},
success: (response) => {
console.log("getInfo");
console.log(response);
let data = uPublic.checkResponseData(response.data);
if(data){
console.log(data);
if(data.hasOwnProperty('relAccounts')){
self.userInfo = data.relAccounts;
getLockInfo(self);
}
}
},
error: (error) => {
console.log(error);
},
complete: () => {}
});
}
}else{
setValueOfSwitch(self, true);
self.setLockId(null);
self.mac = null;
......@@ -432,11 +487,6 @@ function getDevices(self){
self.opendoorRecordFlag = false;
self.securityAlarmFlag = false;
self.hijackAlarmFlag = false;
}else if(data){
self.mac = data[0].mac;
self.deviceId = data[0].sn;
self.uuid = data[0].uuid;
getLockInfo(self);
}
},
error: (error) => {
......@@ -455,9 +505,9 @@ function getDevices(self){
function registerPushListener(self){
iot.business.sds.registerPushListener({
success: (response) => {
let data = response.data;
console.log("registerPushListener");
console.log(data);
console.log(response);
let data = response.data;
setDevceInfo(self, data.params.data);
},
error: (error) => {
......@@ -474,9 +524,6 @@ function registerPushListener(self){
}
async function getRecordTime(self, data){
// let notifyTime = null;
// let alarmTime = null;
// let openTime = null;
try{
self.notifyTime = await getRecordTimeMap('notifyTime');
}
......@@ -615,7 +662,9 @@ function getLockInfo(self){
console.log("getLockInfo");
iot.business.api.sendCustom('lock/getLockInfo',{
data: {
device_id: self.deviceId
device_id: self.deviceId,
// product_id: self.model,
// userinfo: self.userInfo
},
success: (response) => {
console.log(response);
......@@ -697,6 +746,8 @@ function getLockInfo(self){
//设置设备信息
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){
......@@ -709,8 +760,10 @@ function setDevceInfo(self, data) {
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"));
ringBell(self);
......@@ -730,13 +783,13 @@ function setDevceInfo(self, data) {
},(300-now.diff(time,'seconds'))*1000);
}
}else if(data.notify_type.value == 2){
// getLockInfo(self);
}else if(notifyMode.indexOf(data.notify_type.value) != -1){
loopGetLockInfo(self, 1, 10);
}
}
if(data.action.value == 'lock_log' && (data.lock_action.value == '1' || data.lock_action.value == '4')){
//开门或远程开门成功
// getLockInfo(self);
loopGetLockInfo(self, 1, 10);
if(data.lock_action.value == '4'){
uComponents.changeCommLoadingStatusAndText(self, 1, Vue.t('remoteOpendoor.openDoorSuccess'));
uComponents.changeCommButtonText(self, Vue.t('btn.confirm'));
......@@ -752,32 +805,51 @@ function setDevceInfo(self, data) {
self.setStatus(2);
}
}
async function ringBell(self){
self.setRingTime(0);
try{
self.setRingTime(config.ring_time/(config.shake_times+config.await_time));
for(let i =0 ; i< self.getRingTime();){
function ringBell(self){
window.clearInterval(self.time);
window.clearTimeout(self.timeout);
let intervalTime = 10000;
let i = 0;
simpleRingBell(self,i);
self.time = setInterval(function(){
i++;
simpleRingBell(self,i);
},intervalTime);
}
function simpleRingBell(self,i){
window.clearTimeout(self.timeout);
self.setDoorbellRingingFlag(true);
let time = await sleep(1000*config.shake_times);
let p = plus.audio.createPlayer( "_../../resources/audio/tipSound2.mp3" );
p.play( function () {
console.log( "Audio play success!" );
}, function ( e ) {
console.log( "Audio play error: " + e.message );
});
self.timeout = setTimeout(function(){
p = plus.audio.createPlayer( "_../../resources/audio/tipSound2.mp3" );
p.play( function () {
console.log( "Audio play success!" );
}, function ( e ) {
console.log( "Audio play error: " + e.message );
});
window.clearTimeout(self.timeout);
self.timeout = setTimeout(function(){
self.setDoorbellRingingFlag(false);
time = await sleep(config.await_time);
i++;
window.clearTimeout(self.timeout);
if(i>2){
window.clearInterval(self.time);
}
},3000);
if(i>2){
window.clearInterval(self.time);
}
catch (err){
console.log(err);
},2000);
if(i>2){
window.clearInterval(self.time);
}
}
function sleep(time){
return new Promise(function(resolve, reject){
let timeOut = setTimeout(()=>{
resolve(time);
clearTimeout(timeOut);
},time);
})
}
function pushAction(self, msg) {
var payload = msg.payload;
console.log(payload);
......@@ -799,7 +871,9 @@ function pushAction(self, msg) {
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){
ringBell(self);
if(!self.getRingTime()){
// ringBell(self);
}
}
}else if(payload.type == "remoteOpen"){
//远程开门通知
......
......@@ -286,7 +286,7 @@ function setUserInfo(self, data){
image: data.role == 0 ? '../../resources/image/green_admin_icon.png' : data.user_id == null ? '../../resources/image/gray_unbindHead_icon.png' : '../../resources/image/green_bindHead_icon.png',
role: data.role,
title: data.nickname,
subtitle: data.username
subtitle: ''
}
self.setBindShowFlag(data.user_id ? false : true);
self.setUnbindShowFlag(data.user_id ? true : false);
......
......@@ -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
subtitle: data[i].username ? Vue.t('userList.binded'):Vue.t('userList.unbind')
}
}
console.log(data);
......
......@@ -9740,6 +9740,34 @@ iot.navigator.getCurrentWebView = function () {
return plus.webview.currentWebview();
};
uPublic.loopUtils = function (func, opts, intervalTime, time) {
var _this = this;
var params = _extends({}, opts);
var loop = function loop() {
var handle = setTimeout(function () {
_this.loopUtils(func, opts, intervalTime, time);
window.clearTimeout(handle);
}, intervalTime);
};
params.success = function (ret) {
if (opts.success(ret) === false) {
return;
}
loop();
};
params.error = function (err) {
if (opts.error(err) === false) {
return;
}
loop();
};
func();
var timeout = setTimeout(function () {
window.clearTimeout(handle);
window.clearTimeout(timeout);
}, time);
};
exports.iot = iot;
exports.uPublic = uPublic;
exports.uComponents = uComponents;
......
......@@ -33,7 +33,7 @@
<v-touch tag="p" class="userInfo-title" v-bind:class="{'userInfo-title-disabled': role}" v-on:tap="onEditNameTap">{{ userInfo.title == (null || '') ? $t('doorlockUser.defaultName') : userInfo.title}}</v-touch>
<p class="userInfo-subtitle">
<img class="userInfo-subimage" v-if="userInfo.image && userInfo.role != 0" v-bind:src="userInfo.image">
{{ $t('doorlockUser.name') }}<span class="userInfo-name" v-if="userInfo.subtitle">{{ userInfo.subtitle }}</span>
<!--<span class="userInfo-name" v-if="userInfo.subtitle">{{ userInfo.subtitle }}</span>-->
<v-touch tag="span" class="userInfo-toBind" v-show="bindShowFlag && !role" v-on:tap="onBindTap">{{ $t('doorlockUser.inviteBind') }}</v-touch>
<u-button :init-param="componentsConfig.unbindButton.initParam" v-on:u-button-tap="onUnbindButtonTap" v-show="(unbindShowFlag && !role && userInfo.role != 0)"></u-button>
</p>
......
......@@ -1136,7 +1136,7 @@ function setUserInfo(self, data) {
image: data.role == 0 ? '../../resources/image/green_admin_icon.png' : data.user_id == null ? '../../resources/image/gray_unbindHead_icon.png' : '../../resources/image/green_bindHead_icon.png',
role: data.role,
title: data.nickname,
subtitle: data.username
subtitle: ''
};
self.setBindShowFlag(data.user_id ? false : true);
self.setUnbindShowFlag(data.user_id ? true : false);
......
......@@ -36,7 +36,7 @@
<p class="user-list-title">{{ item.title == (null || '')? $t('userList.defaultName'):item.title}}</p>
<p class="user-list-subtitle">
<img class="user-list-subimage" v-if="item.image && item.role != 0" v-bind:src="item.image">
{{ $t('userList.name') }}<span v-if="item.subtitle">{{ item.subtitle }}</span>
<span v-if="item.subtitle">{{ item.subtitle }}</span>
</p>
</div>
</v-touch>
......
......@@ -1019,7 +1019,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
subtitle: data[i].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