From 96b75c6caba3380bb00380c1524a5256a28bc730 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com> Date: Tue, 13 Jan 2026 15:29:12 +0800 Subject: [PATCH] =?UTF-8?q?fix(user):=20=E4=BC=98=E5=8C=96=E5=AE=9E?= =?UTF-8?q?=E5=90=8D=E8=AE=A4=E8=AF=81=E5=AE=A1=E6=A0=B8=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E5=B9=B6=E4=BF=AE=E5=A4=8D=E6=9D=83=E9=99=90=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 重构 onPass 和 onReject 方法,添加异常处理和 Promise 确保操作顺序 - 修复实名认证状态显示问题,当 statusText 为空时显示默认状态文本 - 更新权限检查逻辑,将固定存储检查改为角色权限动态验证 - 修复组织机构筛选逻辑,区分站点角色和商户角色的数据权限范围 - 添加商户角色的多组织机构查询支持,完善数据隔离机制 --- src/hjm/list.tsx | 10 ++-- src/user/userVerify/admin.tsx | 97 +++++++++++++++++++++-------------- 2 files changed, 66 insertions(+), 41 deletions(-) diff --git a/src/hjm/list.tsx b/src/hjm/list.tsx index 903daef..93c1574 100644 --- a/src/hjm/list.tsx +++ b/src/hjm/list.tsx @@ -33,7 +33,7 @@ const List = () => { const loadList = async (pageNum: number, isRefresh = false) => { if (loading) return; - + setLoading(true) // 搜索条件 const where = {status: 1, deleted: 0, keywords, page: pageNum, limit: 10} @@ -47,7 +47,7 @@ const List = () => { // @ts-ignore where.driverId = user.userId; } - if(roleCode == 'zhandian'){ + if(roleCode == 'zhandian' && user.merchants == null){ // @ts-ignore where.organizationId = user.organizationId; } @@ -59,6 +59,10 @@ const List = () => { // @ts-ignore where.installerId = user.userId; } + if(user.merchants != null){ + // @ts-ignore + where.organizationIds = user.merchants; + } if(roleCode == 'user'){ setLoading(false) return false; @@ -152,4 +156,4 @@ const List = () => { ) } -export default List \ No newline at end of file +export default List diff --git a/src/user/userVerify/admin.tsx b/src/user/userVerify/admin.tsx index 1bc8924..4398597 100644 --- a/src/user/userVerify/admin.tsx +++ b/src/user/userVerify/admin.tsx @@ -98,50 +98,71 @@ const UserVerifyAdmin: React.FC = () => { // 检查是否有特定角色 const hasRole = (roleCode: string) => { if (!user || !user.roles) { - return false; + return false } - return user.roles.some(role => role.roleCode === roleCode); - }; + return user.roles.some(role => role.roleCode === roleCode) + } const onPass = async (item: UserVerify) => { - const role = await listUserRole({roleId: 1701,userId: item.userId}) - const userRole = role[0]; - // 审核通过 - updateUserVerify({ - ...item, - status: 1 - }).then(() => { - if(userRole){ - updateUserRole({ - ...userRole, - roleId: 1738 - }) - } - Taro.showToast({ - title: '操作成功', - icon: 'success' - }) - reload().then() + try { + const role = await listUserRole({roleId: 1701, userId: item.userId}) + const userRole = role[0] + + // 审核通过 - 先更新实名认证状态 + await updateUserVerify({ + ...item, + status: 1 + }) + + // 再更新用户角色(如果存在对应角色) + if (userRole) { + await updateUserRole({ + ...userRole, + roleId: 1738 }) + } + + Taro.showToast({ + title: '操作成功', + icon: 'success' + }) + await reload(false) + } catch (error: any) { + console.error('审核通过失败:', error) + Taro.showToast({ + title: error?.message || '操作失败', + icon: 'error' + }) + } } const onReject = async (item: UserVerify) => { - const role = await listUserRole({roleId: 1738,userId: item.userId}) - const userRole = role[0]; - if(userRole){ - userRole.roleId = 1701; - updateUserRole(userRole).then(() => { - updateUserVerify({ - ...item, - status: 2 - }).then(() => { - Taro.showToast({ - title: '操作成功', - icon: 'success' - }) - reload().then() - }) + try { + const role = await listUserRole({roleId: 1738, userId: item.userId}) + const userRole = role[0] + + // 审核驳回 - 先恢复用户角色(如果存在) + if (userRole) { + userRole.roleId = 1701 + await updateUserRole(userRole) + } + + await updateUserVerify({ + ...item, + status: 2 + }) + + Taro.showToast({ + title: '操作成功', + icon: 'success' + }) + await reload(false) + } catch (error: any) { + console.error('审核驳回失败:', error) + Taro.showToast({ + title: error?.message || '操作失败', + icon: 'error' }) } } @@ -297,7 +318,7 @@ const UserVerifyAdmin: React.FC = () => { fontSize: '12px' }} > - {item.statusText} + {item.statusText || statusDisplay.text} @@ -317,7 +338,7 @@ const UserVerifyAdmin: React.FC = () => { } )} - {Taro.getStorageSync('kuaidi') && ( + {(hasRole('admin') || hasRole('kuaidi') || hasRole('zhandian')) && (