Commit 6a4b3465 by 朱建香

1103

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