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')) && (