Compare commits

...
3 Commits
Author SHA1 Message Date
17792275749andClaude Sonnet 4.6 8d69249147 feat: 接口错误处理增强,统一打印并展示后端错误信息
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-09-01 16:57:28 +08:00
17792275749andClaude Sonnet 4.6 85523109f6 feat(userManagement): 添加用户上限 10 位校验
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-09-01 16:57:19 +08:00
17792275749andClaude Sonnet 4.6 b90c79df9f feat(userManagementSync): 同步弹框增加转圈圈与完成对勾
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-09-01 16:56:46 +08:00
8 changed files with 78 additions and 20 deletions
@@ -135,8 +135,9 @@ Component({
})) }))
this.setData({ members }) this.setData({ members })
}) })
.catch(() => { .catch((err: any) => {
wx.showToast({ title: '加载失败', icon: 'none' }) console.error('[selectMemberDrawer] 加载成员失败:', err)
wx.showToast({ title: err?.msg || err?.message || '加载失败', icon: 'none' })
}) })
.finally(() => { .finally(() => {
wx.hideLoading() wx.hideLoading()
@@ -159,8 +160,9 @@ Component({
})) }))
this.setData({ members }) this.setData({ members })
}) })
.catch(() => { .catch((err: any) => {
wx.showToast({ title: '加载失败', icon: 'none' }) console.error('[selectMemberDrawer] 加载成员失败:', err)
wx.showToast({ title: err?.msg || err?.message || '加载失败', icon: 'none' })
}) })
.finally(() => { .finally(() => {
wx.hideLoading() wx.hideLoading()
@@ -23,11 +23,34 @@
align-items: center; align-items: center;
padding: 64rpx 48rpx; padding: 64rpx 48rpx;
.sync-spinner {
width: 96rpx;
height: 96rpx;
border: 8rpx solid rgba(19, 133, 250, 0.1);
border-top-color: #1385FA;
border-radius: 50%;
animation: sync-spin 1s linear infinite;
}
.sync-tick {
width: 96rpx;
height: 96rpx;
border: 8rpx solid #1385FA;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
color: #1385FA;
font-size: 56rpx;
line-height: 56rpx;
}
.sync-title { .sync-title {
color: #252535; color: #252535;
height: 32rpx; height: 32rpx;
font-size: 32rpx; font-size: 32rpx;
line-height: 32rpx; line-height: 32rpx;
margin-top: 40rpx;
} }
.sync-status { .sync-status {
@@ -61,3 +84,13 @@
} }
} }
} }
@keyframes sync-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
@@ -1,6 +1,12 @@
<block wx:if="{{ show }}"> <block wx:if="{{ show }}">
<view class="sync-mask"></view> <view class="sync-mask"></view>
<view class="sync-panel"> <view class="sync-panel">
<block wx:if="{{ percent === 100 }}">
<view class="sync-tick">✓</view>
</block>
<block wx:else>
<view class="sync-spinner"></view>
</block>
<view class="sync-title">同步成员至设备</view> <view class="sync-title">同步成员至设备</view>
<view class="sync-status">{{ status }}</view> <view class="sync-status">{{ status }}</view>
<view class="sync-percent">{{ percent }}%</view> <view class="sync-percent">{{ percent }}%</view>
+6 -4
View File
@@ -101,8 +101,9 @@ Page({
}) })
} }
}) })
.catch(() => { .catch((err: any) => {
wx.showToast({ title: '加载用户信息失败', icon: 'none' }) console.error('[addUser] 加载用户信息失败:', err)
wx.showToast({ title: err?.msg || err?.message || '加载用户信息失败', icon: 'none' })
}) })
}, },
@@ -378,8 +379,9 @@ Page({
prevPage?._loadMembers?.() prevPage?._loadMembers?.()
setTimeout(() => wx.navigateBack(), 1500) setTimeout(() => wx.navigateBack(), 1500)
}) })
.catch(() => { .catch((err: any) => {
wx.showToast({ title: '添加失败,请重试', icon: 'none' }) console.error('[addUser] 添加用户失败:', err)
wx.showToast({ title: err?.msg || err?.message || '添加失败,请重试', icon: 'none' })
}) })
}, },
}) })
+3 -2
View File
@@ -199,8 +199,9 @@ Page({
hasMore: allRecords.length < this.data.total, hasMore: allRecords.length < this.data.total,
}) })
}) })
.catch(() => { .catch((err: any) => {
wx.showToast({ title: '加载失败,请重试', icon: 'none' }) console.error('[data] 加载历史数据失败:', err)
wx.showToast({ title: err?.msg || err?.message || '加载失败,请重试', icon: 'none' })
}) })
.finally(() => { .finally(() => {
wx.hideLoading() wx.hideLoading()
+1
View File
@@ -32,6 +32,7 @@ Page({
wx.reLaunch({ url: '/pages/supplementPersonal/supplementPersonal' }) wx.reLaunch({ url: '/pages/supplementPersonal/supplementPersonal' })
} }
}).catch((err) => { }).catch((err) => {
console.error('[login] 登录失败:', err)
wx.showToast({ title: err.msg || '登录失败,请重试', icon: 'none' }) wx.showToast({ title: err.msg || '登录失败,请重试', icon: 'none' })
}).finally(() => { }).finally(() => {
this.setData({ loading: false }) this.setData({ loading: false })
@@ -149,8 +149,9 @@ Page({
}).then((res) => { }).then((res) => {
wx.setStorageSync('userInfo', res.result) wx.setStorageSync('userInfo', res.result)
wx.switchTab({ url: '/pages/home/home' }) wx.switchTab({ url: '/pages/home/home' })
}).catch(() => { }).catch((err: any) => {
wx.showToast({ title: '保存失败,请重试', icon: 'none' }) console.error('[supplementPersonal] 保存失败:', err)
wx.showToast({ title: err?.msg || err?.message || '保存失败,请重试', icon: 'none' })
}) })
}, },
}) })
@@ -167,8 +167,9 @@ Page({
hasData: list.length > 0, hasData: list.length > 0,
}) })
}) })
.catch(() => { .catch((err: any) => {
wx.showToast({ title: '加载用户列表失败', icon: 'none' }) console.error('[userManagement] 加载用户列表失败:', err)
wx.showToast({ title: err?.msg || err?.message || '加载用户列表失败', icon: 'none' })
}) })
}, },
@@ -295,8 +296,9 @@ Page({
// 先读设备端主用户列表,判断设备是否已有主用户 // 先读设备端主用户列表,判断设备是否已有主用户
leFuService.fetchDeviceUserIds() leFuService.fetchDeviceUserIds()
.then((deviceUserIds) => this._syncUsers(pendingUsers, deviceUserIds)) .then((deviceUserIds) => this._syncUsers(pendingUsers, deviceUserIds))
.catch(() => { .catch((err: any) => {
wx.showToast({ title: '读取设备用户失败', icon: 'none' }) console.error('[userManagement] 读取设备用户失败:', err)
wx.showToast({ title: err?.message || '读取设备用户失败', icon: 'none' })
}) })
}, },
@@ -383,6 +385,10 @@ Page({
/** 添加用户 */ /** 添加用户 */
onTapAddUser() { onTapAddUser() {
if (this.data.memberCount >= 10) {
wx.showToast({ title: '最多添加10位用户', icon: 'none' })
return
}
const sn = targetDevice?.sn || '' const sn = targetDevice?.sn || ''
wx.navigateTo({ url: `/pages/addUser/addUser?sn=${encodeURIComponent(sn)}` }) wx.navigateTo({ url: `/pages/addUser/addUser?sn=${encodeURIComponent(sn)}` })
}, },
@@ -410,8 +416,9 @@ Page({
wx.showToast({ title: '删除成功', icon: 'success' }) wx.showToast({ title: '删除成功', icon: 'success' })
this._loadMembers() this._loadMembers()
}) })
.catch(() => { .catch((err: any) => {
wx.showToast({ title: '删除失败,请重试', icon: 'none' }) console.error('[userManagement] 删除成员失败:', err)
wx.showToast({ title: err?.msg || err?.message || '删除失败,请重试', icon: 'none' })
}) })
}, },
}) })
@@ -419,6 +426,10 @@ Page({
/** 一键添加本人:仅调接口把当前登录用户添加为设备成员,不下发设备 */ /** 一键添加本人:仅调接口把当前登录用户添加为设备成员,不下发设备 */
onTapAddSelf() { onTapAddSelf() {
if (this.data.memberCount >= 10) {
wx.showToast({ title: '最多添加10位用户', icon: 'none' })
return
}
const userInfo = wx.getStorageSync('userInfo') as Record<string, any> | null const userInfo = wx.getStorageSync('userInfo') as Record<string, any> | null
if (!userInfo?.userId) { if (!userInfo?.userId) {
wx.showToast({ title: '请先完善个人信息', icon: 'none' }) wx.showToast({ title: '请先完善个人信息', icon: 'none' })
@@ -444,8 +455,9 @@ Page({
wx.showToast({ title: '添加成功', icon: 'success' }) wx.showToast({ title: '添加成功', icon: 'success' })
this._loadMembers() this._loadMembers()
}) })
.catch(() => { .catch((err: any) => {
wx.showToast({ title: '添加失败,请重试', icon: 'none' }) console.error('[userManagement] 添加本人失败:', err)
wx.showToast({ title: err?.msg || err?.message || '添加失败,请重试', icon: 'none' })
}) })
}, },