Commit 89f60d04 by 朱建香

设备列表

parent fedf09d1
......@@ -9,6 +9,7 @@
"hammerjs": "2.0.8",
"iscroll": "5.2.0",
"moment": "^2.18.1",
"qrcode": "^0.9.0",
"ugen-components": "^0.1.0",
"underscore": "1.8.3",
"vue": "2.2.6",
......
......@@ -95,7 +95,7 @@
"remoteOpendoor":{
"passwordInputTip": "请输入远程开门密码",
"error": {
"noPasswordTip": "远程密码不能为空"
}
},
"hijackRecord":{
......@@ -104,12 +104,16 @@
"doorlockManage":{
"noDeviceTip": "暂无设备",
"deleteDialogTip": "<span>{0}</span>将被删除",
"logoutDialogTip": "确定要退出系统吗?"
"logoutDialogTip": "确定要退出系统吗?",
"deleteSuccess": "删除成功",
"deleteFailue": "删除失败",
"defaultNickname": "门锁"
},
"editName":{
"nameInputTip": "请输入门锁名称",
"editNameSuccess": "名字修改成功",
"editNameFailue": "名字修改失败",
"error": {
}
},
"qrcode":{
......@@ -121,7 +125,9 @@
},
"addDevice": {
"scanCodeAdd": "扫描绑定设备",
"wifiAdd": "配置Wi-Fi"
"wifiAdd": "配置Wi-Fi",
"scanCodeSuccess": "扫描成功",
"scanCodeFailue": "扫描失败"
},
"wifiAddHelp": {
"helpTitle": "配置Wi-Fi说明:",
......
......@@ -16,7 +16,7 @@ const iot = new UIOT({
appId: ''
},
cloud: {
url: 'http://192.168.2.97:20007'
url: 'http://192.168.2.96:20000'
},
plugin: {
log: {
......
......@@ -19,6 +19,14 @@ function init() {
componentsConfig: initComponentsConfig()
},
mounted(){
openScanCode();
iot.utils.scanBarcode({
data: {
id: 'bcid'
},
success: (response) => {},
error: (error) => {}
});
},
methods:{
//tap <
......@@ -49,3 +57,27 @@ function initComponentsConfig() {
function backTap(){
iot.navigator.back();
}
function openScanCode(){
iot.utils.scanBarcode({
data: {
id: 'scanId'
},
success: (response) => {
console.log(response);
//扫描成功
uComponents.openAlert(self, Vue.t('addDevice.scanCodeSuccess'), {
text: Vue.t('btn.confirm'), callback: function () {
}
});
},
error: (error) => {
console.log(error);
//扫描失败
uComponents.openAlert(self, Vue.t('addDevice.scanCodeFailue'), {
text: Vue.t('btn.confirm'), callback: function () {
}
});
}
});
}
......@@ -15,6 +15,7 @@ function init() {
uPublic.componentsInit(['u-text','u-button','u-commstatus-loading','u-dialog','u-loading']);
const app = new Vue({
data:{
textWiFiName: null,
textPassword: null,
textErrorTip: null,
textLoading: 'loading...',
......@@ -23,8 +24,28 @@ function init() {
componentsConfig: initComponentsConfig()
},
mounted(){
iot.business.sds.findWifi({
data: {
// model: 'model',
// ssid: 'ssid',
wifiPwd: 'wifiPwd',
timeout: 20000
},
success: (response) => {
console.log(response);
},
error: (error) => {
console.log(error);
}
});
},
methods:{
getTextPassword(){
return this.textPassword;
},
setTextPassword(pwd){
this.textPassword = pwd;
},
getTextLoading(){
return this.textLoading;
},
......
......@@ -63,8 +63,18 @@ function backTap(){
//tap 开始配置Wi-Fi
function wifiAddButtonTap(){
iot.navigator.openWindow({
url: './wifiAdd.html',
id: 'wifiAdd'
// iot.navigator.openWindow({
// url: './wifiAdd.html',
// id: 'wifiAdd'
// });
iot.business.sds.wifiDeviceConfig({
success: function (response) {
console.log('wifiDeviceConfig success');
console.log(response);
},
error: function (error) {
console.log('wifiDeviceConfig error');
console.log(error);
}
});
}
\ No newline at end of file
......@@ -81,6 +81,7 @@
}
function changeList(self, list) {
console.log(list);
self.list = list;
self.setLoadShowFlag(list.length - self.list.length);
self.$nextTick(function () {
......
......@@ -15,14 +15,22 @@ function init() {
uPublic.componentsInit(['u-text','u-button','u-dialog','u-loading']);
const app = new Vue({
data:{
textName: '门锁-001',
textName: iot.navigator.getExtras().nickName,
textErrorTip: null,
//配置组件
componentsConfig: initComponentsConfig()
componentsConfig: initComponentsConfig(),
extras: {}
},
mounted(){
this.extras = iot.navigator.getExtras();
},
methods:{
getTextName(){
return this.textName;
},
setTextName(text){
this.textName = text;
},
onNameChange(text){
nameChange(this,text);
},
......@@ -32,7 +40,7 @@ function init() {
},
//tap 保存
onSaveButtonTap(){
saveButtonTap();
saveButtonTap(this);
}
}
}).$mount('#app');
......@@ -78,6 +86,34 @@ function backTap(){
}
//tap 保存
function saveButtonTap(){
function saveButtonTap(self){
uComponents.showLoading(self);
iot.business.device.setNickname({
data: {
sds: true,
uuid: self.extras.uuid,
model: self.extras.model,
nickname: self.textName
},
success: (response) => {
console.log("inn");
uComponents.hideLoading(self);
uComponents.openAlert(self, Vue.t('editName.editNameSuccess'), {
text: Vue.t('btn.confirm'), callback: function () {
iot.navigator.back();
}
});
},
error: (error) => {
uComponents.hideLoading(self);
uComponents.openAlert(self, Vue.t('editName.editNameFailue'), {
text: Vue.t('btn.confirm'), callback: function () {
iot.navigator.back();
}
});
},
complete: () => {
uComponents.hideLoading(self);
}
});
}
\ No newline at end of file
......@@ -8,6 +8,7 @@
*/
import {iot, uPublic, uComponents} from '../../public/public.js';
import {projectMethods} from '../../public/components.js';
iot.ready(init);
function init() {
......@@ -18,11 +19,71 @@ function init() {
const app = new Vue({
data:{
//配置组件
componentsConfig: initComponentsConfig()
componentsConfig: initComponentsConfig(),
//设备列表
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: () => {
//
// }
// });
uComponents.showLoading(this);
iot.business.user.login({
data: {
// sds: true,
username: '18679022601',
pwd: '123'
// userinfo: {
// username: '"18679022601"',
//// pwd: '123'
// nickname: 'zhu',
// head: 'head',
// utoken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOjEwMCwiaWF0IjoxNTA1ODE4NDI5LCJleHAiOjE1MDY2ODI0Mjl9.Bhl9TTcT1PUZZdmcPobE3f4OA2IgSURmtHyT2yluBFA'
// }
},
success: (response) => {
console.log(response);
getDeviceList(this);
},
error: (error) => {
console.log(error);
},
complete: () => {}
});
// getDeviceList(this);
// window.addEventListener('returnPage',function(event){
// alert("returnPage");
// });
},
methods:{
getDeviceList(){
return this.deviceList;
},
setDeviceList(list){
this.deviceList = list;
},
getShowDeviceList(){
return this.showDeviceList;
},
setShowDeviceList(list){
this.showDeviceList = list;
},
//tap <
onBackTap(){
backTap();
......@@ -53,11 +114,7 @@ function initComponentsConfig() {
doorlockList: {
initParam: {
class: '',
list: [{value: 1,'leftImage': '../../resources/image/device.png','title': '门锁-001','buttons': [{'icon': '&#xe728;'},{'icon': '&#xe61b;'},{'icon': '&#xe63e;'},{'icon': '&#xe742;'}]},
{value: 2,'leftImage': '../../resources/image/device.png','title': '门锁-002','buttons': [{'icon': '&#xe728;'},{'icon': '&#xe61b;'},{'icon': '&#xe63e;'},{'icon': '&#xe742;'}]},
{value: 3,'leftImage': '../../resources/image/device.png','title': '门锁-003','buttons': [{'icon': '&#xe728;'},{'icon': '&#xe61b;'},{'icon': '&#xe63e;'},{'icon': '&#xe742;'}]},
{value: 4,'leftImage': '../../resources/image/device.png','title': '门锁-004','buttons': [{'icon': '&#xe728;'},{'icon': '&#xe61b;'},{'icon': '&#xe63e;'},{'icon': '&#xe742;'}]},
{value: 5,'leftImage': '../../resources/image/device.png','title': '门锁-005','buttons': [{'icon': '&#xe728;'},{'icon': '&#xe61b;'},{'icon': '&#xe63e;'},{'icon': '&#xe742;'}]}],
list: [],
tip: Vue.t('doorlockManage.noDeviceTip')
}
},
......@@ -81,6 +138,45 @@ function initComponentsConfig() {
}
}
//获取所有的设备
function getDeviceList(self){
console.log("innn");
iot.business.device.getList({
data: {
sds: true,
// product_id: 'product_id',
// parent_id: 0,
// start_id: 0,
// number: 10
},
success: (response) => {
console.log(response);
let data = response.data;
if(data.length == 0 || data.hasOwnProperty('msg')){
return false;
}else{
self.setDeviceList(data);
for(let i=0; i<data.length; i++){
self.getShowDeviceList().push({
value: data[i].uuid,
leftImage: '../../resources/image/device.png',
title: (data[i].nickName && data[i].nickName != 'null') ? data[i].nickName : Vue.t('doorlockManage.defaultNickname'),
buttons: [{'icon': '&#xe728;'},{'icon': '&#xe61b;'},{'icon': '&#xe63e;'},{'icon': '&#xe742;'}]
});
}
projectMethods.changeGridList(self, self.getShowDeviceList());
uComponents.hideLoading(self);
}
},
error: (error) => {
console.log(error);
},
complete: () => {
uComponents.hideLoading(self);
}
});
}
//tap <
function backTap(){
iot.navigator.back();
......@@ -108,14 +204,22 @@ function doorlockListButtonTap(self, value, buttonValue) {
if(buttonValue == '0'){
iot.navigator.openWindow({
url: './editName.html',
id: 'editName'
id: 'editName',
extras: {
uuid: self.getDeviceList()[value].uuid,
model: self.getDeviceList()[value].model,
nickName: self.getDeviceList()[value].nickName
}
});
}
//tap 生成绑定二维码
else if(buttonValue == '1'){
iot.navigator.openWindow({
url: './qrcode.html',
id: 'qrcode'
id: 'qrcode',
extras: {
uuid: self.getDeviceList()[value].uuid
}
});
}
//tap ID-姓名绑定
......@@ -128,8 +232,12 @@ function doorlockListButtonTap(self, value, buttonValue) {
//tap 删除门锁
else if(buttonValue == '3'){
uComponents.openConfirm(self, Vue.t('doorlockManage.deleteDialogTip', ['门锁-001']),
{text: Vue.t('dialog.cancel'), callback: function () {}},
{text: Vue.t('dialog.confirm'), callback: function () {}}
{text: Vue.t('dialog.cancel'), callback: function () {
}},
{text: Vue.t('dialog.confirm'), callback: function () {
deleteDoorlook(self, value);
}}
);
}
}
......@@ -139,10 +247,56 @@ function logoutButtonTap(self){
uComponents.openConfirm(self, Vue.t('doorlockManage.logoutDialogTip'),
{text: Vue.t('dialog.cancel'), callback: function () {}},
{text: Vue.t('dialog.confirm'), callback: function () {
iot.navigator.openWindow({
url: '../login/login.html',
id: 'login'
iot.business.user.logout({
data: {
sds: true
},
success: (response) => {
// iot.navigator.openWindow({
// url: '../login/login.html',
// id: 'login'
// });
},
error: (error) => {},
complete: () => {
console.log("complete");
}
});
}}
);
}
function deleteDoorlook(self, index){
// 显示loading
let uuId = self.getDeviceList()[index].id;
uComponents.showLoading(self);
iot.business.device.unbind({
data: {
sds: true,
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());
}
});
},
error: function (err){
console.log(err);
uComponents.openAlert(self, Vue.t('doorlockManage.editNameFailue'), {
text: Vue.t('btn.confirm'), callback: function () {
uComponents.hideLoading(self);
}
});
},
complete: function (){
console.log("complete");
uComponents.hideLoading(self);
}
});
}
......@@ -7,8 +7,9 @@
* 生成绑定二维码页面
*/
var QRCode = require('qrcode');
console.log(QRCode);
import {iot, uPublic, uComponents} from '../../public/public.js';
iot.ready(init);
function init() {
//通用 按钮、dialog、loading组件
......@@ -16,18 +17,34 @@ function init() {
const app = new Vue({
data:{
//配置组件
componentsConfig: initComponentsConfig()
componentsConfig: initComponentsConfig(),
//页面传递参数
extras: [],
uuid: null,
qrCodeDisabled: false
},
mounted(){
this.extras = iot.navigator.getExtras();
console.log(this.extras);
this.setUuid(this.extras.uuid);
},
methods:{
getUuid(){
return this.uuid;
},
setUuid(id){
this.uuid = id;
},
setQrCodeDisabled(boolean){
this.qrCodeDisabled = boolean;
},
//tap <
onBackTap(){
backTap();
},
//tap 生成二维码
onQRcodeButtonTap(){
qrcodeButtonTap();
qrcodeButtonTap(this);
}
}
}).$mount('#app');
......@@ -62,6 +79,28 @@ function backTap(){
}
//tap 生成二维码
function qrcodeButtonTap(){
alert("生成二维码");
function qrcodeButtonTap(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);
}
});
},
error: (error) => {
console.log(error);
}
});
}
\ 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