Commit 6a4b3465 by 朱建香

1103

parent 0af83892
...@@ -21,7 +21,13 @@ class crypto{ ...@@ -21,7 +21,13 @@ class crypto{
return keyIv; return keyIv;
} }
static encode(msg, keyIv){ static encode(msg, keyIv){
let message = JSON.stringify(msg); let message = '';
if(typeof(msg) == 'object'){
message = JSON.stringify(msg);
}else{
message = msg;
}
console.log(message);
let key = CryptoJS.enc.Utf8.parse(keyIv.key); let key = CryptoJS.enc.Utf8.parse(keyIv.key);
let iv = CryptoJS.enc.Utf8.parse(keyIv.iv); let iv = CryptoJS.enc.Utf8.parse(keyIv.iv);
let code = CryptoJS.AES.encrypt(message, key, { iv: iv},{ mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.nopadding }); let code = CryptoJS.AES.encrypt(message, key, { iv: iv},{ mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.nopadding });
......
...@@ -141,21 +141,21 @@ iot.navigator.trigger = function (element, eventType, eventData) { ...@@ -141,21 +141,21 @@ iot.navigator.trigger = function (element, eventType, eventData) {
}; };
iot.navigator.closeAllBesidesItself = function () { iot.navigator.closeAllBesidesItself = function () {
var wvs = plus.webview.all(); // var wvs = plus.webview.all();
// var curWb = plus.webview.currentWebview(); //// var curWb = plus.webview.currentWebview();
for (var i = 0; i < wvs.length-1; i++) { // for (var i = 0; i < wvs.length-1; i++) {
// if (wvs[i].id != curWb.id) { //// if (wvs[i].id != curWb.id) {
wvs[i].close(); // wvs[i].close();
// } //// }
} // }
} }
iot.navigator.closeAll = function (){ iot.navigator.closeAll = function (){
var wvs = plus.webview.all(); // var wvs = plus.webview.all();
var curWb = plus.webview.currentWebview(); // var curWb = plus.webview.currentWebview();
for (var i = 0; i < wvs.length; i++) { // for (var i = 0; i < wvs.length; i++) {
wvs[i].close(); // wvs[i].close();
} // }
} }
iot.ready(function(){ iot.ready(function(){
......
...@@ -32,42 +32,43 @@ function init() { ...@@ -32,42 +32,43 @@ function init() {
valueHijackAlarm: 0, valueHijackAlarm: 0,
//门锁管理 //门锁管理
valueDoorlockManage: 0, valueDoorlockManage: 0,
//门锁最新消息是否滚动
activeFlag: true, activeFlag: true,
followShowFlag: false,
doorbellShowFlag: false,
bindDoorlockShowFlag: false,
//配置组件 //配置组件
componentsConfig: initComponentsConfig(), componentsConfig: initComponentsConfig(),
//电量 //
batteryState: null, followShowFlag: false,
//电量icon
batteryState: '',
//电量百分比 //电量百分比
batteryPercent: 100, batteryPercent: 100,
//响铃时间 //响铃时间
ringingTime: null, ringingTime: null,
//门铃是否响起 //门铃是否响起
doorbellRingingFlag: false, doorbellRingingFlag: false,
//是否显示"门铃响了"文本 //点击远程开门提示
textDoorbellRingingFlag: false,
//远程开门是否开启
remoteOpendoorFlag: false, remoteOpendoorFlag: false,
//设备ID //设备ID
deviceId: null, deviceId: null,
//设备mac
mac: null, mac: null,
//设备uuid //设备uuid
uuid: null, uuid: null,
//门锁id
lockId: null,
//获取用户的身份
role: null,
//最新消息 //最新消息
newMsg: '', newMsg: '',
//是否第一次获取门锁信息 //是否第一次获取门锁信息
isFirstGetLockInfo: true, isFirstGetLockInfo: true,
lockId: null,
//获取用户的身份
role: null,
//是否显示远程开门页面 //是否显示远程开门页面
remoteOpendoorShowFlag: false, remoteOpendoorShowFlag: false,
//远程开门密码 //远程开门密码
textPassword: null, textPassword: null,
//远程开门错误提示 //远程开门错误提示
textErrorTip: null, textErrorTip: null,
//当前状态
status: null status: null
}, },
mounted(){ mounted(){
...@@ -93,13 +94,10 @@ function init() { ...@@ -93,13 +94,10 @@ function init() {
//注册监听上报 //注册监听上报
iot.business.sds.registerPushListener({ iot.business.sds.registerPushListener({
success: (response) => { success: (response) => {
console.log(response);
let data = response.data; let data = response.data;
console.log("registerPushListener");
console.log(data); console.log(data);
// if(data.hasOwnProperty('params')){ setDevceInfo(self, data.params.data);
console.log("registerPushListener");
setDevceInfo(self, data.params.data);
// }
}, },
error: (error) => { error: (error) => {
console.log(error); console.log(error);
...@@ -175,12 +173,6 @@ function init() { ...@@ -175,12 +173,6 @@ function init() {
setDoorbellRingingFlag(boolean){ setDoorbellRingingFlag(boolean){
this.doorbellRingingFlag = boolean; this.doorbellRingingFlag = boolean;
}, },
getTextDoorbellRingingFlag(){
return this.textDoorbellRingingFlag;
},
setTextDoorbellRingingFlag(flag){
this.textDoorbellRingingFlag = flag;
},
getRemoteOpendoorFlag(){ getRemoteOpendoorFlag(){
return this.remoteOpendoorFlag; return this.remoteOpendoorFlag;
}, },
...@@ -415,8 +407,6 @@ function getDeviceStatus(self){ ...@@ -415,8 +407,6 @@ function getDeviceStatus(self){
success: (response) => { success: (response) => {
console.log(response); console.log(response);
let data = response.data; let data = response.data;
// self.setBatteryPercent(data.BatteryPercentage.value);
// self.setBatteryState(config.powerIcon[Math.round(data.BatteryPercentage.value/20)]);
console.log("getStatus"); console.log("getStatus");
setDevceInfo(self, data); setDevceInfo(self, data);
}, },
...@@ -431,32 +421,26 @@ function getLockInfo(self){ ...@@ -431,32 +421,26 @@ 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:"600194283588"
device_id: self.deviceId device_id: self.deviceId
}, },
success: (response) => { success: (response) => {
console.log(response); console.log(response);
let data = uPublic.checkResponseData(response.data); let data = uPublic.checkResponseData(response.data);
if(data){ if(data){
// self.setBatteryPercent(data.battery);
// self.setBatteryState(config.powerIcon[Math.round(data.battery/20)]);
//判断云端是否绑定 //判断云端是否绑定
if(data.lock_id){ if(data.lock_id){
setValueOfSwitch(self, 1); setValueOfSwitch(self, 1);
self.setLockId(data.lock_id); self.setLockId(data.lock_id);
self.setRole(data.role); self.setRole(data.role);
console.log(data.info);
if(self.isFirstGetLockInfo){ if(self.isFirstGetLockInfo){
getDeviceStatus(self); getDeviceStatus(self);
self.setIsFirstGetLockInfo(false); self.setIsFirstGetLockInfo(false);
} }
if(data.info && data.info.length){ if(data.info && data.info.length){
console.log(data.info);
self.newMsg = ''; self.newMsg = '';
for(let i=0; i< data.info.length; i++){ for(let i=0; i< data.info.length; i++){
let now = moment(); let now = moment();
let time = moment(data.info[i].time); let time = moment(data.info[i].time);
console.log(now.diff(time,'hours'));
if(now.diff(time,'hours') < 24){ if(now.diff(time,'hours') < 24){
if(data.info[i].nickname == null){ if(data.info[i].nickname == null){
self.newMsg += moment(data.info[i].time).format("YY.MM.DD HH:mm") + ' ID:' + data.info[i].openId + Vue.t('opendoorRecord.'+config.openDoorMode[data.info[i].mode]+'')+'<br>'; self.newMsg += moment(data.info[i].time).format("YY.MM.DD HH:mm") + ' ID:' + data.info[i].openId + Vue.t('opendoorRecord.'+config.openDoorMode[data.info[i].mode]+'')+'<br>';
...@@ -465,6 +449,11 @@ function getLockInfo(self){ ...@@ -465,6 +449,11 @@ function getLockInfo(self){
} }
} }
} }
if(data.info[0].nickname == null){
self.newMsg += moment(data.info[0].time).format("YY.MM.DD HH:mm") + ' ID:' + data.info[0].openId + Vue.t('opendoorRecord.'+config.openDoorMode[data.info[0].mode]+'');
}else{
self.newMsg += moment(data.info[0].time).format("YY.MM.DD HH:mm") + data.info[0].nickname + Vue.t('opendoorRecord.'+config.openDoorMode[data.info[0].mode]+'');
}
uComponents.changeMarqueeText(self, self.newMsg); uComponents.changeMarqueeText(self, self.newMsg);
}else{ }else{
uComponents.changeMarqueeText(self, Vue.t('device.noNewMsg')); uComponents.changeMarqueeText(self, Vue.t('device.noNewMsg'));
...@@ -473,10 +462,7 @@ function getLockInfo(self){ ...@@ -473,10 +462,7 @@ function getLockInfo(self){
}else{ }else{
uComponents.changeMarqueeText(self, Vue.t('device.defaultNewMsg')); uComponents.changeMarqueeText(self, Vue.t('device.defaultNewMsg'));
} }
}else{ }else{ }
// uComponents.changeMarqueeText(self, Vue.t('device.noNewMsg'));
// self.setRingingTime(null);
}
}, },
error: (error) => { error: (error) => {
console.log(error); console.log(error);
...@@ -491,14 +477,10 @@ function getLockInfo(self){ ...@@ -491,14 +477,10 @@ function getLockInfo(self){
function setDevceInfo(self, data) { function setDevceInfo(self, data) {
console.log(data); console.log(data);
self.setBatteryPercent(data.BatteryPercentage.value); self.setBatteryPercent(data.BatteryPercentage.value);
// self.setBatteryState(config.powerIcon[Math.round(data.BatteryPercentage.value/20)]);
if(data.BatteryPercentage.value >= 10){ if(data.BatteryPercentage.value >= 10){
//向上取整 //向上取整
//self.setIsYellow(true);
self.setBatteryState(config.powerIcon[Math.ceil(data.BatteryPercentage.value/20)]); self.setBatteryState(config.powerIcon[Math.ceil(data.BatteryPercentage.value/20)]);
}else{ }else{
//
//self.setIsRed(true);
self.setBatteryState(config.powerIcon[Math.round(data.BatteryPercentage.value/20)]); self.setBatteryState(config.powerIcon[Math.round(data.BatteryPercentage.value/20)]);
} }
if(data.action.value == 'notify'){ if(data.action.value == 'notify'){
...@@ -507,7 +489,6 @@ function setDevceInfo(self, data) { ...@@ -507,7 +489,6 @@ function setDevceInfo(self, data) {
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");
if(now.diff(time,'hours') < 24){ if(now.diff(time,'hours') < 24){
self.setTextDoorbellRingingFlag(true);
self.setRingingTime(time.format("HH:mm")); self.setRingingTime(time.format("HH:mm"));
console.log("innnnn"); console.log("innnnn");
ringBell(self); ringBell(self);
...@@ -526,20 +507,26 @@ function setDevceInfo(self, data) { ...@@ -526,20 +507,26 @@ function setDevceInfo(self, data) {
self.setStatus(1); self.setStatus(1);
} }
} }
if(data.ErrorCode){
//远程开门失败
uComponents.changeCommLoadingStatusAndText(self, 2, Vue.t('remoteOpendoor.openDoorFailure'));
uComponents.changeCommButtonText(self, Vue.t('remoteOpendoor.remoteOpendoorAgain'));
self.setStatus(2);
}
} }
async function ringBell(self){ async function ringBell(self){
try{ try{
for(let i =0 ; i< (config.ring_time/(config.shake_times+config.await_time));){ for(let i =0 ; i< (config.ring_time/(config.shake_times+config.await_time));){
self.setDoorbellRingingFlag(true); self.setDoorbellRingingFlag(true);
let time = await sleep(1000*config.shake_times); let time = await sleep(1000*config.shake_times);
self.setDoorbellRingingFlag(false); self.setDoorbellRingingFlag(false);
time = await sleep(config.await_time); time = await sleep(config.await_time);
i++; i++;
}
}
catch (err){
console.log(err);
} }
}
catch (err){
console.log(err);
}
} }
function sleep(time){ function sleep(time){
...@@ -618,6 +605,7 @@ function myInfoTap(self){ ...@@ -618,6 +605,7 @@ function myInfoTap(self){
}); });
} }
//tap 绑定门锁
function bindDoorlockTap(){ function bindDoorlockTap(){
iot.navigator.openWindow({ iot.navigator.openWindow({
url: '../addDevice/index.html', url: '../addDevice/index.html',
...@@ -722,10 +710,12 @@ function laterFollowTap(self){ ...@@ -722,10 +710,12 @@ function laterFollowTap(self){
self.setFollowShowFlag(false); self.setFollowShowFlag(false);
} }
//tap 远程开门页面返回
function backTap(self){ function backTap(self){
self.setRemoteOpendoorShowFlag(false); self.setRemoteOpendoorShowFlag(false);
} }
//远程开门密码
function passwordChange(self,text){ function passwordChange(self,text){
self.setTextPassword(text); self.setTextPassword(text);
self.setTextErrorTip(''); self.setTextErrorTip('');
...@@ -742,6 +732,7 @@ function confirmButtonTap(self){ ...@@ -742,6 +732,7 @@ function confirmButtonTap(self){
console.log(self.mac); console.log(self.mac);
let keyIv = crypto.enkey(self.mac.replace(/:/g,'')); let keyIv = crypto.enkey(self.mac.replace(/:/g,''));
console.log(keyIv); console.log(keyIv);
self.setTextPassword({'pwd': '123'});
let pwd = crypto.encode(self.getTextPassword(), keyIv); let pwd = crypto.encode(self.getTextPassword(), keyIv);
console.log(pwd); console.log(pwd);
let msg = crypto.decode(pwd, keyIv); let msg = crypto.decode(pwd, keyIv);
...@@ -783,6 +774,7 @@ function confirmButtonTap(self){ ...@@ -783,6 +774,7 @@ function confirmButtonTap(self){
},config.remote_opendoor_timeout); },config.remote_opendoor_timeout);
} }
//tap comm-loading ‘确认’
function commLoadingButtonTap(self){ function commLoadingButtonTap(self){
if(self.getStatus() == 1){ if(self.getStatus() == 1){
//绑定成功 //绑定成功
......
...@@ -106,7 +106,7 @@ function loginButtonTap(self){ ...@@ -106,7 +106,7 @@ function loginButtonTap(self){
} }
function cloudsLogin(self, id){ function cloudsLogin(self, id){
uComponents.showLoading(self); // uComponents.showLoading(self);
iot.business.user.simpleLogin({ iot.business.user.simpleLogin({
data: { data: {
username: id, username: id,
...@@ -141,7 +141,7 @@ function cloudsLogin(self, id){ ...@@ -141,7 +141,7 @@ function cloudsLogin(self, id){
uPublic.openRequestErrorAlert(self); uPublic.openRequestErrorAlert(self);
}, },
complete: () => { complete: () => {
uComponents.hideLoading(self); // uComponents.hideLoading(self);
} }
}); });
} }
\ No newline at end of file
...@@ -9646,21 +9646,21 @@ iot.navigator.trigger = function (element, eventType, eventData) { ...@@ -9646,21 +9646,21 @@ iot.navigator.trigger = function (element, eventType, eventData) {
}; };
iot.navigator.closeAllBesidesItself = function () { iot.navigator.closeAllBesidesItself = function () {
var wvs = plus.webview.all(); // var wvs = plus.webview.all();
// var curWb = plus.webview.currentWebview(); //// var curWb = plus.webview.currentWebview();
for (var i = 0; i < wvs.length - 1; i++) { // for (var i = 0; i < wvs.length-1; i++) {
// if (wvs[i].id != curWb.id) { //// if (wvs[i].id != curWb.id) {
wvs[i].close(); // wvs[i].close();
// } //// }
} // }
}; };
iot.navigator.closeAll = function () { iot.navigator.closeAll = function () {
var wvs = plus.webview.all(); // var wvs = plus.webview.all();
var curWb = plus.webview.currentWebview(); // var curWb = plus.webview.currentWebview();
for (var i = 0; i < wvs.length; i++) { // for (var i = 0; i < wvs.length; i++) {
wvs[i].close(); // wvs[i].close();
} // }
}; };
iot.ready(function () { iot.ready(function () {
...@@ -17795,6 +17795,7 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); ...@@ -17795,6 +17795,7 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
let uComponents = {}; let uComponents = {};
uComponents.showLoading = function (vmObj) { uComponents.showLoading = function (vmObj) {
console.log("uComponents.showLoading"+(new Date().getTime()));
vmObj.$refs.uloading.show(); vmObj.$refs.uloading.show();
}; };
uComponents.hideLoading = function (vmObj) { uComponents.hideLoading = function (vmObj) {
......
...@@ -1255,31 +1255,32 @@ p { ...@@ -1255,31 +1255,32 @@ p {
} }
.active .u-marquee-text { .active .u-marquee-text {
-webkit-animation: marquee 5s linear infinite; -webkit-animation: marquee 10s linear infinite;
animation: marquee 5s linear infinite; animation: marquee 10s linear infinite;
line-height: 0.96rem;
} }
@-webkit-keyframes marquee { @-webkit-keyframes marquee {
from { from {
-webkit-transform: translate(0,0.533rem); -webkit-transform: translate(0,0rem);
transform: translate(0,0.533rem); transform: translate(0,0rem);
} }
to { to {
-webkit-transform: translate(0,-100%); -webkit-transform: translate(0,-2.83rem);
transform: translate(0,-100%); transform: translate(0,-2.83rem);
} }
} }
@keyframes marquee { @keyframes marquee {
from { from {
-webkit-transform: translate(0,0.533rem); -webkit-transform: translate(0,0rem);
transform: translate(0,0.533rem); transform: translate(0,0rem);
} }
to { to {
-webkit-transform: translate(0,-100%); -webkit-transform: translate(0,-2.83rem);
transform: translate(0,-100%); transform: translate(0,-2.83rem);
} }
} }
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
<p></p> <p></p>
</div> </div>
</div> </div>
<div class="doorbellTip"><span>{{ ringingTime }}</span>{{ textDoorbellRingingFlag ? $t('device.doorLockRinging'):'' }}</div> <div class="doorbellTip"><span>{{ ringingTime }}</span>{{ ringingTime ? $t('device.doorLockRinging'):'' }}</div>
</div> </div>
<p class="batteryState" :class="[{yellowWarning: batteryPercent<=20},{redWarning: batteryPercent<10}]"><span v-html="batteryState" ></span><span>{{ batteryPercent }}%</span></p> <p class="batteryState" :class="[{yellowWarning: batteryPercent<=20},{redWarning: batteryPercent<10}]"><span v-html="batteryState" ></span><span>{{ batteryPercent }}%</span></p>
</div> </div>
......
...@@ -6106,6 +6106,8 @@ Object.defineProperty(exports, "__esModule", { ...@@ -6106,6 +6106,8 @@ Object.defineProperty(exports, "__esModule", {
value: true value: true
}); });
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /** var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /**
* @class * @class
* crypto * crypto
...@@ -6148,7 +6150,13 @@ var crypto = function () { ...@@ -6148,7 +6150,13 @@ var crypto = function () {
}, { }, {
key: "encode", key: "encode",
value: function encode(msg, keyIv) { value: function encode(msg, keyIv) {
var message = JSON.stringify(msg); var message = '';
if ((typeof msg === "undefined" ? "undefined" : _typeof(msg)) == 'object') {
message = JSON.stringify(msg);
} else {
message = msg;
}
console.log(message);
var key = _cryptoJs2.default.enc.Utf8.parse(keyIv.key); var key = _cryptoJs2.default.enc.Utf8.parse(keyIv.key);
var iv = _cryptoJs2.default.enc.Utf8.parse(keyIv.iv); var iv = _cryptoJs2.default.enc.Utf8.parse(keyIv.iv);
var code = _cryptoJs2.default.AES.encrypt(message, key, { iv: iv }, { mode: _cryptoJs2.default.mode.CBC, padding: _cryptoJs2.default.pad.nopadding }); var code = _cryptoJs2.default.AES.encrypt(message, key, { iv: iv }, { mode: _cryptoJs2.default.mode.CBC, padding: _cryptoJs2.default.pad.nopadding });
......
...@@ -112,7 +112,7 @@ function loginButtonTap(self) { ...@@ -112,7 +112,7 @@ function loginButtonTap(self) {
} }
function cloudsLogin(self, id) { function cloudsLogin(self, id) {
_public.uComponents.showLoading(self); // uComponents.showLoading(self);
_public.iot.business.user.simpleLogin({ _public.iot.business.user.simpleLogin({
data: { data: {
username: id, username: id,
...@@ -146,7 +146,7 @@ function cloudsLogin(self, id) { ...@@ -146,7 +146,7 @@ function cloudsLogin(self, id) {
_public.uPublic.openRequestErrorAlert(self); _public.uPublic.openRequestErrorAlert(self);
}, },
complete: function complete() { complete: function complete() {
_public.uComponents.hideLoading(self); // uComponents.hideLoading(self);
} }
}); });
} }
......
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