上传代码
This commit is contained in:
629
uniapp04/unpackage/dist/dev/mp-weixin/pages/blueTooth/blueTooth.js
vendored
Normal file
629
uniapp04/unpackage/dist/dev/mp-weixin/pages/blueTooth/blueTooth.js
vendored
Normal file
@ -0,0 +1,629 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../common/vendor.js");
|
||||
const _sfc_main = {
|
||||
data() {
|
||||
return {
|
||||
config: {
|
||||
color: "#333",
|
||||
backgroundColor: [1, "#fff"],
|
||||
title: "多设备蓝牙连接",
|
||||
back: false
|
||||
},
|
||||
title: "Hello",
|
||||
bleDevs: [],
|
||||
status: -2,
|
||||
//-2未连接 -1已连接 0连接成功
|
||||
deviceId: "",
|
||||
serviceId: "",
|
||||
characteristicId: "",
|
||||
sendData: "",
|
||||
getData: [],
|
||||
deviceIds: [],
|
||||
totalList: [],
|
||||
// 全部已连接的设备
|
||||
timeIndex: 0,
|
||||
// 默认是列表的第一个
|
||||
timeout: null,
|
||||
shows: false,
|
||||
testItems: [
|
||||
{
|
||||
index: 1,
|
||||
typeNums: 1,
|
||||
min: 0,
|
||||
max: 150,
|
||||
name: "设定频率",
|
||||
value: "F"
|
||||
},
|
||||
{
|
||||
index: 2,
|
||||
typeNums: 250,
|
||||
min: 50,
|
||||
max: 250,
|
||||
name: "设定脉宽",
|
||||
value: "W"
|
||||
},
|
||||
{ index: 3, typeNums: 3, min: 0, max: 3, name: "设定类型", value: "C" },
|
||||
{
|
||||
index: 4,
|
||||
typeNums: 0,
|
||||
min: 0,
|
||||
max: 120,
|
||||
name: "设定电流",
|
||||
value: "I"
|
||||
},
|
||||
{
|
||||
index: 5,
|
||||
typeNums: 0,
|
||||
min: 1,
|
||||
max: 100,
|
||||
name: "设定方案",
|
||||
value: "M"
|
||||
}
|
||||
],
|
||||
titleTime: "00:00:00",
|
||||
timer: "",
|
||||
hour: 0,
|
||||
minutes: 0,
|
||||
seconds: 0,
|
||||
input1: "B",
|
||||
input2: ""
|
||||
};
|
||||
},
|
||||
destroyed() {
|
||||
clearInterval(this.timer);
|
||||
},
|
||||
onLoad() {
|
||||
},
|
||||
mounted() {
|
||||
this.onBLEConnectionStateChange();
|
||||
},
|
||||
methods: {
|
||||
// 开始计时
|
||||
begin() {
|
||||
if (this.start) {
|
||||
return;
|
||||
}
|
||||
this.sendData = "BS1\r";
|
||||
this.start = true;
|
||||
this.timer = setInterval(this.startTimer, 1e3);
|
||||
this.send();
|
||||
},
|
||||
startTimer() {
|
||||
this.seconds += 1;
|
||||
if (this.seconds >= 60) {
|
||||
this.seconds = 0;
|
||||
this.minute = this.minute + 1;
|
||||
}
|
||||
if (this.minute >= 60) {
|
||||
this.minute = 0;
|
||||
this.hour = this.hour + 1;
|
||||
}
|
||||
this.titleTime = (this.hour < 10 ? "0" + this.hour : this.hour) + ":" + (this.minutes < 10 ? "0" + this.minutes : this.minutes) + ":" + (this.seconds < 10 ? "0" + this.seconds : this.seconds);
|
||||
},
|
||||
// 暂停倒计时
|
||||
pause() {
|
||||
if (this.timer) {
|
||||
clearInterval(this.timer);
|
||||
this.start = false;
|
||||
this.sendData = "BS2\r";
|
||||
this.send();
|
||||
}
|
||||
},
|
||||
stop() {
|
||||
if (this.timer) {
|
||||
clearInterval(this.timer);
|
||||
this.sendData = "BS3\r";
|
||||
this.send();
|
||||
this.titleTime = "00:00:00";
|
||||
this.timer = "";
|
||||
this.hour = 0;
|
||||
this.minutes = 0;
|
||||
this.seconds = 0;
|
||||
this.start = false;
|
||||
}
|
||||
},
|
||||
changNums(index, item) {
|
||||
if (index == 1) {
|
||||
if (item.typeNums <= item.min) {
|
||||
common_vendor.index.showToast({
|
||||
title: "已经不能再减少了",
|
||||
icon: "none"
|
||||
});
|
||||
return;
|
||||
}
|
||||
item.typeNums--;
|
||||
} else if (index == 2) {
|
||||
if (item.typeNums >= item.max) {
|
||||
common_vendor.index.showToast({
|
||||
title: "已经不能再增加了",
|
||||
icon: "none"
|
||||
});
|
||||
return;
|
||||
}
|
||||
item.typeNums++;
|
||||
}
|
||||
this.changeBar(item);
|
||||
},
|
||||
changeBar(item) {
|
||||
if (this.timeout) {
|
||||
clearTimeout(this.timeout);
|
||||
}
|
||||
this.timeout = setTimeout(() => {
|
||||
if (item.typeNums < item.min) {
|
||||
common_vendor.index.showToast({
|
||||
title: "低于最小值,已变更为最小值发送",
|
||||
icon: "none"
|
||||
});
|
||||
item.typeNums = item.min;
|
||||
} else if (item.typeNums > item.max) {
|
||||
common_vendor.index.showToast({
|
||||
title: "超过最大值,已变更为最大值发送",
|
||||
icon: "none"
|
||||
});
|
||||
item.typeNums = item.max;
|
||||
}
|
||||
this.sendData = "B" + item.value + item.typeNums + "\r";
|
||||
for (let i = 0; i < this.deviceIds.length; i++) {
|
||||
this.getBLEDeviceServices(1, this.deviceIds[i]);
|
||||
}
|
||||
}, 500);
|
||||
},
|
||||
checkboxChange(e) {
|
||||
if (e.target.value[0] && e.target.dataset.name) {
|
||||
let item = {
|
||||
deviceId: e.target.value[0],
|
||||
name: e.target.dataset.name
|
||||
};
|
||||
this.deviceIds.push(item);
|
||||
} else {
|
||||
for (let index = 0; index < this.deviceIds.length; index++) {
|
||||
let item = this.deviceIds[index];
|
||||
if (item.deviceId == e.target.dataset.deviceid) {
|
||||
this.deviceIds.splice(index, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
hextoString(hex) {
|
||||
var arr = hex.split("");
|
||||
var out = "";
|
||||
for (var i = 0; i < arr.length / 2; i++) {
|
||||
var tmp = "0x" + arr[i * 2] + arr[i * 2 + 1];
|
||||
var charValue = String.fromCharCode(tmp);
|
||||
out += charValue;
|
||||
}
|
||||
return out;
|
||||
},
|
||||
send(index) {
|
||||
let that = this;
|
||||
if (index == 1) {
|
||||
that.sendData = that.input1 + that.input2 + "\r";
|
||||
}
|
||||
if (!that.sendData) {
|
||||
return common_vendor.index.showToast({
|
||||
title: "发送数据不可为空",
|
||||
icon: "none"
|
||||
});
|
||||
}
|
||||
common_vendor.index.showLoading({
|
||||
title: "发送中,请稍等",
|
||||
mask: true
|
||||
});
|
||||
for (let i = 0; i < that.deviceIds.length; i++) {
|
||||
that.getBLEDeviceServices(1, that.deviceIds[i]);
|
||||
}
|
||||
},
|
||||
// ArrayBuffer转16进度字符串示例
|
||||
ab2hex(buffer) {
|
||||
const hexArr = Array.prototype.map.call(
|
||||
new Uint8Array(buffer),
|
||||
function(bit) {
|
||||
return ("00" + bit.toString(16)).slice(-2);
|
||||
}
|
||||
);
|
||||
return hexArr.join("");
|
||||
},
|
||||
onBLEConnectionStateChange() {
|
||||
common_vendor.index.onBLEConnectionStateChange((res) => {
|
||||
if (res.connected == false) {
|
||||
common_vendor.index.hideLoading();
|
||||
for (let i = 0; i < this.deviceIds.length; i++) {
|
||||
if (res.deviceId == this.deviceIds[i].deviceId) {
|
||||
common_vendor.index.showToast({
|
||||
title: this.deviceIds[i].name + " 蓝牙设备断开连接",
|
||||
icon: "none"
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
//初始化蓝牙
|
||||
initBle() {
|
||||
this.bleDevs = [];
|
||||
this.deviceIds = [];
|
||||
common_vendor.index.openBluetoothAdapter({
|
||||
success: (res) => {
|
||||
common_vendor.index.getBluetoothAdapterState({
|
||||
//蓝牙的匹配状态
|
||||
success: (res1) => {
|
||||
this.startBluetoothDeviceDiscovery();
|
||||
},
|
||||
fail(error) {
|
||||
common_vendor.index.showToast({ icon: "none", title: "查看手机蓝牙是否打开" });
|
||||
}
|
||||
});
|
||||
},
|
||||
fail: (err) => {
|
||||
common_vendor.index.showToast({ icon: "none", title: "查看手机蓝牙是否打开" });
|
||||
}
|
||||
});
|
||||
},
|
||||
// 开始搜索蓝牙设备
|
||||
startBluetoothDeviceDiscovery() {
|
||||
common_vendor.index.startBluetoothDevicesDiscovery({
|
||||
success: (res) => {
|
||||
this.onBluetoothDeviceFound();
|
||||
},
|
||||
fail: (err) => {
|
||||
}
|
||||
});
|
||||
},
|
||||
// 发现外围设备
|
||||
onBluetoothDeviceFound() {
|
||||
common_vendor.index.onBluetoothDeviceFound((res) => {
|
||||
if (this.bleDevs.indexOf(res.devices[0]) == -1) {
|
||||
this.bleDevs.push(res.devices[0]);
|
||||
}
|
||||
});
|
||||
},
|
||||
// 多选然后连接
|
||||
connectBle() {
|
||||
if (this.deviceIds.length == 0) {
|
||||
common_vendor.index.showToast({ title: "请选择连接的设备", icon: "none" });
|
||||
return;
|
||||
}
|
||||
this.getData = [];
|
||||
this.deviceIds.forEach((item) => {
|
||||
this.nowLinkLis(item);
|
||||
});
|
||||
},
|
||||
//选择设备连接吧deviceId传进来
|
||||
createBLEConnection(item) {
|
||||
common_vendor.index.showLoading({
|
||||
title: "连接中,请稍等",
|
||||
mask: true
|
||||
});
|
||||
let that = this;
|
||||
common_vendor.index.createBLEConnection({
|
||||
deviceId: item.deviceId,
|
||||
success(res) {
|
||||
that.shows = true;
|
||||
that.stopBluetoothDevicesDiscovery();
|
||||
that.getBLEDeviceServices(2, item);
|
||||
},
|
||||
fail(res) {
|
||||
console.log("蓝牙连接失败", res);
|
||||
common_vendor.index.showToast({
|
||||
title: items.name + "蓝牙连接失败",
|
||||
icon: "none"
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
// 停止搜寻蓝牙设备
|
||||
stopBluetoothDevicesDiscovery() {
|
||||
common_vendor.index.stopBluetoothDevicesDiscovery({
|
||||
success: (e) => {
|
||||
this.loading = false;
|
||||
},
|
||||
fail: (e) => {
|
||||
console.log("停止搜索蓝牙设备失败,错误码:" + e.errCode);
|
||||
}
|
||||
});
|
||||
},
|
||||
//获取蓝牙的所有服务
|
||||
getBLEDeviceServices(index, items2) {
|
||||
setTimeout(() => {
|
||||
common_vendor.index.getBLEDeviceServices({
|
||||
// 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接
|
||||
deviceId: items2.deviceId,
|
||||
success: (res) => {
|
||||
console.log("services", res.services);
|
||||
res.services.forEach((item) => {
|
||||
if (item.uuid.indexOf("0000FFE0-0000-1000-8000-00805F9B34FB") != -1) {
|
||||
items2["serviceId"] = item.uuid;
|
||||
this.getBLEDeviceCharacteristics(index, items2);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}, 1e3);
|
||||
},
|
||||
//获取蓝牙特征
|
||||
getBLEDeviceCharacteristics(index, items2) {
|
||||
setTimeout(() => {
|
||||
common_vendor.index.getBLEDeviceCharacteristics({
|
||||
// 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接
|
||||
deviceId: items2.deviceId,
|
||||
// 这里的 serviceId 需要在 getBLEDeviceServices 接口中获取
|
||||
serviceId: items2.serviceId,
|
||||
success: (res) => {
|
||||
console.log("characteristics", res);
|
||||
res.characteristics.forEach((item) => {
|
||||
if (
|
||||
// 2 支持监听 1 支持写入
|
||||
item.uuid.indexOf(
|
||||
index == 1 ? "0000FFE1-0000-1000-8000-00805F9B34FB" : "0000FFE2-0000-1000-8000-00805F9B34FB"
|
||||
) != -1
|
||||
) {
|
||||
items2["characteristicId"] = item.uuid;
|
||||
if (index == 2) {
|
||||
this.notifyBLECharacteristicValueChange(items2);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (index == 1) {
|
||||
this.writeString(this.sendData, items2);
|
||||
}
|
||||
},
|
||||
fail: (res) => {
|
||||
console.log(res);
|
||||
}
|
||||
});
|
||||
}, 0);
|
||||
},
|
||||
// 启用 notify 功能
|
||||
notifyBLECharacteristicValueChange(items2) {
|
||||
let that = this;
|
||||
common_vendor.index.notifyBLECharacteristicValueChange({
|
||||
state: true,
|
||||
// 启用 notify 功能
|
||||
// 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接
|
||||
deviceId: items2.deviceId,
|
||||
// 这里的 serviceId 需要在 getBLEDeviceServices 接口中获取
|
||||
serviceId: items2.serviceId,
|
||||
// 这里的 characteristicId 需要在 getBLEDeviceCharacteristics 接口中获取
|
||||
characteristicId: items2.characteristicId,
|
||||
success: (res) => {
|
||||
console.log("启用 notify 功能成功", res);
|
||||
common_vendor.index.hideLoading();
|
||||
items2["status"] = true;
|
||||
items2["text"] = "";
|
||||
that.totalList.push(items2);
|
||||
common_vendor.index.onBLECharacteristicValueChange((res2) => {
|
||||
for (let i = 0; i < that.deviceIds.length; i++) {
|
||||
if (res2.deviceId == that.deviceIds[i].deviceId) {
|
||||
let item = {
|
||||
name: that.deviceIds[i].name,
|
||||
txt: "接收到:" + that.hextoString(that.ab2hex(res2.value))
|
||||
};
|
||||
that.getData.unshift(item);
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < that.totalList.length; i++) {
|
||||
if (res2.deviceId == that.totalList[i].deviceId) {
|
||||
that.totalList[i].text = that.hextoString(
|
||||
that.ab2hex(res2.value)
|
||||
);
|
||||
}
|
||||
}
|
||||
that.totalList = JSON.stringify(that.totalList);
|
||||
that.totalList = JSON.parse(that.totalList);
|
||||
});
|
||||
},
|
||||
fail: (res) => {
|
||||
console.log("启用 notify 功能失败", res);
|
||||
}
|
||||
});
|
||||
},
|
||||
close() {
|
||||
let that = this;
|
||||
common_vendor.index.showModal({
|
||||
title: "提示",
|
||||
content: "将断开全部蓝牙连接",
|
||||
success: function(res) {
|
||||
if (res.confirm) {
|
||||
for (let index = 0; index < that.deviceIds.length; index++) {
|
||||
let item = that.deviceIds[index];
|
||||
common_vendor.index.closeBLEConnection({
|
||||
deviceId: item.deviceId,
|
||||
success(res2) {
|
||||
console.log("断开蓝牙成功", res2);
|
||||
that.shows = false;
|
||||
that.totalList = [];
|
||||
common_vendor.index.showToast({
|
||||
title: "断开蓝牙成功"
|
||||
});
|
||||
},
|
||||
fail(res2) {
|
||||
console.log("断开蓝牙失败", res2);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
// 向蓝牙设备发送字符串数据 writeBLECharacteristicValueString
|
||||
writeString(str, items2) {
|
||||
let that = this;
|
||||
let buffer = new ArrayBuffer(str.length);
|
||||
let dataView = new DataView(buffer);
|
||||
for (let i in str) {
|
||||
dataView.setUint8(i, str[i].charCodeAt() | 0);
|
||||
}
|
||||
setTimeout(() => {
|
||||
common_vendor.index.writeBLECharacteristicValue({
|
||||
deviceId: items2.deviceId,
|
||||
serviceId: items2.serviceId,
|
||||
characteristicId: items2.characteristicId,
|
||||
value: buffer,
|
||||
writeType: "write",
|
||||
success: function(res) {
|
||||
common_vendor.index.hideLoading();
|
||||
let item = {
|
||||
name: items2.name,
|
||||
txt: "已发送:" + str
|
||||
};
|
||||
that.getData.unshift(item);
|
||||
},
|
||||
fail: function(res) {
|
||||
common_vendor.index.hideLoading();
|
||||
common_vendor.index.showToast({
|
||||
title: "发送失败,可能蓝牙目前不支持写入",
|
||||
icon: "none"
|
||||
});
|
||||
}
|
||||
});
|
||||
}, 0);
|
||||
},
|
||||
// 直接启用监听功能
|
||||
nowLinkLis(items2) {
|
||||
let that = this;
|
||||
console.log("items", items2);
|
||||
common_vendor.index.showLoading({
|
||||
title: "连接中,请稍等",
|
||||
mask: true
|
||||
});
|
||||
common_vendor.index.createBLEConnection({
|
||||
deviceId: items2.deviceId,
|
||||
success(res) {
|
||||
that.stopBluetoothDevicesDiscovery();
|
||||
setTimeout(() => {
|
||||
common_vendor.index.notifyBLECharacteristicValueChange({
|
||||
state: true,
|
||||
// 启用 notify 功能
|
||||
deviceId: items2.deviceId,
|
||||
serviceId: "0000FFE0-0000-1000-8000-00805F9B34FB",
|
||||
characteristicId: "0000FFE2-0000-1000-8000-00805F9B34FB",
|
||||
success: (res2) => {
|
||||
console.log("启用监听了", res2);
|
||||
that.shows = true;
|
||||
common_vendor.index.hideLoading();
|
||||
items2["status"] = true;
|
||||
items2["text"] = "";
|
||||
that.totalList.push(items2);
|
||||
common_vendor.index.onBLECharacteristicValueChange((res3) => {
|
||||
for (let i = 0; i < that.deviceIds.length; i++) {
|
||||
if (res3.deviceId == that.deviceIds[i].deviceId) {
|
||||
let item = {
|
||||
name: that.deviceIds[i].name,
|
||||
txt: "接收到:" + that.hextoString(that.ab2hex(res3.value))
|
||||
};
|
||||
that.getData.unshift(item);
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < that.totalList.length; i++) {
|
||||
if (res3.deviceId == that.totalList[i].deviceId) {
|
||||
that.totalList[i].text = that.hextoString(
|
||||
that.ab2hex(res3.value)
|
||||
);
|
||||
}
|
||||
}
|
||||
that.totalList = JSON.stringify(that.totalList);
|
||||
that.totalList = JSON.parse(that.totalList);
|
||||
});
|
||||
},
|
||||
fail: (res2) => {
|
||||
console.log("启用 notify 功能失败", res2);
|
||||
common_vendor.index.hideLoading();
|
||||
common_vendor.index.showToast({ title: "连接失败", icon: "none" });
|
||||
}
|
||||
});
|
||||
}, 800);
|
||||
},
|
||||
fail(res) {
|
||||
console.log("蓝牙连接失败", res);
|
||||
common_vendor.index.showToast({
|
||||
title: items2.name + "连接失败",
|
||||
icon: "none"
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
if (!Array) {
|
||||
const _component_viwe = common_vendor.resolveComponent("viwe");
|
||||
_component_viwe();
|
||||
}
|
||||
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
return common_vendor.e({
|
||||
a: !$data.shows,
|
||||
b: common_vendor.o((...args) => $options.initBle && $options.initBle(...args)),
|
||||
c: Math.max(100 + _ctx.item.RSSI, 0) >= 30
|
||||
}, Math.max(100 + _ctx.item.RSSI, 0) >= 30 ? {
|
||||
d: common_vendor.f($data.bleDevs, (item, index, i0) => {
|
||||
return {
|
||||
a: common_vendor.t(item.name),
|
||||
b: item.deviceId,
|
||||
c: common_vendor.o((...args) => $options.checkboxChange && $options.checkboxChange(...args), index),
|
||||
d: item.name,
|
||||
e: item.deviceId,
|
||||
f: common_vendor.t(item.deviceId),
|
||||
g: common_vendor.t(item.RSSI),
|
||||
h: common_vendor.t(Math.max(100 + item.RSSI, 0)),
|
||||
i: index,
|
||||
j: item.name.length > 0 && !$data.shows
|
||||
};
|
||||
})
|
||||
} : {}, {
|
||||
e: !$data.shows
|
||||
}, !$data.shows ? {
|
||||
f: common_vendor.o((...args) => $options.connectBle && $options.connectBle(...args))
|
||||
} : {}, {
|
||||
g: $data.shows
|
||||
}, $data.shows ? {
|
||||
h: common_vendor.o((...args) => $options.close && $options.close(...args))
|
||||
} : {}, {
|
||||
i: $data.shows
|
||||
}, $data.shows ? {
|
||||
j: common_vendor.f($data.testItems, (item, index, i0) => {
|
||||
return {
|
||||
a: common_vendor.t(item.name),
|
||||
b: common_vendor.o(($event) => $options.changNums(1, item), index),
|
||||
c: common_vendor.o([($event) => item.typeNums = $event.detail.value, index, ($event) => $options.changeBar(item), index], index),
|
||||
d: item.typeNums,
|
||||
e: common_vendor.o(($event) => $options.changNums(2, item), index),
|
||||
f: index
|
||||
};
|
||||
})
|
||||
} : {}, {
|
||||
k: $data.shows
|
||||
}, $data.shows ? {
|
||||
l: common_vendor.t($data.titleTime),
|
||||
m: common_vendor.o((...args) => $options.begin && $options.begin(...args)),
|
||||
n: common_vendor.o((...args) => $options.pause && $options.pause(...args)),
|
||||
o: common_vendor.o((...args) => $options.stop && $options.stop(...args))
|
||||
} : {}, {
|
||||
p: $data.shows
|
||||
}, $data.shows ? {
|
||||
q: $data.input1,
|
||||
r: common_vendor.o(($event) => $data.input1 = $event.detail.value),
|
||||
s: $data.input2,
|
||||
t: common_vendor.o(($event) => $data.input2 = $event.detail.value),
|
||||
v: common_vendor.o(($event) => $options.send(1))
|
||||
} : {}, {
|
||||
w: common_vendor.f($data.totalList, (item, index, i0) => {
|
||||
return {
|
||||
a: common_vendor.t(item.text),
|
||||
b: common_vendor.t(item.name),
|
||||
c: common_vendor.n(item.status ? "item bakBlue" : "item"),
|
||||
d: index,
|
||||
e: "cb7d404f-0-" + i0
|
||||
};
|
||||
}),
|
||||
x: $data.shows
|
||||
}, $data.shows ? {
|
||||
y: common_vendor.f($data.getData, (item, index, i0) => {
|
||||
return {
|
||||
a: common_vendor.t(item.name),
|
||||
b: common_vendor.t(item.txt),
|
||||
c: index
|
||||
};
|
||||
})
|
||||
} : {});
|
||||
}
|
||||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-cb7d404f"]]);
|
||||
wx.createPage(MiniProgramPage);
|
5
uniapp04/unpackage/dist/dev/mp-weixin/pages/blueTooth/blueTooth.json
vendored
Normal file
5
uniapp04/unpackage/dist/dev/mp-weixin/pages/blueTooth/blueTooth.json
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"navigationBarTitleText": "蓝牙",
|
||||
"enablePullDownRefresh": false,
|
||||
"usingComponents": {}
|
||||
}
|
1
uniapp04/unpackage/dist/dev/mp-weixin/pages/blueTooth/blueTooth.wxml
vendored
Normal file
1
uniapp04/unpackage/dist/dev/mp-weixin/pages/blueTooth/blueTooth.wxml
vendored
Normal file
@ -0,0 +1 @@
|
||||
<view class="content data-v-cb7d404f"><button class="data-v-cb7d404f" type="default" hidden="{{!a}}" bindtap="{{b}}"> 初始化蓝牙模块 </button><scroll-view class="data-v-cb7d404f" scroll-y="true" show-scrollbar="true"><radio-group class="data-v-cb7d404f"><block wx:if="{{c}}"><view wx:for="{{d}}" wx:for-item="item" wx:key="i" class="data-v-cb7d404f" hidden="{{!item.j}}" style="padding:10rpx 20rpx;border-bottom:1rpx solid #ececec"><view class="data-v-cb7d404f" style="font-size:32rpx;color:#333"><checkbox-group class="data-v-cb7d404f" bindchange="{{item.c}}" data-name="{{item.d}}" data-deviceId="{{item.e}}"><label class="data-v-cb7d404f"><checkbox class="data-v-cb7d404f" value="{{item.b}}">{{item.a}}</checkbox></label></checkbox-group></view><view class="data-v-cb7d404f" style="font-size:20rpx;padding:10rpx 0"> deviceId: {{item.f}} 信号强度: {{item.g}}dBm ({{item.h}}%) </view></view></block><view class="dis data-v-cb7d404f"><view wx:if="{{e}}" bindtap="{{f}}" class="pl data-v-cb7d404f"> 连接 </view><view wx:if="{{g}}" bindtap="{{h}}" class="pl data-v-cb7d404f"> 断开 </view></view></radio-group></scroll-view><view wx:if="{{i}}" class="barItems data-v-cb7d404f"><view wx:for="{{j}}" wx:for-item="item" wx:key="f" class="barItem data-v-cb7d404f"><view class="name data-v-cb7d404f">{{item.a}}</view><view class="bar data-v-cb7d404f"><view class="reduce data-v-cb7d404f" bindtap="{{item.b}}">-</view><input class="data-v-cb7d404f" type="tel" bindinput="{{item.c}}" value="{{item.d}}"/><view class="add data-v-cb7d404f" bindtap="{{item.e}}">+</view></view></view></view><view wx:if="{{k}}" class="timers data-v-cb7d404f"><view class="time data-v-cb7d404f">{{l}}</view><view class="btns data-v-cb7d404f"><view class="data-v-cb7d404f" bindtap="{{m}}">启动</view><view class="data-v-cb7d404f" bindtap="{{n}}">暂停</view><view class="data-v-cb7d404f" bindtap="{{o}}">停止</view></view></view><view wx:if="{{p}}" class="data-v-cb7d404f"><view class="input3 data-v-cb7d404f"><input class="data-v-cb7d404f" type="text" value="{{q}}" bindinput="{{r}}"/><input class="data-v-cb7d404f" type="text" value="{{s}}" bindinput="{{t}}"/></view><button type="default" class="send data-v-cb7d404f" bindtap="{{v}}">发送</button></view><view class="appItems data-v-cb7d404f"><viwe wx:for="{{w}}" wx:for-item="item" wx:key="d" u-s="{{['d']}}" class="{{['data-v-cb7d404f', item.c]}}" u-i="{{item.e}}" bind:__l="__l"><view class="txt data-v-cb7d404f">{{item.a}}</view><view class="name p_hide data-v-cb7d404f">{{item.b}}</view></viwe></view><view wx:if="{{x}}" class="items data-v-cb7d404f"><view wx:for="{{y}}" wx:for-item="item" wx:key="c" class="item data-v-cb7d404f">{{item.a}}:{{item.b}}</view></view></view>
|
167
uniapp04/unpackage/dist/dev/mp-weixin/pages/blueTooth/blueTooth.wxss
vendored
Normal file
167
uniapp04/unpackage/dist/dev/mp-weixin/pages/blueTooth/blueTooth.wxss
vendored
Normal file
@ -0,0 +1,167 @@
|
||||
/**
|
||||
* 这里是uni-app内置的常用样式变量
|
||||
*
|
||||
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
|
||||
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
|
||||
*
|
||||
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
|
||||
*/
|
||||
/* 颜色变量 */
|
||||
/* 行为相关颜色 */
|
||||
/* 文字基本颜色 */
|
||||
/* 背景颜色 */
|
||||
/* 边框颜色 */
|
||||
/* 尺寸变量 */
|
||||
/* 文字尺寸 */
|
||||
/* 图片尺寸 */
|
||||
/* Border Radius */
|
||||
/* 水平间距 */
|
||||
/* 垂直间距 */
|
||||
/* 透明度 */
|
||||
/* 文章场景相关 */
|
||||
.input3.data-v-cb7d404f {
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
}
|
||||
.input3 input.data-v-cb7d404f {
|
||||
border: 1rpx solid #ccc;
|
||||
margin: 20rpx;
|
||||
text-align: center;
|
||||
height: 60rpx;
|
||||
border-radius: 10rpx;
|
||||
font-size: 50rpx;
|
||||
}
|
||||
.input3 input.data-v-cb7d404f:first-child,
|
||||
.input3 input.data-v-cb7d404f:last-child {
|
||||
width: 200rpx;
|
||||
}
|
||||
.bakBlue.data-v-cb7d404f {
|
||||
background-color: #007aff !important;
|
||||
}
|
||||
.appItems.data-v-cb7d404f {
|
||||
padding: 30rpx 0 30rpx 4rpx;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.appItems .item.data-v-cb7d404f {
|
||||
color: #333;
|
||||
width: 160rpx;
|
||||
height: 160rpx;
|
||||
border-radius: 50%;
|
||||
border: 1rpx solid #ececec;
|
||||
margin: 10rpx 15rpx;
|
||||
position: relative;
|
||||
}
|
||||
.appItems .item .txt.data-v-cb7d404f {
|
||||
position: absolute;
|
||||
font-size: 26rpx;
|
||||
top: 56rpx;
|
||||
width: 100%;
|
||||
color: #fff;
|
||||
z-index: 10;
|
||||
text-align: center;
|
||||
}
|
||||
.appItems .item .name.data-v-cb7d404f {
|
||||
position: absolute;
|
||||
width: 80%;
|
||||
left: 10%;
|
||||
bottom: 30rpx;
|
||||
font-size: 20rpx;
|
||||
text-align: center;
|
||||
}
|
||||
.timers.data-v-cb7d404f {
|
||||
text-align: center;
|
||||
margin-top: 30rpx;
|
||||
}
|
||||
.timers .time.data-v-cb7d404f {
|
||||
margin-bottom: 40rpx;
|
||||
width: 100%;
|
||||
font-size: 80rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
.timers .btns.data-v-cb7d404f {
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
}
|
||||
.timers .btns view.data-v-cb7d404f {
|
||||
width: 200rpx;
|
||||
height: 60rpx;
|
||||
background-color: #007aff;
|
||||
color: #fff;
|
||||
line-height: 60rpx;
|
||||
border-radius: 10rpx;
|
||||
}
|
||||
.timers .btns view.data-v-cb7d404f:active {
|
||||
background-color: #2990ff;
|
||||
}
|
||||
.items.data-v-cb7d404f {
|
||||
width: 100%;
|
||||
font-size: 32rpx;
|
||||
overflow-y: scroll;
|
||||
height: 300rpx;
|
||||
background-color: #ccc;
|
||||
margin: 40rpx 0;
|
||||
}
|
||||
.items .item.data-v-cb7d404f {
|
||||
padding: 4rpx 20rpx 0 20rpx;
|
||||
}
|
||||
.pl.data-v-cb7d404f {
|
||||
margin: 20rpx;
|
||||
background-color: #007aff;
|
||||
padding: 10rpx;
|
||||
}
|
||||
.classText.data-v-cb7d404f {
|
||||
width: 94%;
|
||||
padding: 10rpx;
|
||||
margin: 3%;
|
||||
border: 1rpx solid #ececec;
|
||||
}
|
||||
.send.data-v-cb7d404f {
|
||||
background-color: #ff3e3e;
|
||||
color: #fff;
|
||||
}
|
||||
.dis.data-v-cb7d404f {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.dis view.data-v-cb7d404f {
|
||||
width: 100%;
|
||||
border-radius: 8rpx;
|
||||
font-size: 32rpx;
|
||||
}
|
||||
.barItems.data-v-cb7d404f {
|
||||
width: 100%;
|
||||
}
|
||||
.barItems .barItem.data-v-cb7d404f {
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
height: 100rpx;
|
||||
padding-top: 20rpx;
|
||||
align-items: center;
|
||||
}
|
||||
.barItems .barItem .bar.data-v-cb7d404f {
|
||||
width: 300rpx;
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
}
|
||||
.barItems .barItem .bar view.data-v-cb7d404f {
|
||||
border: 1rpx solid #ececec;
|
||||
width: 50rpx;
|
||||
height: 50rpx;
|
||||
text-align: center;
|
||||
}
|
||||
.barItems .barItem .bar input.data-v-cb7d404f {
|
||||
width: 100rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
page {
|
||||
background-color: #fff;
|
||||
}
|
Reference in New Issue
Block a user