Commit 22735af2 by 朱建香

1123

parent 6ea9af5f
...@@ -697,12 +697,14 @@ function getLockInfo(self){ ...@@ -697,12 +697,14 @@ function getLockInfo(self){
//设置设备信息 //设置设备信息
function setDevceInfo(self, data) { function setDevceInfo(self, data) {
console.log(data); console.log(data);
self.setBatteryPercent(data.BatteryPercentage.value); if(data.BatteryPercentage){
if(data.BatteryPercentage.value >= 10){ self.setBatteryPercent(data.BatteryPercentage.value);
//向上取整 if(data.BatteryPercentage.value >= 10){
self.setBatteryState(config.powerIcon[Math.ceil(data.BatteryPercentage.value/20)]); //向上取整
}else{ self.setBatteryState(config.powerIcon[Math.ceil(data.BatteryPercentage.value/20)]);
self.setBatteryState(config.powerIcon[Math.round(data.BatteryPercentage.value/20)]); }else{
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,15 +21,17 @@ function init() { ...@@ -21,15 +21,17 @@ 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) {
console.log('success', res); console.log('success', res);
var clientInfo = plus.push.getClientInfo(); var clientInfo = plus.push.getClientInfo();
self.setClientId(clientInfo.clientid); self.setClientId(clientInfo.clientid);
loginButtonTap(self); loginButtonTap(self);
}, function (err) { }, function (err) {
console.log('error', err); console.log('error', err);
...@@ -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);
}, if(data){
success: (response) => { cloudsLogin(self, data.UserID);
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){
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);
}
});
},
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);
} }
}); },(err)=>{
console.log(err);
})
// 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){
...@@ -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',
......
(function(window) {
var m = {};
document.addEventListener("plusready", function() {
// 声明的JS“扩展插件别名”
var _BLECODE = 'SDSPlugin',
B = window.plus.bridge;
var sdstool = {
// 声明异步返回方法
login: function(userInfo, successCallback, errorCallback) {
var success = typeof successCallback !== 'function' ? null : function(args) {
successCallback(args);
},
fail = typeof errorCallback !== 'function' ? null : function(code) {
errorCallback(code);
};
callbackID = B.callbackId(success, fail);
return B.exec(_BLECODE, "login", [callbackID, userInfo]);
},
logout: function(successCallback, errorCallback) {
var success = typeof successCallback !== 'function' ? null : function(args) {
successCallback(args);
},
fail = typeof errorCallback !== 'function' ? null : function(code) {
errorCallback(code);
};
callbackID = B.callbackId(success, fail);
return B.exec(_BLECODE, "logout", [callbackID]);
},
/** ******************下行監聽API********************** **/
//注册下行监听
registerPushListener: function(successCallback, errorCallback) {
var success = typeof successCallback !== 'function' ? null : function(args) {
successCallback(args);
},
fail = typeof errorCallback !== 'function' ? null : function(code) {
errorCallback(code);
};
callbackID = B.callbackId(success, fail);
return B.exec(_BLECODE, "registerPushListener", [callbackID]);
},
//注销下行监听
unregisterPushListener: function(successCallback, errorCallback) {
var success = typeof successCallback !== 'function' ? null : function(args) {
successCallback(args);
},
fail = typeof errorCallback !== 'function' ? null : function(code) {
errorCallback(code);
};
callbackID = B.callbackId(success, fail);
return B.exec(_BLECODE, "unregisterPushListener", [callbackID]);
},
/** ******************產品API********************** **/
//获取产品列表
getProductList: function(successCallback, errorCallback) {
var success = typeof successCallback !== 'function' ? null : function(args) {
successCallback(args);
},
fail = typeof errorCallback !== 'function' ? null : function(code) {
errorCallback(code);
};
callbackID = B.callbackId(success, fail);
return B.exec(_BLECODE, "getProductList", [callbackID]);
},
//查询产品信息
getProductDetail: function(model, successCallback, errorCallback) {
var success = typeof successCallback !== 'function' ? null : function(args) {
successCallback(args);
},
fail = typeof errorCallback !== 'function' ? null : function(code) {
errorCallback(code);
};
callbackID = B.callbackId(success, fail);
return B.exec(_BLECODE, "getProductDetail", [callbackID, model]);
},
//获取系统时间
getAlinktime: function(successCallback, errorCallback) {
var success = typeof successCallback !== 'function' ? null : function(args) {
successCallback(args);
},
fail = typeof errorCallback !== 'function' ? null : function(code) {
errorCallback(code);
};
callbackID = B.callbackId(success, fail);
return B.exec(_BLECODE, "getAlinktime", [callbackID]);
},
//注册设备 (目前仅限蓝牙设备需要主动调用该接口)
//TODO
registerByuser: function(model, successCallback, errorCallback) {
var success = typeof successCallback !== 'function' ? null : function(args) {
successCallback(args);
},
fail = typeof errorCallback !== 'function' ? null : function(code) {
errorCallback(code);
};
callbackID = B.callbackId(success, fail);
return B.exec(_BLECODE, "registerByuser", [callbackID, model]);
},
//绑定设备
bindDevice: function(successCallback, errorCallback) {
var success = typeof successCallback !== 'function' ? null : function(args) {
successCallback(args);
},
fail = typeof errorCallback !== 'function' ? null : function(code) {
errorCallback(code);
};
callbackID = B.callbackId(success, fail);
return B.exec(_BLECODE, "bindDevice", [callbackID]);
},
//解绑设备
unbindDevice: function(uuid, successCallback, errorCallback) {
var success = typeof successCallback !== 'function' ? null : function(args) {
successCallback(args);
},
fail = typeof errorCallback !== 'function' ? null : function(code) {
errorCallback(code);
};
callbackID = B.callbackId(success, fail);
return B.exec(_BLECODE, "unbindDevice", [callbackID, uuid]);
},
//生成二维码
saveqr: function(uuid, successCallback, errorCallback) {
var success = typeof successCallback !== 'function' ? null : function(args) {
successCallback(args);
},
fail = typeof errorCallback !== 'function' ? null : function(code) {
errorCallback(code);
};
callbackID = B.callbackId(success, fail);
return B.exec(_BLECODE, "saveqr", [callbackID, uuid]);
},
//扫描二维码
scanqr: function(qr_key, successCallback, errorCallback) {
var success = typeof successCallback !== 'function' ? null : function(args) {
successCallback(args);
},
fail = typeof errorCallback !== 'function' ? null : function(code) {
errorCallback(code);
};
callbackID = B.callbackId(success, fail);
return B.exec(_BLECODE, "scanqr", [callbackID, qr_key]);
},
// getDevicesByuser: function(successCallback, errorCallback) {
// console.log(11111111111);
// var success = typeof successCallback !== 'function' ? null : function(args) {
// successCallback(args);
// },
// fail = typeof errorCallback !== 'function' ? null : function(code) {
// errorCallback(code);
// };
// callbackID = B.callbackId(success, fail);
// return B.exec(_BLECODE, "getDevicesByuser", [callbackID]);
// },
//获取与当前用户绑定的所有设备
getDevicesByuser: function(successCallback, errorCallback) {
var success = typeof successCallback !== 'function' ? null : function(args) {
successCallback(args);
},
fail = typeof errorCallback !== 'function' ? null : function(code) {
errorCallback(code);
};
callbackID = B.callbackId(success, fail);
return B.exec(_BLECODE, "getDevicesByuser", [callbackID]);
},
//获取设备最新状态
getDeviceStatus: function(uuid, successCallback, errorCallback) {
var success = typeof successCallback !== 'function' ? null : function(args) {
successCallback(args);
},
fail = typeof errorCallback !== 'function' ? null : function(code) {
errorCallback(code);
};
callbackID = B.callbackId(success, fail);
return B.exec(_BLECODE, "getDeviceStatus", [callbackID, uuid]);
},
//设置设备属性
setDeviceStatus: function(uuid, setParams, successCallback, errorCallback) {
var success = typeof successCallback !== 'function' ? null : function(args) {
successCallback(args);
},
fail = typeof errorCallback !== 'function' ? null : function(code) {
errorCallback(code);
};
callbackID = B.callbackId(success, fail);
return B.exec(_BLECODE, "setDeviceStatus", [callbackID, uuid, setParams]);
},
//获取设备详情
getDeviceDetail: function(uuid, successCallback, errorCallback) {
var success = typeof successCallback !== 'function' ? null : function(args) {
successCallback(args);
},
fail = typeof errorCallback !== 'function' ? null : function(code) {
errorCallback(code);
};
callbackID = B.callbackId(success, fail);
return B.exec(_BLECODE, "getDeviceDetail", [callbackID, uuid]);
},
//上报设备数据
postDeviceData: function(uuid, deviceData, successCallback, errorCallback) {
var success = typeof successCallback !== 'function' ? null : function(args) {
successCallback(args);
},
fail = typeof errorCallback !== 'function' ? null : function(code) {
errorCallback(code);
};
callbackID = B.callbackId(success, fail);
return B.exec(_BLECODE, "postDeviceData", [callbackID, uuid, deviceData]);
},
//更改设备昵称
updateDeviceInfo: function(uuid, nickName, model, successCallback, errorCallback) {
var success = typeof successCallback !== 'function' ? null : function(args) {
successCallback(args);
},
fail = typeof errorCallback !== 'function' ? null : function(code) {
errorCallback(code);
};
callbackID = B.callbackId(success, fail);
return B.exec(_BLECODE, "updateDeviceInfo", [callbackID, uuid, nickName, model]);
},
//保存用户私有数据
savePrivateData: function(dataKey, dataValue, successCallback, errorCallback) {
var success = typeof successCallback !== 'function' ? null : function(args) {
successCallback(args);
},
fail = typeof errorCallback !== 'function' ? null : function(code) {
errorCallback(code);
};
callbackID = B.callbackId(success, fail);
return B.exec(_BLECODE, "savePrivateData", [callbackID, dataKey, dataValue]);
},
//获取用户私有数据
getPrivateData: function(dataKey, successCallback, errorCallback) {
var success = typeof successCallback !== 'function' ? null : function(args) {
successCallback(args);
},
fail = typeof errorCallback !== 'function' ? null : function(code) {
errorCallback(code);
};
callbackID = B.callbackId(success, fail);
return B.exec(_BLECODE, "getPrivateData", [callbackID, dataKey]);
},
//设备状态变更
//TODO(需要商量處理)
deviceStatusChange: function(dataKey, successCallback, errorCallback) {
var success = typeof successCallback !== 'function' ? null : function(args) {
successCallback(args);
},
fail = typeof errorCallback !== 'function' ? null : function(code) {
errorCallback(code);
};
callbackID = B.callbackId(success, fail);
return B.exec(_BLECODE, "deviceStatusChange", [callbackID, dataKey]);
},
//设备绑定关系变更下行推送
deviceBindRelChange: function(uuid, auid, relation, successCallback, errorCallback) {
var success = typeof successCallback !== 'function' ? null : function(args) {
successCallback(args);
},
fail = typeof errorCallback !== 'function' ? null : function(code) {
errorCallback(code);
};
callbackID = B.callbackId(success, fail);
return B.exec(_BLECODE, "deviceBindRelChange", [callbackID, uuid, auid, relation]);
},
//设备配网
wifiBind: function(successCallback, errorCallback) {
var success = typeof successCallback !== 'function' ? null : function(args) {
successCallback(args);
},
fail = typeof errorCallback !== 'function' ? null : function(code) {
errorCallback(code);
};
callbackID = B.callbackId(success, fail);
return B.exec(_BLECODE, "wifiBind", [callbackID]);
},
/******************** 设备自定义配网API ******************************/
//获取ssid
getSSId: function (successCallback, errorCallback) {
var success = typeof successCallback !== 'function' ? null : function (args) {
successCallback(args);
},
fail = typeof errorCallback !== 'function' ? null : function (code) {
errorCallback(code);
};
callbackID = B.callbackId(success, fail);
return B.exec(_BLECODE, "getSSId", [callbackID]);
},
//开始查找设备
findDevices: function (successCallback, errorCallback) {
var success = typeof successCallback !== 'function' ? null : function (args) {
successCallback(args);
},
fail = typeof errorCallback !== 'function' ? null : function (code) {
errorCallback(code);
};
callbackID = B.callbackId(success, fail);
return B.exec(_BLECODE, "findDevices", [callbackID]);
},
//停止查找设备
stopFindDevices: function (successCallback, errorCallback) {
var success = typeof successCallback !== 'function' ? null : function (args) {
successCallback(args);
},
fail = typeof errorCallback !== 'function' ? null : function (code) {
errorCallback(code);
};
callbackID = B.callbackId(success, fail);
return B.exec(_BLECODE, "stopFindDevices", [callbackID]);
},
//开始连接wifi
startFindWIFI: function (model, ssid, wifiPWD, timeOut, successCallback, errorCallback) {
var success = typeof successCallback !== 'function' ? null : function (args) {
successCallback(args);
},
fail = typeof errorCallback !== 'function' ? null : function (code) {
errorCallback(code);
};
callbackID = B.callbackId(success, fail);
return B.exec(_BLECODE, "startFindWIFI", [callbackID, model, ssid, wifiPWD, timeOut]);
},
//停止连接wifi
stopFindWIFI: function (successCallback, errorCallback) {
var success = typeof successCallback !== 'function' ? null : function (args) {
successCallback(args);
},
fail = typeof errorCallback !== 'function' ? null : function (code) {
errorCallback(code);
};
callbackID = B.callbackId(success, fail);
return B.exec(_BLECODE, "stopFindWIFI", [callbackID]);
}
};
window.plus.sdstool = sdstool;
}, true);
m.login = function(userInfo, success, failure) {
console.log(11111);
plus.sdstool.login(userInfo, function(ret) {
success(ret);
console.log(ret);
}, function(err) {
failure(err);
});
};
m.logout = function(success, failure) {
plus.sdstool.logout(function(ret) {
success(ret);
console.log(ret);
}, function(err) {
failure(err);
});
};
m.getProductList = function(success, failure) {
plus.sdstool.getProductList(function(ret) {
success(ret);
console.log(ret);
}, function(err) {
failure(err);
});
};
m.registerPushListener = function(success, failure) {
plus.sdstool.registerPushListener(function(ret) {
success(ret);
console.log(ret);
}, function(err) {
failure(err);
});
};
m.unregisterPushListener = function(success, failure) {
plus.sdstool.unregisterPushListener(function(ret) {
success(ret);
console.log(ret);
}, function(err) {
failure(err);
});
};
m.getProductDetail = function(model, success, failure) {
plus.sdstool.getProductDetail(model, function(ret) {
success(ret);
console.log(ret);
}, function(err) {
failure(err);
});
};
m.getAlinktime = function(success, failure) {
plus.sdstool.getAlinktime(function(ret) {
success(ret);
console.log(ret);
}, function(err) {
failure(err);
});
};
m.registerByuser = function(model, success, failure) {
plus.sdstool.registerByuser(model, function(ret) {
success(ret);
console.log(ret);
}, function(err) {
failure(err);
});
};
m.bindDevice = function(uuid, success, failure) {
plus.sdstool.bindDevice(uuid, function(ret) {
success(ret);
console.log(ret);
}, function(err) {
failure(err);
});
};
m.unbindDevice = function(uuid, success, failure) {
plus.sdstool.unbindDevice(uuid, function(ret) {
success(ret);
console.log(ret);
}, function(err) {
failure(err);
});
};
m.saveqr = function(uuid, success, failure) {
plus.sdstool.saveqr(uuid, function(ret) {
success(ret);
console.log(ret);
}, function(err) {
console.log(err);
failure(err);
});
};
m.scanqr = function(qr_key, success, failure) {
plus.sdstool.scanqr(qr_key, function(ret) {
success(ret);
console.log(ret);
}, function(err) {
failure(err);
});
};
m.getDevicesByuser = function(success, failure) {
plus.sdstool.getDevicesByuser(function(ret) {
success(ret);
console.log(ret);
}, function(err) {
failure(err);
});
};
m.getDeviceStatus = function(uuid, success, failure) {
plus.sdstool.getDeviceStatus(uuid,function(ret) {
success(ret);
console.log(ret);
}, function(err) {
failure(err);
});
};
m.setDeviceStatus = function(uuid, setParams, success, failure) {
plus.sdstool.setDeviceStatus(uuid, setParams, function(ret) {
success(ret);
console.log(ret);
}, function(err) {
failure(err);
});
};
m.getDeviceDetail = function(uuid, success, failure) {
plus.sdstool.getDeviceDetail(uuid, function(ret) {
success(ret);
console.log(ret);
}, function(err) {
failure(err);
});
};
m.postDeviceData = function(uuid, deviceData, success, failure) {
plus.sdstool.postDeviceData(uuid, deviceData, function(ret) {
success(ret);
console.log(ret);
}, function(err) {
failure(err);
});
};
m.updateDeviceInfo = function(uuid, nickName, model, success, failure) {
plus.sdstool.updateDeviceInfo(uuid, nickName, model, function(ret) {
success(ret);
console.log(ret);
}, function(err) {
failure(err);
});
};
m.savePrivateData = function(dataKey, dataValue, success, failure) {
plus.sdstool.savePrivateData(dataKey, dataValue, function(ret) {
success(ret);
console.log(ret);
}, function(err) {
failure(err);
});
};
m.getPrivateData = function(dataKey, success, failure) {
plus.sdstool.getPrivateData(dataKey, function(ret) {
success(ret);
console.log(ret);
}, function(err) {
failure(err);
});
};
//TODO
m.deviceStatusChange = function(dataKey, success, failure) {
plus.sdstool.deviceStatusChange(dataKey, function(ret) {
success(ret);
console.log(ret);
}, function(err) {
failure(err);
});
};
m.deviceBindRelChange = function(uuid, auid, relation, success, failure) {
plus.sdstool.deviceBindRelChange(uuid, auid, relation, function(ret) {
success(ret);
console.log(ret);
}, function(err) {
failure(err);
});
};
m.wifiBind = function(success, failure) {
plus.sdstool.wifiBind(function(ret) {
success(ret);
console.log(ret);
}, function(err) {
failure(err);
});
};
/******************** 设备自定义配网API ******************************/
//获取ssid
m.getSSId = function(success, failure) {
plus.sdstool.getSSId(function(ret) {
success(ret);
console.log(ret);
}, function(err) {
failure(err);
});
};
m.startFindWIFI = function(model, ssid, wifiPWD, timeOut, success, failure) {
plus.sdstool.startFindWIFI(model, ssid, wifiPWD, timeOut, function(ret) {
success(ret);
// console.log(ret);
}, function(err) {
failure(err);
});
};
window.SDSPlugin = m;
})(window);
...@@ -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,12 +24588,14 @@ function getLockInfo(self) { ...@@ -24588,12 +24588,14 @@ function getLockInfo(self) {
//设置设备信息 //设置设备信息
function setDevceInfo(self, data) { function setDevceInfo(self, data) {
console.log(data); console.log(data);
self.setBatteryPercent(data.BatteryPercentage.value); if (data.BatteryPercentage) {
if (data.BatteryPercentage.value >= 10) { self.setBatteryPercent(data.BatteryPercentage.value);
//向上取整 if (data.BatteryPercentage.value >= 10) {
self.setBatteryState(_config2.default.powerIcon[Math.ceil(data.BatteryPercentage.value / 20)]); //向上取整
} else { self.setBatteryState(_config2.default.powerIcon[Math.ceil(data.BatteryPercentage.value / 20)]);
self.setBatteryState(_config2.default.powerIcon[Math.round(data.BatteryPercentage.value / 20)]); } else {
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="">
......
...@@ -18,195 +18,181 @@ _public.iot.ready(init); /** ...@@ -18,195 +18,181 @@ _public.iot.ready(init); /**
*/ */
function init() { function init() {
//通用 dialog、loading组件 //通用 dialog、loading组件
_public.uPublic.componentsInit(['u-dialog', 'u-loading', 'u-button']); _public.uPublic.componentsInit(['u-dialog', 'u-loading', 'u-button']);
var app = new Vue({ var app = new Vue({
data: { data: {
//配置组件 //配置组件
componentsConfig: initComponentsConfig(), componentsConfig: initComponentsConfig(),
clientId: null, clientId: null,
showLoginButtonFlag: true showLoginButtonFlag: true
}, },
mounted: function mounted() { mounted: function mounted() {
if (window.iotDebug) { // loginButtonTap(this);
iotDebug.push('start: Debug'); if (window.iotDebug) {
} iotDebug.push('start: Debug');
var self = this; }
if (plus.os.name == 'Android') {
_public.iot.permission.checkPermission(['READ_EXTERNAL_STORAGE'], function (res) { var self = this;
console.log('success', res); if (plus.os.name == 'Android') {
var clientInfo = plus.push.getClientInfo(); _public.iot.permission.checkPermission(['READ_EXTERNAL_STORAGE'], function (res) {
self.setClientId(clientInfo.clientid); console.log('success', res);
loginButtonTap(self); var clientInfo = plus.push.getClientInfo();
}, function (err) { self.setClientId(clientInfo.clientid);
console.log('error', err); loginButtonTap(self);
}); }, function (err) {
} console.log('error', err);
// var clientInfo = plus.push.getClientInfo(); });
// this.setClientId(clientInfo.clientid); }
// loginButtonTap(this); // var clientInfo = plus.push.getClientInfo();
}, // this.setClientId(clientInfo.clientid);
// loginButtonTap(this);
methods: { },
getShowLoginButtonFlag: function getShowLoginButtonFlag() {
return this.showLoginButtonFlag; methods: {
}, getShowLoginButtonFlag: function getShowLoginButtonFlag() {
setShowLoginButtonFlag: function setShowLoginButtonFlag(flag) { return this.showLoginButtonFlag;
this.showLoginButtonFlag = flag; },
}, setShowLoginButtonFlag: function setShowLoginButtonFlag(flag) {
onLoginButtonTap: function onLoginButtonTap() { this.showLoginButtonFlag = flag;
loginButtonTap(this); },
}, onLoginButtonTap: function onLoginButtonTap() {
getClientId: function getClientId() { loginButtonTap(this);
return this.clientId; },
}, getClientId: function getClientId() {
setClientId: function setClientId(id) { return this.clientId;
this.clientId = id; },
} setClientId: function setClientId(id) {
} this.clientId = id;
}).$mount('#app'); }
}
}).$mount('#app');
} }
//配置组件参数 //配置组件参数
function initComponentsConfig() { function initComponentsConfig() {
return { return {
//登录 button 参数 //登录 button 参数
loginButton: { loginButton: {
initParam: { initParam: {
class: 'custom-guide-button', class: 'custom-guide-button',
text: Vue.t('btn.guideLogin') text: Vue.t('btn.guideLogin')
} }
}, },
dialog: { dialog: {
initParam: { initParam: {
class: 'custom-dialog' class: 'custom-dialog'
} }
}, },
loading: { loading: {
initParam: { initParam: {
class: 'custom-loading' class: 'custom-loading'
} }
} }
}; };
} }
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);
}, if (data) {
success: function success(response) { cloudsLogin(self, data.UserID);
console.log(response); }
if (window.iotDebug) { }, function (err) {
iotDebug.push('end: initSDSLoginSuccess'); console.log(err);
} });
if (window.iotDebug) { // iot.business.sds.login({
iotDebug.push('start: SDSlogin'); // data: {
} //// sds: true
_public.iot.business.user.login({ // },
data: { // success: (response) => {
sds: true //// console.log(response);
}, //// if(window.iotDebug){
success: function success(response) { //// iotDebug.push('end: SDSloginSuccees');
console.log(response); //// }
if (window.iotDebug) { ////// console.log(response);
iotDebug.push('end: SDSloginSuccees'); ////// alert(JSON.stringify(response));
} //// var data = uPublic.checkResponseData(response.data);
// console.log(response); //// if(data){
// alert(JSON.stringify(response)); //// self.setShowLoginButtonFlag(false);
var data = _public.uPublic.checkResponseData(response.data); //// if(data.hasOwnProperty('UserID')){
if (data) { //// console.log("sds登陆成功了");
self.setShowLoginButtonFlag(false); //// cloudsLogin(self, data.UserID);
if (data.hasOwnProperty('UserID')) { //// }
console.log("sds登陆成功了"); ////// iot.navigator.openWindow({
cloudsLogin(self, data.UserID); ////// url: '../device/index.html',
} ////// id: 'device'
// iot.navigator.openWindow({ ////// });
// url: '../device/index.html', //// }else{
// id: 'device' ////
// }); //// }
} else {} // },
}, // error: (error) => {
error: function error(_error) { //// console.log(error);
console.log(_error); //// if(window.iotDebug){
if (window.iotDebug) { //// iotDebug.push('end: sds登陆失败'+JSON.stringify(error));
iotDebug.push('end: sds登陆失败' + JSON.stringify(_error)); //// }
} //// if (window.iotDebug) {
if (window.iotDebug) { //// iotDebug.upload(iot,'sds登陆失败');
iotDebug.upload(_public.iot, 'sds登陆失败'); //// }
} //// //请求失败
//请求失败 ////// uPublic.openRequestErrorAlert(self);
// uPublic.openRequestErrorAlert(self); // },
}, // complete: () => {
complete: function complete() { //// uComponents.hideLoading(self);
_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);
}
});
} }
function cloudsLogin(self, id) { function cloudsLogin(self, id) {
_public.uComponents.showLoading(self); _public.uComponents.showLoading(self);
if (window.iotDebug) { if (window.iotDebug) {
iotDebug.push('start: cloudsLogin'); iotDebug.push('start: cloudsLogin');
} }
_public.iot.business.user.simpleLogin({ _public.iot.business.user.simpleLogin({
data: { data: {
username: id, username: id,
clienId: self.getClientId() clienId: self.getClientId()
}, },
success: function success(response) { success: function success(response) {
if (window.iotDebug) { if (window.iotDebug) {
iotDebug.push('end: cloudsLogin'); iotDebug.push('end: cloudsLogin');
} }
if (window.iotDebug) { if (window.iotDebug) {
iotDebug.upload(_public.iot, '登陆流程时间'); iotDebug.upload(_public.iot, '登陆流程时间');
} }
_public.iot.navigator.openWindow({ _public.iot.navigator.openWindow({
url: '../device/index.html', url: '../device/index.html',
id: 'device' id: 'device'
}); });
// uPublic.openWindow({ plus.navigator.closeSplashscreen();
// url: '../device/index.html', // uPublic.openWindow({
// id: 'device', // url: '../device/index.html',
// styles: { // id: 'device',
// 'background': 'transparent' // styles: {
// } // 'background': 'transparent'
// }); // }
}, // });
error: function error(_error3) { },
console.log(_error3); error: function error(_error) {
// if(window.iotDebug){ console.log(_error);
// iotDebug.push('end: 云端登陆失败'+JSON.stringify(error)); // if(window.iotDebug){
// } // iotDebug.push('end: 云端登陆失败'+JSON.stringify(error));
// if (window.iotDebug) { // }
// iotDebug.upload(iot,'云端登陆失败'); // if (window.iotDebug) {
// } // iotDebug.upload(iot,'云端登陆失败');
_public.uPublic.openRequestErrorAlert(self); // }
}, _public.uPublic.openRequestErrorAlert(self);
complete: function complete() { },
// uComponents.hideLoading(self); complete: function complete() {
} // uComponents.hideLoading(self);
}); }
});
} }
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)["default"])) /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)["default"]))
......
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