Commit 22735af2 by 朱建香

1123

parent 6ea9af5f
...@@ -697,6 +697,7 @@ function getLockInfo(self){ ...@@ -697,6 +697,7 @@ function getLockInfo(self){
//设置设备信息 //设置设备信息
function setDevceInfo(self, data) { function setDevceInfo(self, data) {
console.log(data); console.log(data);
if(data.BatteryPercentage){
self.setBatteryPercent(data.BatteryPercentage.value); self.setBatteryPercent(data.BatteryPercentage.value);
if(data.BatteryPercentage.value >= 10){ if(data.BatteryPercentage.value >= 10){
//向上取整 //向上取整
...@@ -704,6 +705,7 @@ function setDevceInfo(self, data) { ...@@ -704,6 +705,7 @@ function setDevceInfo(self, data) {
}else{ }else{
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'){
if(data.notify_type.value == 104){ if(data.notify_type.value == 104){
//门铃响了 //门铃响了
......
...@@ -21,9 +21,11 @@ function init() { ...@@ -21,9 +21,11 @@ function init() {
showLoginButtonFlag: true showLoginButtonFlag: true
}, },
mounted(){ mounted(){
// loginButtonTap(this);
if(window.iotDebug){ if(window.iotDebug){
iotDebug.push('start: Debug'); iotDebug.push('start: Debug');
} }
var self = this; var self = this;
if (plus.os.name == 'Android') { if (plus.os.name == 'Android') {
iot.permission.checkPermission(['READ_EXTERNAL_STORAGE'], function (res) { iot.permission.checkPermission(['READ_EXTERNAL_STORAGE'], function (res) {
...@@ -83,79 +85,60 @@ function initComponentsConfig() { ...@@ -83,79 +85,60 @@ function initComponentsConfig() {
} }
function loginButtonTap(self){ function loginButtonTap(self){
uComponents.showLoading(self); // uComponents.showLoading(self);
if(window.iotDebug){ // if(window.iotDebug){
iotDebug.push('start: initSDSLogin'); // iotDebug.push('start: initSDSLogin');
} // }
iot.business.sds.init({ window.SDSPlugin.login({},(res)=>{
data: { console.log(res);
oa: true var data = uPublic.checkResponseData(res.data);
},
success: (response) => {
console.log(response);
if(window.iotDebug){
iotDebug.push('end: initSDSLoginSuccess');
}
if(window.iotDebug){
iotDebug.push('start: SDSlogin');
}
iot.business.user.login({
data: {
sds: true
},
success: (response) => {
console.log(response);
if(window.iotDebug){
iotDebug.push('end: SDSloginSuccees');
}
// console.log(response);
// alert(JSON.stringify(response));
var data = uPublic.checkResponseData(response.data);
if(data){ if(data){
self.setShowLoginButtonFlag(false);
if(data.hasOwnProperty('UserID')){
console.log("sds登陆成功了");
cloudsLogin(self, data.UserID); cloudsLogin(self, data.UserID);
} }
// iot.navigator.openWindow({ },(err)=>{
// url: '../device/index.html', console.log(err);
// id: 'device' })
// iot.business.sds.login({
// data: {
//// sds: true
// },
// success: (response) => {
//// console.log(response);
//// if(window.iotDebug){
//// iotDebug.push('end: SDSloginSuccees');
//// }
////// console.log(response);
////// alert(JSON.stringify(response));
//// var data = uPublic.checkResponseData(response.data);
//// if(data){
//// self.setShowLoginButtonFlag(false);
//// if(data.hasOwnProperty('UserID')){
//// console.log("sds登陆成功了");
//// cloudsLogin(self, data.UserID);
//// }
////// iot.navigator.openWindow({
////// url: '../device/index.html',
////// id: 'device'
////// });
//// }else{
////
//// }
// },
// error: (error) => {
//// console.log(error);
//// if(window.iotDebug){
//// iotDebug.push('end: sds登陆失败'+JSON.stringify(error));
//// }
//// if (window.iotDebug) {
//// iotDebug.upload(iot,'sds登陆失败');
//// }
//// //请求失败
////// uPublic.openRequestErrorAlert(self);
// },
// complete: () => {
//// uComponents.hideLoading(self);
// }
// }); // });
}else{
}
},
error: (error) => {
console.log(error);
if(window.iotDebug){
iotDebug.push('end: sds登陆失败'+JSON.stringify(error));
}
if (window.iotDebug) {
iotDebug.upload(iot,'sds登陆失败');
}
//请求失败
// uPublic.openRequestErrorAlert(self);
},
complete: () => {
uComponents.hideLoading(self);
}
});
},
error: (error) => {
console.log(error);
if(window.iotDebug){
iotDebug.push('end: sds登陆初始化失败'+JSON.stringify(error));
}
if (window.iotDebug) {
iotDebug.upload(iot,'sds登陆初始化失败');
}
//请求失败
uPublic.openRequestErrorAlert(self);
},
complete: () => {
uComponents.hideLoading(self);
}
});
} }
function cloudsLogin(self, id){ function cloudsLogin(self, id){
...@@ -179,6 +162,7 @@ function cloudsLogin(self, id){ ...@@ -179,6 +162,7 @@ function cloudsLogin(self, id){
url: '../device/index.html', url: '../device/index.html',
id: 'device' id: 'device'
}); });
plus.navigator.closeSplashscreen();
// uPublic.openWindow({ // uPublic.openWindow({
// url: '../device/index.html', // url: '../device/index.html',
// id: 'device', // id: 'device',
......
...@@ -26,7 +26,7 @@ UIOT_Debug.prototype.upload = function (iot,title) { ...@@ -26,7 +26,7 @@ UIOT_Debug.prototype.upload = function (iot,title) {
http.open('POST', 'https://admin.iot.u-gen.net/admin/api/debug/uploadDebugLog', true); http.open('POST', 'https://admin.iot.u-gen.net/admin/api/debug/uploadDebugLog', true);
http.setRequestHeader('Accept', 'application/json'); http.setRequestHeader('Accept', 'application/json');
http.setRequestHeader('Content-type', 'application/json; charset=UTF-8'); http.setRequestHeader('Content-type', 'application/json; charset=UTF-8');
http.onreadystatechange = () => { http.onreadystatechange = function() {
if (http.readyState === 4 && http.status === 200) { if (http.readyState === 4 && http.status === 200) {
var response = JSON.parse(http.responseText); var response = JSON.parse(http.responseText);
// console.log(response); // console.log(response);
......
...@@ -24588,6 +24588,7 @@ function getLockInfo(self) { ...@@ -24588,6 +24588,7 @@ function getLockInfo(self) {
//设置设备信息 //设置设备信息
function setDevceInfo(self, data) { function setDevceInfo(self, data) {
console.log(data); console.log(data);
if (data.BatteryPercentage) {
self.setBatteryPercent(data.BatteryPercentage.value); self.setBatteryPercent(data.BatteryPercentage.value);
if (data.BatteryPercentage.value >= 10) { if (data.BatteryPercentage.value >= 10) {
//向上取整 //向上取整
...@@ -24595,6 +24596,7 @@ function setDevceInfo(self, data) { ...@@ -24595,6 +24596,7 @@ function setDevceInfo(self, data) {
} else { } else {
self.setBatteryState(_config2.default.powerIcon[Math.round(data.BatteryPercentage.value / 20)]); self.setBatteryState(_config2.default.powerIcon[Math.round(data.BatteryPercentage.value / 20)]);
} }
}
if (data.action.value == 'notify') { if (data.action.value == 'notify') {
if (data.notify_type.value == 104) { if (data.notify_type.value == 104) {
//门铃响了 //门铃响了
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
<script type="text/javascript" src="../../lib/js/start.js"></script> <script type="text/javascript" src="../../lib/js/start.js"></script>
<script type="text/javascript" src="../../lib/js/p.js"></script> <script type="text/javascript" src="../../lib/js/p.js"></script>
<script type="text/javascript" src="../../lib/js/UIOT.js"></script> <script type="text/javascript" src="../../lib/js/UIOT.js"></script>
<script type="text/javascript" src="../../lib/js/SDSPlugin.js"></script>
</head> </head>
<body ontouchstart=""> <body ontouchstart="">
......
...@@ -28,9 +28,11 @@ function init() { ...@@ -28,9 +28,11 @@ function init() {
showLoginButtonFlag: true showLoginButtonFlag: true
}, },
mounted: function mounted() { mounted: function mounted() {
// loginButtonTap(this);
if (window.iotDebug) { if (window.iotDebug) {
iotDebug.push('start: Debug'); iotDebug.push('start: Debug');
} }
var self = this; var self = this;
if (plus.os.name == 'Android') { if (plus.os.name == 'Android') {
_public.iot.permission.checkPermission(['READ_EXTERNAL_STORAGE'], function (res) { _public.iot.permission.checkPermission(['READ_EXTERNAL_STORAGE'], function (res) {
...@@ -91,77 +93,60 @@ function initComponentsConfig() { ...@@ -91,77 +93,60 @@ function initComponentsConfig() {
} }
function loginButtonTap(self) { function loginButtonTap(self) {
_public.uComponents.showLoading(self); // uComponents.showLoading(self);
if (window.iotDebug) { // if(window.iotDebug){
iotDebug.push('start: initSDSLogin'); // iotDebug.push('start: initSDSLogin');
} // }
_public.iot.business.sds.init({ window.SDSPlugin.login({}, function (res) {
data: { console.log(res);
oa: true var data = _public.uPublic.checkResponseData(res.data);
},
success: function success(response) {
console.log(response);
if (window.iotDebug) {
iotDebug.push('end: initSDSLoginSuccess');
}
if (window.iotDebug) {
iotDebug.push('start: SDSlogin');
}
_public.iot.business.user.login({
data: {
sds: true
},
success: function success(response) {
console.log(response);
if (window.iotDebug) {
iotDebug.push('end: SDSloginSuccees');
}
// console.log(response);
// alert(JSON.stringify(response));
var data = _public.uPublic.checkResponseData(response.data);
if (data) { if (data) {
self.setShowLoginButtonFlag(false);
if (data.hasOwnProperty('UserID')) {
console.log("sds登陆成功了");
cloudsLogin(self, data.UserID); cloudsLogin(self, data.UserID);
} }
// iot.navigator.openWindow({ }, function (err) {
// url: '../device/index.html', console.log(err);
// id: 'device'
// });
} else {}
},
error: function error(_error) {
console.log(_error);
if (window.iotDebug) {
iotDebug.push('end: sds登陆失败' + JSON.stringify(_error));
}
if (window.iotDebug) {
iotDebug.upload(_public.iot, 'sds登陆失败');
}
//请求失败
// uPublic.openRequestErrorAlert(self);
},
complete: function complete() {
_public.uComponents.hideLoading(self);
}
});
},
error: function error(_error2) {
console.log(_error2);
if (window.iotDebug) {
iotDebug.push('end: sds登陆初始化失败' + JSON.stringify(_error2));
}
if (window.iotDebug) {
iotDebug.upload(_public.iot, 'sds登陆初始化失败');
}
//请求失败
_public.uPublic.openRequestErrorAlert(self);
},
complete: function complete() {
_public.uComponents.hideLoading(self);
}
}); });
// iot.business.sds.login({
// data: {
//// sds: true
// },
// success: (response) => {
//// console.log(response);
//// if(window.iotDebug){
//// iotDebug.push('end: SDSloginSuccees');
//// }
////// console.log(response);
////// alert(JSON.stringify(response));
//// var data = uPublic.checkResponseData(response.data);
//// if(data){
//// self.setShowLoginButtonFlag(false);
//// if(data.hasOwnProperty('UserID')){
//// console.log("sds登陆成功了");
//// cloudsLogin(self, data.UserID);
//// }
////// iot.navigator.openWindow({
////// url: '../device/index.html',
////// id: 'device'
////// });
//// }else{
////
//// }
// },
// error: (error) => {
//// console.log(error);
//// if(window.iotDebug){
//// iotDebug.push('end: sds登陆失败'+JSON.stringify(error));
//// }
//// if (window.iotDebug) {
//// iotDebug.upload(iot,'sds登陆失败');
//// }
//// //请求失败
////// uPublic.openRequestErrorAlert(self);
// },
// complete: () => {
//// uComponents.hideLoading(self);
// }
// });
} }
function cloudsLogin(self, id) { function cloudsLogin(self, id) {
...@@ -185,6 +170,7 @@ function cloudsLogin(self, id) { ...@@ -185,6 +170,7 @@ function cloudsLogin(self, id) {
url: '../device/index.html', url: '../device/index.html',
id: 'device' id: 'device'
}); });
plus.navigator.closeSplashscreen();
// uPublic.openWindow({ // uPublic.openWindow({
// url: '../device/index.html', // url: '../device/index.html',
// id: 'device', // id: 'device',
...@@ -193,8 +179,8 @@ function cloudsLogin(self, id) { ...@@ -193,8 +179,8 @@ function cloudsLogin(self, id) {
// } // }
// }); // });
}, },
error: function error(_error3) { error: function error(_error) {
console.log(_error3); console.log(_error);
// if(window.iotDebug){ // if(window.iotDebug){
// iotDebug.push('end: 云端登陆失败'+JSON.stringify(error)); // iotDebug.push('end: 云端登陆失败'+JSON.stringify(error));
// } // }
......
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