From 26db77ee12b0ffe0f7314dc04e87d1f2d4e4c405 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, 17 Jun 2025 23:01:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=EF=BC=9A=E9=BB=84=E5=AE=B6?= =?UTF-8?q?=E6=98=8E=E9=A1=B9=E7=9B=AE=E7=9A=84=E5=BC=80=E5=8F=91=E5=B9=B6?= =?UTF-8?q?=E5=AD=98=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/hjm/hjmGpsLog/model/index.ts | 2 + src/app.config.ts | 3 +- src/hjm/gps-log/gps-log.config.ts | 4 ++ src/hjm/gps-log/gps-log.tsx | 91 ++++++++++++++++++++++++++++ src/hjm/query.tsx | 64 +++++++++++++++---- src/pages/index/Header.tsx | 6 ++ src/pages/index/index.tsx | 8 ++- src/user/userVerify/index.tsx | 21 +++++++ src/utils/common.ts | 21 ++++++- src/utils/server.ts | 1 - 10 files changed, 203 insertions(+), 18 deletions(-) create mode 100644 src/hjm/gps-log/gps-log.config.ts create mode 100644 src/hjm/gps-log/gps-log.tsx diff --git a/src/api/hjm/hjmGpsLog/model/index.ts b/src/api/hjm/hjmGpsLog/model/index.ts index 6601260..993aab4 100644 --- a/src/api/hjm/hjmGpsLog/model/index.ts +++ b/src/api/hjm/hjmGpsLog/model/index.ts @@ -18,6 +18,8 @@ export interface HjmGpsLog { ddmmyy?: string; // 时分秒 hhmmss?: string; + // 速度 + speed?: string; // 备注 comments?: string; // 状态, 0正常, 1冻结 diff --git a/src/app.config.ts b/src/app.config.ts index 458a1cc..58b20ad 100644 --- a/src/app.config.ts +++ b/src/app.config.ts @@ -48,7 +48,8 @@ export default defineAppConfig({ "exam/exam", "bx/bx", "bx/bx-add", - "trajectory/trajectory" + "trajectory/trajectory", + "gps-log/gps-log" // "bx/bx-list", // "question/detail" ] diff --git a/src/hjm/gps-log/gps-log.config.ts b/src/hjm/gps-log/gps-log.config.ts new file mode 100644 index 0000000..ff6a355 --- /dev/null +++ b/src/hjm/gps-log/gps-log.config.ts @@ -0,0 +1,4 @@ +export default definePageConfig({ + navigationBarTitleText: '位置明细', + navigationBarBackgroundColor: '#ffe0e0' +}) diff --git a/src/hjm/gps-log/gps-log.tsx b/src/hjm/gps-log/gps-log.tsx new file mode 100644 index 0000000..f7316a2 --- /dev/null +++ b/src/hjm/gps-log/gps-log.tsx @@ -0,0 +1,91 @@ +import {Cell, Space} from '@nutui/nutui-react-taro' +import {useEffect, useState, CSSProperties} from "react"; +import {InfiniteLoading} from '@nutui/nutui-react-taro' +import {useRouter} from '@tarojs/taro' +import {pageHjmGpsLog} from "@/api/hjm/hjmGpsLog"; +import {HjmGpsLog} from "@/api/hjm/hjmGpsLog/model"; + +const InfiniteUlStyle: CSSProperties = { + height: '80vh', + width: '100%', + padding: '0', + overflowY: 'auto', + overflowX: 'hidden', +} + +function PayRecord() { + const {params} = useRouter(); + const [list, setList] = useState([]) + const [page, setPage] = useState(1) + const [hasMore, setHasMore] = useState(true) + const reload = async () => { + pageHjmGpsLog({page, gpsNo: params.id}).then(res => { + if (res?.list && res?.list.length > 0) { + const newList = list?.concat(res.list) + setList(newList); + setHasMore(true) + } else { + setHasMore(false) + } + }) + } + + const reloadMore = async () => { + setPage(page + 1) + reload(); + } + + useEffect(() => { + setPage(2) + reload() + }, []) + + return ( + + + + ) +} + +export default PayRecord diff --git a/src/hjm/query.tsx b/src/hjm/query.tsx index 1139294..852b0b9 100644 --- a/src/hjm/query.tsx +++ b/src/hjm/query.tsx @@ -43,6 +43,7 @@ const Query = () => { const [dict, setDict] = useState([]) const [adminId, setAdminId] = useState() const [showPreview, setShowPreview] = useState(false) + const [disabled, setDisabled] = useState(false) const [userRole, setUserRole] = useState() const [fileList, setFileList] = useState([]) // 图片文件列表 const [FormData, setFormData] = useState( @@ -106,6 +107,10 @@ const Query = () => { // 提交表单 const submitSucceed = (values: any) => { + // 禁用按钮 + if(disabled){ + return false; + } console.log(values) if(FormData.image == '[]' || !FormData.image){ Taro.showToast({ @@ -129,14 +134,18 @@ const Query = () => { 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(() => {}) + Taro.showToast({title: `绑定成功`, icon: 'success'}) + // 变更角色 + if (Taro.getStorageSync('OrganizationParentId') > 0) { + 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() @@ -214,7 +223,7 @@ const Query = () => { } // 上传单张图片 - const uploadSingleImage = (filePath: string, index: number) => { + const uploadSingleImage = (filePath: any, index: number) => { const TenantId = Taro.getStorageSync('TenantId') Taro.uploadFile({ @@ -322,6 +331,13 @@ const Query = () => { // } // } const reload = () => { + if (!Taro.getStorageSync('UserId')) { + Taro.showToast({ + title: '请先登录', + icon: 'error' + }) + return false + } const code = params.id; // 获取数据字典 pageDictData({dictCode: 'InsuranceStatus'}).then(res => { @@ -349,6 +365,7 @@ const Query = () => { } if(data){ setAdminId(data.userId); + setFormData( {...FormData, driverName: Taro.getStorageSync('RealName')}) } }) // 获取车辆信息 @@ -384,7 +401,21 @@ const Query = () => { Taro.setNavigationBarTitle({ title: '安装设备' }) - setFormData({...data, driver: Taro.getStorageSync('RealName')}) + setFormData({...data}) + } + + // 查询名下的车辆数 + if(data?.status == 0 && Taro.getStorageSync('OrganizationParentId') != 0){ + pageHjmCar({driverId: Taro.getStorageSync('UserId')}).then(res => { + if(res?.count && res?.count > 0){ + setDisabled(true) + Taro.showToast({ + title: '可绑定数量已达上限', + icon: 'none' + }) + return false; + } + }) } } }) @@ -427,7 +458,7 @@ const Query = () => { width: '100%' }} > - @@ -598,7 +629,7 @@ const Query = () => { @@ -685,6 +716,15 @@ const Query = () => { }> 播放轨迹 + diff --git a/src/pages/index/Header.tsx b/src/pages/index/Header.tsx index 9bd0f8f..f8d7f52 100644 --- a/src/pages/index/Header.tsx +++ b/src/pages/index/Header.tsx @@ -6,6 +6,7 @@ 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"; +import {myUserVerify} from "@/api/system/userVerify"; const Header = (props: any) => { const [IsLogin, setIsLogin] = useState(true) @@ -101,6 +102,11 @@ const Header = (props: any) => { setIsLogin(false); console.log('未登录') }); + myUserVerify({status: 1}).then(data => { + if(data?.realName){ + Taro.setStorageSync('RealName',data.realName) + } + }) } /* 获取用户手机号 */ diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index 6937ece..33d0a1d 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -116,6 +116,7 @@ function Home() { setLongitude(res.longitude) } + console.log(Taro.getStorageSync('RoleName')) // 已认证用户 if(Taro.getStorageSync('Certification')){ setIsAdmin(true) @@ -124,7 +125,7 @@ function Home() { } // 游客 - if(!Taro.getStorageSync('access_token')){ + if(!Taro.getStorageSync('access_token') || Taro.getStorageSync('RoleName') == '注册用户'){ setScale(15) const arr = [] // @ts-ignore @@ -326,6 +327,11 @@ function Home() { } }).catch(() => { setIsLogin(false); + setMarkers([{ + id: 123, + latitude: latitude, + longitude: longitude + }]) console.log('未登录') }); } diff --git a/src/user/userVerify/index.tsx b/src/user/userVerify/index.tsx index 44dc825..5165e00 100644 --- a/src/user/userVerify/index.tsx +++ b/src/user/userVerify/index.tsx @@ -85,6 +85,13 @@ function Index() { return false; } } + if(!FormData.realName){ + Taro.showToast({ + title: '请填写真实姓名', + icon: 'none' + }); + return false; + } const saveOrUpdate = isUpdate ? updateUserVerify : addUserVerify; saveOrUpdate({...FormData, status: 0}).then(() => { Taro.showToast({title: `提交成功`, icon: 'success'}) @@ -286,6 +293,20 @@ function Index() { ) } + + setFormData({...FormData, realName: value})} + /> + { FormData.status != undefined && ( { + let fileManager = Taro.getFileSystemManager(); + fileManager.readFile({ + filePath, + encoding: 'base64', + success: (e: any) => { + resolve(`data:image/jpg;base64,${e.data}`); + } + }); + }); +}; + /** * 转义微信富文本图片样式 * @param htmlText @@ -26,7 +41,7 @@ export function wxParse(htmlText) { } -export function copyText(text:string){ +export function copyText(text: string) { Taro.setClipboardData({ data: text, success: function () { diff --git a/src/utils/server.ts b/src/utils/server.ts index 0e6fad9..710f85c 100644 --- a/src/utils/server.ts +++ b/src/utils/server.ts @@ -16,6 +16,5 @@ export function saveStorageByLoginUser(token: string, user: User) { Taro.setStorageSync('access_token', token) Taro.setStorageSync('UserId', user.userId) Taro.setStorageSync('Phone', user.phone) - Taro.setStorageSync('RealName', user.realName) Taro.setStorageSync('User', user) }