Commit 505e5da4 by 朱建香

1206

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