diff --git a/src/api/hjm/hjmBxLog/model/index.ts b/src/api/hjm/hjmBxLog/model/index.ts index 5f1521e..c105e65 100644 --- a/src/api/hjm/hjmBxLog/model/index.ts +++ b/src/api/hjm/hjmBxLog/model/index.ts @@ -37,5 +37,6 @@ export interface HjmBxLog { */ export interface HjmBxLogParam extends PageParam { id?: number; + userId?: number; keywords?: string; } diff --git a/src/api/hjm/hjmCar/index.ts b/src/api/hjm/hjmCar/index.ts index afd9d81..f37006f 100644 --- a/src/api/hjm/hjmCar/index.ts +++ b/src/api/hjm/hjmCar/index.ts @@ -137,3 +137,16 @@ export async function pushSubscriptionMessages(data: any) { } return Promise.reject(new Error(res.message)); } + +/** + * 启动mqtt服务 + */ +export async function mqttStart() { + const res = await request.get>( + '/hjm/hjm-car/mqtt' + ); + if (res.code === 0) { + return res.data; + } + return Promise.reject(new Error(res.message)); +} diff --git a/src/api/hjm/hjmCar/model/index.ts b/src/api/hjm/hjmCar/model/index.ts index 2eaff71..dc0c1d2 100644 --- a/src/api/hjm/hjmCar/model/index.ts +++ b/src/api/hjm/hjmCar/model/index.ts @@ -18,6 +18,7 @@ export interface HjmCar { // 管理负责人 kuaidiAdmin?: string; organization?: string; + organizationId?: number; organizationParentId?: number; parentOrganization?: string; parentOrganizationAdmin?: string; @@ -27,10 +28,14 @@ export interface HjmCar { driverId?: number; // 操作员 driver?: any; + // 操作员名称 + driverName?: string; // 保险状态 insuranceStatus?: number; // GPS设备编号 gpsNo?: string; + // 速度 + speed?: string; // 电子围栏ID fenceId?: number; // 电子围栏名称 @@ -61,6 +66,8 @@ export interface HjmCar { createTime?: string; // 更新时间 updateTime?: string; + // 是否在电子围栏内 + inFence?: boolean; } /** @@ -70,6 +77,8 @@ export interface HjmCarParam extends PageParam { id?: number; userId?: number; driverId?: number; + organizationId?: number; + organizationParentId?: number; status?: number; latitude?: number; longitude?: number; diff --git a/src/api/system/organization/index.ts b/src/api/system/organization/index.ts index 64ea42f..fbfede2 100644 --- a/src/api/system/organization/index.ts +++ b/src/api/system/organization/index.ts @@ -71,3 +71,16 @@ export async function removeOrganization(id?: number) { } return Promise.reject(new Error(res.message)); } + +/** + * 根据id查询机构 + */ +export async function getOrganization(id: number) { + const res = await request.get>( + SERVER_API_URL + '/system/organization/' + id + ); + if (res.code === 0 && res.data) { + return res.data; + } + return Promise.reject(new Error(res.message)); +} diff --git a/src/api/system/parameter/index.ts b/src/api/system/parameter/index.ts index 0de22cd..0dfba32 100644 --- a/src/api/system/parameter/index.ts +++ b/src/api/system/parameter/index.ts @@ -1,7 +1,7 @@ import request from '@/utils/request'; import type { ApiResult, PageResult } from '@/api/index'; import type { Parameter, ParameterParam } from './model'; -import {SERVER_API_URL} from '@/config/index'; +import {SERVER_API_URL} from "@/utils/server"; /** * 分页查询应用参数 diff --git a/src/api/system/userRole/index.ts b/src/api/system/userRole/index.ts new file mode 100644 index 0000000..3dfa2e1 --- /dev/null +++ b/src/api/system/userRole/index.ts @@ -0,0 +1,32 @@ +import request from '@/utils/request'; +import type { ApiResult } from '@/api/index'; +import type { UserRole, UserRoleParam } from './model'; +import {SERVER_API_URL} from "@/utils/server"; + +/** + * 查询用户角色 + */ +export async function listUserRole(params?: UserRoleParam) { + const res = await request.get>( + SERVER_API_URL + '/system/user-role', + params + ); + if (res.code === 0 && res.data) { + return res.data; + } + return Promise.reject(new Error(res.message)); +} + +/** + * 修改用户角色 + */ +export async function updateUserRole(data: UserRole) { + const res = await request.put>( + SERVER_API_URL + '/system/user-role', + data + ); + if (res.code === 0) { + return res.message; + } + return Promise.reject(new Error(res.message)); +} diff --git a/src/api/system/userRole/model/index.ts b/src/api/system/userRole/model/index.ts new file mode 100644 index 0000000..926bf9b --- /dev/null +++ b/src/api/system/userRole/model/index.ts @@ -0,0 +1,28 @@ +import type { PageParam } from '@/api'; + +/** + * 用户 + */ +export interface UserRole { + id?: number; + // 用户id + userId?: number; + // 角色ID + roleId?: number; + // 创建时间 + createTime?: string; + // 修改时间 + updateTime?: string; + // 角色名称 + roleName?: string; + // 租户ID + tenantId?: number; +} + +/** + * 用户搜索条件 + */ +export interface UserRoleParam extends PageParam { + keywords?: any; + userId?: number; +} diff --git a/src/app.ts b/src/app.ts index b60462a..9475559 100644 --- a/src/app.ts +++ b/src/app.ts @@ -6,9 +6,13 @@ import './app.scss' import {loginByOpenId} from "@/api/layout"; import {TenantId} from "@/utils/config"; import {saveStorageByLoginUser} from "@/utils/server"; +import {mqttStart} from "@/api/hjm/hjmCar"; function App(props) { const reload = () => { + mqttStart().then(res => { + console.log(res, 'mqttStart') + }) Taro.login({ success: (res) => { loginByOpenId({ diff --git a/src/hjm/BestSellers.tsx b/src/hjm/BestSellers.tsx index 1ab0a97..5136f7d 100644 --- a/src/hjm/BestSellers.tsx +++ b/src/hjm/BestSellers.tsx @@ -27,6 +27,8 @@ const BestSellers = (props: any) => {
{item.code}
快递公司:{item.parentOrganization}
+
所属站点:{item.organization}
保险状态:{item.insuranceStatus}
绑定操作员: { setRefreshing(true) const res = await pageHjmBxLog({ - keywords: keywords.trim() + keywords: keywords.trim(), + userId: Taro.getStorageSync('UserId') }) setList(res?.list.map(d => { @@ -85,7 +86,7 @@ const Bx: React.FC = () => { } useEffect(() => { - reload() + reload().then() }, []) return ( diff --git a/src/hjm/list.tsx b/src/hjm/list.tsx index 31b42d4..9338fc3 100644 --- a/src/hjm/list.tsx +++ b/src/hjm/list.tsx @@ -3,6 +3,7 @@ import {Search} from '@nutui/icons-react-taro' import {Button, Input, InfiniteLoading} from '@nutui/nutui-react-taro' import {pageHjmCar} from "@/api/hjm/hjmCar"; import {HjmCar} from "@/api/hjm/hjmCar/model"; +import Taro from '@tarojs/taro' import './location.scss' import BestSellers from "./BestSellers"; @@ -19,8 +20,25 @@ const List = () => { } const reload = () => { + // 搜索条件 + const where = {status: 1,deleted: 0, keywords} + // 判断身份 + const roleCode = Taro.getStorageSync('RoleCode'); + if(roleCode == 'kuaidiyuan'){ + // @ts-ignore + where.driverId = Taro.getStorageSync('UserId') + } + if(roleCode == 'zhandian'){ + // @ts-ignore + where.organizationId = Taro.getStorageSync('OrganizationId'); + } + if(roleCode == 'kuaidi'){ + // @ts-ignore + where.organizationParentId = Taro.getStorageSync('OrganizationParentId'); + } + // 获取车辆列表 - pageHjmCar({status: 1,deleted: 0, keywords}).then(res => { + pageHjmCar(where).then(res => { setList(res?.list || []) }) } diff --git a/src/hjm/location.tsx b/src/hjm/location.tsx index c32e29f..c0d5b4a 100644 --- a/src/hjm/location.tsx +++ b/src/hjm/location.tsx @@ -170,15 +170,18 @@ const Location = () => { {item ? (
-
- 最后更新时间:{item?.updateTime} -
- 操作员:{item?.driver} + 操作人员:{item?.driver} +
+
+ 电子围栏:{item?.fenceName} ({item?.inFence ? '围栏内' : '围栏外'}) +
+
+ 当前车速:{item?.speed} +
+
+ 更新时间:{item?.updateTime}
- {/*
*/} - {/* 位置信息:{item?.address}*/} - {/*
*/}
) : ''} @@ -192,8 +195,16 @@ const Location = () => { id: 1, latitude: latitude, longitude: longitude, - // @ts-ignore - name: '位置' + label: { + content: `${item?.code}`, + color: '#000000', + fontSize: 12, + borderRadius: 5, + bgColor: '#FFFFFF', + // @ts-ignore + padding: '5px 5px', + borderWidth: 1 + }, }]} polygons={points.length > 0 ? [ { diff --git a/src/hjm/query.tsx b/src/hjm/query.tsx index d078728..1139294 100644 --- a/src/hjm/query.tsx +++ b/src/hjm/query.tsx @@ -19,6 +19,9 @@ import {Scan} from '@nutui/icons-react-taro' import {pageDictData} from "@/api/system/dict-data"; import {DictData} from "@/api/system/dict-data/model"; import {myUserVerify} from "@/api/system/userVerify"; +import {listUserRole, updateUserRole} from "@/api/system/userRole"; +import {UserRole} from "@/api/system/userRole/model"; +import {updateUser} from "@/api/system/user"; // 图片数据接口 interface UploadedImageData { @@ -40,6 +43,7 @@ const Query = () => { const [dict, setDict] = useState([]) const [adminId, setAdminId] = useState() const [showPreview, setShowPreview] = useState(false) + const [userRole, setUserRole] = useState() const [fileList, setFileList] = useState([]) // 图片文件列表 const [FormData, setFormData] = useState( { @@ -117,18 +121,33 @@ const Query = () => { }); return false } - updateHjmCar({...FormData, status: 1, driverId: adminId}).then(() => { - Taro.showToast({title: `绑定成功`, icon: 'success'}) - setTimeout(() => { - reload(); - return Taro.navigateBack() - }, 1000) - }).catch(() => { - Taro.showToast({ - title: '绑定失败', - icon: 'error' - }); - }) + // 升级为快递员 + if(userRole){ + updateHjmCar({ + ...FormData, + status: 1, + driverId: adminId, + driverName: Taro.getStorageSync('RealName') + }).then(() => { + userRole.roleId = 1738; + updateUserRole(userRole).then(() => { + Taro.showToast({title: `绑定成功`, icon: 'success'}) + }) + updateUser({ + userId: Taro.getStorageSync('UserId'), + organizationId: FormData.organizationId + }).then(() => {}) + setTimeout(() => { + reload(); + return Taro.navigateBack() + }, 1000) + }).catch(() => { + Taro.showToast({ + title: '绑定失败', + icon: 'error' + }); + }) + } } const submitFailed = (error: any) => { @@ -308,6 +327,12 @@ const Query = () => { pageDictData({dictCode: 'InsuranceStatus'}).then(res => { setDict(res?.list || []) }) + // 查询角色 + listUserRole({userId: Taro.getStorageSync('UserId')}).then(res => { + if(res.length > 0){ + setUserRole(res[0]) + } + }) // 检查是否已实名 myUserVerify({status: 1}).then(data => { if (!data) { @@ -623,6 +648,9 @@ const Query = () => { 快递公司品牌:{FormData?.parentOrganization} + + 所属站点:{FormData?.organization} + 管理责任人:{FormData?.parentOrganizationAdmin} diff --git a/src/hjm/trajectory/trajectory.tsx b/src/hjm/trajectory/trajectory.tsx index 3427fee..c212061 100644 --- a/src/hjm/trajectory/trajectory.tsx +++ b/src/hjm/trajectory/trajectory.tsx @@ -20,13 +20,11 @@ const Location = () => { const [latitude, setLatitude] = useState() const [scale, setScale] = useState(16) const [showCircles, setShowCircles] = useState(false) - const [points, setPoints] = useState([]) + // const [points, setPoints] = useState([]) const [hjmGpsLog, setHjmGpsLog] = useState([]) - const [dateTime, setDateTime] = useState('') const [ddmmyy, setDdmmyy] = useState(formatCurrentDate()) const [hhmmss, setHhmmss] = useState(getCurrentHour()) const [show1, setShow1] = useState(false) - const [value, setValue] = useState(new Date()) const defaultValue = new Date() const defaultDescription = `${defaultValue.getFullYear()}年${defaultValue.getMonth() + 1}月${defaultValue.getDate()}日` const [desc1, setDesc1] = useState(defaultDescription) @@ -34,7 +32,6 @@ const Location = () => { const startDate = new Date(2025, 0, 1) const endDate = new Date(2030, 10, 1) const [show, setShow] = useState(false) - const [desc, setDesc] = useState() // 通用的坐标字符串转数组函数 const parseCoordinateString = (coordStr: string) => { @@ -105,13 +102,13 @@ const Location = () => { Taro.showLoading({title: '加载中...'}); pageHjmGpsLog(where).then(res => { console.log(res?.list, 'list') - setPoints(res?.list.map(item => { - console.log(item, 'item.') - return { - latitude: item.latitude, - longitude: item.longitude - } - }) || []) + // setPoints(res?.list.map(item => { + // console.log(item, 'item.') + // return { + // latitude: item.latitude, + // longitude: item.longitude + // } + // }) || []) setHjmGpsLog(res?.list || []); }).finally(() => { Taro.hideLoading(); @@ -190,7 +187,7 @@ const Location = () => { setShow1(false)} @@ -217,6 +214,7 @@ const Location = () => { endDate={endDate} visible={show} onClose={() => setShow(false)} + // @ts-ignore onConfirm={(options, values) => confirm(options, values)} />
diff --git a/src/pages/index/ExpirationTime.tsx b/src/pages/index/ExpirationTime.tsx index 94b29c7..284dfc3 100644 --- a/src/pages/index/ExpirationTime.tsx +++ b/src/pages/index/ExpirationTime.tsx @@ -3,19 +3,21 @@ import Taro from '@tarojs/taro' import {Button} from '@nutui/nutui-react-taro' import {Target, Scan, Truck} from '@nutui/icons-react-taro' import {getUserInfo} from "@/api/layout"; +import navTo from "@/utils/common"; const ExpirationTime = () => { + const [isAdmin, setIsAdmin] = useState(false) const [roleName, setRoleName] = useState() const onScanCode = () => { Taro.scanCode({ onlyFromCamera: true, scanType: ['qrCode'], success: (res) => { - console.log(res,'qrcode...') - Taro.navigateTo({ url: '/hjm/query?id=' + res.result }) + console.log(res, 'qrcode...') + Taro.navigateTo({url: '/hjm/query?id=' + res.result}) }, fail: (res) => { - console.log(res,'扫码失败') + console.log(res, '扫码失败') Taro.showToast({ title: '扫码失败', icon: 'none', @@ -25,11 +27,20 @@ const ExpirationTime = () => { }) } + const navToCarList = () => { + if (isAdmin) { + navTo('/hjm/list', true) + } + } + useEffect(() => { getUserInfo().then((data) => { if (data) { - data.roles?.map((item,index) => { - if(index == 0){ + if(data.certification){ + setIsAdmin( true) + } + data.roles?.map((item, index) => { + if (index == 0) { setRoleName(item.roleCode) } }) @@ -39,15 +50,31 @@ const ExpirationTime = () => { }, []) return ( -
+
- - + <> + + + + { - roleName == 'youzheng' && + roleName == 'youzheng' && } + { - roleName == 'kuaidiyuan' && + roleName == 'kuaidiyuan' && }
diff --git a/src/pages/index/Header.tsx b/src/pages/index/Header.tsx index 10ac0fb..9bd0f8f 100644 --- a/src/pages/index/Header.tsx +++ b/src/pages/index/Header.tsx @@ -5,6 +5,7 @@ import {TriangleDown} from '@nutui/icons-react-taro' import {Popup, Avatar, NavBar} from '@nutui/nutui-react-taro' import {getUserInfo} from "@/api/layout"; import {TenantId} from "@/utils/config"; +import {getOrganization} from "@/api/system/organization"; const Header = (props: any) => { const [IsLogin, setIsLogin] = useState(true) @@ -31,11 +32,22 @@ const Header = (props: any) => { if (data) { setIsLogin(true); Taro.setStorageSync('UserId', data.userId) - // 安装人员 + // 机构ID + Taro.setStorageSync('OrganizationId',data.organizationId) + // 父级机构ID + getOrganization(Number(data.organizationId)).then(res => { + Taro.setStorageSync('OrganizationParentId',res.parentId) + }) + // 是否已认证 + if(data.certification){ + Taro.setStorageSync('Certification','1') + } + // 管理员 const isKdy = data.roles?.findIndex(item => item.roleCode == 'admin') if(isKdy != -1){ - setRoleName('安装人员') - Taro.setStorageSync('RoleName', '安装人员') + setRoleName('管理员') + Taro.setStorageSync('RoleName', '管理') + Taro.setStorageSync('RoleCode', 'admin') return false; } // 交警 @@ -43,6 +55,7 @@ const Header = (props: any) => { if(isJj != -1){ setRoleName('交警') Taro.setStorageSync('RoleName', '交警') + Taro.setStorageSync('RoleCode', 'jiaojing') return false; } // 邮政协会/管局 @@ -50,6 +63,7 @@ const Header = (props: any) => { if(isYz != -1){ setRoleName('邮政协会/管局') Taro.setStorageSync('RoleName', '邮政协会/管局') + Taro.setStorageSync('RoleCode', 'youzheng') return false; } // 快递公司 @@ -57,13 +71,21 @@ const Header = (props: any) => { if(isKd != -1){ setRoleName('快递公司') Taro.setStorageSync('RoleName', '快递公司') + Taro.setStorageSync('RoleCode', 'kuaidi') return false; } + const isZD = data.roles?.findIndex(item => item.roleCode == 'zhandian') + if(isZD != -1){ + setRoleName('快递站点') + Taro.setStorageSync('RoleName', '快递站点') + Taro.setStorageSync('RoleCode', 'zhandian') + } // 快递员 const isKdyy = data.roles?.findIndex(item => item.roleCode == 'kuaidiyuan') if(isKdyy != -1){ setRoleName('快递员') Taro.setStorageSync('RoleName', '快递员') + Taro.setStorageSync('RoleCode', 'kuaidiyuan') return false; } // 注册用户 @@ -71,6 +93,7 @@ const Header = (props: any) => { if(isUser != -1){ setRoleName('注册用户') Taro.setStorageSync('RoleName', '注册用户') + Taro.setStorageSync('RoleCode', 'user') return false; } } diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index 7e9f087..6937ece 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -24,12 +24,13 @@ export interface Market { function Home() { const [IsLogin, setIsLogin] = useState(true) + const [isAdmin, setIsAdmin] = useState(false) const [search, setSearch] = useState(false) const [userInfo, setUserInfo] = useState() const [longitude, setLongitude] = useState(108.374959) const [latitude, setLatitude] = useState(22.767024) const [markers, setMarkers] = useState([]) - const [scale, setScale] = useState(16) + const [scale, setScale] = useState(12) const [keywords, setKeywords] = useState('') const [list, setList] = useState([]) @@ -108,56 +109,163 @@ function Home() { const res = await Taro.getLocation({ type: 'gcj02' //返回可以用于wx.openLocation的经纬度 }) - pageByQQMap({ - latitude: res.latitude, - longitude: res.longitude, - }).then(res => { - if (res?.list && res?.list.length > 0) { - const data = res?.list; - const arr = [] - data?.map((item: HjmCar) => { - // @ts-ignore - arr.push({ - id: item.id, - latitude: item.latitude, - longitude: item.longitude, - title: `${item.organization}`, - name: item.organization - }) - }) - setMarkers(arr) - } - }) if (res.latitude) { setLatitude(res.latitude) } if (res.longitude) { setLongitude(res.longitude) } - console.log(res) - console.log('当前位置:', res.latitude, res.longitude); + + // 已认证用户 + if(Taro.getStorageSync('Certification')){ + setIsAdmin(true) + setScale(11) + pageHjmCarByMap(res.latitude,res.longitude) + } + + // 游客 + if(!Taro.getStorageSync('access_token')){ + setScale(15) + const arr = [] + // @ts-ignore + arr.push({ + id: 10001, + latitude: res.latitude, + longitude: res.longitude, + title: '当前位置', + name: '当前位置' + }) + setMarkers(arr) + } return res; } catch (err) { console.error('获取位置失败:', err); } } + const onQuery = () => { + if(!keywords){ + Taro.showToast({ + title: '请输入关键字', + icon: 'none' + }); + return false; + } + reload(); + } + + const pageHjmCarByMap = (latitude?: any,longitude?: any) => { + // 搜索条件 + const where = {} + + if(latitude){ + // @ts-ignore + where.latitude = latitude + } + if(longitude){ + // @ts-ignore + where.longitude = longitude + } + // 判断身份 + const roleCode = Taro.getStorageSync('RoleCode'); + if(roleCode == 'kuaidiyuan'){ + // @ts-ignore + where.driverId = Taro.getStorageSync('UserId') + } + if(roleCode == 'zhandian'){ + // @ts-ignore + where.organizationId = Taro.getStorageSync('OrganizationId'); + } + if(roleCode == 'kuaidi'){ + // @ts-ignore + where.organizationParentId = Taro.getStorageSync('OrganizationParentId'); + } + + pageByQQMap(where).then(res => { + console.log(res,'pageByQQMap') + if(res?.count == 0){ + const arr = [] + // @ts-ignore + arr.push({ + id: 10001, + latitude: 22.813371, + longitude: 108.323885, + title: '当前位置', + name: '当前位置' + }) + setMarkers(arr) + return false + } + if (res?.list && res?.list.length > 0) { + const data = res?.list; + const arr = [] + data?.map((item: HjmCar) => { + // @ts-ignore + arr.push({ + id: item.id, + latitude: item.latitude, + longitude: item.longitude, + label: { + content: `${item?.code}`, + color: '#000000', + fontSize: 12, + borderRadius: 5, + bgColor: '#FFFFFF', + // @ts-ignore + padding: '5px 5px', + borderWidth: 1 + }, + title: `${item.organization}`, + name: item.organization + }) + }) + setMarkers(arr) + } + }) + } + const reload = () => { + if(!Taro.getStorageSync('access_token')){ + return false; + } + if(!isAdmin){ + return false; + } setMarkers([]) + setScale(12) pageHjmCar({keywords,deleted: 0}).then(res => { + if(res?.count == 0){ + Taro.showToast({ + title: '没有搜索结果', + icon: 'none' + }); + return false + } setList(res?.list || []) if (res?.list && res?.list.length > 0) { - setScale(16) const data = res?.list[0]; setLongitude(data?.longitude) setLatitude(data?.latitude) - setMarkers([{ - id: data.id, - latitude: data.latitude, - longitude: data.longitude, - title: `${data.organization}`, - name: `${data.organization}` - }]) + if(isAdmin){ + setMarkers([{ + id: data.id, + latitude: data.latitude, + longitude: data.longitude, + // @ts-ignore + label: { + content: `${data?.code}`, + color: '#000000', + fontSize: 12, + borderRadius: 5, + bgColor: '#FFFFFF', + // @ts-ignore + padding: '5px 5px', + borderWidth: 1 + }, + title: `${data.organization}`, + name: `${data.organization}` + }]) + } } console.log(list.length,'carList.length') }) @@ -165,7 +273,6 @@ function Home() { useEffect(() => { // Taro.hideTabBar() - setScale(14) getLocation().then() // 获取站点信息 getSiteInfo().then((data) => { @@ -199,6 +306,11 @@ function Home() { }) getUserInfo().then((data) => { if (data) { + // 是否管理员 + console.log(data.certification, 'certification') + if(data.certification){ + setIsAdmin(true) + } setUserInfo(data) setIsLogin(true); Taro.setStorageSync('UserId', data.userId) @@ -241,12 +353,12 @@ function Home() { placeholder="车辆编号" value={keywords} onChange={onKeywords} - onConfirm={reload} + onConfirm={onQuery} />
-
diff --git a/src/pages/study/study.tsx b/src/pages/study/study.tsx index ed6ffcc..a77a2bf 100644 --- a/src/pages/study/study.tsx +++ b/src/pages/study/study.tsx @@ -5,18 +5,26 @@ import {pageCmsArticle} from "@/api/cms/cmsArticle"; import {CmsArticle} from "@/api/cms/cmsArticle/model"; import {checkMonthTaskCompleted} from "@/api/hjm/hjmExamLog"; import Questions from '@/components/Questions'; +import {getUserInfo} from "@/api/layout"; /** * 文章终极列表 * @constructor */ const Study = () => { + const [isAdmin, setIsAdmin] = useState(false) const [loading, setLoading] = useState(false) const [list, setList] = useState() const [monthTaskCompleted, setMonthTaskCompleted] = useState(false) const reload = () => { setLoading(true) + getUserInfo().then((data) => { + console.log(data) + if(data.certification){ + setIsAdmin(true) + } + }) checkMonthTaskCompleted().then(res => { if (res) { setMonthTaskCompleted(true) @@ -34,29 +42,33 @@ const Study = () => { }, []) return ( -
- {/* 已完成任务 */} - {monthTaskCompleted && !loading && ( -
-

🎉 - 本月学习任务已完成!

-
- 您已经完成了本月的学习任务,无需再进行考试。 -
+ <> + {isAdmin && ( +
+ {/* 已完成任务 */} + {monthTaskCompleted && !loading && ( +
+

🎉 + 本月学习任务已完成!

+
+ 您已经完成了本月的学习任务,无需再进行考试。 +
+
+ )} + { + !monthTaskCompleted && list?.map((item, index) => { + return ( +
Taro.navigateTo({url: `/hjm/video/video?id=${item.articleId}`})}> + +
+ ) + }) + }
)} - { - !monthTaskCompleted && list?.map((item, index) => { - return ( -
Taro.navigateTo({url: `/hjm/video/video?id=${item.articleId}`})}> - -
- ) - }) - } - {list?.length == 0 && } -
+ {!isAdmin && } + ) } export default Study