feat(userManagement): 用户管理新增空态与同步进度弹框组件

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
17792275749
2026-08-19 15:58:28 +08:00
co-authored by Claude Opus 4.7
parent 9040fc4fba
commit 3e0d260fdc
8 changed files with 443 additions and 331 deletions
@@ -0,0 +1,4 @@
{
"component": true,
"usingComponents": {}
}
@@ -0,0 +1,63 @@
.sync-mask {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(37, 37, 53, 0.6);
z-index: 100;
}
.sync-panel {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 560rpx;
box-sizing: border-box;
background-color: #FFFFFF;
border-radius: 24rpx;
z-index: 101;
display: flex;
flex-direction: column;
align-items: center;
padding: 64rpx 48rpx;
.sync-title {
color: #252535;
height: 32rpx;
font-size: 32rpx;
line-height: 32rpx;
}
.sync-status {
color: #808080;
height: 24rpx;
font-size: 24rpx;
line-height: 24rpx;
margin-top: 24rpx;
}
.sync-percent {
color: #77849E;
height: 24rpx;
font-size: 24rpx;
line-height: 24rpx;
margin-top: 48rpx;
}
.sync-progress {
width: 464rpx;
height: 10rpx;
border-radius: 6rpx;
background-color: #D9D9D9;
margin-top: 16rpx;
overflow: hidden;
.sync-progress-inner {
height: 10rpx;
border-radius: 6rpx;
background-color: #1385FA;
}
}
}
@@ -0,0 +1,19 @@
Component({
properties: {
/** 是否显示弹框 */
show: {
type: Boolean,
value: false
},
/** 同步进度百分比 */
percent: {
type: Number,
value: 0
},
/** 同步状态文案 */
status: {
type: String,
value: ''
}
}
})
@@ -0,0 +1,11 @@
<block wx:if="{{ show }}">
<view class="sync-mask"></view>
<view class="sync-panel">
<view class="sync-title">同步成员至设备</view>
<view class="sync-status">{{ status }}</view>
<view class="sync-percent">{{ percent }}%</view>
<view class="sync-progress">
<view class="sync-progress-inner" style="width: {{ percent }}%;"></view>
</view>
</view>
</block>
@@ -1,5 +1,7 @@
{ {
"usingComponents": {}, "usingComponents": {
"user-management-sync": "/components/userManagementSync/userManagementSync"
},
"navigationBarTitleText": "用户管理", "navigationBarTitleText": "用户管理",
"navigationBarTextStyle": "black", "navigationBarTextStyle": "black",
"navigationBarBackgroundColor": "#FFFFFF" "navigationBarBackgroundColor": "#FFFFFF"
@@ -1,312 +1,307 @@
.userManagement { .userManagement {
width: 100%; width: 100%;
min-height: 100%; height: 100%;
padding: 24rpx 30rpx; display: flex;
box-sizing: border-box; flex-direction: column;
/* 设备卡片 */ /* 顶部固定区 */
.device-card { .header {
width: 100%; width: 100%;
padding: 30rpx; padding: 24rpx 30rpx 0;
display: flex;
flex-wrap: nowrap;
border-radius: 24rpx;
background-color: #FFFFFF;
box-sizing: border-box; box-sizing: border-box;
margin-bottom: 32rpx; margin-bottom: 24rpx;
.device-icon { .device-card {
width: 88rpx; width: 100%;
height: 88rpx; padding: 32rpx;
overflow: hidden;
margin-right: 24rpx;
border-radius: 24rpx; border-radius: 24rpx;
background-color: #1385FA; background-color: #FFFFFF;
} box-sizing: border-box;
margin-bottom: 24rpx;
display: flex;
align-items: center;
.device-info { .device-icon {
flex: 1; width: 88rpx;
height: 88rpx;
overflow: hidden;
margin-right: 24rpx;
border-radius: 24rpx;
background-color: #1385FA;
flex-shrink: 0;
}
.device-name-row { .device-info {
width: 100%; flex: 1;
height: 40rpx;
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 14rpx;
.device-name { .device-name-row {
color: #252535; width: 100%;
height: 40rpx;
font-size: 32rpx;
font-weight: bolder;
line-height: 40rpx;
}
.device-status {
height: 40rpx;
padding: 0 16rpx;
display: flex; display: flex;
flex-wrap: nowrap;
align-items: center; align-items: center;
border-radius: 20rpx; justify-content: space-between;
background-color: #EAFAF6; margin-bottom: 16rpx;
.status-dot { .device-name {
width: 12rpx; color: #252535;
height: 12rpx; height: 32rpx;
margin-right: 8rpx; font-size: 32rpx;
border-radius: 50%; line-height: 32rpx;
background-color: #2AC79F;
} }
.status-text { .device-status {
color: #2AC79F; height: 22rpx;
display: flex;
align-items: center;
.status-dot {
width: 12rpx;
height: 12rpx;
border-radius: 50%;
background-color: #2AC79F;
margin-right: 8rpx;
}
.status-text {
color: #2AC79F;
height: 22rpx;
font-size: 22rpx;
line-height: 22rpx;
}
}
}
.device-meta {
color: #808080;
height: 26rpx;
font-size: 26rpx;
line-height: 26rpx;
margin-bottom: 8rpx;
}
}
}
.section-header {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 16rpx;
.section-title {
color: #252535;
height: 32rpx;
font-size: 32rpx;
line-height: 32rpx;
}
.sync-btn {
height: 48rpx;
padding: 0 20rpx;
border-radius: 24rpx;
background-color: #1385FA;
color: #FFFFFF;
font-size: 24rpx;
line-height: 48rpx;
}
}
.sync-tip {
color: #F2994A;
font-size: 24rpx;
line-height: 34rpx;
}
}
/* 用户列表滚动区 */
.body {
flex: 1;
overflow: hidden;
.empty-state {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
.empty-img {
width: 193rpx;
height: 138rpx;
}
.empty-text {
color: #B6B6B6;
font-size: 28rpx;
line-height: 42rpx;
text-align: center;
margin-top: 32rpx;
white-space: pre-line;
}
}
.scrollViewContent {
width: 100%;
padding: 0 30rpx;
box-sizing: border-box;
.member-card {
width: 100%;
padding: 32rpx;
border-radius: 24rpx;
background-color: #FFFFFF;
box-sizing: border-box;
margin-bottom: 24rpx;
display: flex;
align-items: center;
.member-avatar {
width: 88rpx;
height: 88rpx;
border-radius: 24rpx;
margin-right: 24rpx;
flex-shrink: 0;
}
.member-avatar--male {
background-color: #C6E6FF;
}
.member-avatar--female {
background-color: #FFD5E3;
}
.member-info {
flex: 1;
.member-name-row {
display: flex;
align-items: center;
margin-bottom: 16rpx;
.member-name {
color: #252535;
height: 32rpx;
font-size: 32rpx;
line-height: 32rpx;
margin-right: 16rpx;
}
.member-type-tag {
height: 40rpx;
padding: 0 10rpx;
font-size: 24rpx;
line-height: 40rpx;
border-radius: 8rpx;
color: #FFFFFF;
}
.member-type-tag--self {
background-color: #1385FA;
}
.member-type-tag--employee {
background-color: #10B981;
}
.member-type-tag--family {
background-color: #F59E0B;
}
}
.member-sub {
color: #808080;
height: 26rpx;
font-size: 26rpx;
line-height: 26rpx;
}
}
.member-right {
display: flex;
flex-direction: column;
align-items: flex-end;
.member-sync {
height: 22rpx; height: 22rpx;
font-size: 22rpx; font-size: 22rpx;
line-height: 22rpx; line-height: 22rpx;
margin-bottom: 16rpx;
}
.member-sync--done {
color: #2AC79F;
}
.member-sync--pending {
color: #F2994A;
}
.member-sync--deleted {
color: #F24439;
}
.member-ops {
display: flex;
.op-edit {
color: #77849E;
height: 26rpx;
font-size: 26rpx;
line-height: 26rpx;
margin-right: 24rpx;
}
.op-delete {
color: #F24439;
height: 26rpx;
font-size: 26rpx;
line-height: 26rpx;
}
} }
} }
} }
.device-meta {
color: #808080;
height: 26rpx;
font-size: 26rpx;
line-height: 26rpx;
}
} }
} }
/* 已录入用户 + 同步按钮 */ /* 底部常驻添加用户按钮 */
.section-header { .footer {
width: 100%; width: 100%;
height: 48rpx; height: 120rpx;
padding: 0 30rpx;
display: flex; display: flex;
gap: 15rpx;
flex-wrap: nowrap;
align-items: center; align-items: center;
justify-content: space-between; box-sizing: border-box;
margin-bottom: 16rpx; background-color: #FFFFFF;
box-shadow: 0 2rpx 8rpx 0 rgba(19, 133, 250, 0.06);
.section-title { .btn-cancel {
color: #252535; color: #1385FA;
height: 32rpx; flex: 1;
height: 88rpx;
font-size: 32rpx; font-size: 32rpx;
font-weight: bolder; text-align: center;
line-height: 32rpx; line-height: 84rpx;
border-radius: 44rpx;
box-sizing: border-box;
border: 2rpx solid #1385FA;
background-color: #FFFFFF;
} }
.sync-btn { .btn-primary {
color: #FFFFFF; color: #FFFFFF;
height: 48rpx; flex: 1;
font-size: 24rpx; height: 88rpx;
padding: 0 16rpx; font-size: 32rpx;
line-height: 48rpx; font-weight: bold;
border-radius: 8rpx; text-align: center;
line-height: 88rpx;
border-radius: 44rpx;
background-color: #1385FA; background-color: #1385FA;
} }
} }
/* 同步提示 */
.sync-tip {
color: #F2994A;
font-size: 24rpx;
line-height: 34rpx;
margin-bottom: 24rpx;
}
/* 用户卡片 */
.member-card {
width: 100%;
padding: 32rpx;
border-radius: 24rpx;
background-color: #FFFFFF;
box-sizing: border-box;
margin-bottom: 24rpx;
display: flex;
align-items: center;
.member-avatar {
width: 88rpx;
height: 88rpx;
border-radius: 24rpx;
margin-right: 24rpx;
flex-shrink: 0;
}
.member-avatar--male {
background-color: #C6E6FF;
}
.member-avatar--female {
background-color: #FFD5E3;
}
.member-info {
flex: 1;
.member-name-row {
display: flex;
align-items: center;
margin-bottom: 16rpx;
.member-name {
color: #252535;
height: 32rpx;
font-size: 32rpx;
line-height: 32rpx;
margin-right: 16rpx;
}
.member-type-tag {
height: 40rpx;
padding: 0 10rpx;
font-size: 24rpx;
line-height: 40rpx;
border-radius: 8rpx;
color: #FFFFFF;
}
.member-type-tag--self {
background-color: #1385FA;
}
.member-type-tag--employee {
background-color: #10B981;
}
.member-type-tag--family {
background-color: #F59E0B;
}
}
.member-sub {
color: #808080;
height: 26rpx;
font-size: 26rpx;
line-height: 26rpx;
}
}
.member-right {
display: flex;
flex-direction: column;
align-items: flex-end;
.member-sync {
height: 22rpx;
font-size: 22rpx;
line-height: 22rpx;
margin-bottom: 16rpx;
}
.member-sync--done {
color: #2AC79F;
}
.member-sync--pending {
color: #F2994A;
}
.member-sync--deleted {
color: #F24439;
}
.member-ops {
display: flex;
.op-edit {
color: #77849E;
height: 26rpx;
font-size: 26rpx;
line-height: 26rpx;
margin-right: 24rpx;
}
.op-delete {
color: #F24439;
height: 26rpx;
font-size: 26rpx;
line-height: 26rpx;
}
}
}
}
/* 底部添加用户按钮 */
.add-btn {
width: 100%;
height: 96rpx;
border-radius: 48rpx;
background-color: #1385FA;
color: #FFFFFF;
font-size: 36rpx;
line-height: 96rpx;
text-align: center;
margin-top: 8rpx;
}
/* 同步进度弹框 */
.sync-mask {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(37, 37, 53, 0.6);
z-index: 100;
}
.sync-panel {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 560rpx;
box-sizing: border-box;
background-color: #FFFFFF;
border-radius: 24rpx;
z-index: 101;
display: flex;
flex-direction: column;
align-items: center;
padding: 64rpx 48rpx;
.sync-title {
color: #252535;
height: 32rpx;
font-size: 32rpx;
line-height: 32rpx;
}
.sync-status {
color: #808080;
height: 24rpx;
font-size: 24rpx;
line-height: 24rpx;
margin-top: 24rpx;
}
.sync-percent {
color: #77849E;
height: 24rpx;
font-size: 24rpx;
line-height: 24rpx;
margin-top: 48rpx;
}
.sync-progress {
width: 464rpx;
height: 10rpx;
border-radius: 6rpx;
background-color: #D9D9D9;
margin-top: 16rpx;
overflow: hidden;
.sync-progress-inner {
height: 10rpx;
border-radius: 6rpx;
background-color: #1385FA;
}
}
}
} }
@@ -31,5 +31,15 @@ Page({
/** 添加用户 */ /** 添加用户 */
onTapAddUser() { onTapAddUser() {
wx.navigateTo({ url: '/pages/addUser/addUser' }) wx.navigateTo({ url: '/pages/addUser/addUser' })
},
/** 一键添加本人 */
onTapAddSelf() {
// 一键添加本人(待接入)
},
/** 添加新用户 */
onTapAddNew() {
wx.navigateTo({ url: '/pages/addUser/addUser' })
} }
}) })
@@ -1,63 +1,71 @@
<view class="userManagement"> <view class="userManagement">
<!-- 设备卡片 --> <!-- 顶部固定区 -->
<view class="device-card"> <view class="header">
<view class="device-icon"></view> <!-- 设备卡片 -->
<view class="device-info"> <view class="device-card">
<view class="device-name-row"> <view class="device-icon"></view>
<view class="device-name">{{ device.name }}</view> <view class="device-info">
<view class="device-status"> <view class="device-name-row">
<view class="status-dot"></view> <view class="device-name">{{ device.name }}</view>
<view class="status-text">{{ device.connected ? '已连接' : '未连接' }}</view> <view class="device-status">
<view class="status-dot"></view>
<view class="status-text">{{ device.connected ? '已连接' : '未连接' }}</view>
</view>
</view> </view>
<view class="device-meta">型号:{{ device.model }}</view>
<view class="device-meta">设备编号:{{ device.serial }}</view>
</view> </view>
<view class="device-meta" style="margin-bottom: 20rpx;">型号:{{ device.model }}</view> </view>
<view class="device-meta">设备编号:{{ device.serial }}</view>
<!-- 已录入用户 + 同步按钮 -->
<view class="section-header">
<view class="section-title">已录入用户({{ memberCount }}/10</view>
<view class="sync-btn" bind:tap="onTapSync">同步用户至设备</view>
</view>
<!-- 同步提示 -->
<view class="sync-tip">当前用户信息未同步至设备,请在连接设备的状态下,点击同步按钮完成信息同步</view>
</view>
<!-- 用户列表滚动区 -->
<view class="body">
<scroll-view scroll-y class="scrollView" wx:if="{{ members.length }}">
<view class="scrollViewContent">
<block wx:for="{{ members }}" wx:key="id">
<view class="member-card">
<view class="member-avatar {{ item.gender === '女' ? 'member-avatar--female' : 'member-avatar--male' }}"></view>
<view class="member-info">
<view class="member-name-row">
<view class="member-name">{{ item.name }}</view>
<view class="member-type-tag member-type-tag--{{ item.typeClass }}">{{ item.type }}</view>
</view>
<view class="member-sub">{{ item.gender }}·{{ item.age }}岁 丨 {{ item.height }}cm</view>
</view>
<view class="member-right">
<view class="member-sync member-sync--{{ item.syncClass }}">{{ item.sync }}</view>
<view class="member-ops">
<view class="op-edit">编辑</view>
<view class="op-delete">删除</view>
</view>
</view>
</view>
</block>
</view>
</scroll-view>
<view class="empty-state" wx:else>
<image class="empty-img" src="/images/emptyData.png" mode="aspectFit" />
<view class="empty-text">暂无用户\n请添加用户以使用设备测量</view>
</view> </view>
</view> </view>
<!-- 已录入用户 + 同步按钮 -->
<view class="section-header"> <!-- 底部常驻添加用户按钮 -->
<view class="section-title">已录入用户({{ memberCount }}/10</view> <view class="footer">
<view class="sync-btn" bind:tap="onTapSync">同步用户至设备</view> <view class="btn-primary" bind:tap="onTapAddUser">添加用户(最多10位)</view>
<!-- <view class="btn-primary" bind:tap="onTapAddSelf">一键添加本人</view>-->
<!-- <view class="btn-cancel" bind:tap="onTapAddNew">添加新用户</view>-->
</view> </view>
<!-- 同步提示 -->
<view class="sync-tip">当前用户信息未同步至设备,请在连接设备的状态下,点击同步按钮完成信息同步</view>
<!-- 用户列表 -->
<block wx:for="{{ members }}" wx:key="id">
<view class="member-card">
<view class="member-avatar {{ item.gender === '女' ? 'member-avatar--female' : 'member-avatar--male' }}"></view>
<view class="member-info">
<view class="member-name-row">
<view class="member-name">{{ item.name }}</view>
<view class="member-type-tag member-type-tag--{{ item.typeClass }}">{{ item.type }}</view>
</view>
<view class="member-sub">{{ item.gender }}·{{ item.age }}岁 丨 {{ item.height }}cm</view>
</view>
<view class="member-right">
<view class="member-sync member-sync--{{ item.syncClass }}">{{ item.sync }}</view>
<view class="member-ops">
<view class="op-edit">编辑</view>
<view class="op-delete">删除</view>
</view>
</view>
</view>
</block>
<!-- 底部添加用户按钮 -->
<view class="add-btn" bind:tap="onTapAddUser">添加用户(最多10位)</view>
<!-- 同步进度弹框 --> <!-- 同步进度弹框 -->
<block wx:if="{{ syncShow }}"> <user-management-sync show="{{ syncShow }}" percent="{{ syncPercent }}" status="{{ syncStatus }}" />
<view class="sync-mask"></view>
<view class="sync-panel">
<view class="sync-title">同步成员至设备</view>
<view class="sync-status">{{ syncStatus }}</view>
<view class="sync-percent">{{ syncPercent }}%</view>
<view class="sync-progress">
<view class="sync-progress-inner" style="width: {{ syncPercent }}%;"></view>
</view>
</view>
</block>
</view> </view>