对接H08

This commit is contained in:
qiaocl 2024-07-30 17:05:20 +08:00
parent 7bccef6dcc
commit 872f97cc4d
64 changed files with 1635 additions and 516 deletions

468
BLEPages/child/H08.vue Normal file
View File

@ -0,0 +1,468 @@
<template>
<view>
<view class="content weightPages">
<view class="title" v-if="isConnection == 0">连接中请稍后</view>
<view class="title" v-if="isConnection == 1">连接成功请开始测量</view>
<view class="title" v-if="isConnection == 2" @click="openBluetoothAdapter">连接失败点击重新连接</view>
<view class="text">{{text}}</view>
<view class="text">{{textH}}</view>
<view class="image">
<image src="/BLEPages/static/H08B.gif" v-if="type == 1"></image>
<image src="/BLEPages/static/H08B2.gif" v-if="type == 2"></image>
</view>
<view class="tips">
<text>提示</text>
<text>1.请确定设备是开机状态</text>
<text>2.请确定手机蓝牙位置信息已打开</text>
<text>3.ios系统需打开设置>应用>微信里的蓝牙权限</text>
</view>
</view>
</view>
</template>
<script>
import {
mapState
} from "vuex";
var myTime;
export default {
data() {
return {
text: "",
textH: "",
height: "",
weight: "",
imp: 0,
type: 1,
uuid1: "",
uuid2: "",
uuid3: "",
macAddr: "",
deviceId: "",
serviceId: "",
Unload: false,
isConnection: 0, //
}
},
computed: {
...mapState(["user", "isConnected", "isBluetoothTyle", "appTheme"]),
info() {
return this.user
}
},
onUnload: function() {
let that = this
if (!that.Unload) {
that.stopBluetoothDevicesDiscovery() //
clearTimeout(myTime);
that.closeBLEConnection()
that.closeBluetoothAdapter()
uni.switchTab({
url: "/pages/index/index"
})
console.log("返回首页")
}
},
onLoad(options) {
let that = this
//
uni.setNavigationBarColor({
frontColor: '#ffffff',
backgroundColor: this.appTheme,
})
//
that.text = ""
that.textH = ""
that.imp = 0
if (options && options.deviceId) {
that.deviceId = options.deviceId
that.closeBLEConnection()
that.closeBluetoothAdapter()
that.openBluetoothAdapter()
}
that.onBLEConnectionStateChange()
uni.onBluetoothAdapterStateChange(function(res) {
that.$store.commit("changeBluetooth", res.available);
})
},
watch: {
isConnected: function() {
let that = this
if (!that.isConnected) {
that.handleBack()
that.isConnection = 2
}
},
isBluetoothTyle: function() {
let that = this
if (!that.isBluetoothTyle) {
that.handleBack()
that.isConnection = 2
}
},
},
methods: {
//
openBluetoothAdapter() {
let that = this
that.type = 1
that.text = ""
that.textH = ""
uni.openBluetoothAdapter({
success: e => {
that.isConnection = 0
that.startBluetoothDeviceDiscovery()
},
fail: e => {
that.isConnection = 2
that.$tools.msg("请确定设备是开机状态、手机蓝牙权限已打开!")
}
});
},
//
startBluetoothDeviceDiscovery() {
let that = this
uni.startBluetoothDevicesDiscovery({
allowDuplicatesKey: false,
interval: 500, //
services: [
"FFE0",
],
success: res => {
that.isConnection = 0
that.onBluetoothDeviceFound();
},
fail: res => {
that.isConnection = 2
that.$tools.msg("请确定设备是开机状态、手机蓝牙权限已打开!")
}
});
},
/**
* 发现外围设备
*/
onBluetoothDeviceFound() {
var that = this;
that.isConnection = 0
uni.onBluetoothDeviceFound(res => {
res.devices.forEach(device => {
if (!device.name && !device.localName) {
return
}
if (device.name.indexOf('AiLink_') != -1 || (device.localName && device.localName
.indexOf('AiLink_') != -1)) {
clearTimeout(myTime);
let buff = device.advertisData.slice(-6)
device.mac = new Uint8Array(buff) // 广maciOSmac
let tempMac = Array.from(device.mac)
tempMac.reverse()
device.macAddr = that.$tools.ab2hex(tempMac, ':').toUpperCase()
if (device.deviceId.indexOf(that.deviceId) != -1 || device.macAddr.indexOf(that
.deviceId) != -1) {
that.stopBluetoothDevicesDiscovery()
that.macAddr = device.macAddr
that.deviceId = device.deviceId;
that.createBLEConnection()
return;
}
}
})
});
that.handleMyTime()
},
handleMyTime() {
var that = this;
myTime = setTimeout(function() {
if (!that.macAddr) {
clearTimeout(myTime);
that.Unload = true
that.isConnection = 2
that.closeBLEConnection()
that.closeBluetoothAdapter()
}
}, 20000);
},
/**
* 停止搜索蓝牙设备
*/
stopBluetoothDevicesDiscovery() {
uni.stopBluetoothDevicesDiscovery({
success: e => {
console.log("停止搜索蓝牙设备", e)
},
});
},
//
onBLEConnectionStateChange() {
let that = this
uni.onBLEConnectionStateChange(function(res) {
console.log("监听蓝牙连接状态", res.connected)
if (!res.connected) {
that.Unload = true
that.isConnection = 2
clearTimeout(myTime);
that.closeBLEConnection()
that.closeBluetoothAdapter()
}
that.$store.commit("changeConnected", res.connected);
})
},
//
createBLEConnection() {
let that = this;
uni.createBLEConnection({
deviceId: that.deviceId,
success: res => {
that.isConnection = 0
that.getBLEDeviceServices();
},
fail: res => {
that.isConnection = 2
console.log("设备连接失败,请重新连接", res);
}
});
},
/**
* 获取设备的UUID
*/
getBLEDeviceServices() {
let serviceList = [];
let that = this;
uni.getBLEDeviceServices({
deviceId: that.deviceId,
success: res => {
console.log("获取设备的UUID成功", res)
serviceList = res.services;
for (let i = 0; i < serviceList.length; i++) {
let service = serviceList[i];
if (service.uuid.indexOf("FFE0") != -1) {
that.isConnection = 1
that.serviceId = service.uuid;
that.getBLEDeviceCharacteristics();
console.log("设备的FFE0的serviceId " + that.serviceId);
break;
}
}
},
fail: res => {
console.log('获取设备的UUID失败:', res)
}
});
},
/**
* 获取指定服务的特征值
*/
getBLEDeviceCharacteristics() {
let characteristicsList = [];
let that = this;
uni.getBLEDeviceCharacteristics({
deviceId: that.deviceId,
serviceId: that.serviceId,
success: res => {
console.log("服务的特征值成功", res)
for (let i = 0; i < res.characteristics.length; i++) {
let item = res.characteristics[i];
if (item.uuid.indexOf('0000FFE1') != -1) {
that.uuid1 = item.uuid //
} else if (item.uuid.indexOf('0000FFE2') != -1) {
that.uuid2 = item.uuid //
} else if (item.uuid.indexOf('0000FFE3') != -1) {
that.uuid3 = item.uuid //
}
}
uni.notifyBLECharacteristicValueChange({
deviceId: that.deviceId,
serviceId: that.serviceId,
characteristicId: that.uuid2,
state: true,
})
uni.notifyBLECharacteristicValueChange({
deviceId: that.deviceId,
serviceId: that.serviceId,
characteristicId: that.uuid3,
state: true,
})
that.sendData()
uni.onBLECharacteristicValueChange(function(res) {
let value = that.$tools.ab2hex(res.value, "");
let num = value.substring(18, 19)
let dw = value.substring(19, 20)
let type = value.substring(8, 10)
let typeInfo = value.substring(10, 12)
console.log("单位", value, dw)
if (type == "10") {
let data = parseInt(value.substring(13, 18), 16)
let dw1 = "kg"
let dw2 = "kg"
if (dw == "1") {
dw1 = "斤"
dw2 = "jin"
}
if (dw == "4") {
dw1 = "st:lb"
dw2 = "st"
data = 1 * data + 5
}
if (dw == "6") {
dw1 = "lb"
dw2 = "lb"
}
if (num == "1") {
data = parseInt(value.substring(13, 18), 16) / 10
}
if (num == "2") {
data = parseInt(value.substring(13, 18), 16) / 100
}
if (num == "3") {
data = parseInt(value.substring(13, 18), 16) / 1000
}
if (typeInfo == "01") {
that.text = "您的实时体重是:" + data + dw1
}
if (typeInfo == "02") {
that.text = "您的体重是:" + data + dw1
that.weight = data + dw2
console.log("稳定体重:", value, that.weight)
}
}
if (type == "14") {
that.height = parseInt(value.substring(10, 14), 16) / 10
that.textH = "您的身高是:" + that.height + "cm"
that.type = 2
console.log("稳定身高:", that.height)
}
if (type == "11") {
if (typeInfo == "03" || typeInfo == "04") {
that.imp = parseInt(value.substring(17, 22), 16)
}
console.log("阻抗:", typeInfo, parseInt(value.substring(17, 22), 16))
}
if (type == "30") {
console.log("测量完成", that.weight, that.imp, that.height)
if (that.imp == 0) {
uni.showModal({
title: '提示',
content: "体脂测量失败,是否保存本次测量结果?",
cancelText: "放弃",
confirmText: "保存",
success(res) {
if (res.confirm) {
that.imp = 0
that.handleGetMeasure()
} else {
console.log("放弃保存")
that.Unload = true
that.closeBLEConnection()
that.closeBluetoothAdapter()
uni.switchTab({
url: "/pages/index/index"
})
}
}
})
} else {
that.handleGetMeasure()
}
}
});
},
fail: res => {
console.log('获取特征值失败:', JSON.stringify(res))
}
})
},
//
sendData() {
let that = this
let j = Number(26 + 3 + 6 + 1).toString(16)
let str = "A9002603060100" + j.substr(j.length - 2, 2) + "9A"
let buf = new Uint8Array(str.match(/[\da-f]{2}/gi).map(function(h) {
return parseInt(h, 16)
}))
uni.writeBLECharacteristicValue({
deviceId: that.deviceId,
serviceId: that.serviceId,
characteristicId: that.uuid1,
value: buf.buffer,
success: res => {
console.log('下发指令成功', res.errMsg)
},
fail: res => {
console.log("下发指令失败", res);
},
})
},
//
handleGetMeasure() {
let that = this
that.$model.getmeasure({
weight: that.weight,
imp: that.imp,
ecode: that.macAddr,
height: that.height,
familyid: that.info.familyid,
}).then(res => {
if (res.code == 0) {
that.$store.dispatch("getUserInfo", {
familyid: that.info.familyid,
});
that.$store.dispatch("getResult", {
birthday: that.info.birthday,
familyid: that.info.familyid,
height: that.height,
sex: that.info.sex,
});
that.$tools.msg("测量成功")
} else {
console.log("测量失败", res.message)
that.$tools.msg(res.message)
}
that.Unload = true
setTimeout(function() {
that.closeBLEConnection()
that.closeBluetoothAdapter()
uni.switchTab({
url: "/pages/index/index"
})
}, 200)
})
},
handleBack(ind) {
let that = this
that.text = ""
that.textH = ""
that.Unload = true
that.stopBluetoothDevicesDiscovery() //
that.closeBLEConnection()
that.closeBluetoothAdapter()
},
/**
* 断开蓝牙模块
*/
closeBluetoothAdapter() {
let that = this;
uni.closeBluetoothAdapter({
success: res => {
console.log('蓝牙模块关闭成功');
}
})
},
/**
* 断开蓝牙连接
*/
closeBLEConnection() {
var that = this;
uni.closeBLEConnection({
deviceId: that.deviceId,
success: res => {
console.log('断开蓝牙连接成功');
}
});
},
},
}
</script>
<style scoped lang="scss">
</style>

View File

@ -1,465 +1,468 @@
<template> <template>
<view> <view>
<view class="content weightPages"> <view class="content weightPages">
<view class="title" v-if="isConnection == 0">连接中请稍后</view> <view class="title" v-if="isConnection == 0">连接中请稍后</view>
<view class="title" v-if="isConnection == 1">连接成功请开始测量</view> <view class="title" v-if="isConnection == 1">连接成功请开始测量</view>
<view class="title" v-if="isConnection == 2" @click="openBluetoothAdapter">连接失败点击重新连接</view> <view class="title" v-if="isConnection == 2" @click="openBluetoothAdapter">连接失败点击重新连接</view>
<view class="text">{{text}}</view> <view class="text">{{text}}</view>
<view class="text">{{textH}}</view> <view class="text">{{textH}}</view>
<view class="image"> <view class="image">
<image src="/BLEPages/static/H09B.gif" v-if="type == 1"></image> <image src="/BLEPages/static/H09B.gif" v-if="type == 1"></image>
<image src="/BLEPages/static/H09B2.gif" v-if="type == 2"></image> <image src="/BLEPages/static/H09B2.gif" v-if="type == 2"></image>
</view> </view>
<view class="tips"> <view class="tips">
<text>提示</text> <text>提示</text>
<text>1.请确定设备是开机状态</text> <text>1.请确定设备是开机状态</text>
<text>2.请确定手机蓝牙位置信息已打开</text> <text>2.请确定手机蓝牙位置信息已打开</text>
<text>3.ios系统需打开设置>应用>微信里的蓝牙权限</text> <text>3.ios系统需打开设置>应用>微信里的蓝牙权限</text>
</view> </view>
</view> </view>
</view> </view>
</template> </template>
<script> <script>
import { import {
mapState mapState
} from "vuex"; } from "vuex";
var myTime; var myTime;
export default { export default {
data() { data() {
return { return {
text: "", text: "",
textH: "", textH: "",
height: "", height: "",
weight: "", weight: "",
imp: 0, imp: 0,
type: 1, type: 1,
uuid1: "", uuid1: "",
uuid2: "", uuid2: "",
uuid3: "", uuid3: "",
macAddr: "", macAddr: "",
deviceId: "", deviceId: "",
serviceId: "", serviceId: "",
Unload: false, Unload: false,
isConnection: 0, // isConnection: 0, //
} }
}, },
computed: { computed: {
...mapState(["user", "isConnected", "isBluetoothTyle", "appTheme"]), ...mapState(["user", "isConnected", "isBluetoothTyle", "appTheme"]),
info() { info() {
return this.user return this.user
} }
}, },
onUnload: function() { onUnload: function() {
let that = this let that = this
if (!that.Unload) { if (!that.Unload) {
that.stopBluetoothDevicesDiscovery() // that.stopBluetoothDevicesDiscovery() //
clearTimeout(myTime); clearTimeout(myTime);
that.closeBLEConnection() that.closeBLEConnection()
that.closeBluetoothAdapter() that.closeBluetoothAdapter()
uni.switchTab({ uni.switchTab({
url: "/pages/index/index" url: "/pages/index/index"
}) })
console.log("返回首页") console.log("返回首页")
} }
}, },
onLoad(options) { onLoad(options) {
let that = this let that = this
// //
uni.setNavigationBarColor({ uni.setNavigationBarColor({
frontColor: '#ffffff', frontColor: '#ffffff',
backgroundColor: this.appTheme, backgroundColor: this.appTheme,
}) })
// //
that.text = "" that.text = ""
that.textH = "" that.textH = ""
that.imp = 0 that.imp = 0
if (options && options.deviceId) { if (options && options.deviceId) {
that.deviceId = options.deviceId that.deviceId = options.deviceId
that.closeBLEConnection() that.closeBLEConnection()
that.closeBluetoothAdapter() that.closeBluetoothAdapter()
that.openBluetoothAdapter() that.openBluetoothAdapter()
} }
that.onBLEConnectionStateChange() that.onBLEConnectionStateChange()
uni.onBluetoothAdapterStateChange(function(res) { uni.onBluetoothAdapterStateChange(function(res) {
that.$store.commit("changeBluetooth", res.available); that.$store.commit("changeBluetooth", res.available);
}) })
}, },
watch: { watch: {
isConnected: function() { isConnected: function() {
let that = this let that = this
if (!that.isConnected) { if (!that.isConnected) {
that.handleBack() that.handleBack()
that.isConnection = 2 that.isConnection = 2
} }
}, },
isBluetoothTyle: function() { isBluetoothTyle: function() {
let that = this let that = this
if (!that.isBluetoothTyle) { if (!that.isBluetoothTyle) {
that.handleBack() that.handleBack()
that.isConnection = 2 that.isConnection = 2
} }
}, },
}, },
methods: { methods: {
// //
openBluetoothAdapter() { openBluetoothAdapter() {
let that = this let that = this
that.type = 1 that.type = 1
that.text = "" that.text = ""
that.textH = "" that.textH = ""
uni.openBluetoothAdapter({ uni.openBluetoothAdapter({
success: e => { success: e => {
that.isConnection = 0 that.isConnection = 0
that.startBluetoothDeviceDiscovery() that.startBluetoothDeviceDiscovery()
}, },
fail: e => { fail: e => {
that.isConnection = 2 that.isConnection = 2
that.$tools.msg("请确定设备是开机状态、手机蓝牙权限已打开!") that.$tools.msg("请确定设备是开机状态、手机蓝牙权限已打开!")
} }
}); });
}, },
// //
startBluetoothDeviceDiscovery() { startBluetoothDeviceDiscovery() {
let that = this let that = this
uni.startBluetoothDevicesDiscovery({ uni.startBluetoothDevicesDiscovery({
allowDuplicatesKey: false, allowDuplicatesKey: false,
interval: 500, // interval: 500, //
services: [ services: [
"FFE0", "FFE0",
], ],
success: res => { success: res => {
that.isConnection = 0 that.isConnection = 0
that.onBluetoothDeviceFound(); that.onBluetoothDeviceFound();
}, },
fail: res => { fail: res => {
that.isConnection = 2 that.isConnection = 2
that.$tools.msg("请确定设备是开机状态、手机蓝牙权限已打开!") that.$tools.msg("请确定设备是开机状态、手机蓝牙权限已打开!")
} }
}); });
}, },
/** /**
* 发现外围设备 * 发现外围设备
*/ */
onBluetoothDeviceFound() { onBluetoothDeviceFound() {
var that = this; var that = this;
that.isConnection = 0 that.isConnection = 0
uni.onBluetoothDeviceFound(res => { uni.onBluetoothDeviceFound(res => {
res.devices.forEach(device => { res.devices.forEach(device => {
if (!device.name && !device.localName) { if (!device.name && !device.localName) {
return return
} }
if (device.name.indexOf('AiLink_') != -1 || (device.localName && device.localName.indexOf('AiLink_') != -1)) { if (device.name.indexOf('AiLink_') != -1 || (device.localName && device.localName
clearTimeout(myTime); .indexOf('AiLink_') != -1)) {
let buff = device.advertisData.slice(-6) clearTimeout(myTime);
device.mac = new Uint8Array(buff) // 广maciOSmac let buff = device.advertisData.slice(-6)
let tempMac = Array.from(device.mac) device.mac = new Uint8Array(buff) // 广maciOSmac
tempMac.reverse() let tempMac = Array.from(device.mac)
device.macAddr = that.$tools.ab2hex(tempMac, ':').toUpperCase() tempMac.reverse()
if (device.deviceId.indexOf(that.deviceId) != -1 || device.macAddr.indexOf(that.deviceId) != -1) { device.macAddr = that.$tools.ab2hex(tempMac, ':').toUpperCase()
that.stopBluetoothDevicesDiscovery() if (device.deviceId.indexOf(that.deviceId) != -1 || device.macAddr.indexOf(that
that.macAddr = device.macAddr .deviceId) != -1) {
that.deviceId = device.deviceId; that.stopBluetoothDevicesDiscovery()
that.createBLEConnection() that.macAddr = device.macAddr
return; that.deviceId = device.deviceId;
} that.createBLEConnection()
} return;
}) }
}); }
that.handleMyTime() })
}, });
handleMyTime() { that.handleMyTime()
var that = this; },
myTime = setTimeout(function() { handleMyTime() {
if (!that.macAddr) { var that = this;
clearTimeout(myTime); myTime = setTimeout(function() {
that.Unload = true if (!that.macAddr) {
that.isConnection = 2 clearTimeout(myTime);
that.closeBLEConnection() that.Unload = true
that.closeBluetoothAdapter() that.isConnection = 2
} that.closeBLEConnection()
}, 20000); that.closeBluetoothAdapter()
}, }
/** }, 20000);
* 停止搜索蓝牙设备 },
*/ /**
stopBluetoothDevicesDiscovery() { * 停止搜索蓝牙设备
uni.stopBluetoothDevicesDiscovery({ */
success: e => { stopBluetoothDevicesDiscovery() {
console.log("停止搜索蓝牙设备", e) uni.stopBluetoothDevicesDiscovery({
}, success: e => {
}); console.log("停止搜索蓝牙设备", e)
}, },
// });
onBLEConnectionStateChange() { },
let that = this //
uni.onBLEConnectionStateChange(function(res) { onBLEConnectionStateChange() {
console.log("监听蓝牙连接状态", res.connected) let that = this
if (!res.connected) { uni.onBLEConnectionStateChange(function(res) {
that.Unload = true console.log("监听蓝牙连接状态", res.connected)
that.isConnection = 2 if (!res.connected) {
clearTimeout(myTime); that.Unload = true
that.closeBLEConnection() that.isConnection = 2
that.closeBluetoothAdapter() clearTimeout(myTime);
} that.closeBLEConnection()
that.$store.commit("changeConnected", res.connected); that.closeBluetoothAdapter()
}) }
}, that.$store.commit("changeConnected", res.connected);
// })
createBLEConnection() { },
let that = this; //
uni.createBLEConnection({ createBLEConnection() {
deviceId: that.deviceId, let that = this;
success: res => { uni.createBLEConnection({
that.isConnection = 0 deviceId: that.deviceId,
that.getBLEDeviceServices(); success: res => {
}, that.isConnection = 0
fail: res => { that.getBLEDeviceServices();
that.isConnection = 2 },
console.log("设备连接失败,请重新连接", res); fail: res => {
} that.isConnection = 2
}); console.log("设备连接失败,请重新连接", res);
}, }
/** });
* 获取设备的UUID },
*/ /**
getBLEDeviceServices() { * 获取设备的UUID
let serviceList = []; */
let that = this; getBLEDeviceServices() {
uni.getBLEDeviceServices({ let serviceList = [];
deviceId: that.deviceId, let that = this;
success: res => { uni.getBLEDeviceServices({
console.log("获取设备的UUID成功", res) deviceId: that.deviceId,
serviceList = res.services; success: res => {
for (let i = 0; i < serviceList.length; i++) { console.log("获取设备的UUID成功", res)
let service = serviceList[i]; serviceList = res.services;
if (service.uuid.indexOf("FFE0") != -1) { for (let i = 0; i < serviceList.length; i++) {
that.isConnection = 1 let service = serviceList[i];
that.serviceId = service.uuid; if (service.uuid.indexOf("FFE0") != -1) {
that.getBLEDeviceCharacteristics(); that.isConnection = 1
console.log("设备的FFE0的serviceId " + that.serviceId); that.serviceId = service.uuid;
break; that.getBLEDeviceCharacteristics();
} console.log("设备的FFE0的serviceId " + that.serviceId);
} break;
}, }
fail: res => { }
console.log('获取设备的UUID失败:', res) },
} fail: res => {
}); console.log('获取设备的UUID失败:', res)
}, }
/** });
* 获取指定服务的特征值 },
*/ /**
getBLEDeviceCharacteristics() { * 获取指定服务的特征值
let characteristicsList = []; */
let that = this; getBLEDeviceCharacteristics() {
uni.getBLEDeviceCharacteristics({ let characteristicsList = [];
deviceId: that.deviceId, let that = this;
serviceId: that.serviceId, uni.getBLEDeviceCharacteristics({
success: res => { deviceId: that.deviceId,
console.log("服务的特征值成功", res) serviceId: that.serviceId,
for (let i = 0; i < res.characteristics.length; i++) { success: res => {
let item = res.characteristics[i]; console.log("服务的特征值成功", res)
if (item.uuid.indexOf('0000FFE1') != -1) { for (let i = 0; i < res.characteristics.length; i++) {
that.uuid1 = item.uuid // let item = res.characteristics[i];
} else if (item.uuid.indexOf('0000FFE2') != -1) { if (item.uuid.indexOf('0000FFE1') != -1) {
that.uuid2 = item.uuid // that.uuid1 = item.uuid //
} else if (item.uuid.indexOf('0000FFE3') != -1) { } else if (item.uuid.indexOf('0000FFE2') != -1) {
that.uuid3 = item.uuid // that.uuid2 = item.uuid //
} } else if (item.uuid.indexOf('0000FFE3') != -1) {
} that.uuid3 = item.uuid //
uni.notifyBLECharacteristicValueChange({ }
deviceId: that.deviceId, }
serviceId: that.serviceId, uni.notifyBLECharacteristicValueChange({
characteristicId: that.uuid2, deviceId: that.deviceId,
state: true, serviceId: that.serviceId,
}) characteristicId: that.uuid2,
uni.notifyBLECharacteristicValueChange({ state: true,
deviceId: that.deviceId, })
serviceId: that.serviceId, uni.notifyBLECharacteristicValueChange({
characteristicId: that.uuid3, deviceId: that.deviceId,
state: true, serviceId: that.serviceId,
}) characteristicId: that.uuid3,
that.sendData() state: true,
uni.onBLECharacteristicValueChange(function(res) { })
let value = that.$tools.ab2hex(res.value, ""); that.sendData()
let num = value.substring(18, 19) uni.onBLECharacteristicValueChange(function(res) {
let dw = value.substring(19, 20) let value = that.$tools.ab2hex(res.value, "");
let type = value.substring(8, 10) let num = value.substring(18, 19)
let typeInfo = value.substring(10, 12) let dw = value.substring(19, 20)
if (type == "10") { let type = value.substring(8, 10)
let data = parseInt(value.substring(13, 18), 16) let typeInfo = value.substring(10, 12)
let dw1 = "kg" console.log("单位", value, dw)
let dw2 = "kg" if (type == "10") {
if (dw == "1") { let data = parseInt(value.substring(13, 18), 16)
dw1 = "斤" let dw1 = "kg"
dw2 = "jin" let dw2 = "kg"
} if (dw == "1") {
if (dw == "4") { dw1 = "斤"
dw1 = "st:lb" dw2 = "jin"
dw2 = "st" }
data = 1 * data + 5 if (dw == "4") {
} dw1 = "st:lb"
if (dw == "6") { dw2 = "st"
dw1 = "lb" data = 1 * data + 5
dw2 = "lb" }
} if (dw == "6") {
if (num == "1") { dw1 = "lb"
data = parseInt(value.substring(13, 18), 16) / 10 dw2 = "lb"
} }
if (num == "2") { if (num == "1") {
data = parseInt(value.substring(13, 18), 16) / 100 data = parseInt(value.substring(13, 18), 16) / 10
} }
if (num == "3") { if (num == "2") {
data = parseInt(value.substring(13, 18), 16) / 1000 data = parseInt(value.substring(13, 18), 16) / 100
} }
if (typeInfo == "01") { if (num == "3") {
that.text = "您的实时体重是:" + data + dw1 data = parseInt(value.substring(13, 18), 16) / 1000
} }
if (typeInfo == "02") { if (typeInfo == "01") {
that.text = "您的体重是:" + data + dw1 that.text = "您的实时体重是:" + data + dw1
that.weight = data + dw2 }
console.log("稳定体重:", value, that.weight) if (typeInfo == "02") {
} that.text = "您的体重是:" + data + dw1
} that.weight = data + dw2
if (type == "14") { console.log("稳定体重:", value, that.weight)
that.height = parseInt(value.substring(10, 14), 16) / 10 }
that.textH = "您的身高是:" + that.height + "cm" }
that.type = 2 if (type == "14") {
console.log("稳定身高:", that.height) that.height = parseInt(value.substring(10, 14), 16) / 10
} that.textH = "您的身高是:" + that.height + "cm"
if (type == "11") { that.type = 2
if (typeInfo == "03" || typeInfo == "04") { console.log("稳定身高:", that.height)
that.imp = parseInt(value.substring(17, 22), 16) }
} if (type == "11") {
console.log("阻抗:", typeInfo, parseInt(value.substring(17, 22), 16)) if (typeInfo == "03" || typeInfo == "04") {
} that.imp = parseInt(value.substring(17, 22), 16)
if (type == "30") { }
console.log("测量完成", that.weight, that.imp, that.height) console.log("阻抗:", typeInfo, parseInt(value.substring(17, 22), 16))
if (that.imp == 0) { }
uni.showModal({ if (type == "30") {
title: '提示', console.log("测量完成", that.weight, that.imp, that.height)
content: "体脂测量失败,是否保存本次测量结果?", if (that.imp == 0) {
cancelText: "放弃", uni.showModal({
confirmText: "保存", title: '提示',
success(res) { content: "体脂测量失败,是否保存本次测量结果?",
if (res.confirm) { cancelText: "放弃",
that.imp = 0 confirmText: "保存",
that.handleGetMeasure() success(res) {
} else { if (res.confirm) {
console.log("放弃保存") that.imp = 0
that.Unload = true that.handleGetMeasure()
that.closeBLEConnection() } else {
that.closeBluetoothAdapter() console.log("放弃保存")
uni.switchTab({ that.Unload = true
url: "/pages/index/index" that.closeBLEConnection()
}) that.closeBluetoothAdapter()
} uni.switchTab({
} url: "/pages/index/index"
}) })
} else { }
that.handleGetMeasure() }
} })
} } else {
}); that.handleGetMeasure()
}, }
fail: res => { }
console.log('获取特征值失败:', JSON.stringify(res)) });
} },
}) fail: res => {
}, console.log('获取特征值失败:', JSON.stringify(res))
// }
sendData() { })
let that = this },
let j = Number(26 + 3 + 6 + 1).toString(16) //
let str = "A9002603060100" + j.substr(j.length - 2, 2) + "9A" sendData() {
let buf = new Uint8Array(str.match(/[\da-f]{2}/gi).map(function(h) { let that = this
return parseInt(h, 16) let j = Number(26 + 3 + 6 + 1).toString(16)
})) let str = "A9002603060100" + j.substr(j.length - 2, 2) + "9A"
uni.writeBLECharacteristicValue({ let buf = new Uint8Array(str.match(/[\da-f]{2}/gi).map(function(h) {
deviceId: that.deviceId, return parseInt(h, 16)
serviceId: that.serviceId, }))
characteristicId: that.uuid1, uni.writeBLECharacteristicValue({
value: buf.buffer, deviceId: that.deviceId,
success: res => { serviceId: that.serviceId,
console.log('下发指令成功', res.errMsg) characteristicId: that.uuid1,
}, value: buf.buffer,
fail: res => { success: res => {
console.log("下发指令失败", res); console.log('下发指令成功', res.errMsg)
}, },
}) fail: res => {
}, console.log("下发指令失败", res);
// },
handleGetMeasure() { })
let that = this },
that.$model.getmeasure({ //
weight: that.weight, handleGetMeasure() {
imp: that.imp, let that = this
ecode: that.macAddr, that.$model.getmeasure({
height: that.height, weight: that.weight,
familyid: that.info.familyid, imp: that.imp,
}).then(res => { ecode: that.macAddr,
if (res.code == 0) { height: that.height,
that.$store.dispatch("getUserInfo", { familyid: that.info.familyid,
familyid: that.info.familyid, }).then(res => {
}); if (res.code == 0) {
that.$store.dispatch("getResult", { that.$store.dispatch("getUserInfo", {
birthday: that.info.birthday, familyid: that.info.familyid,
familyid: that.info.familyid, });
height: that.height, that.$store.dispatch("getResult", {
sex: that.info.sex, birthday: that.info.birthday,
}); familyid: that.info.familyid,
that.$tools.msg("测量成功") height: that.height,
} else { sex: that.info.sex,
console.log("测量失败", res.message) });
that.$tools.msg(res.message) that.$tools.msg("测量成功")
} } else {
that.Unload = true console.log("测量失败", res.message)
setTimeout(function() { that.$tools.msg(res.message)
that.closeBLEConnection() }
that.closeBluetoothAdapter() that.Unload = true
uni.switchTab({ setTimeout(function() {
url: "/pages/index/index" that.closeBLEConnection()
}) that.closeBluetoothAdapter()
}, 200) uni.switchTab({
}) url: "/pages/index/index"
}, })
handleBack(ind) { }, 200)
let that = this })
that.text = "" },
that.textH = "" handleBack(ind) {
that.Unload = true let that = this
that.stopBluetoothDevicesDiscovery() // that.text = ""
that.closeBLEConnection() that.textH = ""
that.closeBluetoothAdapter() that.Unload = true
}, that.stopBluetoothDevicesDiscovery() //
/** that.closeBLEConnection()
* 断开蓝牙模块 that.closeBluetoothAdapter()
*/ },
closeBluetoothAdapter() { /**
let that = this; * 断开蓝牙模块
uni.closeBluetoothAdapter({ */
success: res => { closeBluetoothAdapter() {
console.log('蓝牙模块关闭成功'); let that = this;
} uni.closeBluetoothAdapter({
}) success: res => {
}, console.log('蓝牙模块关闭成功');
/** }
* 断开蓝牙连接 })
*/ },
closeBLEConnection() { /**
var that = this; * 断开蓝牙连接
uni.closeBLEConnection({ */
deviceId: that.deviceId, closeBLEConnection() {
success: res => { var that = this;
console.log('断开蓝牙连接成功'); uni.closeBLEConnection({
} deviceId: that.deviceId,
}); success: res => {
}, console.log('断开蓝牙连接成功');
}, }
} });
},
},
}
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
</style> </style>

View File

@ -38,7 +38,6 @@
notifyId: "", notifyId: "",
isSend: true, isSend: true,
Unload: false, Unload: false,
devicesList: [],
isConnection: 0, isConnection: 0,
data01: {}, data01: {},
data02: {}, data02: {},
@ -89,7 +88,9 @@
}) })
// //
that.textW = "" that.textW = ""
console.log("options", options) that.data01 = {}
that.data02 = {}
that.BLEResult = {}
if (options && options.deviceId) { if (options && options.deviceId) {
that.macAddr = options.deviceId that.macAddr = options.deviceId
that.deviceId = options.deviceId that.deviceId = options.deviceId
@ -109,6 +110,9 @@
let that = this let that = this
that.textW = "" that.textW = ""
that.isSend = true that.isSend = true
that.data01 = {}
that.data02 = {}
that.BLEResult = {}
uni.openBluetoothAdapter({ uni.openBluetoothAdapter({
success: e => { success: e => {
that.isConnection = 0 that.isConnection = 0
@ -163,8 +167,7 @@
if (!device.name && !device.localName) { if (!device.name && !device.localName) {
return return
} }
if (device.name.indexOf('AiLink_') != -1 || (device.localName && device.localName if (device.name.indexOf('AiLink_') != -1 || (device.localName && device.localName.indexOf('AiLink_') != -1)) {
.indexOf('AiLink_') != -1)) {
clearTimeout(myTime); clearTimeout(myTime);
let buff = device.advertisData.slice(-6) let buff = device.advertisData.slice(-6)
device.mac = new Uint8Array(buff) // 广maciOSmac device.mac = new Uint8Array(buff) // 广maciOSmac
@ -344,7 +347,6 @@
} }
if (typeInfo == '02') { if (typeInfo == '02') {
that.data02 = { that.data02 = {
water: parseInt(value.substring(16, 20), 16) / 10, // water: parseInt(value.substring(16, 20), 16) / 10, //
bone: parseInt(value.substring(12, 16), 16) / 100, // bone: parseInt(value.substring(12, 16), 16) / 100, //
bmi: parseInt(value.substring(24, 28), 16) / 10, //BMI bmi: parseInt(value.substring(24, 28), 16) / 10, //BMI
@ -373,7 +375,7 @@
}, },
// //
handleGetMeasure(data) { handleGetMeasure(data) {
console.log("保存结果") console.log("保存结果", data)
let that = this let that = this
that.$model.getmeasuredata(data).then(res => { that.$model.getmeasuredata(data).then(res => {
if (res.code == 0) { if (res.code == 0) {

BIN
BLEPages/static/H08B.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
BLEPages/static/H08B2.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -296,7 +296,16 @@
"path": "child/HCSG818", "path": "child/HCSG818",
"style": { "style": {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"enablePullDownRefresh": false "enablePullDownRefresh": false,
"navigationBarBackgroundColor": "#F9FAFC"
}
},
{
"path": "child/H08",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false,
"navigationBarBackgroundColor": "#F9FAFC"
} }
} }
] ]

View File

@ -194,6 +194,14 @@
that.userId = options.userid that.userId = options.userid
} }
await that.login() await that.login()
// let value = "a900260e1501003200000000021d03fa1600ae9a"
let value = "a900260710020064451100f99a"
let dw = value.substring(19, 20)
let type = value.substring(8, 10)
let typeInfo = value.substring(10, 12)
let weight = parseInt(value.substring(12, 18), 16)
console.log("value", type, typeInfo, weight, dw ,value.substring(12, 18))
}, },
onShow() { onShow() {
this.token = uni.getStorageSync('token') this.token = uni.getStorageSync('token')

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
{"version":3,"sources":["uni-app:///main.js"],"names":["wx","__webpack_require_UNI_MP_PLUGIN__","__webpack_require__","createPage","Page"],"mappings":";;;;;;;;;;;;;AAAA;AAGA;AACA;AAHA;AACAA,EAAE,CAACC,iCAAiC,GAAGC,mBAAmB;AAG1DC,UAAU,CAACC,WAAI,CAAC,C","file":"BLEPages/child/SG919.js","sourcesContent":["import 'uni-pages';\n// @ts-ignore\nwx.__webpack_require_UNI_MP_PLUGIN__ = __webpack_require__;\nimport Vue from 'vue'\nimport Page from './BLEPages/child/SG919.vue'\ncreatePage(Page)"],"sourceRoot":""}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,588 @@
(global["webpackJsonp"] = global["webpackJsonp"] || []).push([["BLEPages/child/H08"],{
/***/ 537:
/*!********************************************************************************************!*\
!*** E:/qiaocongli////adultDeviceApp/main.js?{"page":"BLEPages%2Fchild%2FH08"} ***!
\********************************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(wx, createPage) {
var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ 4);
__webpack_require__(/*! uni-pages */ 26);
var _vue = _interopRequireDefault(__webpack_require__(/*! vue */ 25));
var _H = _interopRequireDefault(__webpack_require__(/*! ./BLEPages/child/H08.vue */ 551));
// @ts-ignore
wx.__webpack_require_UNI_MP_PLUGIN__ = __webpack_require__;
createPage(_H.default);
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./node_modules/@dcloudio/uni-mp-weixin/dist/wx.js */ 1)["default"], __webpack_require__(/*! ./node_modules/@dcloudio/uni-mp-weixin/dist/index.js */ 2)["createPage"]))
/***/ }),
/***/ 551:
/*!*************************************************************************!*\
!*** E:/qiaocongli////adultDeviceApp/BLEPages/child/H08.vue ***!
\*************************************************************************/
/*! no static exports found */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _H08_vue_vue_type_template_id_ae7cbfb6_scoped_true___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./H08.vue?vue&type=template&id=ae7cbfb6&scoped=true& */ 552);
/* harmony import */ var _H08_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./H08.vue?vue&type=script&lang=js& */ 554);
/* harmony reexport (unknown) */ for(var __WEBPACK_IMPORT_KEY__ in _H08_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__) if(["default"].indexOf(__WEBPACK_IMPORT_KEY__) < 0) (function(key) { __webpack_require__.d(__webpack_exports__, key, function() { return _H08_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__[key]; }) }(__WEBPACK_IMPORT_KEY__));
/* harmony import */ var _D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_vue_cli_plugin_uni_packages_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/vue-loader/lib/runtime/componentNormalizer.js */ 31);
var renderjs
/* normalize component */
var component = Object(_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_vue_cli_plugin_uni_packages_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
_H08_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
_H08_vue_vue_type_template_id_ae7cbfb6_scoped_true___WEBPACK_IMPORTED_MODULE_0__["render"],
_H08_vue_vue_type_template_id_ae7cbfb6_scoped_true___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
false,
null,
"ae7cbfb6",
null,
false,
_H08_vue_vue_type_template_id_ae7cbfb6_scoped_true___WEBPACK_IMPORTED_MODULE_0__["components"],
renderjs
)
component.options.__file = "BLEPages/child/H08.vue"
/* harmony default export */ __webpack_exports__["default"] = (component.exports);
/***/ }),
/***/ 552:
/*!********************************************************************************************************************!*\
!*** E:/qiaocongli////adultDeviceApp/BLEPages/child/H08.vue?vue&type=template&id=ae7cbfb6&scoped=true& ***!
\********************************************************************************************************************/
/*! exports provided: render, staticRenderFns, recyclableRender, components */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_vue_cli_plugin_uni_packages_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_vue_cli_plugin_uni_packages_webpack_preprocess_loader_index_js_ref_17_0_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_webpack_uni_mp_loader_lib_template_js_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_vue_cli_plugin_uni_packages_webpack_uni_app_loader_page_meta_js_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_vue_cli_plugin_uni_packages_vue_loader_lib_index_js_vue_loader_options_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_webpack_uni_mp_loader_lib_style_js_H08_vue_vue_type_template_id_ae7cbfb6_scoped_true___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!./node_modules/@dcloudio/vue-cli-plugin-uni/packages/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/@dcloudio/vue-cli-plugin-uni/packages/webpack-preprocess-loader??ref--17-0!./node_modules/@dcloudio/webpack-uni-mp-loader/lib/template.js!./node_modules/@dcloudio/vue-cli-plugin-uni/packages/webpack-uni-app-loader/page-meta.js!./node_modules/@dcloudio/vue-cli-plugin-uni/packages/vue-loader/lib??vue-loader-options!./node_modules/@dcloudio/webpack-uni-mp-loader/lib/style.js!./H08.vue?vue&type=template&id=ae7cbfb6&scoped=true& */ 553);
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "render", function() { return _D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_vue_cli_plugin_uni_packages_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_vue_cli_plugin_uni_packages_webpack_preprocess_loader_index_js_ref_17_0_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_webpack_uni_mp_loader_lib_template_js_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_vue_cli_plugin_uni_packages_webpack_uni_app_loader_page_meta_js_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_vue_cli_plugin_uni_packages_vue_loader_lib_index_js_vue_loader_options_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_webpack_uni_mp_loader_lib_style_js_H08_vue_vue_type_template_id_ae7cbfb6_scoped_true___WEBPACK_IMPORTED_MODULE_0__["render"]; });
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return _D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_vue_cli_plugin_uni_packages_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_vue_cli_plugin_uni_packages_webpack_preprocess_loader_index_js_ref_17_0_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_webpack_uni_mp_loader_lib_template_js_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_vue_cli_plugin_uni_packages_webpack_uni_app_loader_page_meta_js_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_vue_cli_plugin_uni_packages_vue_loader_lib_index_js_vue_loader_options_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_webpack_uni_mp_loader_lib_style_js_H08_vue_vue_type_template_id_ae7cbfb6_scoped_true___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"]; });
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "recyclableRender", function() { return _D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_vue_cli_plugin_uni_packages_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_vue_cli_plugin_uni_packages_webpack_preprocess_loader_index_js_ref_17_0_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_webpack_uni_mp_loader_lib_template_js_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_vue_cli_plugin_uni_packages_webpack_uni_app_loader_page_meta_js_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_vue_cli_plugin_uni_packages_vue_loader_lib_index_js_vue_loader_options_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_webpack_uni_mp_loader_lib_style_js_H08_vue_vue_type_template_id_ae7cbfb6_scoped_true___WEBPACK_IMPORTED_MODULE_0__["recyclableRender"]; });
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "components", function() { return _D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_vue_cli_plugin_uni_packages_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_vue_cli_plugin_uni_packages_webpack_preprocess_loader_index_js_ref_17_0_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_webpack_uni_mp_loader_lib_template_js_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_vue_cli_plugin_uni_packages_webpack_uni_app_loader_page_meta_js_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_vue_cli_plugin_uni_packages_vue_loader_lib_index_js_vue_loader_options_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_webpack_uni_mp_loader_lib_style_js_H08_vue_vue_type_template_id_ae7cbfb6_scoped_true___WEBPACK_IMPORTED_MODULE_0__["components"]; });
/***/ }),
/***/ 553:
/*!********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************!*\
!*** ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/@dcloudio/vue-cli-plugin-uni/packages/webpack-preprocess-loader??ref--17-0!./node_modules/@dcloudio/webpack-uni-mp-loader/lib/template.js!./node_modules/@dcloudio/vue-cli-plugin-uni/packages/webpack-uni-app-loader/page-meta.js!./node_modules/@dcloudio/vue-cli-plugin-uni/packages/vue-loader/lib??vue-loader-options!./node_modules/@dcloudio/webpack-uni-mp-loader/lib/style.js!E:/qiaocongli////adultDeviceApp/BLEPages/child/H08.vue?vue&type=template&id=ae7cbfb6&scoped=true& ***!
\********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************/
/*! exports provided: render, staticRenderFns, recyclableRender, components */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "recyclableRender", function() { return recyclableRender; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "components", function() { return components; });
var components
var render = function () {
var _vm = this
var _h = _vm.$createElement
var _c = _vm._self._c || _h
}
var recyclableRender = false
var staticRenderFns = []
render._withStripped = true
/***/ }),
/***/ 554:
/*!**************************************************************************************************!*\
!*** E:/qiaocongli////adultDeviceApp/BLEPages/child/H08.vue?vue&type=script&lang=js& ***!
\**************************************************************************************************/
/*! no static exports found */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_babel_loader_lib_index_js_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_vue_cli_plugin_uni_packages_webpack_preprocess_loader_index_js_ref_13_1_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_webpack_uni_mp_loader_lib_script_js_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_vue_cli_plugin_uni_packages_vue_loader_lib_index_js_vue_loader_options_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_webpack_uni_mp_loader_lib_style_js_H08_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!./node_modules/babel-loader/lib!./node_modules/@dcloudio/vue-cli-plugin-uni/packages/webpack-preprocess-loader??ref--13-1!./node_modules/@dcloudio/webpack-uni-mp-loader/lib/script.js!./node_modules/@dcloudio/vue-cli-plugin-uni/packages/vue-loader/lib??vue-loader-options!./node_modules/@dcloudio/webpack-uni-mp-loader/lib/style.js!./H08.vue?vue&type=script&lang=js& */ 555);
/* harmony import */ var _D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_babel_loader_lib_index_js_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_vue_cli_plugin_uni_packages_webpack_preprocess_loader_index_js_ref_13_1_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_webpack_uni_mp_loader_lib_script_js_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_vue_cli_plugin_uni_packages_vue_loader_lib_index_js_vue_loader_options_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_webpack_uni_mp_loader_lib_style_js_H08_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_babel_loader_lib_index_js_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_vue_cli_plugin_uni_packages_webpack_preprocess_loader_index_js_ref_13_1_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_webpack_uni_mp_loader_lib_script_js_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_vue_cli_plugin_uni_packages_vue_loader_lib_index_js_vue_loader_options_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_webpack_uni_mp_loader_lib_style_js_H08_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__);
/* harmony reexport (unknown) */ for(var __WEBPACK_IMPORT_KEY__ in _D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_babel_loader_lib_index_js_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_vue_cli_plugin_uni_packages_webpack_preprocess_loader_index_js_ref_13_1_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_webpack_uni_mp_loader_lib_script_js_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_vue_cli_plugin_uni_packages_vue_loader_lib_index_js_vue_loader_options_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_webpack_uni_mp_loader_lib_style_js_H08_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__) if(["default"].indexOf(__WEBPACK_IMPORT_KEY__) < 0) (function(key) { __webpack_require__.d(__webpack_exports__, key, function() { return _D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_babel_loader_lib_index_js_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_vue_cli_plugin_uni_packages_webpack_preprocess_loader_index_js_ref_13_1_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_webpack_uni_mp_loader_lib_script_js_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_vue_cli_plugin_uni_packages_vue_loader_lib_index_js_vue_loader_options_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_webpack_uni_mp_loader_lib_style_js_H08_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__[key]; }) }(__WEBPACK_IMPORT_KEY__));
/* harmony default export */ __webpack_exports__["default"] = (_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_babel_loader_lib_index_js_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_vue_cli_plugin_uni_packages_webpack_preprocess_loader_index_js_ref_13_1_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_webpack_uni_mp_loader_lib_script_js_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_vue_cli_plugin_uni_packages_vue_loader_lib_index_js_vue_loader_options_D_HBuilderX_3_6_4_20220922_HBuilderX_plugins_uniapp_cli_node_modules_dcloudio_webpack_uni_mp_loader_lib_style_js_H08_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0___default.a);
/***/ }),
/***/ 555:
/*!*********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************!*\
!*** ./node_modules/babel-loader/lib!./node_modules/@dcloudio/vue-cli-plugin-uni/packages/webpack-preprocess-loader??ref--13-1!./node_modules/@dcloudio/webpack-uni-mp-loader/lib/script.js!./node_modules/@dcloudio/vue-cli-plugin-uni/packages/vue-loader/lib??vue-loader-options!./node_modules/@dcloudio/webpack-uni-mp-loader/lib/style.js!E:/qiaocongli////adultDeviceApp/BLEPages/child/H08.vue?vue&type=script&lang=js& ***!
\*********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(uni) {
var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ 4);
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ 11));
var _vuex = __webpack_require__(/*! vuex */ 30);
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var myTime;
var _default = {
data: function data() {
return {
text: "",
textH: "",
height: "",
weight: "",
imp: 0,
type: 1,
uuid1: "",
uuid2: "",
uuid3: "",
macAddr: "",
deviceId: "",
serviceId: "",
Unload: false,
isConnection: 0 //是否连接成功
};
},
computed: _objectSpread(_objectSpread({}, (0, _vuex.mapState)(["user", "isConnected", "isBluetoothTyle", "appTheme"])), {}, {
info: function info() {
return this.user;
}
}),
onUnload: function onUnload() {
var that = this;
if (!that.Unload) {
that.stopBluetoothDevicesDiscovery(); //取消蓝牙搜索
clearTimeout(myTime);
that.closeBLEConnection();
that.closeBluetoothAdapter();
uni.switchTab({
url: "/pages/index/index"
});
console.log("返回首页");
}
},
onLoad: function onLoad(options) {
var that = this;
// 导航栏颜色
uni.setNavigationBarColor({
frontColor: '#ffffff',
backgroundColor: this.appTheme
});
//
that.text = "";
that.textH = "";
that.imp = 0;
if (options && options.deviceId) {
that.deviceId = options.deviceId;
that.closeBLEConnection();
that.closeBluetoothAdapter();
that.openBluetoothAdapter();
}
that.onBLEConnectionStateChange();
uni.onBluetoothAdapterStateChange(function (res) {
that.$store.commit("changeBluetooth", res.available);
});
},
watch: {
isConnected: function isConnected() {
var that = this;
if (!that.isConnected) {
that.handleBack();
that.isConnection = 2;
}
},
isBluetoothTyle: function isBluetoothTyle() {
var that = this;
if (!that.isBluetoothTyle) {
that.handleBack();
that.isConnection = 2;
}
}
},
methods: {
// 初始化蓝牙
openBluetoothAdapter: function openBluetoothAdapter() {
var that = this;
that.type = 1;
that.text = "";
that.textH = "";
uni.openBluetoothAdapter({
success: function success(e) {
that.isConnection = 0;
that.startBluetoothDeviceDiscovery();
},
fail: function fail(e) {
that.isConnection = 2;
that.$tools.msg("请确定设备是开机状态、手机蓝牙权限已打开!");
}
});
},
// 开始搜寻附近的蓝牙外围设备
startBluetoothDeviceDiscovery: function startBluetoothDeviceDiscovery() {
var that = this;
uni.startBluetoothDevicesDiscovery({
allowDuplicatesKey: false,
interval: 500,
//上报设备的间隔
services: ["FFE0"],
success: function success(res) {
that.isConnection = 0;
that.onBluetoothDeviceFound();
},
fail: function fail(res) {
that.isConnection = 2;
that.$tools.msg("请确定设备是开机状态、手机蓝牙权限已打开!");
}
});
},
/**
* 发现外围设备
*/
onBluetoothDeviceFound: function onBluetoothDeviceFound() {
var that = this;
that.isConnection = 0;
uni.onBluetoothDeviceFound(function (res) {
res.devices.forEach(function (device) {
if (!device.name && !device.localName) {
return;
}
if (device.name.indexOf('AiLink_') != -1 || device.localName && device.localName.indexOf('AiLink_') != -1) {
clearTimeout(myTime);
var buff = device.advertisData.slice(-6);
device.mac = new Uint8Array(buff); // 保存广播数据中的mac地址这是由于iOS不直接返回mac地址
var tempMac = Array.from(device.mac);
tempMac.reverse();
device.macAddr = that.$tools.ab2hex(tempMac, ':').toUpperCase();
if (device.deviceId.indexOf(that.deviceId) != -1 || device.macAddr.indexOf(that.deviceId) != -1) {
that.stopBluetoothDevicesDiscovery();
that.macAddr = device.macAddr;
that.deviceId = device.deviceId;
that.createBLEConnection();
return;
}
}
});
});
that.handleMyTime();
},
handleMyTime: function handleMyTime() {
var that = this;
myTime = setTimeout(function () {
if (!that.macAddr) {
clearTimeout(myTime);
that.Unload = true;
that.isConnection = 2;
that.closeBLEConnection();
that.closeBluetoothAdapter();
}
}, 20000);
},
/**
* 停止搜索蓝牙设备
*/
stopBluetoothDevicesDiscovery: function stopBluetoothDevicesDiscovery() {
uni.stopBluetoothDevicesDiscovery({
success: function success(e) {
console.log("停止搜索蓝牙设备", e);
}
});
},
// 监听蓝牙连接状态
onBLEConnectionStateChange: function onBLEConnectionStateChange() {
var that = this;
uni.onBLEConnectionStateChange(function (res) {
console.log("监听蓝牙连接状态", res.connected);
if (!res.connected) {
that.Unload = true;
that.isConnection = 2;
clearTimeout(myTime);
that.closeBLEConnection();
that.closeBluetoothAdapter();
}
that.$store.commit("changeConnected", res.connected);
});
},
// 连接蓝牙
createBLEConnection: function createBLEConnection() {
var that = this;
uni.createBLEConnection({
deviceId: that.deviceId,
success: function success(res) {
that.isConnection = 0;
that.getBLEDeviceServices();
},
fail: function fail(res) {
that.isConnection = 2;
console.log("设备连接失败,请重新连接", res);
}
});
},
/**
* 获取设备的UUID
*/
getBLEDeviceServices: function getBLEDeviceServices() {
var serviceList = [];
var that = this;
uni.getBLEDeviceServices({
deviceId: that.deviceId,
success: function success(res) {
console.log("获取设备的UUID成功", res);
serviceList = res.services;
for (var i = 0; i < serviceList.length; i++) {
var service = serviceList[i];
if (service.uuid.indexOf("FFE0") != -1) {
that.isConnection = 1;
that.serviceId = service.uuid;
that.getBLEDeviceCharacteristics();
console.log("设备的FFE0的serviceId " + that.serviceId);
break;
}
}
},
fail: function fail(res) {
console.log('获取设备的UUID失败:', res);
}
});
},
/**
* 获取指定服务的特征值
*/
getBLEDeviceCharacteristics: function getBLEDeviceCharacteristics() {
var characteristicsList = [];
var that = this;
uni.getBLEDeviceCharacteristics({
deviceId: that.deviceId,
serviceId: that.serviceId,
success: function success(res) {
console.log("服务的特征值成功", res);
for (var i = 0; i < res.characteristics.length; i++) {
var item = res.characteristics[i];
if (item.uuid.indexOf('0000FFE1') != -1) {
that.uuid1 = item.uuid; //下发数据
} else if (item.uuid.indexOf('0000FFE2') != -1) {
that.uuid2 = item.uuid; //监听数据
} else if (item.uuid.indexOf('0000FFE3') != -1) {
that.uuid3 = item.uuid; //写入设置
}
}
uni.notifyBLECharacteristicValueChange({
deviceId: that.deviceId,
serviceId: that.serviceId,
characteristicId: that.uuid2,
state: true
});
uni.notifyBLECharacteristicValueChange({
deviceId: that.deviceId,
serviceId: that.serviceId,
characteristicId: that.uuid3,
state: true
});
that.sendData();
uni.onBLECharacteristicValueChange(function (res) {
var value = that.$tools.ab2hex(res.value, "");
var num = value.substring(18, 19);
var dw = value.substring(19, 20);
var type = value.substring(8, 10);
var typeInfo = value.substring(10, 12);
console.log("单位", value, dw);
if (type == "10") {
var data = parseInt(value.substring(13, 18), 16);
var dw1 = "kg";
var dw2 = "kg";
if (dw == "1") {
dw1 = "斤";
dw2 = "jin";
}
if (dw == "4") {
dw1 = "st:lb";
dw2 = "st";
data = 1 * data + 5;
}
if (dw == "6") {
dw1 = "lb";
dw2 = "lb";
}
if (num == "1") {
data = parseInt(value.substring(13, 18), 16) / 10;
}
if (num == "2") {
data = parseInt(value.substring(13, 18), 16) / 100;
}
if (num == "3") {
data = parseInt(value.substring(13, 18), 16) / 1000;
}
if (typeInfo == "01") {
that.text = "您的实时体重是:" + data + dw1;
}
if (typeInfo == "02") {
that.text = "您的体重是:" + data + dw1;
that.weight = data + dw2;
console.log("稳定体重:", value, that.weight);
}
}
if (type == "14") {
that.height = parseInt(value.substring(10, 14), 16) / 10;
that.textH = "您的身高是:" + that.height + "cm";
that.type = 2;
console.log("稳定身高:", that.height);
}
if (type == "11") {
if (typeInfo == "03" || typeInfo == "04") {
that.imp = parseInt(value.substring(17, 22), 16);
}
console.log("阻抗:", typeInfo, parseInt(value.substring(17, 22), 16));
}
if (type == "30") {
console.log("测量完成", that.weight, that.imp, that.height);
if (that.imp == 0) {
uni.showModal({
title: '提示',
content: "体脂测量失败,是否保存本次测量结果?",
cancelText: "放弃",
confirmText: "保存",
success: function success(res) {
if (res.confirm) {
that.imp = 0;
that.handleGetMeasure();
} else {
console.log("放弃保存");
that.Unload = true;
that.closeBLEConnection();
that.closeBluetoothAdapter();
uni.switchTab({
url: "/pages/index/index"
});
}
}
});
} else {
that.handleGetMeasure();
}
}
});
},
fail: function fail(res) {
console.log('获取特征值失败:', JSON.stringify(res));
}
});
},
// 身高体重体脂模式
sendData: function sendData() {
var that = this;
var j = Number(26 + 3 + 6 + 1).toString(16);
var str = "A9002603060100" + j.substr(j.length - 2, 2) + "9A";
var buf = new Uint8Array(str.match(/[\da-f]{2}/gi).map(function (h) {
return parseInt(h, 16);
}));
uni.writeBLECharacteristicValue({
deviceId: that.deviceId,
serviceId: that.serviceId,
characteristicId: that.uuid1,
value: buf.buffer,
success: function success(res) {
console.log('下发指令成功', res.errMsg);
},
fail: function fail(res) {
console.log("下发指令失败", res);
}
});
},
// 保存测量结果
handleGetMeasure: function handleGetMeasure() {
var that = this;
that.$model.getmeasure({
weight: that.weight,
imp: that.imp,
ecode: that.macAddr,
height: that.height,
familyid: that.info.familyid
}).then(function (res) {
if (res.code == 0) {
that.$store.dispatch("getUserInfo", {
familyid: that.info.familyid
});
that.$store.dispatch("getResult", {
birthday: that.info.birthday,
familyid: that.info.familyid,
height: that.height,
sex: that.info.sex
});
that.$tools.msg("测量成功");
} else {
console.log("测量失败", res.message);
that.$tools.msg(res.message);
}
that.Unload = true;
setTimeout(function () {
that.closeBLEConnection();
that.closeBluetoothAdapter();
uni.switchTab({
url: "/pages/index/index"
});
}, 200);
});
},
handleBack: function handleBack(ind) {
var that = this;
that.text = "";
that.textH = "";
that.Unload = true;
that.stopBluetoothDevicesDiscovery(); //取消蓝牙搜索
that.closeBLEConnection();
that.closeBluetoothAdapter();
},
/**
* 断开蓝牙模块
*/
closeBluetoothAdapter: function closeBluetoothAdapter() {
var that = this;
uni.closeBluetoothAdapter({
success: function success(res) {
console.log('蓝牙模块关闭成功');
}
});
},
/**
* 断开蓝牙连接
*/
closeBLEConnection: function closeBLEConnection() {
var that = this;
uni.closeBLEConnection({
deviceId: that.deviceId,
success: function success(res) {
console.log('断开蓝牙连接成功');
}
});
}
}
};
exports.default = _default;
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./node_modules/@dcloudio/uni-mp-weixin/dist/index.js */ 2)["default"]))
/***/ })
},[[537,"common/runtime","common/vendor"]]]);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/BLEPages/child/H08.js.map

View File

@ -0,0 +1,6 @@
{
"navigationBarTitleText": "",
"enablePullDownRefresh": false,
"navigationBarBackgroundColor": "#F9FAFC",
"usingComponents": {}
}

View File

@ -0,0 +1 @@
<view class="data-v-ae7cbfb6"><view class="content weightPages data-v-ae7cbfb6"><block wx:if="{{isConnection==0}}"><view class="title data-v-ae7cbfb6">连接中,请稍后</view></block><block wx:if="{{isConnection==1}}"><view class="title data-v-ae7cbfb6">连接成功,请开始测量</view></block><block wx:if="{{isConnection==2}}"><view data-event-opts="{{[['tap',[['openBluetoothAdapter',['$event']]]]]}}" class="title data-v-ae7cbfb6" bindtap="__e">连接失败,点击重新连接</view></block><view class="text data-v-ae7cbfb6">{{text}}</view><view class="text data-v-ae7cbfb6">{{textH}}</view><view class="image data-v-ae7cbfb6"><block wx:if="{{type==1}}"><image src="/BLEPages/static/H08B.gif" class="data-v-ae7cbfb6"></image></block><block wx:if="{{type==2}}"><image src="/BLEPages/static/H08B2.gif" class="data-v-ae7cbfb6"></image></block></view><view class="tips data-v-ae7cbfb6"><text class="data-v-ae7cbfb6">提示:</text><text class="data-v-ae7cbfb6">1.请确定设备是开机状态</text><text class="data-v-ae7cbfb6">2.请确定手机蓝牙、位置信息已打开</text><text class="data-v-ae7cbfb6">3.ios系统需打开设置—>应用—>微信里的蓝牙权限</text></view></view></view>

View File

@ -0,0 +1 @@
/* BLEPages/child/H08.wxss */

View File

@ -407,6 +407,7 @@ var _default = {
var dw = value.substring(19, 20); var dw = value.substring(19, 20);
var type = value.substring(8, 10); var type = value.substring(8, 10);
var typeInfo = value.substring(10, 12); var typeInfo = value.substring(10, 12);
console.log("单位", value, dw);
if (type == "10") { if (type == "10") {
var data = parseInt(value.substring(13, 18), 16); var data = parseInt(value.substring(13, 18), 16);
var dw1 = "kg"; var dw1 = "kg";

View File

@ -159,7 +159,6 @@ var _default = {
notifyId: "", notifyId: "",
isSend: true, isSend: true,
Unload: false, Unload: false,
devicesList: [],
isConnection: 0, isConnection: 0,
data01: {}, data01: {},
data02: {}, data02: {},
@ -209,7 +208,9 @@ var _default = {
}); });
// //
that.textW = ""; that.textW = "";
console.log("options", options); that.data01 = {};
that.data02 = {};
that.BLEResult = {};
if (options && options.deviceId) { if (options && options.deviceId) {
that.macAddr = options.deviceId; that.macAddr = options.deviceId;
that.deviceId = options.deviceId; that.deviceId = options.deviceId;
@ -228,6 +229,9 @@ var _default = {
var that = this; var that = this;
that.textW = ""; that.textW = "";
that.isSend = true; that.isSend = true;
that.data01 = {};
that.data02 = {};
that.BLEResult = {};
uni.openBluetoothAdapter({ uni.openBluetoothAdapter({
success: function success(e) { success: function success(e) {
that.isConnection = 0; that.isConnection = 0;
@ -501,7 +505,7 @@ var _default = {
}, },
// 保存测量结果 // 保存测量结果
handleGetMeasure: function handleGetMeasure(data) { handleGetMeasure: function handleGetMeasure(data) {
console.log("保存结果"); console.log("保存结果", data);
var that = this; var that = this;
that.$model.getmeasuredata(data).then(function (res) { that.$model.getmeasuredata(data).then(function (res) {
if (res.code == 0) { if (res.code == 0) {

View File

@ -1,5 +1,6 @@
{ {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"enablePullDownRefresh": false, "enablePullDownRefresh": false,
"navigationBarBackgroundColor": "#F9FAFC",
"usingComponents": {} "usingComponents": {}
} }

View File

@ -0,0 +1 @@
Component({})

View File

@ -0,0 +1,6 @@
{
"navigationBarTitleText": "",
"enablePullDownRefresh": false,
"navigationBarBackgroundColor": "#F9FAFC",
"usingComponents": {}
}

View File

@ -0,0 +1 @@
<view class="data-v-698f2b62"><view class="content weightPages data-v-698f2b62"><block wx:if="{{isConnection==0}}"><view class="title data-v-698f2b62">连接中,请稍后</view></block><block wx:if="{{isConnection==1}}"><view class="title data-v-698f2b62">连接成功,请开始测量</view></block><block wx:if="{{isConnection==2}}"><view data-event-opts="{{[['tap',[['openBluetoothAdapter',['$event']]]]]}}" class="title data-v-698f2b62" bindtap="__e">连接失败,点击重新连接</view></block><view class="text data-v-698f2b62">{{text}}</view><view class="text data-v-698f2b62">{{textH}}</view><view class="image data-v-698f2b62"><block wx:if="{{type==1}}"><image src="/BLEPages/static/H09B.gif" class="data-v-698f2b62"></image></block><block wx:if="{{type==2}}"><image src="/BLEPages/static/H09B2.gif" class="data-v-698f2b62"></image></block></view><view class="tips data-v-698f2b62"><text class="data-v-698f2b62">提示:</text><text class="data-v-698f2b62">1.请确定设备是开机状态</text><text class="data-v-698f2b62">2.请确定手机蓝牙、位置信息已打开</text><text class="data-v-698f2b62">3.ios系统需打开设置—>应用—>微信里的蓝牙权限</text></view></view></view>

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -45,7 +45,8 @@
"child/L01A", "child/L01A",
"child/B03B", "child/B03B",
"child/EFS003", "child/EFS003",
"child/HCSG818" "child/HCSG818",
"child/H08"
] ]
} }
], ],

View File

@ -1758,7 +1758,7 @@ function initData(vueOptions, context) {
try { try {
data = data.call(context); // 支持 Vue.prototype 上挂的数据 data = data.call(context); // 支持 Vue.prototype 上挂的数据
} catch (e) { } catch (e) {
if (Object({"NODE_ENV":"development","VUE_APP_DARK_MODE":"false","VUE_APP_NAME":"成人","VUE_APP_PLATFORM":"mp-weixin","BASE_URL":"/"}).VUE_APP_DEBUG) { if (Object({"VUE_APP_DARK_MODE":"false","VUE_APP_NAME":"成人","VUE_APP_PLATFORM":"mp-weixin","NODE_ENV":"development","BASE_URL":"/"}).VUE_APP_DEBUG) {
console.warn('根据 Vue 的 data 函数初始化小程序 data 失败,请尽量确保 data 函数中不访问 vm 对象,否则可能影响首次数据渲染速度。', data); console.warn('根据 Vue 的 data 函数初始化小程序 data 失败,请尽量确保 data 函数中不访问 vm 对象,否则可能影响首次数据渲染速度。', data);
} }
} }
@ -8801,7 +8801,7 @@ function type(obj) {
function flushCallbacks$1(vm) { function flushCallbacks$1(vm) {
if (vm.__next_tick_callbacks && vm.__next_tick_callbacks.length) { if (vm.__next_tick_callbacks && vm.__next_tick_callbacks.length) {
if (Object({"NODE_ENV":"development","VUE_APP_DARK_MODE":"false","VUE_APP_NAME":"成人","VUE_APP_PLATFORM":"mp-weixin","BASE_URL":"/"}).VUE_APP_DEBUG) { if (Object({"VUE_APP_DARK_MODE":"false","VUE_APP_NAME":"成人","VUE_APP_PLATFORM":"mp-weixin","NODE_ENV":"development","BASE_URL":"/"}).VUE_APP_DEBUG) {
var mpInstance = vm.$scope; var mpInstance = vm.$scope;
console.log('[' + (+new Date) + '][' + (mpInstance.is || mpInstance.route) + '][' + vm._uid + console.log('[' + (+new Date) + '][' + (mpInstance.is || mpInstance.route) + '][' + vm._uid +
']:flushCallbacks[' + vm.__next_tick_callbacks.length + ']'); ']:flushCallbacks[' + vm.__next_tick_callbacks.length + ']');
@ -8822,14 +8822,14 @@ function nextTick$1(vm, cb) {
//1.nextTick 之前 已 setData 且 setData 还未回调完成 //1.nextTick 之前 已 setData 且 setData 还未回调完成
//2.nextTick 之前存在 render watcher //2.nextTick 之前存在 render watcher
if (!vm.__next_tick_pending && !hasRenderWatcher(vm)) { if (!vm.__next_tick_pending && !hasRenderWatcher(vm)) {
if(Object({"NODE_ENV":"development","VUE_APP_DARK_MODE":"false","VUE_APP_NAME":"成人","VUE_APP_PLATFORM":"mp-weixin","BASE_URL":"/"}).VUE_APP_DEBUG){ if(Object({"VUE_APP_DARK_MODE":"false","VUE_APP_NAME":"成人","VUE_APP_PLATFORM":"mp-weixin","NODE_ENV":"development","BASE_URL":"/"}).VUE_APP_DEBUG){
var mpInstance = vm.$scope; var mpInstance = vm.$scope;
console.log('[' + (+new Date) + '][' + (mpInstance.is || mpInstance.route) + '][' + vm._uid + console.log('[' + (+new Date) + '][' + (mpInstance.is || mpInstance.route) + '][' + vm._uid +
']:nextVueTick'); ']:nextVueTick');
} }
return nextTick(cb, vm) return nextTick(cb, vm)
}else{ }else{
if(Object({"NODE_ENV":"development","VUE_APP_DARK_MODE":"false","VUE_APP_NAME":"成人","VUE_APP_PLATFORM":"mp-weixin","BASE_URL":"/"}).VUE_APP_DEBUG){ if(Object({"VUE_APP_DARK_MODE":"false","VUE_APP_NAME":"成人","VUE_APP_PLATFORM":"mp-weixin","NODE_ENV":"development","BASE_URL":"/"}).VUE_APP_DEBUG){
var mpInstance$1 = vm.$scope; var mpInstance$1 = vm.$scope;
console.log('[' + (+new Date) + '][' + (mpInstance$1.is || mpInstance$1.route) + '][' + vm._uid + console.log('[' + (+new Date) + '][' + (mpInstance$1.is || mpInstance$1.route) + '][' + vm._uid +
']:nextMPTick'); ']:nextMPTick');
@ -8925,7 +8925,7 @@ var patch = function(oldVnode, vnode) {
}); });
var diffData = this.$shouldDiffData === false ? data : diff(data, mpData); var diffData = this.$shouldDiffData === false ? data : diff(data, mpData);
if (Object.keys(diffData).length) { if (Object.keys(diffData).length) {
if (Object({"NODE_ENV":"development","VUE_APP_DARK_MODE":"false","VUE_APP_NAME":"成人","VUE_APP_PLATFORM":"mp-weixin","BASE_URL":"/"}).VUE_APP_DEBUG) { if (Object({"VUE_APP_DARK_MODE":"false","VUE_APP_NAME":"成人","VUE_APP_PLATFORM":"mp-weixin","NODE_ENV":"development","BASE_URL":"/"}).VUE_APP_DEBUG) {
console.log('[' + (+new Date) + '][' + (mpInstance.is || mpInstance.route) + '][' + this._uid + console.log('[' + (+new Date) + '][' + (mpInstance.is || mpInstance.route) + '][' + this._uid +
']差量更新', ']差量更新',
JSON.stringify(diffData)); JSON.stringify(diffData));
@ -19323,7 +19323,15 @@ var _default = {
"path": "child/HCSG818", "path": "child/HCSG818",
"style": { "style": {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"enablePullDownRefresh": false "enablePullDownRefresh": false,
"navigationBarBackgroundColor": "#F9FAFC"
}
}, {
"path": "child/H08",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false,
"navigationBarBackgroundColor": "#F9FAFC"
} }
}] }]
}], }],

View File

@ -252,7 +252,7 @@ var _default = {
onLoad: function onLoad(options) { onLoad: function onLoad(options) {
var _this = this; var _this = this;
return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() { return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
var that; var that, value, dw, type, typeInfo, weight;
return _regenerator.default.wrap(function _callee$(_context) { return _regenerator.default.wrap(function _callee$(_context) {
while (1) { while (1) {
switch (_context.prev = _context.next) { switch (_context.prev = _context.next) {
@ -269,6 +269,14 @@ var _default = {
_context.next = 6; _context.next = 6;
return that.login(); return that.login();
case 6: case 6:
// let value = "a900260e1501003200000000021d03fa1600ae9a"
value = "a900260710020064451100f99a";
dw = value.substring(19, 20);
type = value.substring(8, 10);
typeInfo = value.substring(10, 12);
weight = parseInt(value.substring(12, 18), 16);
console.log("value", type, typeInfo, weight, dw, value.substring(12, 18));
case 12:
case "end": case "end":
return _context.stop(); return _context.stop();
} }

View File

@ -4,7 +4,7 @@
}, },
"projectname": "%E6%AF%8F%E6%97%A5%E4%B8%80%E7%A7%B0", "projectname": "%E6%AF%8F%E6%97%A5%E4%B8%80%E7%A7%B0",
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"libVersion": "2.23.3", "libVersion": "3.5.2",
"condition": { "condition": {
"miniprogram": { "miniprogram": {
"list": [ "list": [