Commit feb4a2f5 by 朱建香

1031

parent 25f89540
...@@ -168,6 +168,7 @@ ...@@ -168,6 +168,7 @@
"addDevice": { "addDevice": {
"scanCodeAdd": "扫描绑定设备", "scanCodeAdd": "扫描绑定设备",
"wifiAdd": "配置Wi-Fi", "wifiAdd": "配置Wi-Fi",
"loading": "loading",
"bindSuccess": "绑定成功", "bindSuccess": "绑定成功",
"bindFailure": "绑定失败", "bindFailure": "绑定失败",
"reBindDevice": "请重新绑定" "reBindDevice": "请重新绑定"
......
...@@ -25,5 +25,7 @@ export default { ...@@ -25,5 +25,7 @@ export default {
20: "hijackingAlarm", 20: "hijackingAlarm",
}, },
"mode_type": "UGEN_SECURITY_SMARTDOOR_", "mode_type": "UGEN_SECURITY_SMARTDOOR_",
"mode": "UGEN_SECURITY_SMARTDOOR_YJ2017" "mode": "UGEN_SECURITY_SMARTDOOR_YJ2017",
"GET_MSG_INTERVAL": 5000,
"wifi_add_timeout": 30000
} }
\ No newline at end of file
...@@ -103,7 +103,7 @@ function initComponentsConfig() { ...@@ -103,7 +103,7 @@ function initComponentsConfig() {
initParam: { initParam: {
class: 'custom-comm-loading', class: 'custom-comm-loading',
buttonText: Vue.t('btn.confirm'), buttonText: Vue.t('btn.confirm'),
text: 'loading', text: Vue.t('addDevice.loading'),
status: 0 status: 0
} }
} }
...@@ -197,7 +197,7 @@ function connectButtonTap(self){ ...@@ -197,7 +197,7 @@ function connectButtonTap(self){
//连接失败 //连接失败
uComponents.changeCommLoadingStatusAndText(self, 2, Vue.t('addDevice.bindFailure')); uComponents.changeCommLoadingStatusAndText(self, 2, Vue.t('addDevice.bindFailure'));
self.setStatus(2); self.setStatus(2);
uComponents.changeCommButtonText(Vue.t('addDevice.reBindDevice')); uComponents.changeCommButtonText(self, Vue.t('addDevice.reBindDevice'));
//停止查找设备 //停止查找设备
iot.business.sds.stopFindDevices({ iot.business.sds.stopFindDevices({
success: (response) => {}, success: (response) => {},
...@@ -210,6 +210,20 @@ function connectButtonTap(self){ ...@@ -210,6 +210,20 @@ function connectButtonTap(self){
} }
}); });
} }
setTimeout(function (){
if(self.getStatus() == 0){
console.log("timeout");
//连接失败
uComponents.changeCommLoadingStatusAndText(self, 2, Vue.t('addDevice.bindFailure'));
self.setStatus(2);
uComponents.changeCommButtonText(self, Vue.t('addDevice.reBindDevice'));
//停止查找设备
iot.business.sds.stopFindDevices({
success: (response) => {},
error: (error) => {}
});
}
},config.wifi_add_timeout);
} }
//tap loading button //tap loading button
...@@ -224,6 +238,8 @@ function commLoadingButtonTap(self) { ...@@ -224,6 +238,8 @@ function commLoadingButtonTap(self) {
}else if(self.getStatus() == 2){ }else if(self.getStatus() == 2){
//绑定失败 //绑定失败
uComponents.hideCommLoading(self); uComponents.hideCommLoading(self);
self.setStatus(0);
uComponents.changeCommLoadingStatusAndText(self, 0, Vue.t('addDevice.loading'));
} }
} }
...@@ -258,12 +274,14 @@ function bind(self, deviceId, productId){ ...@@ -258,12 +274,14 @@ function bind(self, deviceId, productId){
let data = response.data; let data = response.data;
if(data.success){ if(data.success){
uComponents.changeCommLoadingStatusAndText(self, 1, Vue.t('addDevice.bindSuccess')); uComponents.changeCommLoadingStatusAndText(self, 1, Vue.t('addDevice.bindSuccess'));
uComponents.changeCommButtonText(self, Vue.t('btn.confirm'));
self.setStatus(1); self.setStatus(1);
} }
}, },
error: (error) => { error: (error) => {
console.log(error); console.log(error);
uComponents.changeCommLoadingStatusAndText(self, 2, Vue.t('addDevice.bindFailure')); uComponents.changeCommLoadingStatusAndText(self, 2, Vue.t('addDevice.bindFailure'));
uComponents.changeCommButtonText(self, Vue.t('addDevice.reBindDevice'));
self.setStatus(2); self.setStatus(2);
}, },
complete: () => {} complete: () => {}
......
...@@ -77,7 +77,6 @@ function init() { ...@@ -77,7 +77,6 @@ function init() {
error: (error) => {} error: (error) => {}
}); });
console.log(1);
//注册监听上报 //注册监听上报
iot.business.sds.registerPushListener({ iot.business.sds.registerPushListener({
success: (response) => { success: (response) => {
...@@ -95,6 +94,8 @@ function init() { ...@@ -95,6 +94,8 @@ function init() {
} }
}); });
notificationListener();
}, },
methods:{ methods:{
getValueOpendoorRecord(){ getValueOpendoorRecord(){
...@@ -435,6 +436,49 @@ function setDevceInfo(self, data) { ...@@ -435,6 +436,49 @@ function setDevceInfo(self, data) {
} }
} }
function pushAction(msg) {
console.log(msg);
// var payload = msg.payload;
// if (typeof payload == 'string') {
// payload = JSON.parse(msg.payload);
// }
// console.log(payload);
// if (payload.hasOwnProperty('date')) {
// console.log('in evaluation');
// } else if (payload.hasOwnProperty('report')) {
// console.log('in slim');
// }
}
function notificationListener() {
if (plus.os.name == 'Android') {
setInterval(function () {
console.log("innn");
var pushMsgArray = plus.push.getAllMessage();
plus.push.setAutoNotification(false);
console.log(pushMsgArray);
if (pushMsgArray) {
var pushMsgLength = pushMsgArray.length;
console.log(pushMsgLength);
if (pushMsgLength) {
var pushMsg = pushMsgArray[(pushMsgArray.length - 1)];
pushAction(pushMsg);
plus.push.clear();
}
}
}, config.GET_MSG_INTERVAL);
}
// 从系统消息中心点击消息启动应用事件
plus.push.addEventListener('click', function (msg) {
pushAction(msg);
}, false);
// 应用从推送服务器接收到推送消息事件
plus.push.addEventListener('receive', function (msg) {
pushAction(msg);
}, false);
}
//tap 个人信息 //tap 个人信息
function myInfoTap(self){ function myInfoTap(self){
iot.navigator.openWindow({ iot.navigator.openWindow({
...@@ -519,7 +563,7 @@ function remoteOpendoorTap(self){ ...@@ -519,7 +563,7 @@ function remoteOpendoorTap(self){
id: 'remoteOpendoor', id: 'remoteOpendoor',
extras: { extras: {
uuid: self.getUuid(), uuid: self.getUuid(),
deviceId: self.deviceId, deviceId: self.deviceId
} }
}); });
} }
......
...@@ -16,20 +16,22 @@ function init() { ...@@ -16,20 +16,22 @@ function init() {
const app = new Vue({ const app = new Vue({
data:{ data:{
//配置组件 //配置组件
componentsConfig: initComponentsConfig() componentsConfig: initComponentsConfig(),
clientId: null
}, },
mounted(){ mounted(){
// setTimeout(function(){ let clientInfo = plus.push.getClientInfo();
// iot.navigator.openWindow({ this.setClientId(clientInfo.clientid);
// url: './login.html',
// id: 'login'
// });
// },2000)
let self = this;
}, },
methods:{ methods:{
onLoginButtonTap(){ onLoginButtonTap(){
loginButtonTap(this); loginButtonTap(this);
},
getClientId(){
return this.clientId;
},
setClientId(id){
this.clientId = id;
} }
} }
}).$mount('#app'); }).$mount('#app');
...@@ -103,98 +105,12 @@ function loginButtonTap(self){ ...@@ -103,98 +105,12 @@ function loginButtonTap(self){
}); });
} }
//云端登陆
//function cloudsLogin(self, id){
// iot.business.user.autoLogin({
// success: (response) => {
// console.log("autoLogin");
// console.log(response);
// let data = uPublic.checkResponseData(response.data);
// if(data){
// uComponents.hideLoading(self);
// iot.navigator.openWindow({
// url: '../device/index.html',
// id: 'device'
// });
// }else{
//
// }
// },
// error: (error) => {
// console.log(error);
// iot.business.user.login({
// data: {
// username: id,
// pwd: id,
// },
// success: (response) => {
// console.log("login");
// console.log(response);
// let data = uPublic.checkResponseData(response.data);
// if(data){
// uComponents.hideLoading(self);
// iot.navigator.openWindow({
// url: '../device/index.html',
// id: 'device'
// });
// }else{
//
// }
// },
// error: (error) => {
// console.log(error);
// //不存在此用户
//// if(code == 10002){
// //用户注册
// iot.business.user.reg({
// data: {
// username: id,
// pwd: id,
// vcode: id
// },
// success: (response) => {
// console.log("regist");
// console.log(response);
// //注册成功
// let data = uPublic.checkResponseData(response.data);
// if(data){
// uComponents.hideLoading(self);
// iot.navigator.openWindow({
// url: '../device/index.html',
// id: 'device'
// });
// }else{
//
// }
// },
// error: (error) => {
// console.log(error);
// //注册失败
// uComponents.openAlert(self, Vue.t('login.failure'), {
// text: Vue.t('dialog.confirm'), callback: function () {
// plus.webview.currentWebview().reload();
// }
// });
// },
// complete: () => {}
// });
//// }
// //请求失败
// uPublic.openRequestErrorAlert(self);
// },
// complete: () => {}
// });
// },
// complete: () => {}
// });
////
//}
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,
clienId: self.getClientId()
}, },
success: (response) => { success: (response) => {
let data = uPublic.checkResponseData(response.data); let data = uPublic.checkResponseData(response.data);
......
...@@ -9935,7 +9935,9 @@ exports.default = { ...@@ -9935,7 +9935,9 @@ exports.default = {
20: "hijackingAlarm" 20: "hijackingAlarm"
}, },
"mode_type": "UGEN_SECURITY_SMARTDOOR_", "mode_type": "UGEN_SECURITY_SMARTDOOR_",
"mode": "UGEN_SECURITY_SMARTDOOR_YJ2017" "mode": "UGEN_SECURITY_SMARTDOOR_YJ2017",
"GET_MSG_INTERVAL": 5000,
"wifi_add_timeout": 30000
}; };
/***/ }), /***/ }),
......
...@@ -119,7 +119,7 @@ function initComponentsConfig() { ...@@ -119,7 +119,7 @@ function initComponentsConfig() {
initParam: { initParam: {
class: 'custom-comm-loading', class: 'custom-comm-loading',
buttonText: Vue.t('btn.confirm'), buttonText: Vue.t('btn.confirm'),
text: 'loading', text: Vue.t('addDevice.loading'),
status: 0 status: 0
} }
} }
...@@ -213,7 +213,7 @@ function connectButtonTap(self) { ...@@ -213,7 +213,7 @@ function connectButtonTap(self) {
//连接失败 //连接失败
_public.uComponents.changeCommLoadingStatusAndText(self, 2, Vue.t('addDevice.bindFailure')); _public.uComponents.changeCommLoadingStatusAndText(self, 2, Vue.t('addDevice.bindFailure'));
self.setStatus(2); self.setStatus(2);
_public.uComponents.changeCommButtonText(Vue.t('addDevice.reBindDevice')); _public.uComponents.changeCommButtonText(self, Vue.t('addDevice.reBindDevice'));
//停止查找设备 //停止查找设备
_public.iot.business.sds.stopFindDevices({ _public.iot.business.sds.stopFindDevices({
success: function success(response) {}, success: function success(response) {},
...@@ -226,6 +226,20 @@ function connectButtonTap(self) { ...@@ -226,6 +226,20 @@ function connectButtonTap(self) {
} }
}); });
} }
setTimeout(function () {
if (self.getStatus() == 0) {
console.log("timeout");
//连接失败
_public.uComponents.changeCommLoadingStatusAndText(self, 2, Vue.t('addDevice.bindFailure'));
self.setStatus(2);
_public.uComponents.changeCommButtonText(self, Vue.t('addDevice.reBindDevice'));
//停止查找设备
_public.iot.business.sds.stopFindDevices({
success: function success(response) {},
error: function error(_error5) {}
});
}
}, _config2.default.wifi_add_timeout);
} }
//tap loading button //tap loading button
...@@ -240,6 +254,8 @@ function commLoadingButtonTap(self) { ...@@ -240,6 +254,8 @@ function commLoadingButtonTap(self) {
} else if (self.getStatus() == 2) { } else if (self.getStatus() == 2) {
//绑定失败 //绑定失败
_public.uComponents.hideCommLoading(self); _public.uComponents.hideCommLoading(self);
self.setStatus(0);
_public.uComponents.changeCommLoadingStatusAndText(self, 0, Vue.t('addDevice.loading'));
} }
} }
...@@ -253,8 +269,8 @@ function unbind(self, deviceId, productId) { ...@@ -253,8 +269,8 @@ function unbind(self, deviceId, productId) {
console.log(response); console.log(response);
bind(self, deviceId, productId); bind(self, deviceId, productId);
}, },
error: function error(_error5) { error: function error(_error6) {
console.log(_error5); console.log(_error6);
}, },
complete: function complete() {} complete: function complete() {}
}); });
...@@ -273,12 +289,14 @@ function bind(self, deviceId, productId) { ...@@ -273,12 +289,14 @@ function bind(self, deviceId, productId) {
var data = response.data; var data = response.data;
if (data.success) { if (data.success) {
_public.uComponents.changeCommLoadingStatusAndText(self, 1, Vue.t('addDevice.bindSuccess')); _public.uComponents.changeCommLoadingStatusAndText(self, 1, Vue.t('addDevice.bindSuccess'));
_public.uComponents.changeCommButtonText(self, Vue.t('btn.confirm'));
self.setStatus(1); self.setStatus(1);
} }
}, },
error: function error(_error6) { error: function error(_error7) {
console.log(_error6); console.log(_error7);
_public.uComponents.changeCommLoadingStatusAndText(self, 2, Vue.t('addDevice.bindFailure')); _public.uComponents.changeCommLoadingStatusAndText(self, 2, Vue.t('addDevice.bindFailure'));
_public.uComponents.changeCommButtonText(self, Vue.t('addDevice.reBindDevice'));
self.setStatus(2); self.setStatus(2);
}, },
complete: function complete() {} complete: function complete() {}
......
...@@ -15980,7 +15980,6 @@ function init() { ...@@ -15980,7 +15980,6 @@ function init() {
error: function error(_error) {} error: function error(_error) {}
}); });
console.log(1);
//注册监听上报 //注册监听上报
_public.iot.business.sds.registerPushListener({ _public.iot.business.sds.registerPushListener({
success: function success(response) { success: function success(response) {
...@@ -15997,6 +15996,8 @@ function init() { ...@@ -15997,6 +15996,8 @@ function init() {
_public.uPublic.openRequestErrorAlert(self); _public.uPublic.openRequestErrorAlert(self);
} }
}); });
notificationListener();
}, },
methods: { methods: {
...@@ -16345,6 +16346,48 @@ function setDevceInfo(self, data) { ...@@ -16345,6 +16346,48 @@ function setDevceInfo(self, data) {
} }
} }
function pushAction(msg) {
console.log(msg);
// var payload = msg.payload;
// if (typeof payload == 'string') {
// payload = JSON.parse(msg.payload);
// }
// console.log(payload);
// if (payload.hasOwnProperty('date')) {
// console.log('in evaluation');
// } else if (payload.hasOwnProperty('report')) {
// console.log('in slim');
// }
}
function notificationListener() {
if (plus.os.name == 'Android') {
setInterval(function () {
console.log("innn");
var pushMsgArray = plus.push.getAllMessage();
plus.push.setAutoNotification(false);
console.log(pushMsgArray);
if (pushMsgArray) {
var pushMsgLength = pushMsgArray.length;
console.log(pushMsgLength);
if (pushMsgLength) {
var pushMsg = pushMsgArray[pushMsgArray.length - 1];
pushAction(pushMsg);
plus.push.clear();
}
}
}, _config2.default.GET_MSG_INTERVAL);
}
// 从系统消息中心点击消息启动应用事件
plus.push.addEventListener('click', function (msg) {
pushAction(msg);
}, false);
// 应用从推送服务器接收到推送消息事件
plus.push.addEventListener('receive', function (msg) {
pushAction(msg);
}, false);
}
//tap 个人信息 //tap 个人信息
function myInfoTap(self) { function myInfoTap(self) {
_public.iot.navigator.openWindow({ _public.iot.navigator.openWindow({
......
...@@ -23,21 +23,23 @@ function init() { ...@@ -23,21 +23,23 @@ function init() {
var app = new Vue({ var app = new Vue({
data: { data: {
//配置组件 //配置组件
componentsConfig: initComponentsConfig() componentsConfig: initComponentsConfig(),
clientId: null
}, },
mounted: function mounted() { mounted: function mounted() {
// setTimeout(function(){ var clientInfo = plus.push.getClientInfo();
// iot.navigator.openWindow({ this.setClientId(clientInfo.clientid);
// url: './login.html',
// id: 'login'
// });
// },2000)
var self = this;
}, },
methods: { methods: {
onLoginButtonTap: function onLoginButtonTap() { onLoginButtonTap: function onLoginButtonTap() {
loginButtonTap(this); loginButtonTap(this);
},
getClientId: function getClientId() {
return this.clientId;
},
setClientId: function setClientId(id) {
this.clientId = id;
} }
} }
}).$mount('#app'); }).$mount('#app');
...@@ -109,98 +111,12 @@ function loginButtonTap(self) { ...@@ -109,98 +111,12 @@ function loginButtonTap(self) {
}); });
} }
//云端登陆
//function cloudsLogin(self, id){
// iot.business.user.autoLogin({
// success: (response) => {
// console.log("autoLogin");
// console.log(response);
// let data = uPublic.checkResponseData(response.data);
// if(data){
// uComponents.hideLoading(self);
// iot.navigator.openWindow({
// url: '../device/index.html',
// id: 'device'
// });
// }else{
//
// }
// },
// error: (error) => {
// console.log(error);
// iot.business.user.login({
// data: {
// username: id,
// pwd: id,
// },
// success: (response) => {
// console.log("login");
// console.log(response);
// let data = uPublic.checkResponseData(response.data);
// if(data){
// uComponents.hideLoading(self);
// iot.navigator.openWindow({
// url: '../device/index.html',
// id: 'device'
// });
// }else{
//
// }
// },
// error: (error) => {
// console.log(error);
// //不存在此用户
//// if(code == 10002){
// //用户注册
// iot.business.user.reg({
// data: {
// username: id,
// pwd: id,
// vcode: id
// },
// success: (response) => {
// console.log("regist");
// console.log(response);
// //注册成功
// let data = uPublic.checkResponseData(response.data);
// if(data){
// uComponents.hideLoading(self);
// iot.navigator.openWindow({
// url: '../device/index.html',
// id: 'device'
// });
// }else{
//
// }
// },
// error: (error) => {
// console.log(error);
// //注册失败
// uComponents.openAlert(self, Vue.t('login.failure'), {
// text: Vue.t('dialog.confirm'), callback: function () {
// plus.webview.currentWebview().reload();
// }
// });
// },
// complete: () => {}
// });
//// }
// //请求失败
// uPublic.openRequestErrorAlert(self);
// },
// complete: () => {}
// });
// },
// complete: () => {}
// });
////
//}
function cloudsLogin(self, id) { function cloudsLogin(self, id) {
_public.uComponents.showLoading(self); _public.uComponents.showLoading(self);
_public.iot.business.user.simpleLogin({ _public.iot.business.user.simpleLogin({
data: { data: {
username: id username: id,
clienId: self.getClientId()
}, },
success: function success(response) { success: function success(response) {
var data = _public.uPublic.checkResponseData(response.data); var data = _public.uPublic.checkResponseData(response.data);
......
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