refactor: 统一术语「成员」→「用户」,代码格式化
- 页面文案、注释、Toast 提示统一改为"用户" - lefu 模块缩进格式化(空格→Tab) - selectMemberDrawer 组件注释统一 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
97c135786c
commit
485725a486
@@ -108,14 +108,14 @@
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* 成员滚动列表 */
|
||||
/* 用户滚动列表 */
|
||||
.drawer-list {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
padding-bottom: env(safe-area-inset-bottom);
|
||||
}
|
||||
|
||||
/* 成员行 */
|
||||
/* 用户行 */
|
||||
.member-item {
|
||||
width: 100%;
|
||||
height: 90rpx;
|
||||
|
||||
@@ -25,7 +25,7 @@ interface HistoryApiItem {
|
||||
relationType: number | string | null
|
||||
}
|
||||
|
||||
/** 抽屉内部成员项(含回填所需全量字段) */
|
||||
/** 抽屉内部用户项(含回填所需全量字段) */
|
||||
interface ExistingMember {
|
||||
id: string
|
||||
name: string
|
||||
@@ -44,9 +44,9 @@ interface ExistingMember {
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择已有成员抽屉组件
|
||||
* 选择已有用户抽屉组件
|
||||
* Properties: show(控制显示)
|
||||
* Events: close(关闭), select(选中成员,携带 ExistingMember)
|
||||
* Events: close(关闭), select(选中用户,携带 ExistingMember)
|
||||
*/
|
||||
Component({
|
||||
properties: {
|
||||
@@ -55,12 +55,12 @@ Component({
|
||||
type: Boolean,
|
||||
value: false
|
||||
},
|
||||
/** 数据来源模式:addMember=新增成员选择 / history=历史数据切换成员 */
|
||||
/** 数据来源模式:addMember=新增用户选择 / history=历史数据切换用户 */
|
||||
source: {
|
||||
type: String,
|
||||
value: 'addMember'
|
||||
},
|
||||
/** 需要排除的用户 ID(history 模式下排除当前查看的成员) */
|
||||
/** 需要排除的用户 ID(history 模式下排除当前查看的用户) */
|
||||
excludeUserId: {
|
||||
type: String,
|
||||
value: ''
|
||||
@@ -72,7 +72,7 @@ Component({
|
||||
innerShow: false,
|
||||
/** 控制 --visible 类,触发 CSS transition */
|
||||
animVisible: false,
|
||||
/** 成员列表(组件内部拉取) */
|
||||
/** 用户列表(组件内部拉取) */
|
||||
members: [] as ExistingMember[]
|
||||
},
|
||||
|
||||
@@ -109,7 +109,7 @@ Component({
|
||||
return Math.max(0, age)
|
||||
},
|
||||
|
||||
/** 调接口获取可选成员列表,根据 source 调不同接口 */
|
||||
/** 调接口获取可选用户列表,根据 source 调不同接口 */
|
||||
_fetchMembers() {
|
||||
const userInfo = wx.getStorageSync('userInfo') as { userId?: string } | null
|
||||
const userId = userInfo?.userId ?? ''
|
||||
@@ -175,7 +175,7 @@ Component({
|
||||
},
|
||||
|
||||
/**
|
||||
* 点击成员行,触发 select 事件
|
||||
* 点击用户行,触发 select 事件
|
||||
* @param e 携带 data-member 的点击事件
|
||||
*/
|
||||
onTapMember(e: WechatMiniprogram.TouchEvent) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<!-- 选择已有成员抽屉 -->
|
||||
<!-- 选择已有用户抽屉 -->
|
||||
<block wx:if="{{ innerShow }}">
|
||||
<!-- 遮罩 -->
|
||||
<view class="drawer-mask {{ animVisible ? 'drawer-mask--visible' : '' }}" bind:tap="onTapMask"></view>
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
<!-- 标题栏 -->
|
||||
<view class="drawer-header">
|
||||
<text class="drawer-title">选择已有成员</text>
|
||||
<text class="drawer-title">选择已有用户</text>
|
||||
<view class="drawer-close" bind:tap="onTapClose">
|
||||
<view class="drawer-close-icon"></view>
|
||||
</view>
|
||||
@@ -20,7 +20,7 @@
|
||||
<!-- 分隔线 -->
|
||||
<view class="drawer-divider"></view>
|
||||
|
||||
<!-- 成员列表 -->
|
||||
<!-- 用户列表 -->
|
||||
<block wx:if="{{ members.length }}">
|
||||
<scroll-view class="drawer-list" scroll-y>
|
||||
<block wx:for="{{ members }}" wx:key="id">
|
||||
@@ -52,11 +52,11 @@
|
||||
</scroll-view>
|
||||
</block>
|
||||
|
||||
<!-- 无成员:占位 -->
|
||||
<!-- 无用户:占位 -->
|
||||
<block wx:else>
|
||||
<view class="drawer-empty">
|
||||
<image class="drawer-empty-icon" src="/images/selectMemberDrawer/noData.png" mode="aspectFit"/>
|
||||
<text class="drawer-empty-text">暂无可选成员</text>
|
||||
<text class="drawer-empty-text">暂无可选用户</text>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
|
||||
@@ -273,7 +273,7 @@ class LeFuService {
|
||||
clearTimeout(timer)
|
||||
console.log(TAG, 'getWifiList 结果:', res)
|
||||
if (!res?.length) {
|
||||
this._activeProtocol.dataExitWifiConfig(() => {})
|
||||
this._activeProtocol.dataExitWifiConfig(() => { })
|
||||
resolve([])
|
||||
return
|
||||
}
|
||||
@@ -399,35 +399,35 @@ class LeFuService {
|
||||
}, 2000)
|
||||
}
|
||||
|
||||
// ─── 清除设备成员(不下发) ─────────────────────
|
||||
// ─── 清除设备用户(不下发) ─────────────────────
|
||||
clearDeviceMembers(): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!this._activeProtocol) { reject(new Error('设备未连接')); return }
|
||||
const timer = setTimeout(() => reject(new Error('清除设备成员超时')), 15000)
|
||||
const timer = setTimeout(() => reject(new Error('清除设备用户超时')), 15000)
|
||||
this._activeProtocol.codeClearDeviceData('01', (res: number) => {
|
||||
clearTimeout(timer)
|
||||
res === 0 ? resolve() : reject(new Error('清除设备成员失败'))
|
||||
res === 0 ? resolve() : reject(new Error('清除设备用户失败'))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// ─── 成员同步 ─────────────────────────────────
|
||||
// ─── 用户同步 ─────────────────────────────────
|
||||
syncMembersToDevice(members: DeviceMember[], onProgress?: (current: number, total: number) => void): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!this._activeProtocol) { reject(new Error('设备未连接')); return }
|
||||
const mainUser = members.find(m => m.isSelf)
|
||||
if (!mainUser) { reject(new Error('缺少主用户')); return }
|
||||
|
||||
const clearTimer = setTimeout(() => reject(new Error('清除设备成员超时')), 15000)
|
||||
const clearTimer = setTimeout(() => reject(new Error('清除设备用户超时')), 15000)
|
||||
this._activeProtocol.codeClearDeviceData('01', (clearRes: number) => {
|
||||
clearTimeout(clearTimer)
|
||||
if (clearRes != 0) { reject(new Error('清除设备成员失败')); return }
|
||||
if (clearRes != 0) { reject(new Error('清除设备用户失败')); return }
|
||||
|
||||
let index = 0
|
||||
let syncTimer: number | null = null
|
||||
const resetTimer = () => {
|
||||
if (syncTimer !== null) clearTimeout(syncTimer)
|
||||
syncTimer = setTimeout(() => reject(new Error(`第 ${index + 1} 个成员下发超时`)), 15000)
|
||||
syncTimer = setTimeout(() => reject(new Error(`第 ${index + 1} 个用户下发超时`)), 15000)
|
||||
}
|
||||
const syncNext = () => {
|
||||
if (index >= members.length) {
|
||||
|
||||
@@ -95,9 +95,9 @@ export interface FirmwareVersion {
|
||||
resVersion: string
|
||||
}
|
||||
|
||||
/** 下发给设备的成员信息(lefu 层使用,业务层转换后传入) */
|
||||
/** 下发给设备的用户信息(lefu 层使用,业务层转换后传入) */
|
||||
export interface DeviceMember {
|
||||
/** 成员唯一 ID */
|
||||
/** 用户唯一 ID */
|
||||
id: string
|
||||
/** 姓名 */
|
||||
name: string
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"navigationBarTitleText": "添加成员",
|
||||
"navigationBarTitleText": "添加用户",
|
||||
"usingComponents": {
|
||||
"select-member-drawer": "/components/selectMemberDrawer/selectMemberDrawer",
|
||||
"user-info-confirm-modal": "/components/userInfoConfirmModal/userInfoConfirmModal"
|
||||
|
||||
@@ -167,7 +167,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
/* 从已有成员中选择(蓝色描边幽灵按钮) */
|
||||
/* 从已有用户中选择(蓝色描边幽灵按钮) */
|
||||
.ghost-btn {
|
||||
color: #1385FA;
|
||||
width: 580rpx;
|
||||
|
||||
@@ -64,7 +64,7 @@ interface IdCardParsed {
|
||||
birthday: string
|
||||
}
|
||||
|
||||
/** 从抽屉组件 select 事件接收的成员数据(完整 item) */
|
||||
/** 从抽屉组件 select 事件接收的用户数据(完整 item) */
|
||||
interface ExistingMember {
|
||||
id: string
|
||||
name: string
|
||||
@@ -78,8 +78,8 @@ interface ExistingMember {
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加/编辑成员页
|
||||
* URL 参数含 userId 时为编辑模式,隐藏「从已有成员中选择」按钮并预填表单
|
||||
* 添加/编辑用户页
|
||||
* URL 参数含 userId 时为编辑模式,隐藏「从已有用户中选择」按钮并预填表单
|
||||
*/
|
||||
Page({
|
||||
data: {
|
||||
@@ -97,7 +97,7 @@ Page({
|
||||
weight: ''
|
||||
} as MemberForm,
|
||||
|
||||
/** 从抽屉选中的完整成员数据,提交时作为 base spread */
|
||||
/** 从抽屉选中的完整用户数据,提交时作为 base spread */
|
||||
selectedMember: null as ExistingMember | null,
|
||||
showSelectDrawer: false,
|
||||
/** 正在请求身份证查询接口 */
|
||||
@@ -391,7 +391,7 @@ Page({
|
||||
.then(() => {
|
||||
wx.showToast({ title: successMsg, icon: 'success' })
|
||||
setTimeout(() => {
|
||||
// 通知上一页(equipmentMember)刷新成员列表
|
||||
// 通知上一页(equipmentMember)刷新用户列表
|
||||
const pages = getCurrentPages()
|
||||
const prevPage = pages[pages.length - 2] as any
|
||||
if (prevPage && prevPage.data?.sn) {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<!-- 顶部浅蓝提示条 -->
|
||||
<view class="tips">
|
||||
<view class="tips-icon">!</view>
|
||||
<text class="tips-text">最多支持 10 位成员</text>
|
||||
<text class="tips-text">最多支持 10 位用户</text>
|
||||
</view>
|
||||
|
||||
<view class="form">
|
||||
@@ -126,21 +126,21 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 从已有成员中选择(编辑模式隐藏) -->
|
||||
<!-- 从已有用户中选择(编辑模式隐藏) -->
|
||||
<block wx:if="{{ !isEdit }}">
|
||||
<view class="ghost-btn" bind:tap="onTapSelectExisting">从已有成员中选择</view>
|
||||
<view class="ghost-btn" bind:tap="onTapSelectExisting">从已有用户中选择</view>
|
||||
</block>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
|
||||
<!-- 底部双按钮:取消 / 保存成员信息 -->
|
||||
<!-- 底部双按钮:取消 / 保存用户信息 -->
|
||||
<view class="actions">
|
||||
<view class="btn-cancel" bind:tap="onCancel">取消</view>
|
||||
<view class="btn-primary" bind:tap="onSubmit">保存成员信息</view>
|
||||
<view class="btn-primary" bind:tap="onSubmit">保存用户信息</view>
|
||||
</view>
|
||||
|
||||
<!-- 选择已有成员抽屉 -->
|
||||
<!-- 选择已有用户抽屉 -->
|
||||
<select-member-drawer
|
||||
show="{{ showSelectDrawer }}"
|
||||
bind:close="onSelectMemberClose"
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
}
|
||||
|
||||
|
||||
/* 成员信息行 */
|
||||
/* 用户信息行 */
|
||||
.userInfo {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
@@ -100,7 +100,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
/* 切换成员按钮 */
|
||||
/* 切换用户按钮 */
|
||||
.btn {
|
||||
color: #1385FA;
|
||||
width: 120rpx;
|
||||
|
||||
@@ -208,7 +208,7 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/** 打开切换成员抽屉 */
|
||||
/** 打开切换用户抽屉 */
|
||||
onTapSwitchMember() {
|
||||
this.setData({ showSelectDrawer: true })
|
||||
},
|
||||
@@ -218,7 +218,7 @@ Page({
|
||||
this.setData({ showSelectDrawer: false })
|
||||
},
|
||||
|
||||
/** 选中成员后更新 userInfo 并重新请求数据 */
|
||||
/** 选中用户后更新 userInfo 并重新请求数据 */
|
||||
onSelectMember(e: WechatMiniprogram.CustomEvent) {
|
||||
const m = e.detail as {
|
||||
userId?: string
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
>
|
||||
<view class="scrollViewContent">
|
||||
|
||||
<!-- 数据卡(成员信息 + 时间 Tab + 统计) -->
|
||||
<!-- 数据卡(用户信息 + 时间 Tab + 统计) -->
|
||||
<view class="data-card">
|
||||
|
||||
<!-- 成员信息 -->
|
||||
<!-- 用户信息 -->
|
||||
<view class="userInfo">
|
||||
<view class="avatar">{{ userInfo.realname[0] }}</view>
|
||||
<view class="info">
|
||||
@@ -29,7 +29,7 @@
|
||||
<view class="meta-text">{{ userInfo.height }}cm</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="btn" bind:tap="onTapSwitchMember">切换成员</view>
|
||||
<view class="btn" bind:tap="onTapSwitchMember">切换用户</view>
|
||||
</view>
|
||||
|
||||
<view class="card-divider"></view>
|
||||
|
||||
@@ -184,7 +184,7 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/* 点击「成员管理」→ 跳转成员管理页,sn 由目标页从缓存读取 */
|
||||
/* 点击「用户管理」→ 跳转用户管理页,sn 由目标页从缓存读取 */
|
||||
onTapMember() {
|
||||
wx.navigateTo({ url: '/pages/equipmentMember/equipmentMember' })
|
||||
},
|
||||
|
||||
@@ -37,15 +37,13 @@
|
||||
<block wx:if="{{ item.connected }}">
|
||||
<!-- 已连接:单按钮居中 -->
|
||||
<view class="card-actions card-actions-single">
|
||||
<view class="btn-ghost-full" bind:tap="onTapMember">成员管理</view>
|
||||
<view class="btn-ghost-full" bind:tap="onTapMember">用户管理</view>
|
||||
</view>
|
||||
</block>
|
||||
<block wx:else>
|
||||
<!-- 未连接:双按钮 连接 / 成员管理 -->
|
||||
<!-- 未连接:双按钮 连接 / 用户管理 -->
|
||||
<view class="card-actions card-actions-single">
|
||||
<view class="btn-ghost-full" data-connect-device-info="{{ item.connectDeviceInfo }}" data-user-info="{{ item }}" bind:tap="onTapConnect">连接</view>
|
||||
<!-- <view class="btn-ghost-half" data-connect-device-info="{{ item.connectDeviceInfo }}" data-user-info="{{ item }}" bind:tap="onTapConnect">连接</view>-->
|
||||
<!-- <view class="btn-ghost-half" bind:tap="onTapMember">成员管理</view>-->
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"navigationBarTitleText": "设备成员",
|
||||
"navigationBarTitleText": "设备用户",
|
||||
"usingComponents": {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user