diff --git a/src/hjm/location.tsx b/src/hjm/location.tsx index c0d5b4a..926c5c0 100644 --- a/src/hjm/location.tsx +++ b/src/hjm/location.tsx @@ -57,8 +57,11 @@ const Location = () => { getHjmCarByCode(keywords).then(data => { console.log('执行搜索', data) setItem(data) - setLatitude(data.latitude) - setLongitude(data.longitude) + // setLatitude(data.latitude) + // setLongitude(data.longitude) + // wgs48坐标转gcj02坐标代 + + setKeywords(data.code) if (data.fence) { // 方法2:使用实际的 fence 数据(如果是字符串格式) diff --git a/src/pages/user/components/UserCard.tsx b/src/pages/user/components/UserCard.tsx index 12a4c28..0150825 100644 --- a/src/pages/user/components/UserCard.tsx +++ b/src/pages/user/components/UserCard.tsx @@ -8,7 +8,6 @@ import navTo from "@/utils/common"; function UserCard() { const [IsLogin, setIsLogin] = useState(false) const [userInfo, setUserInfo] = useState() - const [roleName, setRoleName] = useState('注册用户') useEffect(() => { @@ -51,11 +50,6 @@ function UserCard() { } }) } - // 判断身份 - const roleName = Taro.getStorageSync('RoleName'); - if(roleName){ - setRoleName(roleName) - } } }).catch(() => { console.log('未登录') @@ -98,6 +92,44 @@ function UserCard() { }); }; + // 获取用户显示的角色(同步版本) + const getRoleName = () => { + if(hasRole('superAdmin')){ + return '超级管理员'; + } + if(hasRole('admin')){ + return '管理员'; + } + if(hasRole('jiaojing')){ + return '交警'; + } + if(hasRole('youzheng')){ + return '邮政协会/管局'; + } + if(hasRole('Installer')){ + return '安装人员'; + } + if(hasRole('kuaidi')){ + return '快递公司'; + } + if(hasRole('zhandian')){ + return '快递站点'; + } + if(hasRole('kuaidiyuan')){ + return '快递员'; + } + return '注册用户'; + } + + + // 检查是否有特定角色 + const hasRole = (roleCode: string) => { + if (!userInfo || !userInfo.roles) { + return false; + } + return userInfo.roles.some(role => role.roleCode === roleCode); + }; + return ( <>
@@ -127,7 +159,7 @@ function UserCard() { {IsLogin ? ( -
{roleName || '注册用户'}
+
{getRoleName()}
{/*{*/} {/* userInfo?.organizationName && (*/} diff --git a/src/user/userVerify/admin.tsx b/src/user/userVerify/admin.tsx index 0ac71bf..1bc8924 100644 --- a/src/user/userVerify/admin.tsx +++ b/src/user/userVerify/admin.tsx @@ -13,6 +13,7 @@ import {UserVerify} from "@/api/system/userVerify/model"; import {pageUserVerify, updateUserVerify} from "@/api/system/userVerify"; import {listUserRole, updateUserRole} from "@/api/system/userRole"; import {listOrganizations} from "@/api/system/organization"; +import {useUser} from "@/hooks/useUser"; /** @@ -24,7 +25,9 @@ const UserVerifyAdmin: React.FC = () => { const [keywords, setKeywords] = useState('') // const [showTextArea, setShowTextArea] = useState(false) const [refreshing, setRefreshing] = useState(false) + const {user} = useUser() console.log(refreshing) + // 获取状态显示 const getStatusDisplay = (status?: number) => { switch (status) { @@ -92,6 +95,15 @@ const UserVerifyAdmin: React.FC = () => { setKeywords(value) } + // 检查是否有特定角色 + const hasRole = (roleCode: string) => { + if (!user || !user.roles) { + return false; + } + 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]; @@ -305,12 +317,12 @@ const UserVerifyAdmin: React.FC = () => { }
)} - - - - - - + {Taro.getStorageSync('kuaidi') && ( + + + + + )} {/*{showTextArea && (*/} {/*