Commit 1a5e6c81 by 朱建香

0921

parent b1348d9c
...@@ -126,8 +126,8 @@ ...@@ -126,8 +126,8 @@
"addDevice": { "addDevice": {
"scanCodeAdd": "扫描绑定设备", "scanCodeAdd": "扫描绑定设备",
"wifiAdd": "配置Wi-Fi", "wifiAdd": "配置Wi-Fi",
"scanCodeSuccess": "扫描成功", "bindSuccess": "绑定成功",
"scanCodeFailue": "扫描失败" "bindFailue": "绑定失败"
}, },
"wifiAddHelp": { "wifiAddHelp": {
"helpTitle": "配置Wi-Fi说明:", "helpTitle": "配置Wi-Fi说明:",
...@@ -174,5 +174,8 @@ ...@@ -174,5 +174,8 @@
"connectSuccess": "Wi-Fi连接成功,正在绑定...", "connectSuccess": "Wi-Fi连接成功,正在绑定...",
"bindSuccess": "绑定成功", "bindSuccess": "绑定成功",
"bindFailed": "绑定失败" "bindFailed": "绑定失败"
},
"request":{
"error": "请求发送失败"
} }
} }
\ No newline at end of file
...@@ -54,6 +54,33 @@ uPublic.componentsExtend = function (array) { ...@@ -54,6 +54,33 @@ uPublic.componentsExtend = function (array) {
}); });
}; };
//请求发送失败弹框
uPublic.openRequestErrorAlert = function (vmObj, content = Vue.t('request.error')) {
uComponents.openAlert(vmObj, content, {
text: Vue.t('dialog.confirm'), callback: function () {
}
});
};
// 检查请求成功后data参数
uPublic.checkResponseData = function (data) {
// json
if (data != null && typeof data === 'object') {
if (Object.keys(data).length == 0 || data.hasOwnProperty('msg')) {
return false;
} else {
return data;
}
// array
} else if (Array.isArray(data)) {
if (data.length > 0) {
return data;
} else {
return false;
}
}
};
iot.ready(() => { iot.ready(() => {
uPublic.recalc(); uPublic.recalc();
}); });
......
...@@ -19,14 +19,7 @@ function init() { ...@@ -19,14 +19,7 @@ function init() {
componentsConfig: initComponentsConfig() componentsConfig: initComponentsConfig()
}, },
mounted(){ mounted(){
openScanCode(); openScanCode(this);
iot.utils.scanBarcode({
data: {
id: 'bcid'
},
success: (response) => {},
error: (error) => {}
});
}, },
methods:{ methods:{
//tap < //tap <
...@@ -58,26 +51,51 @@ function backTap(){ ...@@ -58,26 +51,51 @@ function backTap(){
iot.navigator.back(); iot.navigator.back();
} }
function openScanCode(){ function openScanCode(self){
iot.utils.scanBarcode({ iot.utils.scanBarcode({
data: { data: {
id: 'scanId' id: 'bcid',
styles: {
frameColor: '#00ffff',
scanbarColor: '#00ffff',
background: '#242b35'
}
}, },
success: (response) => { success: (response) => {
console.log(response); let data = uPublic.checkResponseData(response.data);
if(data){
//扫描成功 //扫描成功
uComponents.openAlert(self, Vue.t('addDevice.scanCodeSuccess'), { let qrKey = data.result;
//绑定设备
iot.business.sds.scanqr({
data: {
qrKey: qrKey
},
success: (response) => {
let data = uPublic.checkResponseData(response.data);
if(data){
console.log(response);
uComponents.openAlert(self, Vue.t('addDevice.bindSuccess'), {
text: Vue.t('btn.confirm'), callback: function () { text: Vue.t('btn.confirm'), callback: function () {
iot.navigator.openWindow({
url: '../device/',
id: 'device'
});
} }
}); });
}else{}
}, },
error: (error) => { error: (error) => {
console.log(error); //请求失败
//扫描失败 uPublic.openRequestErrorAlert(self);
uComponents.openAlert(self, Vue.t('addDevice.scanCodeFailue'), {
text: Vue.t('btn.confirm'), callback: function () {
} }
}); });
}else{}
},
error: (error) => {
console.log(error);
//请求失败
uPublic.openRequestErrorAlert(self);
} }
}); });
} }
...@@ -75,6 +75,10 @@ function initComponentsConfig() { ...@@ -75,6 +75,10 @@ function initComponentsConfig() {
} }
} }
function alert(){
alert('aaa');
}
function nameChange(self,text){ function nameChange(self,text){
self.textName = text; self.textName = text;
console.log('nameChange: ' + self.textName); console.log('nameChange: ' + self.textName);
...@@ -100,7 +104,23 @@ function saveButtonTap(self){ ...@@ -100,7 +104,23 @@ function saveButtonTap(self){
uComponents.hideLoading(self); uComponents.hideLoading(self);
uComponents.openAlert(self, Vue.t('editName.editNameSuccess'), { uComponents.openAlert(self, Vue.t('editName.editNameSuccess'), {
text: Vue.t('btn.confirm'), callback: function () { text: Vue.t('btn.confirm'), callback: function () {
iot.navigator.back(); // iot.navigator.back();
iot.navigator.openWindow({
url: '../doorlockManage/',
id: 'doorlockManage'
});
//// console.log(window.opener);
// // 创建
// /*var evt = document.createEvent("HTMLEvents");
// // 初始化
// evt.initEvent("alert", false, false);*/
// console.log(evt);
// var opener = plus.webview.currentWebview().opener();
// var view = plus.webview.getWebviewById(opener.id);
// view.evalJS("alert()");
// window.parent.dispatchEvent(evt);
mui.fire();
} }
}); });
}, },
......
...@@ -25,23 +25,7 @@ function init() { ...@@ -25,23 +25,7 @@ function init() {
showDeviceList: [] showDeviceList: []
}, },
mounted(){ mounted(){
// iot.business.user.reg({ //显示loading
// data:{
// username: '18679022601',
// pwd: '123',
// vcode: '666666'
// },
// success: (response) => {
// console.log('注册成功');
// console.log(response);
// },
// error: (err) => {
// console.log(err);
// },
// complete: () => {
//
// }
// });
uComponents.showLoading(this); uComponents.showLoading(this);
iot.business.user.login({ iot.business.user.login({
data: { data: {
...@@ -58,6 +42,7 @@ function init() { ...@@ -58,6 +42,7 @@ function init() {
}, },
success: (response) => { success: (response) => {
console.log(response); console.log(response);
//获取设备列表
getDeviceList(this); getDeviceList(this);
}, },
error: (error) => { error: (error) => {
...@@ -66,9 +51,8 @@ function init() { ...@@ -66,9 +51,8 @@ function init() {
complete: () => {} complete: () => {}
}); });
// getDeviceList(this); // getDeviceList(this);
// window.addEventListener('alert',function(event){
// window.addEventListener('returnPage',function(event){ // getDeviceList(this);
// alert("returnPage");
// }); // });
}, },
methods:{ methods:{
...@@ -108,6 +92,7 @@ function init() { ...@@ -108,6 +92,7 @@ function init() {
}).$mount('#app'); }).$mount('#app');
} }
//配置组件参数 //配置组件参数
function initComponentsConfig() { function initComponentsConfig() {
return { return {
...@@ -140,7 +125,6 @@ function initComponentsConfig() { ...@@ -140,7 +125,6 @@ function initComponentsConfig() {
//获取所有的设备 //获取所有的设备
function getDeviceList(self){ function getDeviceList(self){
console.log("innn");
iot.business.device.getList({ iot.business.device.getList({
data: { data: {
sds: true, sds: true,
...@@ -151,10 +135,8 @@ function getDeviceList(self){ ...@@ -151,10 +135,8 @@ function getDeviceList(self){
}, },
success: (response) => { success: (response) => {
console.log(response); console.log(response);
let data = response.data; let data = uPublic.checkResponseData(response.data);
if(data.length == 0 || data.hasOwnProperty('msg')){ if(data){
return false;
}else{
self.setDeviceList(data); self.setDeviceList(data);
for(let i=0; i<data.length; i++){ for(let i=0; i<data.length; i++){
self.getShowDeviceList().push({ self.getShowDeviceList().push({
...@@ -164,12 +146,17 @@ function getDeviceList(self){ ...@@ -164,12 +146,17 @@ function getDeviceList(self){
buttons: [{'icon': '&#xe728;'},{'icon': '&#xe61b;'},{'icon': '&#xe63e;'},{'icon': '&#xe742;'}] buttons: [{'icon': '&#xe728;'},{'icon': '&#xe61b;'},{'icon': '&#xe63e;'},{'icon': '&#xe742;'}]
}); });
} }
//更新设备列表
projectMethods.changeGridList(self, self.getShowDeviceList()); projectMethods.changeGridList(self, self.getShowDeviceList());
uComponents.hideLoading(self); uComponents.hideLoading(self);
}else{
} }
}, },
error: (error) => { error: (error) => {
console.log(error); console.log(error);
//请求失败
uPublic.openRequestErrorAlert(self);
}, },
complete: () => { complete: () => {
uComponents.hideLoading(self); uComponents.hideLoading(self);
...@@ -276,7 +263,9 @@ function deleteDoorlook(self, index){ ...@@ -276,7 +263,9 @@ function deleteDoorlook(self, index){
uuid: self.getDeviceList()[index].uuid uuid: self.getDeviceList()[index].uuid
}, },
success: function (response){ success: function (response){
console.log(response); let data = uPublic.checkResponseData(response.data);
if(data){
//删除成功
self.getDeviceList().splice(index, 1); self.getDeviceList().splice(index, 1);
self.getShowDeviceList().splice(index, 1); self.getShowDeviceList().splice(index, 1);
rojectMethods.changeGridList(self, self.getDeviceList()); rojectMethods.changeGridList(self, self.getDeviceList());
...@@ -285,14 +274,19 @@ function deleteDoorlook(self, index){ ...@@ -285,14 +274,19 @@ function deleteDoorlook(self, index){
projectMethods.changeGridList(self, self.getShowDeviceList()); projectMethods.changeGridList(self, self.getShowDeviceList());
} }
}); });
}, }else{
error: function (err){ //删除失败
console.log(err);
uComponents.openAlert(self, Vue.t('doorlockManage.editNameFailue'), { uComponents.openAlert(self, Vue.t('doorlockManage.editNameFailue'), {
text: Vue.t('btn.confirm'), callback: function () { text: Vue.t('btn.confirm'), callback: function () {
uComponents.hideLoading(self); uComponents.hideLoading(self);
} }
}); });
}
},
error: function (err){
console.log(err);
//请求失败
uPublic.openRequestErrorAlert(self);
}, },
complete: function (){ complete: function (){
console.log("complete"); console.log("complete");
......
...@@ -80,27 +80,33 @@ function backTap(){ ...@@ -80,27 +80,33 @@ function backTap(){
//tap 生成二维码 //tap 生成二维码
function qrcodeButtonTap(self){ function qrcodeButtonTap(self){
uComponents.showLoading(self);
iot.business.sds.saveqr({ iot.business.sds.saveqr({
data: { data: {
uuid: self.getUuid() uuid: self.getUuid()
}, },
success: (response) => { success: (response) => {
console.log(response); let data = uPublic.checkResponseData(response.data);
if(data){
let qrKey = response.data.qrKey; let qrKey = response.data.qrKey;
var qr = self.$refs.qrcode; var qr = self.$refs.qrcode;
QRCode.toCanvas(qr, qrKey, (error) => { QRCode.toCanvas(qr, qrKey, (error) => {
if (error) { if (error) {
console.log(error) console.log(error)
} else { } else {
console.log('success') console.log('success');
uComponents.hideLoading(self);
setTimeout(() => { setTimeout(() => {
self.setQrCodeDisabled(true); self.setQrCodeDisabled(true);
},1000*60*10); },1000*60*10);
} }
}); });
}else{}
}, },
error: (error) => { error: (error) => {
console.log(error); console.log(error);
//请求失败
uPublic.openRequestErrorAlert(self);
} }
}); });
} }
\ No newline at end of file
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