Commit 51d671d5 by liangjianmin

js

parent 5f81aba0
Showing with 41 additions and 11 deletions
......@@ -103,10 +103,11 @@ export default {
fail: res => {
uni.hideLoading();
console.log('查找设备失败!');
uni.showToast({
icon: 'error',
title: '查找设备失败!',
duration: 3000
uni.showModal({
title: '提示',
content: '查找设备失败',
showCancel: false,
confirmText: '关闭'
});
}
});
......@@ -182,10 +183,11 @@ export default {
uni.setStorageSync('device', { name: this.deviceName, deviceId: this.deviceId });
},
fail: error => {
uni.showToast({
icon: 'error',
title: '连接设备失败!',
duration: 3000
uni.showModal({
title: '提示',
content: '连接设备失败',
showCancel: false,
confirmText: '关闭'
});
}
});
......@@ -197,9 +199,12 @@ export default {
uni.showLoading({
title: '连接设备中'
});
//判断设备当前是否有连接
if (this.deviceId) {
//先断开现有蓝牙连接
uni.closeBLEConnection({
deviceId: this.deviceId,
deviceId: deviceId,
success: res => {
console.log('断开蓝牙连接:', JSON.stringify(res.errMsg));
this.deviceName = name; //设备名称
......@@ -216,8 +221,33 @@ export default {
}
this.textArr = tempArr;
}
},
fail: error => {
uni.hideLoading();
uni.showModal({
title: '提示',
content: '断开设备失败',
showCancel: false,
confirmText: '关闭'
});
}
});
} else {
this.deviceName = name; //设备名称
this.deviceId = deviceId; //设备id
this.current = index;
this.stopBluetoothDevicesDiscovery(); //先停止蓝牙搜索
//恢复蓝牙连接状态的初始值
if (this.textArr.length > 0) {
var tempArr = [];
for (let i = 0; i < this.textArr.length; i++) {
tempArr.push('连接');
}
this.textArr = tempArr;
}
}
},
/**
* 刷新蓝牙列表
......
//const API_BASE = 'https://api.ichunt.com';
const API_BASE = 'http://api.liexin.com'
const API_BASE = 'https://api.ichunt.com';
//const API_BASE = 'http://api.liexin.com'
const API = {
/**
* 上传数据
......
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 sign in to comment