完成:黄家明项目的开发并存档

This commit is contained in:
2025-06-17 12:21:15 +08:00
parent 942143c678
commit d37e9509c1
18 changed files with 437 additions and 105 deletions

View File

@@ -37,5 +37,6 @@ export interface HjmBxLog {
*/
export interface HjmBxLogParam extends PageParam {
id?: number;
userId?: number;
keywords?: string;
}

View File

@@ -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<ApiResult<unknown>>(
'/hjm/hjm-car/mqtt'
);
if (res.code === 0) {
return res.data;
}
return Promise.reject(new Error(res.message));
}

View File

@@ -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;

View File

@@ -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<ApiResult<Organization>>(
SERVER_API_URL + '/system/organization/' + id
);
if (res.code === 0 && res.data) {
return res.data;
}
return Promise.reject(new Error(res.message));
}

View File

@@ -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";
/**
* 分页查询应用参数

View File

@@ -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<ApiResult<UserRole[]>>(
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<ApiResult<unknown>>(
SERVER_API_URL + '/system/user-role',
data
);
if (res.code === 0) {
return res.message;
}
return Promise.reject(new Error(res.message));
}

View File

@@ -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;
}

View File

@@ -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({

View File

@@ -27,6 +27,8 @@ const BestSellers = (props: any) => {
<div className={'car-no text-lg font-bold'}>{item.code}</div>
<div className={'flex text-xs text-gray-500'}><span
className={'text-gray-700'}>{item.parentOrganization}</span></div>
<div className={'flex text-xs text-gray-500'}><span
className={'text-gray-700'}>{item.organization}</span></div>
<div className={'flex text-xs text-gray-500'}><span className={'text-green-600'}>{item.insuranceStatus}</span>
</div>
<div className={'flex text-xs text-gray-500'}><span

View File

@@ -43,7 +43,8 @@ const Bx: React.FC = () => {
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 (

View File

@@ -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 || [])
})
}

View File

@@ -170,15 +170,18 @@ const Location = () => {
{item ? (
<div className={'car-info fixed bottom-0 left-0 w-full z-20 bg-white p-4'}>
<div className={'car-info-item'}>
<div className={'car-info-item-title'}>
{item?.updateTime}
</div>
<div className={'car-info-item-content'}>
{item?.driver}
{item?.driver}
</div>
<div className={'car-info-item-content pr-6'}>
{item?.fenceName} ({item?.inFence ? '围栏内' : '围栏外'})
</div>
<div className={'car-info-item-content pr-6'}>
{item?.speed}
</div>
<div className={'car-info-item-title'}>
{item?.updateTime}
</div>
{/*<div className={'car-info-item-content pr-6'}>*/}
{/* 位置信息:{item?.address}*/}
{/*</div>*/}
</div>
</div>
) : ''}
@@ -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 ? [
{

View File

@@ -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<DictData[]>([])
const [adminId, setAdminId] = useState<number>()
const [showPreview, setShowPreview] = useState(false)
const [userRole, setUserRole] = useState<UserRole>()
const [fileList, setFileList] = useState<UploadedImageData[]>([]) // 图片文件列表
const [FormData, setFormData] = useState<HjmCar>(
{
@@ -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 = () => {
<Cell className={'car-info-item-title'}>
{FormData?.parentOrganization}
</Cell>
<Cell className={'car-info-item-title'}>
{FormData?.organization}
</Cell>
<Cell className={'car-info-item-title'}>
{FormData?.parentOrganizationAdmin}
</Cell>

View File

@@ -20,13 +20,11 @@ const Location = () => {
const [latitude, setLatitude] = useState<any>()
const [scale, setScale] = useState<any>(16)
const [showCircles, setShowCircles] = useState<boolean>(false)
const [points, setPoints] = useState<any[]>([])
// const [points, setPoints] = useState<any[]>([])
const [hjmGpsLog, setHjmGpsLog] = useState<any[]>([])
const [dateTime, setDateTime] = useState<string>('')
const [ddmmyy, setDdmmyy] = useState<string>(formatCurrentDate())
const [hhmmss, setHhmmss] = useState<string>(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<string>()
// 通用的坐标字符串转数组函数
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 = () => {
<DatePicker
title="日期选择"
visible={show1}
value={value}
value={defaultValue}
showChinese
defaultValue={new Date(`${defaultDescription}`)}
onClose={() => setShow1(false)}
@@ -217,6 +214,7 @@ const Location = () => {
endDate={endDate}
visible={show}
onClose={() => setShow(false)}
// @ts-ignore
onConfirm={(options, values) => confirm(options, values)}
/>
</div>

View File

@@ -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<boolean>(false)
const [roleName, setRoleName] = useState<string>()
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 (
<div className={'mb-3 fixed top-36 z-20'} style={{ width: '96%', marginLeft: '3%'}}>
<div className={'mb-3 fixed top-36 z-20'} style={{width: '96%', marginLeft: '3%'}}>
<div className={'w-full flex justify-around items-center py-3 rounded-lg'}>
<Button size={'large'} style={{ background: 'linear-gradient(to right, #f3f2f7, #805de1)',borderColor:'#f3f2f7'}} icon={<Truck />} onClick={() => Taro.navigateTo({ url: '/hjm/list' })}></Button>
<Button size={'large'} style={{ background: 'linear-gradient(to right, #fffbe6, #ffc53d)',borderColor:'#f3f2f7'}} icon={<Scan />} onClick={onScanCode}></Button>
<>
<Button size={'large'}
style={{background: 'linear-gradient(to right, #f3f2f7, #805de1)', borderColor: '#f3f2f7'}}
icon={<Truck/>} onClick={navToCarList}></Button>
<Button size={'large'}
style={{background: 'linear-gradient(to right, #fffbe6, #ffc53d)', borderColor: '#f3f2f7'}}
icon={<Scan/>}
onClick={onScanCode}>
</Button>
</>
{
roleName == 'youzheng' && <Button size={'large'} style={{ background: 'linear-gradient(to right, #eaff8f, #7cb305)',borderColor:'#f3f2f7'}} icon={<Target />} onClick={() => Taro.navigateTo({ url: '/hjm/fence' })}></Button>
roleName == 'youzheng' && <Button size={'large'} style={{
background: 'linear-gradient(to right, #eaff8f, #7cb305)',
borderColor: '#f3f2f7'
}} icon={<Target/>} onClick={() => Taro.navigateTo({url: '/hjm/fence'})}></Button>
}
{
roleName == 'kuaidiyuan' && <Button size={'large'} style={{ background: 'linear-gradient(to right, #ffa39e, #ff4d4f)',borderColor:'#f3f2f7'}} icon={<Target />} onClick={() => Taro.navigateTo({ url: '/hjm/bx/bx-add' })}></Button>
roleName == 'kuaidiyuan' && <Button size={'large'} style={{
background: 'linear-gradient(to right, #ffa39e, #ff4d4f)',
borderColor: '#f3f2f7'
}} icon={<Target/>} onClick={() => Taro.navigateTo({url: '/hjm/bx/bx-add'})}></Button>
}
</div>
</div>

View File

@@ -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<boolean>(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;
}
}

View File

@@ -24,12 +24,13 @@ export interface Market {
function Home() {
const [IsLogin, setIsLogin] = useState<boolean>(true)
const [isAdmin, setIsAdmin] = useState<boolean>(false)
const [search, setSearch] = useState(false)
const [userInfo, setUserInfo] = useState<User>()
const [longitude, setLongitude] = useState<any>(108.374959)
const [latitude, setLatitude] = useState<any>(22.767024)
const [markers, setMarkers] = useState<Market[]>([])
const [scale, setScale] = useState<any>(16)
const [scale, setScale] = useState<any>(12)
const [keywords, setKeywords] = useState<string>('')
const [list, setList] = useState<HjmCar[]>([])
@@ -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}
/>
<div
className={'flex items-center'}
>
<Button type="warning" onClick={reload}>
<Button type="warning" onClick={onQuery}>
</Button>
</div>

View File

@@ -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<boolean>(false)
const [loading, setLoading] = useState<boolean>(false)
const [list, setList] = useState<CmsArticle[]>()
const [monthTaskCompleted, setMonthTaskCompleted] = useState<boolean>(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 (
<div className={'px-3 mt-4 mb-10'}>
{/* 已完成任务 */}
{monthTaskCompleted && !loading && (
<div style={{backgroundColor: 'white', borderRadius: '8px', padding: '24px', textAlign: 'center'}}>
<h1 style={{fontSize: '20px', fontWeight: 'bold', marginBottom: '16px', color: '#52c41a'}}>🎉
</h1>
<div style={{marginBottom: '16px', color: '#666'}}>
</div>
<>
{isAdmin && (
<div className={'px-3 mt-4 mb-10'}>
{/* 已完成任务 */}
{monthTaskCompleted && !loading && (
<div style={{backgroundColor: 'white', borderRadius: '8px', padding: '24px', textAlign: 'center'}}>
<h1 style={{fontSize: '20px', fontWeight: 'bold', marginBottom: '16px', color: '#52c41a'}}>🎉
</h1>
<div style={{marginBottom: '16px', color: '#666'}}>
</div>
</div>
)}
{
!monthTaskCompleted && list?.map((item, index) => {
return (
<div key={index} className={'flex flex-col justify-between items-center bg-white rounded-lg p-2'}
onClick={() => Taro.navigateTo({url: `/hjm/video/video?id=${item.articleId}`})}>
<Image src={item.image} height={200}/>
</div>
)
})
}
</div>
)}
{
!monthTaskCompleted && list?.map((item, index) => {
return (
<div key={index} className={'flex flex-col justify-between items-center bg-white rounded-lg p-2'}
onClick={() => Taro.navigateTo({url: `/hjm/video/video?id=${item.articleId}`})}>
<Image src={item.image} height={200}/>
</div>
)
})
}
{list?.length == 0 && <Questions/>}
</div>
{!isAdmin && <Questions/>}
</>
)
}
export default Study