diff --git a/app.json b/app.json
index 0e776d4..2b5a8ef 100644
--- a/app.json
+++ b/app.json
@@ -10,7 +10,9 @@
"pages/L08/index",
"pages/G01/index",
"pages/FB03/index",
- "pages/PCJ02/index"
+ "pages/PCJ02/index",
+ "pages/PCL10/index",
+ "pages/PCL11/index"
],
"window": {
"navigationBarBackgroundColor": "#0082FE",
diff --git a/app.wxss b/app.wxss
index 2354342..9c79b27 100644
--- a/app.wxss
+++ b/app.wxss
@@ -11,58 +11,69 @@ input,
textarea,
label,
navigator {
- box-sizing: border-box;
+ box-sizing: border-box;
}
page {
- --safe-bottom: env(safe-area-inset-bottom);
+ --safe-bottom: env(safe-area-inset-bottom);
}
.container {
- position: relative;
- display: flex;
- flex-direction: column;
- align-items: center;
- width: 100vw;
- height: 100vh;
- padding-bottom: var(--safe-bottom);
+ position: relative;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ width: 100vw;
+ height: 100vh;
+ padding-bottom: var(--safe-bottom);
}
.header {
- width: 100%;
+ width: 100%;
}
.header button {
- font-size: 16px;
- line-height: 40px;
- width: 100% !important;
- border-bottom: 1px solid #dfdfdf;
+ font-size: 16px;
+ line-height: 40px;
+ width: 100% !important;
+ border-bottom: 1px solid #dfdfdf;
}
.device_item {
- padding: 15px;
- border-bottom: 1px solid #dfdfdf;
+ padding: 15px;
+ border-bottom: 1px solid #dfdfdf;
}
.weight {
- width: 100%;
- margin: 15px;
- padding-bottom: 15px;
- text-align: center;
- font-size: 18px;
- font-weight: 700;
- border-bottom: 1px solid #dfdfdf;
+ width: 100%;
+ margin: 15px;
+ padding-bottom: 15px;
+ text-align: center;
+ font-size: 18px;
+ font-weight: 700;
+ border-bottom: 1px solid #dfdfdf;
}
-.list{
- width: 100%;
- height: auto;
- display: flex;
- justify-content: space-between;
- flex-wrap: wrap;
+
+.list {
+ width: 100%;
+ height: auto;
+ display: flex;
+ justify-content: space-between;
+ flex-wrap: wrap;
}
-.item{
- padding: 15px;
- background: #f7f7f7;
- border-radius: 10px;
- margin-top: 15px;
+
+.item,
+.item2 {
+ width: 100%;
+ padding: 15px 0;
+ background: #f7f7f7;
+ border-radius: 10px;
+ margin-top: 15px;
+ text-align: center;
+ margin: 15px 3% 0;
+}
+.item {
+ width: 44%;
+ margin-right: 3%;
+ float: left;
}
diff --git a/pages/G01/index.js b/pages/G01/index.js
index 4e06d3a..dd8abbd 100644
--- a/pages/G01/index.js
+++ b/pages/G01/index.js
@@ -83,7 +83,7 @@ Page({
let buffer = device.advertisData.slice(3, 9)
device.mac = new Uint8Array(buffer) // 保存广播数据中的mac地址,这是由于iOS不直接返回mac地址
let tempMac = Array.from(device.mac)
- tempMac.reverse()
+ // tempMac.reverse()
device.macAddr = ab2hex(tempMac, ':').toUpperCase()
if (idx === -1) {
dataT[`devices[${foundDevices.length}]`] = device
diff --git a/pages/PCL10/index.js b/pages/PCL10/index.js
new file mode 100644
index 0000000..339460d
--- /dev/null
+++ b/pages/PCL10/index.js
@@ -0,0 +1,164 @@
+const util = require("../../utils/util");
+const {
+ inArray,
+ ab2hex
+} = util
+Page({
+ data: {
+ connected: false,
+ name: '',
+ weight: "",
+ imp: "",
+ devices: [],
+ deviceId: null,
+ },
+ onLoad: function() {},
+ // 初始化蓝牙模块
+ openBluetoothAdapter() {
+ wx.openBluetoothAdapter({
+ success: (res) => {
+ console.log('openBluetoothAdapter success', res)
+ wx.showToast({
+ title: '蓝牙连接中',
+ icon: "none"
+ })
+ this.startBluetoothDevicesDiscovery()
+ },
+ fail: (res) => {
+ if (res.errCode === 10001) {
+ wx.showToast({
+ title: '请打开蓝牙',
+ icon: "none"
+ })
+ // 监听本机蓝牙状态变化的事件
+ wx.onBluetoothAdapterStateChange((res) => {
+ console.log('onBluetoothAdapterStateChange', res)
+ if (res.available) {
+ this.startBluetoothDevicesDiscovery()
+ }
+ })
+ }
+ }
+ })
+ },
+
+ // 开始搜寻附近的蓝牙外围设备
+ startBluetoothDevicesDiscovery() {
+ if (this._discoveryStarted) {
+ return
+ }
+ this._discoveryStarted = true
+ wx.startBluetoothDevicesDiscovery({
+ allowDuplicatesKey: true,
+ interval: 500, //上报设备的间隔
+ success: (res) => {
+ this.onBluetoothDeviceFound()
+ },
+ })
+ },
+ // 停止搜寻附近的蓝牙外围设备
+ stopBluetoothDevicesDiscovery() {
+ wx.stopBluetoothDevicesDiscovery()
+ },
+
+ // 找到新设备的事件
+ onBluetoothDeviceFound() {
+ let that = this
+ wx.onBluetoothDeviceFound((res) => {
+ res.devices.forEach(device => {
+ device.advertisData = device.advertisData ? device.advertisData : ''
+ if (!device.name && !device.localName) {
+ let value = ab2hex(device.advertisData, "")
+ let id = value.substring(12, 16)
+ if (value.indexOf('c0') !== -1 && id == '0002') {
+ device.name = "PCL-体脂称"
+ let buff = device.advertisData.slice(-6)
+ device.mac = new Uint8Array(buff) // 保存广播数据中的mac地址,这是由于iOS不直接返回mac地址
+ let tempMac = Array.from(device.mac)
+ device.macAddr = ab2hex(tempMac, ':').toUpperCase()
+ //
+ const foundDevices = this.data.devices
+ const idx = inArray(foundDevices, 'deviceId', device.deviceId)
+ const dataT = {}
+ if (idx === -1) {
+ dataT[`devices[${foundDevices.length}]`] = device
+ } else {
+ dataT[`devices[${idx}]`] = device
+ }
+ this.setData(dataT)
+ let msg = parseInt(value.substring(16, 18), 16).toString(2)
+ let weight = parseInt(value.substring(4, 8), 16)
+ let type = msg.substring(5, 6) //0实时,1稳定
+ let num = msg.substring(3, 5) //小数点
+ let unit = msg.substring(1, 3) //单位
+ let dw1 = "kg"
+ if (unit == "10") {
+ dw1 = "lb"
+ }
+ if (num == "00") {
+ weight = parseInt(value.substring(4, 8), 16) / 10
+ }
+ if (num == "10") {
+ if (unit == "10") {
+ dw1 = "lb"
+ weight = parseInt(value.substring(4, 8), 16) / 10
+ } else {
+ weight = parseInt(value.substring(4, 8), 16) / 100
+ }
+ }
+ that.setData({
+ weight: "您的实时体重是:" + weight + dw1
+ })
+ if (type == '1') {
+ that.setData({
+ weight: "您的稳定体重是:" + weight + dw1
+ })
+ that.setData({
+ imp:"阻抗是:" + parseInt(value.substring(8, 12), 16) / 10
+ })
+ }
+ }
+ return
+ }
+ })
+ })
+ },
+ //监听蓝牙连接状态
+ onBLEConnectionStateChange() {
+ wx.onBLEConnectionStateChange((res) => {
+ if (!res.connected) {
+ wx.stopBluetoothDevicesDiscovery();
+ setTimeout(() => {
+ wx.showToast({
+ title: '连接已断开',
+ icon: 'none'
+ })
+ }, 500)
+ this.setData({
+ connected: false,
+ devices: [],
+ weight: "",
+ imp: ""
+ })
+ }
+ })
+ },
+
+ /**
+ * 断开蓝牙模块
+ */
+ closeBluetoothAdapter() {
+ wx.stopBluetoothDevicesDiscovery();
+ wx.closeBluetoothAdapter()
+ this._discoveryStarted = false
+ wx.showToast({
+ title: '结束流程',
+ icon: 'none'
+ })
+ this.setData({
+ devices: [],
+ weight: "",
+ imp: ""
+ })
+ },
+});
diff --git a/pages/PCL10/index.json b/pages/PCL10/index.json
new file mode 100644
index 0000000..b55b5a2
--- /dev/null
+++ b/pages/PCL10/index.json
@@ -0,0 +1,4 @@
+{
+ "usingComponents": {
+ }
+}
\ No newline at end of file
diff --git a/pages/PCL10/index.wxml b/pages/PCL10/index.wxml
new file mode 100644
index 0000000..a028441
--- /dev/null
+++ b/pages/PCL10/index.wxml
@@ -0,0 +1,40 @@
+
+module.exports.max = function(n1, n2) {
+ return Math.max(n1, n2)
+}
+module.exports.len = function(arr) {
+ arr = arr || []
+ return arr.length
+}
+
+
+
+
+
+ {{weight}}
+ {{imp}}
+
+ 已发现 {{devices.length}} 个外围设备:
+
+
+
+ {{item.name}}
+ (信号强度: {{item.RSSI}}dBm)
+
+ mac地址: {{item.macAddr || item.deviceId}}
+
+
+
+
+
+
diff --git a/pages/PCL10/index.wxss b/pages/PCL10/index.wxss
new file mode 100644
index 0000000..23ef694
--- /dev/null
+++ b/pages/PCL10/index.wxss
@@ -0,0 +1 @@
+/* pages/PCD01PRO/index.wxss */
\ No newline at end of file
diff --git a/pages/PCL11/index.js b/pages/PCL11/index.js
new file mode 100644
index 0000000..339460d
--- /dev/null
+++ b/pages/PCL11/index.js
@@ -0,0 +1,164 @@
+const util = require("../../utils/util");
+const {
+ inArray,
+ ab2hex
+} = util
+Page({
+ data: {
+ connected: false,
+ name: '',
+ weight: "",
+ imp: "",
+ devices: [],
+ deviceId: null,
+ },
+ onLoad: function() {},
+ // 初始化蓝牙模块
+ openBluetoothAdapter() {
+ wx.openBluetoothAdapter({
+ success: (res) => {
+ console.log('openBluetoothAdapter success', res)
+ wx.showToast({
+ title: '蓝牙连接中',
+ icon: "none"
+ })
+ this.startBluetoothDevicesDiscovery()
+ },
+ fail: (res) => {
+ if (res.errCode === 10001) {
+ wx.showToast({
+ title: '请打开蓝牙',
+ icon: "none"
+ })
+ // 监听本机蓝牙状态变化的事件
+ wx.onBluetoothAdapterStateChange((res) => {
+ console.log('onBluetoothAdapterStateChange', res)
+ if (res.available) {
+ this.startBluetoothDevicesDiscovery()
+ }
+ })
+ }
+ }
+ })
+ },
+
+ // 开始搜寻附近的蓝牙外围设备
+ startBluetoothDevicesDiscovery() {
+ if (this._discoveryStarted) {
+ return
+ }
+ this._discoveryStarted = true
+ wx.startBluetoothDevicesDiscovery({
+ allowDuplicatesKey: true,
+ interval: 500, //上报设备的间隔
+ success: (res) => {
+ this.onBluetoothDeviceFound()
+ },
+ })
+ },
+ // 停止搜寻附近的蓝牙外围设备
+ stopBluetoothDevicesDiscovery() {
+ wx.stopBluetoothDevicesDiscovery()
+ },
+
+ // 找到新设备的事件
+ onBluetoothDeviceFound() {
+ let that = this
+ wx.onBluetoothDeviceFound((res) => {
+ res.devices.forEach(device => {
+ device.advertisData = device.advertisData ? device.advertisData : ''
+ if (!device.name && !device.localName) {
+ let value = ab2hex(device.advertisData, "")
+ let id = value.substring(12, 16)
+ if (value.indexOf('c0') !== -1 && id == '0002') {
+ device.name = "PCL-体脂称"
+ let buff = device.advertisData.slice(-6)
+ device.mac = new Uint8Array(buff) // 保存广播数据中的mac地址,这是由于iOS不直接返回mac地址
+ let tempMac = Array.from(device.mac)
+ device.macAddr = ab2hex(tempMac, ':').toUpperCase()
+ //
+ const foundDevices = this.data.devices
+ const idx = inArray(foundDevices, 'deviceId', device.deviceId)
+ const dataT = {}
+ if (idx === -1) {
+ dataT[`devices[${foundDevices.length}]`] = device
+ } else {
+ dataT[`devices[${idx}]`] = device
+ }
+ this.setData(dataT)
+ let msg = parseInt(value.substring(16, 18), 16).toString(2)
+ let weight = parseInt(value.substring(4, 8), 16)
+ let type = msg.substring(5, 6) //0实时,1稳定
+ let num = msg.substring(3, 5) //小数点
+ let unit = msg.substring(1, 3) //单位
+ let dw1 = "kg"
+ if (unit == "10") {
+ dw1 = "lb"
+ }
+ if (num == "00") {
+ weight = parseInt(value.substring(4, 8), 16) / 10
+ }
+ if (num == "10") {
+ if (unit == "10") {
+ dw1 = "lb"
+ weight = parseInt(value.substring(4, 8), 16) / 10
+ } else {
+ weight = parseInt(value.substring(4, 8), 16) / 100
+ }
+ }
+ that.setData({
+ weight: "您的实时体重是:" + weight + dw1
+ })
+ if (type == '1') {
+ that.setData({
+ weight: "您的稳定体重是:" + weight + dw1
+ })
+ that.setData({
+ imp:"阻抗是:" + parseInt(value.substring(8, 12), 16) / 10
+ })
+ }
+ }
+ return
+ }
+ })
+ })
+ },
+ //监听蓝牙连接状态
+ onBLEConnectionStateChange() {
+ wx.onBLEConnectionStateChange((res) => {
+ if (!res.connected) {
+ wx.stopBluetoothDevicesDiscovery();
+ setTimeout(() => {
+ wx.showToast({
+ title: '连接已断开',
+ icon: 'none'
+ })
+ }, 500)
+ this.setData({
+ connected: false,
+ devices: [],
+ weight: "",
+ imp: ""
+ })
+ }
+ })
+ },
+
+ /**
+ * 断开蓝牙模块
+ */
+ closeBluetoothAdapter() {
+ wx.stopBluetoothDevicesDiscovery();
+ wx.closeBluetoothAdapter()
+ this._discoveryStarted = false
+ wx.showToast({
+ title: '结束流程',
+ icon: 'none'
+ })
+ this.setData({
+ devices: [],
+ weight: "",
+ imp: ""
+ })
+ },
+});
diff --git a/pages/PCL11/index.json b/pages/PCL11/index.json
new file mode 100644
index 0000000..b55b5a2
--- /dev/null
+++ b/pages/PCL11/index.json
@@ -0,0 +1,4 @@
+{
+ "usingComponents": {
+ }
+}
\ No newline at end of file
diff --git a/pages/PCL11/index.wxml b/pages/PCL11/index.wxml
new file mode 100644
index 0000000..a028441
--- /dev/null
+++ b/pages/PCL11/index.wxml
@@ -0,0 +1,40 @@
+
+module.exports.max = function(n1, n2) {
+ return Math.max(n1, n2)
+}
+module.exports.len = function(arr) {
+ arr = arr || []
+ return arr.length
+}
+
+
+
+
+
+ {{weight}}
+ {{imp}}
+
+ 已发现 {{devices.length}} 个外围设备:
+
+
+
+ {{item.name}}
+ (信号强度: {{item.RSSI}}dBm)
+
+ mac地址: {{item.macAddr || item.deviceId}}
+
+
+
+
+
+
diff --git a/pages/PCL11/index.wxss b/pages/PCL11/index.wxss
new file mode 100644
index 0000000..23ef694
--- /dev/null
+++ b/pages/PCL11/index.wxss
@@ -0,0 +1 @@
+/* pages/PCD01PRO/index.wxss */
\ No newline at end of file
diff --git a/pages/index/index.js b/pages/index/index.js
index fb1695a..6581380 100644
--- a/pages/index/index.js
+++ b/pages/index/index.js
@@ -25,18 +25,25 @@ Page({
})
return
}
+ if (type == 'H01PRO') {
+ wx.navigateTo({
+ url: `/pages/H01PRO/index`
+ })
+ return
+ }
+
if (type == 'PCH0809') {
wx.navigateTo({
url: `/pages/PCH0809/index`
})
return
}
- if (type == 'PCF01B') {
- wx.navigateTo({
- url: `/pages/PCF01B/index`
- })
- return
- }
+ // if (type == 'PCF01B') {
+ // wx.navigateTo({
+ // url: `/pages/PCF01B/index`
+ // })
+ // return
+ // }
if (type == 'PCF01proFRK') {
wx.navigateTo({
url: `/pages/PCF01proFRK/index`
@@ -73,20 +80,27 @@ Page({
})
return
}
- if (type == 'L08') {
- wx.navigateTo({
- url: `/pages/L08/index`
- })
- return
- }
-
- if (type == 'H01PRO') {
- wx.navigateTo({
- url: `/pages/H01PRO/index`
- })
- return
- }
+ // if (type == 'L08') {
+ // wx.navigateTo({
+ // url: `/pages/L08/index`
+ // })
+ // return
+ // }
+
+ if (type == 'PCL10') {
+ wx.navigateTo({
+ url: `/pages/PCL10/index`
+ })
+ return
+ }
+ if (type == 'PCL11') {
+ wx.navigateTo({
+ url: `/pages/PCL11/index`
+ })
+ return
+ }
+
},
openBluetoothAdapter() {
wx.openBluetoothAdapter({
diff --git a/pages/index/index.wxml b/pages/index/index.wxml
index 7dd1b89..6a94409 100644
--- a/pages/index/index.wxml
+++ b/pages/index/index.wxml
@@ -10,18 +10,20 @@
+ PCH08/09/H09B/HB02/META10/PCF01B
+ PCJ02/PCJ01/L01/L03/L05/EKS9919
PCD01PRO
H01PRO
- PCH08/09
- PCF01B
+ PCF08/PCF08B
+ L08/L06
+ B03/B02/B07
+ PCL10/PCL11
PCF01pro(旧)
PCF01pro(新)
- PCF08
- L08
- B03
- PCJ02
G01
+
+
diff --git a/project.config.json b/project.config.json
index e252818..74f1bc8 100644
--- a/project.config.json
+++ b/project.config.json
@@ -23,15 +23,15 @@
"uploadWithSourceMap": true,
"compileHotReLoad": false,
"lazyloadPlaceholderEnable": false,
- "useMultiFrameRuntime": true,
- "useApiHook": true,
- "useApiHostProcess": true,
+ "useMultiFrameRuntime": false,
+ "useApiHook": false,
+ "useApiHostProcess": false,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
- "useIsolateContext": true,
+ "useIsolateContext": false,
"userConfirmedBundleSwitch": false,
"packNpmManually": false,
"packNpmRelationList": [],