11 Commits
Author SHA1 Message Date
17792275749andClaude Code 51906af6dd fix(userManagement): 添加本人补传 id 字段
Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-09-15 15:43:19 +08:00
17792275749andClaude Code deea304799 fix(userManagement): 添加本人参数 parentUserId 改为 userId
Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-09-15 15:26:07 +08:00
17792275749andClaude Code 7e2033e235 feat(connectedDevice): 设备卡片底部显示 deviceId
Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-09-15 15:17:23 +08:00
17792275749andClaude Code 9d56e63ce0 fix(userManagement): 补传添加成员 relationType 并修复删除后同步空列表报错
- 一键添加本人传 relationType=1,其他添加新增传 relationType=2
- _clearAndSync 待下发列表为空时跳过 syncMembersToDevice,避免空列表 reject

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-09-15 15:08:47 +08:00
17792275749andClaude Opus 4.7 9332990a77 feat(equipment): 设备页新增 OTA 升级与初始化功能
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-09-14 10:38:52 +08:00
17792275749andClaude Sonnet 4.6 109c9e1b70 style(equipment): 添加设备按钮改灰色胶囊,用户按钮蓝底高亮
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-09-11 15:38:14 +08:00
17792275749andClaude Sonnet 4.6 dc0a294406 feat(userManagement): 新增添加用户弹框组件
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-09-11 15:09:35 +08:00
17792275749andClaude Sonnet 4.6 9e8e26cb19 style(equipment): 设备操作按钮图标与文字尺寸微调
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-09-11 14:11:42 +08:00
17792275749andClaude Sonnet 4.6 6731ec2403 feat(supplementPersonal): 提交按钮文案改为"开始使用"
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-09-11 14:09:35 +08:00
17792275749andClaude Sonnet 4.6 fa0246d1e5 feat(equipment): 已配对设备行按钮重构,添加设备入口仅运维可见
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-09-11 14:09:35 +08:00
17792275749andClaude Sonnet 4.6 b3e2a11423 chore(config): trial 环境域名切换到正式网关
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-09-11 14:09:32 +08:00
20 changed files with 451 additions and 94 deletions
@@ -0,0 +1,4 @@
{
"component": true,
"usingComponents": {}
}
@@ -0,0 +1,58 @@
.userManagementAddUser-mask {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(37, 37, 53, 0.5);
z-index: 100;
}
.userManagementAddUser-panel {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 660rpx;
box-sizing: border-box;
padding: 48rpx 40rpx 56rpx;
background-color: #FFFFFF;
border-radius: 24rpx;
z-index: 101;
display: flex;
flex-direction: column;
align-items: center;
.userManagementAddUser-title {
color: #252535;
height: 36rpx;
font-size: 36rpx;
font-weight: bolder;
line-height: 36rpx;
margin-bottom: 48rpx;
}
.userManagementAddUser-btn {
width: 100%;
height: 96rpx;
font-size: 36rpx;
font-weight: bold;
text-align: center;
border-radius: 48rpx;
box-sizing: border-box;
&--primary {
color: #FFFFFF;
line-height: 96rpx;
background-color: #1385FA;
margin-bottom: 40rpx;
}
&--outline {
color: #1385FA;
line-height: 92rpx;
border: 2rpx solid #1385FA;
background-color: #FFFFFF;
}
}
}
@@ -0,0 +1,26 @@
Component({
properties: {
/** 是否显示弹框 */
show: {
type: Boolean,
value: false
}
},
methods: {
/** 点击遮罩关闭 */
onClose() {
this.triggerEvent('close')
},
/** 一键添加本人 */
onAddSelf() {
this.triggerEvent('addself')
},
/** 添加其他用户 */
onAddOther() {
this.triggerEvent('addother')
}
}
})
@@ -0,0 +1,8 @@
<block wx:if="{{ show }}">
<view class="userManagementAddUser-mask" bind:tap="onClose"></view>
<view class="userManagementAddUser-panel">
<view class="userManagementAddUser-title">添加用户</view>
<view class="userManagementAddUser-btn userManagementAddUser-btn--primary" bind:tap="onAddSelf">一键添加本人</view>
<view class="userManagementAddUser-btn userManagementAddUser-btn--outline" bind:tap="onAddOther">添加其他用户</view>
</view>
</block>
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 880 B

After

Width:  |  Height:  |  Size: 542 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

+2 -2
View File
@@ -8,8 +8,8 @@ const DOMAINS: Record<EnvType, { domain1: string; domain2: string }> = {
domain2: 'http://10.10.10.10:8889/weight',
},
trial: {
domain1: 'http://10.10.10.10:8889',
domain2: 'http://10.10.10.10:8889/weight',
domain1: 'http://device.shuziweidao.com:80/gateway',
domain2: 'http://device.shuziweidao.com:80/weight',
},
release: {
domain1: 'http://device.shuziweidao.com:80/gateway',
+28
View File
@@ -423,6 +423,34 @@ class LeFuService {
})
}
// ─── OTA 升级 ─────────────────────────────
/**
* 下发 OTA 固件升级指令
* 只负责调用协议层 codeOtaUpdate,是否需要升级、版本比较等业务判断由调用方处理。
*/
otaUpdate(): Promise<void> {
return new Promise((resolve, reject) => {
if (!this._activeProtocol) { reject(new Error('设备未连接')); return }
this._activeProtocol.codeOtaUpdate((status: number) => {
status === 0 ? resolve() : reject(new Error('升级指令下发失败'))
})
})
}
// ─── 设备初始化 ───────────────────────────
/**
* 初始化设备信息
* 下发 codeClearDeviceData('00') 指令清除设备信息,区别于 clearDeviceMembers 的 '01'(清空用户数据)。
*/
initDevice(): Promise<void> {
return new Promise((resolve, reject) => {
if (!this._activeProtocol) { reject(new Error('设备未连接')); return }
this._activeProtocol.codeClearDeviceData('00', (res: number) => {
res === 0 ? resolve() : reject(new Error('请求失败'))
})
})
}
// ─── 用户同步 ─────────────────────────────
/**
* 清空设备内的用户数据
+1
View File
@@ -420,6 +420,7 @@ Page({
const payload: Record<string, any> = {
...baseSpread,
...(editId ? {} : { relationType: 2 }),
dataType: userType === 'family' ? 1 : 0,
parentUserId: userInfo?.userId ?? '',
sn: targetSn,
@@ -76,7 +76,7 @@
<view class="card-btn-primary" data-index="{{ index }}" catch:tap="onConnect">连接</view>
</block>
</view>
<!-- <view class="device-card-bottom">deviceId{{ item.deviceId }}</view> -->
<view class="device-card-bottom">deviceId{{ item.deviceId }}</view>
</view>
</block>
</view>
+83 -20
View File
@@ -83,27 +83,47 @@
}
}
/* 描边按钮(蓝色/红色) */
.ops-btn {
width: 180rpx;
.section-right {
height: 48rpx;
display: flex;
flex-wrap: nowrap;
.section-right-red {
height: 48rpx;
padding: 0 15rpx;
border-radius: 8rpx;
font-size: 24rpx;
line-height: 44rpx;
text-align: center;
box-sizing: border-box;
flex-shrink: 0;
}
.ops-btn--blue {
border: 2rpx solid #1385FA;
color: #1385FA;
}
.ops-btn--red {
border: 2rpx solid #F24439;
color: #F24439;
}
.section-right-blue {
height: 48rpx;
display: flex;
flex-wrap: nowrap;
align-items: center;
padding: 0 15rpx;
border-radius: 24rpx;
background-color: #E5E9EF;
> view:nth-child(1) {
width: 32rpx;
height: 32rpx;
display: flex;
align-items: center;
margin-right: 6rpx;
}
> view:nth-child(2) {
color: #77849E;
height: 24rpx;
font-size: 24rpx;
line-height: 24rpx;
}
}
}
}
/* 设备卡片 */
@@ -235,7 +255,7 @@
.device-actions {
width: 100%;
gap: 12px;
gap: 10px;
display: flex;
flex-wrap: nowrap;
justify-content: space-around;
@@ -251,18 +271,61 @@
border: 2rpx solid #EAECF1;
> view:nth-of-type(1) {
width: 26rpx;
height: 26rpx;
width: 24rpx;
height: 24rpx;
display: flex;
align-items: center;
margin-right: 10rpx;
margin-right: 6rpx;
}
> view:nth-of-type(2) {
color: #77849E;
height: 26rpx;
font-size: 26rpx;
line-height: 26rpx;
height: 24rpx;
font-size: 24rpx;
line-height: 24rpx;
}
&.user {
background-color: #1385FA;
> view:nth-of-type(2) {
color: #FFFFFF;
}
}
}
}
.device-update {
width: 100%;
gap: 10px;
display: flex;
flex-wrap: nowrap;
margin-top: 20rpx;
justify-content: space-around;
> view {
flex: 1;
height: 56rpx;
display: flex;
flex-wrap: nowrap;
align-items: center;
justify-content: center;
border-radius: 28rpx;
border: 2rpx solid #EAECF1;
> view:nth-of-type(1) {
width: 24rpx;
height: 24rpx;
display: flex;
align-items: center;
margin-right: 6rpx;
}
> view:nth-of-type(2) {
color: #77849E;
height: 24rpx;
font-size: 24rpx;
line-height: 24rpx;
}
}
}
+97
View File
@@ -39,6 +39,25 @@ const uploadHistoryData = (data: Record<string, any>) =>
/** SN 转 MAC:每两位加一个冒号(如 CEE9052031AC → CE:E9:05:20:31:AC */
const formatMac = (sn: string) => sn.match(/.{2}/g)?.join(':') ?? ''
/** 服务端固件版本(weighingScale/v2/firmware/version 接口 result 字段) */
interface FirmwareVersion {
mcuVersion: string
bleVersion: string
wifiVersion: string
resVersion: string
}
/** 获取服务端最新固件版本 */
const getFirmwareVersion = (modelNumber: string) =>
get<FirmwareVersion>('weighingScale/v2/firmware/version', { type: modelNumber }, { loading: false })
/** 判断服务端版本是否比设备版本新(两端都去掉点号后转数字比较) */
const isServerNewer = (deviceVer: string, serverVer: string) => {
const dn = parseInt(deviceVer, 10)
const sn = parseInt((serverVer || '').replace(/\./g, ''), 10)
return sn > dn
}
/** 展示用设备项 */
interface DeviceItem {
id: string
@@ -327,6 +346,84 @@ Page({
})
},
/** OTA 升级:拉服务端最新版本,比较后下发升级指令 */
onTapOta() {
const deviceInfo = leFuService.deviceInfo
if (!leFuService.isConnected) {
wx.showToast({ title: '请先连接设备', icon: 'none' })
return
}
if (!deviceInfo) {
wx.showToast({ title: '固件信息未就绪', icon: 'none' })
return
}
const { firmwareRevision, modelNumber } = deviceInfo
const [mcuVer, bleVer, wifiVer, resVer] = (firmwareRevision || '').split('.')
console.log('[OTA] 设备版本', { mcuVer, bleVer, wifiVer, resVer })
this.setData({ loadingShow: true, loadingTitle: '正在检测新版本' })
getFirmwareVersion(modelNumber)
.then((res) => {
const { mcuVersion, bleVersion, wifiVersion, resVersion } = res.result
console.log('[OTA] 服务端版本', { mcuVersion, bleVersion, wifiVersion, resVersion })
const needUpdate = isServerNewer(mcuVer, mcuVersion)
|| isServerNewer(bleVer, bleVersion)
|| isServerNewer(wifiVer, wifiVersion)
|| isServerNewer(resVer, resVersion)
if (!needUpdate) {
this.setData({ loadingShow: false })
wx.showToast({ title: '已是最新版本', icon: 'none' })
return
}
this.setData({ loadingTitle: '正在升级' })
leFuService.otaUpdate()
.then(() => {
// 升级后设备重启,清空连接信息
leFuService.disconnect()
this.setData({ loadingShow: false })
wx.showToast({ title: '升级指令已下发', icon: 'success' })
})
.catch(() => {
this.setData({ loadingShow: false })
wx.showToast({ title: '升级失败', icon: 'none' })
})
})
.catch(() => {
this.setData({ loadingShow: false })
})
},
/** 初始化设备信息 */
onTapInit() {
if (!leFuService.isConnected) {
wx.showToast({ title: '请先连接设备', icon: 'none' })
return
}
wx.showModal({
title: '初始化设备',
content: '是否确认初始化设备信息?',
cancelText: '取消',
confirmText: '确定',
confirmColor: '#F24439',
success: (res) => {
if (!res.confirm) return
this.setData({ loadingShow: true, loadingTitle: '正在初始化设备' })
leFuService.initDevice()
.then(() => {
// 初始化后设备归零,清空连接信息
leFuService.disconnect()
this.setData({ loadingShow: false })
wx.showToast({ title: '初始化完成', icon: 'success' })
})
.catch((err: Error) => {
this.setData({ loadingShow: false })
wx.showToast({ title: err?.message || '初始化失败', icon: 'none' })
})
},
})
},
/** 处理历史数据并上传到后台 */
_uploadHistory(mainUserId: string, dataList: any[], done?: () => void) {
if (!dataList || !dataList.length) {
+30 -5
View File
@@ -13,7 +13,6 @@
</view>
<!-- 已配对设备行 -->
<block wx:if="{{ operationsEngineer }}">
<view class="section-bar">
<view class="section-left">
<view class="bt-icon">
@@ -21,9 +20,20 @@
</view>
<view class="section-title">已配对设备</view>
</view>
<view class="ops-btn ops-btn--red" bind:tap="onUnpairAll">取消全部配对</view>
<view class="section-right">
<block wx:if="{{ operationsEngineer }}">
<view class="section-right-red" bind:tap="onUnpairAll">取消全部配对</view>
</block>
<block wx:else>
<view class="section-right-blue" bind:tap="onTapAdd">
<view>
<image src="/images/equipment/add.png"/>
</view>
<view>添加设备</view>
</view>
</block>
</view>
</view>
<!-- 设备列表 -->
<!-- <view class="device">
@@ -82,11 +92,11 @@
<view>设备连接</view>
</view>
</block>
<view class="device-action-btn" bind:tap="onTapUser" data-item="{{ item }}">
<view class="device-action-btn user" bind:tap="onTapUser" data-item="{{ item }}">
<view>
<image src="/images/equipment/users.png"/>
</view>
<view>用户({{ item.userNum }})</view>
<view>用户管理({{ item.userNum }})</view>
</view>
<block wx:if="{{item.status}}">
<view class="device-action-btn" bind:tap="onTapDataRetransfer">
@@ -97,6 +107,19 @@
</view>
</block>
</view>
<block wx:if="{{item.status}}">
<view class="device-update">
<view bind:tap="onTapOta">
<view></view>
<view>OTA升级</view>
</view>
<view bind:tap="onTapInit">
<view></view>
<view>初始化</view>
</view>
</view>
</block>
</view>
</block>
</block>
@@ -105,12 +128,14 @@
</block>
<!-- 添加设备按钮 -->
<block wx:if="{{ operationsEngineer }}">
<view class="add-btn" bind:tap="onTapAdd">
<view class="add-icon">
<image src="/images/addBtn.png"/>
</view>
<view class="add-text">绑定设备</view>
<view class="add-text">添加设备</view>
</view>
</block>
<equipment-dialog show="{{ loadingShow }}" title="{{ loadingTitle }}" content="{{ loadingContent }}"
bind:close="onCloseLoading"/>
@@ -109,7 +109,7 @@
</view>
</view>
<view class="submit-btn" bind:tap="onSubmit">完成并进入首页</view>
<view class="submit-btn" bind:tap="onSubmit">开始使用</view>
<user-info-confirm-modal show="{{ showConfirmModal }}" userInfo="{{ serverResult }}" bind:confirm="onConfirmModalConfirm" bind:cancel="onConfirmModalCancel" />
</view>
@@ -1,6 +1,7 @@
{
"usingComponents": {
"user-management-sync": "/components/userManagementSync/userManagementSync"
"user-management-sync": "/components/userManagementSync/userManagementSync",
"user-management-add-user": "/components/userManagementAddUser/userManagementAddUser"
},
"navigationBarTitleText": "用户管理",
"navigationBarTextStyle": "black",
@@ -120,14 +120,29 @@
line-height: 32rpx;
}
.sync-btn {
color: #FFFFFF;
.section-addUser {
display: flex;
flex-wrap: nowrap;
align-items: center;
height: 48rpx;
font-size: 24rpx;
line-height: 48rpx;
padding: 0 20rpx;
border-radius: 8rpx;
background-color: #1385FA;
border-radius: 32rpx;
background-color: #D9E9FA;
> view:nth-of-type(1) {
width: 32rpx;
height: 32rpx;
display: flex;
align-items: center;
margin-right: 6rpx;
}
> view:nth-of-type(2) {
color: #1385FA;
height: 24rpx;
font-size: 24rpx;
line-height: 24rpx;
}
}
}
@@ -342,36 +357,36 @@
height: 120rpx;
padding: 0 30rpx;
display: flex;
gap: 15rpx;
flex-wrap: nowrap;
align-items: center;
box-sizing: border-box;
background-color: #FFFFFF;
box-shadow: 0 2rpx 8rpx 0 rgba(19, 133, 250, 0.06);
.btn-cancel {
color: #1385FA;
.sync-btn {
flex: 1;
height: 88rpx;
font-size: 32rpx;
text-align: center;
line-height: 84rpx;
border-radius: 44rpx;
box-sizing: border-box;
border: 2rpx solid #1385FA;
background-color: #FFFFFF;
}
.btn-primary {
color: #FFFFFF;
flex: 1;
height: 88rpx;
font-size: 32rpx;
font-weight: bold;
text-align: center;
line-height: 88rpx;
display: flex;
flex-wrap: nowrap;
align-items: center;
justify-content: center;
border-radius: 44rpx;
background-color: #1385FA;
> view:nth-of-type(1) {
width: 32rpx;
height: 32rpx;
display: flex;
align-items: center;
margin-right: 6rpx;
}
> view:nth-of-type(2) {
color: #FFFFFF;
height: 32rpx;
font-size: 32rpx;
line-height: 32rpx;
font-weight: bold;
}
}
}
}
@@ -96,6 +96,7 @@ Page({
syncShow: false,
syncPercent: 0,
syncStatus: '',
addUserShow: false,
isOps: false
},
@@ -390,12 +391,15 @@ Page({
this.setData({ syncShow: true, syncPercent: 0, syncStatus: '正在清空并重新下发...' })
leFuService.clearDeviceMembers()
.then(() => leFuService.syncMembersToDevice(syncDataList, (current, total) => {
.then(() => {
if (!syncDataList.length) return
return leFuService.syncMembersToDevice(syncDataList, (current, total) => {
this.setData({
syncPercent: Math.round((current / total) * 100),
syncStatus: `正在同步 ${current}/${total}...`,
})
}))
})
})
.then(() => this._finishSync(reportUsers, '重新下发成功'))
.catch((err: Error) => {
this.setData({ syncShow: false })
@@ -403,14 +407,34 @@ Page({
})
},
/** 添加用户 */
/** 添加用户:运维模式或已有本人直接跳添加页,否则弹出选择弹框 */
onTapAddUser() {
if (this.data.memberCount >= 10) {
wx.showToast({ title: '最多添加10位用户', icon: 'none' })
return
}
const sn = targetDevice?.sn || ''
wx.navigateTo({ url: `/pages/addUser/addUser?sn=${encodeURIComponent(sn)}` })
if (this.data.isOps || this.data.self) {
this.onTapAddNew()
} else {
this.setData({ addUserShow: true })
}
},
/** 关闭添加用户弹框 */
onCloseAddUser() {
this.setData({ addUserShow: false })
},
/** 弹框:一键添加本人 */
onAddSelfTap() {
this.setData({ addUserShow: false })
this.onTapAddSelf()
},
/** 弹框:添加其他用户 */
onAddOtherTap() {
this.setData({ addUserShow: false })
this.onTapAddNew()
},
/** 编辑成员:跳转 addUser 编辑模式 */
@@ -464,8 +488,10 @@ Page({
if (!sn) return
addSelfUser({
relationType: 1,
dataType: 0,
parentUserId: userInfo.userId,
id: userInfo.id,
userId: userInfo.userId,
sn,
scaleDeviceId: sn,
realname: userInfo.realname ?? '',
@@ -24,7 +24,12 @@
<!-- 已录入用户 + 同步按钮 -->
<view class="section-header">
<view class="section-title" bind:longpress="onLongPressSectionTitle">已录入用户({{ memberCount }}/10</view>
<view class="sync-btn" bind:tap="onTapSync">同步用户至设备</view>
<view class="section-addUser" bind:tap="onTapAddUser">
<view>
<image src="/images/userManagement/add.png" mode="aspectFit" />
</view>
<view>添加用户</view>
</view>
</view>
<!-- 同步提示 -->
@@ -104,17 +109,17 @@
<!-- 底部常驻添加用户按钮 -->
<view class="footer">
<block wx:if="{{ self }}">
<view class="btn-primary" bind:tap="onTapAddUser">添加用户(最多10位)</view>
</block>
<block wx:else>
<block wx:if="{{ !isOps }}">
<view class="btn-primary" bind:tap="onTapAddSelf">一键添加本人</view>
</block>
<view class="btn-cancel" bind:tap="onTapAddNew">添加新用户</view>
</block>
<view class="sync-btn" bind:tap="onTapSync">
<view>
<image src="/images/userManagement/reload.png" mode="aspectFit" />
</view>
<view>同步用户至设备</view>
</view>
</view>
<!-- 同步进度弹框 -->
<user-management-sync show="{{ syncShow }}" percent="{{ syncPercent }}" status="{{ syncStatus }}" />
<!-- 添加用户弹框 -->
<user-management-add-user show="{{ addUserShow }}" bind:addself="onAddSelfTap" bind:addother="onAddOtherTap" bind:close="onCloseAddUser" />
</view>
+1 -1
View File
@@ -3,7 +3,7 @@ import { ENV, type EnvType } from '../env/index'
/** 各环境接口网关地址:develop / trial 走测试网关,release 走正式网关 */
const BASE_URLS: Record<EnvType, string> = {
develop: 'http://10.10.10.10:8889/',
trial: 'http://10.10.10.10:8889/',
trial: 'https://device.shuziweidao.com/gateway/',
release: 'https://device.shuziweidao.com/gateway/',
}