Commit 05505326 by 朱建香

1108

parent 18a27276
......@@ -188,6 +188,13 @@
"helpCont4": "(提示:如果指纹锁已经绑定过用户,重新绑定成功后会清除之前所有绑定信息)"
},
"wifiAdd": {
"unbindWifiTip": "当前无Wi-Fi",
"wifiBinding": "配网中",
"wifiBindSuccess": "配网成功,请激活设备",
"deviceActivating": "设备激活中",
"deviceActivateSuccess":"激活成功",
"deviceActivateFailure":"激活失败",
"bindTimeout":"连接超时",
"passwordInputTip": "请输入Wi-Fi密码",
"remindTitle": "配置Wi-Fi提醒:",
"remindCont1": "1. 请确保Wi-Fi信号良好",
......
......@@ -37,7 +37,7 @@ class crypto{
let key = CryptoJS.enc.Utf8.parse(keyIv.key);
let iv = CryptoJS.enc.Utf8.parse(keyIv.iv);;
let decryptedData = CryptoJS.AES.decrypt(code, key, { iv: iv},{ mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.nopadding });
return JSON.parse(decryptedData.toString(CryptoJS.enc.Utf8));
return decryptedData.toString(CryptoJS.enc.Utf8);
}
}
......
......@@ -73,7 +73,7 @@ function getDeviceList(self){
self.setDeviceList(data);
for(let i =0; i<data.length; i++){
list[i] = {
leftImage: '../../resources/image/deviceImg.png',
leftImage: data[i].icon,
title: data[i].deviceName,
subtitle: Vue.t('deviceList.model')+data[i].model,
rightIcon: '&#xe6a7;'
......
......@@ -135,10 +135,11 @@ function backTap(){
//tap 连接
function connectButtonTap(self){
console.log(self.getTextWiFiName());
// self.setTextPassword('macro_scope00');
console.log(self.getTextPassword());
if(self.getTextPassword() == null || self.getTextPassword().trim() == ''){
// console.log(self.getTextWiFiName());
// console.log(self.getTextPassword());
if(self.getTextWiFiName() == null || self.getTextWiFiName().trim() == ''){
self.setTextErrorTip(Vue.t('wifiAdd.unbindWifiTip'));
}else if(self.getTextPassword() == null || self.getTextPassword().trim() == ''){
self.setTextErrorTip(Vue.t('wifiAdd.passwordInputTip'));
}else{
iot.business.sds.findWifi({
......@@ -154,12 +155,14 @@ function connectButtonTap(self){
if(response.data == 'onProvisioning'){
//wifi链接中
uComponents.showCommLoading(self);
uComponents.changeCommLoadingStatusAndText(self, 0, Vue.t('wifiAdd.wifiBinding'));
}else if(response.data == 'provisioned success'){
//wifi连接成功,停止连接wifi
// iot.business.sds.stopFindWifi({
// success: (response) => {},
// error: (error) => {}
// });
uComponents.changeCommLoadingStatusAndText(self, 0, Vue.t('wifiAdd.wifiBindSuccess'));
// iot.business.sds.stopFindWifi({
// success: (response) => {},
// error: (error) => {}
// });
}
},
error: (error) => {
......@@ -169,32 +172,17 @@ function connectButtonTap(self){
let deviceId = null;
iot.business.sds.findDevices({
success: (response) => {
console.log("findDevices");
console.log(response);
let parameters = {};
if (response.data) {
let info = response.data.split(':[');
if(info[1]){
let query = info[1].split(',');
console.log(query);
for(let i=0; i< query.length; i++){
let pari = query[i].split(' = ');
console.log(pari);
parameters[pari[0]] = pari[1];
}
console.log(parameters.sn);
}
}
if(parameters.sn){
deviceId = parameters.sn;
}
let productId = iot.navigator.getExtras().model;
if(response.data == "joined success"){
if(response.data == "onJoining"){
uComponents.changeCommLoadingStatusAndText(self, 0, Vue.t('wifiAdd.deviceActivating'));
}else if(response.data == "joined success"){
let deviceId = response.info.sn;
unbind(self, deviceId, productId);
// bind(self, deviceId, productId);
}else if(response.data == "fail"){
//连接失败
uComponents.changeCommLoadingStatusAndText(self, 2, Vue.t('addDevice.bindFailure'));
uComponents.changeCommLoadingStatusAndText(self, 2, Vue.t('wifiAdd.deviceActivateFailure'));
self.setStatus(2);
uComponents.changeCommButtonText(self, Vue.t('addDevice.reBindDevice'));
//停止查找设备
......@@ -213,7 +201,7 @@ function connectButtonTap(self){
if(self.getStatus() == 0){
console.log("timeout");
//连接失败
uComponents.changeCommLoadingStatusAndText(self, 2, Vue.t('addDevice.bindFailure'));
uComponents.changeCommLoadingStatusAndText(self, 2, Vue.t('wifiAdd.bindTimeout'));
self.setStatus(2);
uComponents.changeCommButtonText(self, Vue.t('addDevice.reBindDevice'));
//停止查找设备
......@@ -272,14 +260,14 @@ function bind(self, deviceId, productId){
console.log(response);
let data = response.data;
if(data.success){
uComponents.changeCommLoadingStatusAndText(self, 1, Vue.t('addDevice.bindSuccess'));
uComponents.changeCommLoadingStatusAndText(self, 1, Vue.t('wifiAdd.deviceActivateSuccess'));
uComponents.changeCommButtonText(self, Vue.t('btn.confirm'));
self.setStatus(1);
}
},
error: (error) => {
console.log(error);
uComponents.changeCommLoadingStatusAndText(self, 2, Vue.t('addDevice.bindFailure'));
uComponents.changeCommLoadingStatusAndText(self, 2, Vue.t('wifiAdd.deviceActivateFailure'));
uComponents.changeCommButtonText(self, Vue.t('addDevice.reBindDevice'));
self.setStatus(2);
},
......
......@@ -62,6 +62,12 @@ function init() {
newMsg: '',
//是否第一次获取门锁信息
isFirstGetLockInfo: true,
opendoorRecordFlag: false,
securityAlarmFlag: false,
hijackAlarmFlag: false,
notifyTime: null,
alarmTime: null,
openTime: null,
//是否显示远程开门页面
remoteOpendoorShowFlag: false,
//远程开门密码
......@@ -69,7 +75,7 @@ function init() {
//远程开门错误提示
textErrorTip: null,
//当前状态
status: null
status: 0
},
mounted(){
let self = this;
......@@ -390,6 +396,101 @@ function initComponentsConfig() {
}
}
async function getRecordTime(self, data){
// let notifyTime = null;
// let alarmTime = null;
// let openTime = null;
try{
self.notifyTime = await getRecordTimeMap('notifyTime');
}
catch (error) {
console.log(error);
}
try{
self.alarmTime = await getRecordTimeMap('alarmTime');
}
catch (error) {
console.log(error);
}
try{
self.openTime = await getRecordTimeMap('openTime');
}
catch (error) {
console.log(error);
}
let newNotifyTime = moment(data.notify_time);
let newAlarmTime = moment(data.alarm_time);
let newOpenTime = moment(data.open_time);
console.log("newNotifyTime"+newNotifyTime);
console.log("newAlarmTime"+newAlarmTime);
console.log("newOpenTime"+newOpenTime);
console.log("notifyTime"+self.notifyTime);
console.log("alarmTime"+self.alarmTime);
console.log("openTime"+self.openTime);
let now = moment();
if(self.notifyTime){
self.notifyTime = moment(self.notifyTime,moment.ISO_8601);
if(newNotifyTime != null && newNotifyTime.diff(self.notifyTime, 'seconds') > 0){
self.securityAlarmFlag = true;
self.notifyTime = newNotifyTime;
}
}else{
if(newNotifyTime != null && now.diff(newNotifyTime, 'seconds') < 1){
self.securityAlarmFlag = true;
self.notifyTime = newNotifyTime;
}
}
if(self.alarmTime){
self.alarmTime = moment(self.alarmTime,moment.ISO_8601);
if(newAlarmTime != null && newAlarmTime.diff(self.alarmTime, 'seconds') > 0){
self.hijackAlarmFlag = true;
self.alarmTime = newAlarmTime.unix();
}
}else{
if(newAlarmTime != null && now.diff(newAlarmTime, 'seconds') < 1){
self.hijackAlarmFlag = true;
self.alarmTime = newAlarmTime;
}
}
if(self.openTime){
self.openTime = moment(self.openTime,moment.ISO_8601);
if(newOpenTime != null && newOpenTime.diff(self.openTime, 'seconds') > 0){
self.opendoorRecordFlag = true;
self.openTime = newOpenTime;
}
}else{
if(newOpenTime != null && now.diff(newOpenTime, 'seconds') < 1){
self.opendoorRecordFlag = true;
console.log(newOpenTime);
self.openTime = newOpenTime;
}
}
}
function setRecordTime(timeKey, time){
console.log(time);
iot.storage.setMap(timeKey, time, (res) => {
console.log(res);
}, () => {
});
}
//获取websql上的firstLogin
function getRecordTimeMap(time) {
return new Promise(function (resolve, reject) {
console.log(time);
iot.storage.getMap(time, (res) => {
if (res) {
resolve(res);
} else {
reject(res);
}
}, (err) => {
console.log(err);
});
})
}
function setValueOfSwitch(self, flag){
self.setValueOpendoorRecord(flag);
self.setValueSecurityAlarm(flag);
......@@ -427,6 +528,7 @@ function getLockInfo(self){
console.log(response);
let data = uPublic.checkResponseData(response.data);
if(data){
getRecordTime(self, data);
//判断云端是否绑定
if(data.lock_id){
setValueOfSwitch(self, 1);
......@@ -497,18 +599,20 @@ function setDevceInfo(self, data) {
//请求远程开门
// self.setRemoteOpendoorFlag(true);
self.setValueRemoteOpendoor(true);
}else if(data.notify_type.value == 2){
getLockInfo(self);
}
}
if(data.action.value == 'lock_log' && (data.lock_action.value == '1' || data.lock_action.value == '4')){
//开门或远程开门成功
getLockInfo(self);
if(data.lock_action.value == '4'){
uComponents.changeCommLoadingStatusAndText(self, 2, Vue.t('remoteOpendoor.openDoorSuccess'));
uComponents.changeCommLoadingStatusAndText(self, 1, Vue.t('remoteOpendoor.openDoorSuccess'));
uComponents.changeCommButtonText(self, Vue.t('btn.confirm'));
self.setStatus(1);
}
}
if(data.ErrorCode){
if(data.ErrorCode.value != 0){
//远程开门失败
uComponents.changeCommLoadingStatusAndText(self, 2, Vue.t('remoteOpendoor.openDoorFailure'));
uComponents.changeCommButtonText(self, Vue.t('remoteOpendoor.remoteOpendoorAgain'));
......@@ -633,6 +737,8 @@ function doorlockManageTap(self){
//tap 开门记录
function opendoorRecordTap(self){
if(self.getValueOpendoorRecord() == 1){
self.opendoorRecordFlag = false;
setRecordTime('openTime', self.openTime.toISOString());
iot.navigator.openWindow({
url: './opendoorRecord.html',
id: 'opendoorRecord',
......@@ -646,6 +752,8 @@ function opendoorRecordTap(self){
//tap 安全报警
function securityAlarmTap(self){
if(self.getValueSecurityAlarm() == 1){
self.securityAlarmFlag = false;
setRecordTime('notifyTime', self.notifyTime.toISOString());
iot.navigator.openWindow({
url: './alarmInfo.html',
id: 'alarmInfo',
......@@ -691,6 +799,8 @@ function remoteOpendoorTap(self){
//tap 劫持报警
function hijackAlarmTap(self){
if(self.getValueHijackAlarm() == 1){
self.hijackAlarmFlag = false;
setRecordTime('alarmTime', self.alarmTime.toISOString());
iot.navigator.openWindow({
url: './hijackRecord.html',
id: 'hijackRecord',
......@@ -733,7 +843,6 @@ function confirmButtonTap(self){
console.log(self.mac);
let keyIv = crypto.enkey(self.mac.replace(/:/g,''));
console.log(keyIv);
self.setTextPassword({'pwd': '123'});
let pwd = crypto.encode(self.getTextPassword(), keyIv);
console.log(pwd);
let msg = crypto.decode(pwd, keyIv);
......@@ -746,25 +855,29 @@ function confirmButtonTap(self){
'value': 'openDoor'
},
'remote_open_door': {
// 'value': pwd
'value': self.getTextPassword()
'value': pwd
}
}
},
success: (response) => {
//密码下发成功
console.log(response);
self.setStatus(0);
// uComponents.showCommLoading(self);
self.getStatus(0);
// uComponents.changeCommLoadingStatusAndText(self, 1, Vue.t('remoteOpendoor.openDoorSuccess'));
// uComponents.changeCommButtonText(self, Vue.t('btn.confirm'));
},
error: (error) => {
console.log(error);
},
complete(){
uComponents.hideLoading(self);
// uComponents.hideCommLoading(self);
}
});
}
console.log('aaaa');
setTimeout(function (){
console.log(self.getStatus());
if(self.getStatus() == 0){
console.log("timeout");
//连接失败
......@@ -779,6 +892,7 @@ function confirmButtonTap(self){
function commLoadingButtonTap(self){
if(self.getStatus() == 1){
//绑定成功
console.log("1111");
uComponents.hideCommLoading(self);
self.setRemoteOpendoorShowFlag(false);
......
......@@ -82,7 +82,7 @@ function getDeviceList(self) {
self.setDeviceList(data);
for (var i = 0; i < data.length; i++) {
list[i] = {
leftImage: '../../resources/image/deviceImg.png',
leftImage: data[i].icon,
title: data[i].deviceName,
subtitle: Vue.t('deviceList.model') + data[i].model,
rightIcon: '&#xe6a7;'
......
......@@ -152,10 +152,11 @@ function backTap() {
//tap 连接
function connectButtonTap(self) {
console.log(self.getTextWiFiName());
// self.setTextPassword('macro_scope00');
console.log(self.getTextPassword());
if (self.getTextPassword() == null || self.getTextPassword().trim() == '') {
// console.log(self.getTextWiFiName());
// console.log(self.getTextPassword());
if (self.getTextWiFiName() == null || self.getTextWiFiName().trim() == '') {
self.setTextErrorTip(Vue.t('wifiAdd.unbindWifiTip'));
} else if (self.getTextPassword() == null || self.getTextPassword().trim() == '') {
self.setTextErrorTip(Vue.t('wifiAdd.passwordInputTip'));
} else {
_public.iot.business.sds.findWifi({
......@@ -171,8 +172,10 @@ function connectButtonTap(self) {
if (response.data == 'onProvisioning') {
//wifi链接中
_public.uComponents.showCommLoading(self);
_public.uComponents.changeCommLoadingStatusAndText(self, 0, Vue.t('wifiAdd.wifiBinding'));
} else if (response.data == 'provisioned success') {
//wifi连接成功,停止连接wifi
_public.uComponents.changeCommLoadingStatusAndText(self, 0, Vue.t('wifiAdd.wifiBindSuccess'));
// iot.business.sds.stopFindWifi({
// success: (response) => {},
// error: (error) => {}
......@@ -186,32 +189,17 @@ function connectButtonTap(self) {
var deviceId = null;
_public.iot.business.sds.findDevices({
success: function success(response) {
console.log("findDevices");
console.log(response);
var parameters = {};
if (response.data) {
var info = response.data.split(':[');
if (info[1]) {
var query = info[1].split(',');
console.log(query);
for (var i = 0; i < query.length; i++) {
var pari = query[i].split(' = ');
console.log(pari);
parameters[pari[0]] = pari[1];
}
console.log(parameters.sn);
}
}
if (parameters.sn) {
deviceId = parameters.sn;
}
var productId = _public.iot.navigator.getExtras().model;
if (response.data == "joined success") {
unbind(self, deviceId, productId);
if (response.data == "onJoining") {
_public.uComponents.changeCommLoadingStatusAndText(self, 0, Vue.t('wifiAdd.deviceActivating'));
} else if (response.data == "joined success") {
var _deviceId = response.info.sn;
unbind(self, _deviceId, productId);
// bind(self, deviceId, productId);
} else if (response.data == "fail") {
//连接失败
_public.uComponents.changeCommLoadingStatusAndText(self, 2, Vue.t('addDevice.bindFailure'));
_public.uComponents.changeCommLoadingStatusAndText(self, 2, Vue.t('wifiAdd.deviceActivateFailure'));
self.setStatus(2);
_public.uComponents.changeCommButtonText(self, Vue.t('addDevice.reBindDevice'));
//停止查找设备
......@@ -230,7 +218,7 @@ function connectButtonTap(self) {
if (self.getStatus() == 0) {
console.log("timeout");
//连接失败
_public.uComponents.changeCommLoadingStatusAndText(self, 2, Vue.t('addDevice.bindFailure'));
_public.uComponents.changeCommLoadingStatusAndText(self, 2, Vue.t('wifiAdd.bindTimeout'));
self.setStatus(2);
_public.uComponents.changeCommButtonText(self, Vue.t('addDevice.reBindDevice'));
//停止查找设备
......@@ -288,14 +276,14 @@ function bind(self, deviceId, productId) {
console.log(response);
var data = response.data;
if (data.success) {
_public.uComponents.changeCommLoadingStatusAndText(self, 1, Vue.t('addDevice.bindSuccess'));
_public.uComponents.changeCommLoadingStatusAndText(self, 1, Vue.t('wifiAdd.deviceActivateSuccess'));
_public.uComponents.changeCommButtonText(self, Vue.t('btn.confirm'));
self.setStatus(1);
}
},
error: function error(_error7) {
console.log(_error7);
_public.uComponents.changeCommLoadingStatusAndText(self, 2, Vue.t('addDevice.bindFailure'));
_public.uComponents.changeCommLoadingStatusAndText(self, 2, Vue.t('wifiAdd.deviceActivateFailure'));
_public.uComponents.changeCommButtonText(self, Vue.t('addDevice.reBindDevice'));
self.setStatus(2);
},
......
......@@ -47,11 +47,11 @@
<div class="switchGroup">
<div class="guoupRow">
<!-- 开门记录 -->
<div class="col-xs-6 opendoorRecord">
<div class="col-xs-6 opendoorRecord" v-bind:class="{newMsg: opendoorRecordFlag}">
<u-switch :value="valueOpendoorRecord" :init-param="componentsConfig.opendoorRecordSwitch.initParam" v-on:u-switch-tap="onOpendoorRecordTap"></u-switch>
</div>
<!-- 安全报警 -->
<div class="col-xs-6 securityAlarm">
<div class="col-xs-6 securityAlarm" v-bind:class="{newMsg: securityAlarmFlag}">
<u-switch :value="valueSecurityAlarm" :init-param="componentsConfig.securityAlarmSwitch.initParam" v-on:u-switch-tap="onSecurityAlarmTap"></u-switch>
</div>
</div>
......@@ -61,7 +61,7 @@
<u-switch :value="valueDoorlockUser" :init-param="componentsConfig.doorlockUserSwitch.initParam" v-on:u-switch-tap="onDoorlockUserTap"></u-switch>
</div>
<!-- 劫持报警 -->
<div class="col-xs-6 hijackAlarm">
<div class="col-xs-6 hijackAlarm" v-bind:class="{newMsg: hijackAlarmFlag}">
<u-switch :value="valueHijackAlarm" :init-param="componentsConfig.hijackAlarmSwitch.initParam" v-on:u-switch-tap="onHijackAlarmTap"></u-switch>
</div>
</div>
......
......@@ -6168,7 +6168,7 @@ var crypto = function () {
var key = _cryptoJs2.default.enc.Utf8.parse(keyIv.key);
var iv = _cryptoJs2.default.enc.Utf8.parse(keyIv.iv);;
var decryptedData = _cryptoJs2.default.AES.decrypt(code, key, { iv: iv }, { mode: _cryptoJs2.default.mode.CBC, padding: _cryptoJs2.default.pad.nopadding });
return JSON.parse(decryptedData.toString(_cryptoJs2.default.enc.Utf8));
return decryptedData.toString(_cryptoJs2.default.enc.Utf8);
}
}]);
......
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