Compare commits

...
3 Commits
3 changed files with 29 additions and 4 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ interface MemberForm {
/** 员工编号查询接口(页面私有) */
const getEmployeeByWorkNo = (sn: string, workNo: string) =>
get<any>('weighingScale/v6/getUserInfoByWkno', { sn, workNo })
get<any>('weighingScale/v5/getUserInfoByWkno', { sn, workNo })
/** 添加/编辑用户接口(页面私有) */
const addUser = (data: Record<string, any>) =>
@@ -159,11 +159,28 @@ const splitWeight = (weight: number): { int: string; decimal: string } => {
return { int, decimal: `.${dec}` }
}
/** 根据 BMI 计算刻度圆圈位置(百分比) */
/**
* 刻度轨道结构(rpx):屏宽 750 - basicIndicators 左右 padding 30*2 - 左右 border 4*2 = 682。
* BLOCK_GAP 与 less 中 basicIndicatorsTrack 的 gap: 6rpx 保持同步。
*/
const TRACK_WIDTH = 682
const BLOCK_GAP = 6
const BLOCK_WIDTH = (TRACK_WIDTH - BLOCK_GAP * 3) / 4
/** 根据 BMI 计算刻度圆圈圆心位置(百分比),对齐消瘦/正常/超重/肥胖四段分界 18.5/24/28,并计入色块间隙 */
const calcBmiLeft = (bmi?: number): number => {
if (bmi == null || isNaN(bmi)) return 0
const pct = (bmi - 14) / (40 - 14)
return Math.min(Math.max(pct, 0), 1) * 100
let left: number
if (bmi < 18.5) {
left = (bmi / 18.5) * BLOCK_WIDTH
} else if (bmi < 24) {
left = BLOCK_WIDTH + BLOCK_GAP + ((bmi - 18.5) / (24 - 18.5)) * BLOCK_WIDTH
} else if (bmi < 28) {
left = BLOCK_WIDTH * 2 + BLOCK_GAP * 2 + ((bmi - 24) / (28 - 24)) * BLOCK_WIDTH
} else {
left = BLOCK_WIDTH * 3 + BLOCK_GAP * 3 + ((bmi - 28) / (40 - 28)) * BLOCK_WIDTH
}
return Math.min(Math.max(left / TRACK_WIDTH, 0), 1) * 100
}
Page({
+8
View File
@@ -155,6 +155,10 @@ Page({
if (!res.confirm) return
unbindDevice(item.id)
.then(() => {
// 取消配对的是当前连接的设备:断开连接并清缓存
if (leFuService.isConnected && leFuService.lastRawDevice?.deviceId === item.deviceId) {
leFuService.disconnect()
}
const cached = wx.getStorageSync('connectDeviceInfo') as Record<string, any> | null
if (cached?.deviceId === item.deviceId) {
wx.removeStorageSync('connectDeviceInfo')
@@ -359,6 +363,10 @@ Page({
if (!res.confirm) return
unbindDevice()
.then(() => {
// 取消全部配对:断开当前连接并清缓存
if (leFuService.isConnected) {
leFuService.disconnect()
}
wx.removeStorageSync('connectDeviceInfo')
wx.showToast({ title: '已取消全部配对', icon: 'success' })
this.loadDevices()