Commit 1a5e6c81 by 朱建香

0921

parent b1348d9c
......@@ -126,8 +126,8 @@
"addDevice": {
"scanCodeAdd": "扫描绑定设备",
"wifiAdd": "配置Wi-Fi",
"scanCodeSuccess": "扫描成功",
"scanCodeFailue": "扫描失败"
"bindSuccess": "绑定成功",
"bindFailue": "绑定失败"
},
"wifiAddHelp": {
"helpTitle": "配置Wi-Fi说明:",
......@@ -174,5 +174,8 @@
"connectSuccess": "Wi-Fi连接成功,正在绑定...",
"bindSuccess": "绑定成功",
"bindFailed": "绑定失败"
},
"request":{
"error": "请求发送失败"
}
}
\ No newline at end of file
......@@ -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(() => {
uPublic.recalc();
});
......
......@@ -19,14 +19,7 @@ function init() {
componentsConfig: initComponentsConfig()
},
mounted(){
openScanCode();
iot.utils.scanBarcode({
data: {
id: 'bcid'
},
success: (response) => {},
error: (error) => {}
});
openScanCode(this);
},
methods:{
//tap <
......@@ -58,26 +51,51 @@ function backTap(){
iot.navigator.back();
}
function openScanCode(){
function openScanCode(self){
iot.utils.scanBarcode({
data: {
id: 'scanId'
id: 'bcid',
styles: {
frameColor: '#00ffff',
scanbarColor: '#00ffff',
background: '#242b35'
}
},
success: (response) => {
console.log(response);
//扫描成功
uComponents.openAlert(self, Vue.t('addDevice.scanCodeSuccess'), {
text: Vue.t('btn.confirm'), callback: function () {
}
});
let data = uPublic.checkResponseData(response.data);
if(data){
//扫描成功
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 () {
iot.navigator.openWindow({
url: '../device/',
id: 'device'
});
}
});
}else{}
},
error: (error) => {
//请求失败
uPublic.openRequestErrorAlert(self);
}
});
}else{}
},
error: (error) => {
console.log(error);
//扫描失败
uComponents.openAlert(self, Vue.t('addDevice.scanCodeFailue'), {
text: Vue.t('btn.confirm'), callback: function () {
}
});
//请求失败
uPublic.openRequestErrorAlert(self);
}
});
}
......@@ -75,6 +75,10 @@ function initComponentsConfig() {
}
}
function alert(){
alert('aaa');
}
function nameChange(self,text){
self.textName = text;
console.log('nameChange: ' + self.textName);
......@@ -100,7 +104,23 @@ function saveButtonTap(self){
uComponents.hideLoading(self);
uComponents.openAlert(self, Vue.t('editName.editNameSuccess'), {
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();
}
});
},
......
......@@ -24,24 +24,8 @@ function init() {
deviceList: [],
showDeviceList: []
},
mounted(){
// iot.business.user.reg({
// data:{
// username: '18679022601',
// pwd: '123',
// vcode: '666666'
// },
// success: (response) => {
// console.log('注册成功');
// console.log(response);
// },
// error: (err) => {
// console.log(err);
// },
// complete: () => {
//
// }
// });
mounted(){
//显示loading
uComponents.showLoading(this);
iot.business.user.login({
data: {
......@@ -58,6 +42,7 @@ function init() {
},
success: (response) => {
console.log(response);
//获取设备列表
getDeviceList(this);
},
error: (error) => {
......@@ -66,9 +51,8 @@ function init() {
complete: () => {}
});
// getDeviceList(this);
// window.addEventListener('returnPage',function(event){
// alert("returnPage");
// window.addEventListener('alert',function(event){
// getDeviceList(this);
// });
},
methods:{
......@@ -103,11 +87,12 @@ function init() {
//tap 退出系统
onLogoutButtonTap(){
logoutButtonTap(this);
}
}
}
}).$mount('#app');
}
//配置组件参数
function initComponentsConfig() {
return {
......@@ -140,7 +125,6 @@ function initComponentsConfig() {
//获取所有的设备
function getDeviceList(self){
console.log("innn");
iot.business.device.getList({
data: {
sds: true,
......@@ -151,10 +135,8 @@ function getDeviceList(self){
},
success: (response) => {
console.log(response);
let data = response.data;
if(data.length == 0 || data.hasOwnProperty('msg')){
return false;
}else{
let data = uPublic.checkResponseData(response.data);
if(data){
self.setDeviceList(data);
for(let i=0; i<data.length; i++){
self.getShowDeviceList().push({
......@@ -164,12 +146,17 @@ function getDeviceList(self){
buttons: [{'icon': '&#xe728;'},{'icon': '&#xe61b;'},{'icon': '&#xe63e;'},{'icon': '&#xe742;'}]
});
}
//更新设备列表
projectMethods.changeGridList(self, self.getShowDeviceList());
uComponents.hideLoading(self);
}else{
}
},
error: (error) => {
console.log(error);
//请求失败
uPublic.openRequestErrorAlert(self);
},
complete: () => {
uComponents.hideLoading(self);
......@@ -218,7 +205,7 @@ function doorlockListButtonTap(self, value, buttonValue) {
url: './qrcode.html',
id: 'qrcode',
extras: {
uuid: self.getDeviceList()[value].uuid
uuid: self.getDeviceList()[value].uuid
}
});
}
......@@ -276,23 +263,30 @@ function deleteDoorlook(self, index){
uuid: self.getDeviceList()[index].uuid
},
success: function (response){
console.log(response);
self.getDeviceList().splice(index, 1);
self.getShowDeviceList().splice(index, 1);
rojectMethods.changeGridList(self, self.getDeviceList());
uComponents.openAlert(self, Vue.t('doorlockManage.deleteSuccess'), {
text: Vue.t('btn.confirm'), callback: function () {
projectMethods.changeGridList(self, self.getShowDeviceList());
}
});
let data = uPublic.checkResponseData(response.data);
if(data){
//删除成功
self.getDeviceList().splice(index, 1);
self.getShowDeviceList().splice(index, 1);
rojectMethods.changeGridList(self, self.getDeviceList());
uComponents.openAlert(self, Vue.t('doorlockManage.deleteSuccess'), {
text: Vue.t('btn.confirm'), callback: function () {
projectMethods.changeGridList(self, self.getShowDeviceList());
}
});
}else{
//删除失败
uComponents.openAlert(self, Vue.t('doorlockManage.editNameFailue'), {
text: Vue.t('btn.confirm'), callback: function () {
uComponents.hideLoading(self);
}
});
}
},
error: function (err){
console.log(err);
uComponents.openAlert(self, Vue.t('doorlockManage.editNameFailue'), {
text: Vue.t('btn.confirm'), callback: function () {
uComponents.hideLoading(self);
}
});
//请求失败
uPublic.openRequestErrorAlert(self);
},
complete: function (){
console.log("complete");
......
......@@ -80,27 +80,33 @@ function backTap(){
//tap 生成二维码
function qrcodeButtonTap(self){
uComponents.showLoading(self);
iot.business.sds.saveqr({
data: {
uuid: self.getUuid()
},
success: (response) => {
console.log(response);
let qrKey = response.data.qrKey;
var qr = self.$refs.qrcode;
QRCode.toCanvas(qr, qrKey, (error) => {
if (error) {
console.log(error)
} else {
console.log('success')
setTimeout(() => {
self.setQrCodeDisabled(true);
},1000*60*10);
}
});
let data = uPublic.checkResponseData(response.data);
if(data){
let qrKey = response.data.qrKey;
var qr = self.$refs.qrcode;
QRCode.toCanvas(qr, qrKey, (error) => {
if (error) {
console.log(error)
} else {
console.log('success');
uComponents.hideLoading(self);
setTimeout(() => {
self.setQrCodeDisabled(true);
},1000*60*10);
}
});
}else{}
},
error: (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