This commit is contained in:
BianLzhaoMin 2025-10-23 17:49:28 +08:00
parent 69f14e5186
commit 11d9d02597
8 changed files with 201 additions and 43 deletions

View File

@ -1 +1,2 @@
VITE_API_BASE_URL = https://sh.cygrxt.com:19999/hd-realname/prod-api
VITE_API_BASE_URL = /hd-real-name

View File

@ -151,6 +151,10 @@
},
"vueVersion" : "3",
"h5" : {
"title" : ""
"title" : "",
"router" : {
"mode" : "history",
"base" : "/hd-real-name-h5/"
}
}
}

View File

@ -40,7 +40,7 @@
<!-- 验证码输入 -->
<up-form-item prop="code" class="code-form-item">
<view style="width: 70%">
<view style="width: 63%">
<up-input
v-model="formData.code"
placeholder="请输入验证码"
@ -53,7 +53,6 @@
:text="codeButtonText"
:disabled="codeButtonDisabled"
:loading="codeLoading"
size="small"
type="primary"
class="code-button"
color="linear-gradient(135deg, #4facfe 0%, #00f2fe 100%)"
@ -77,7 +76,7 @@
</template>
<template v-if="currentStep === 1">
<Upload @goBack="onGoBack" />
<Upload @goBack="onGoBack" :phone="formData.phone" />
</template>
<!-- 加载页面 -->
@ -95,7 +94,11 @@
<script setup>
import { ref, computed, onUnmounted } from 'vue'
import { debounce } from 'lodash-es'
import { useMemberStore } from '@/stores'
import Upload from './upload.vue'
import { getSmsCodeApi, nextLoginApi } from '@/services/offline-witness'
const memberStore = useMemberStore() //
//
const formRef = ref(null)
@ -189,18 +192,20 @@ const getVerificationCode = debounce(async () => {
codeLoading.value = true
// API
// const res = await getSmsCodeAPI({ phone: formData.value.phone })
const res = await getSmsCodeApi({
username: formData.value.phone,
verificationCodeType: 'WORKER_LOGIN',
})
// console.log(res, '')
// API
await new Promise((resolve) => setTimeout(resolve, 1000))
uni.$u.toast('验证码已发送')
//
startCountdown()
} catch (error) {
console.error('获取验证码失败:', error)
uni.$u.toast('获取验证码失败,请重试')
uni.$u.toast(error?.data?.msg)
} finally {
codeLoading.value = false
}
@ -221,10 +226,6 @@ const startCountdown = () => {
//
const handleNext = debounce(() => {
currentStep.value = 1
console.log(currentStep.value)
return
if (submitDisabled.value) return
formRef.value
@ -235,25 +236,22 @@ const handleNext = debounce(() => {
submitLoading.value = true
// API
// const res = await verifySmsCodeAPI({
// phone: formData.value.phone,
// code: formData.value.code
// })
// API
await new Promise((resolve) => setTimeout(resolve, 1500))
const res = await nextLoginApi({
username: formData.value.phone,
loginType: 'PHONE_OTP_WORKER',
verificationCode: formData.value.code,
})
console.log(res, '验证结果')
if (res.code === 200) {
memberStore.setToken(res.data.access_token)
}
uni.$u.toast('验证成功')
//
setTimeout(() => {
uni.navigateTo({
url: '/pages/offline-witness/upload',
})
}, 500)
//
currentStep.value = 1
} catch (error) {
console.error('验证失败:', error)
uni.$u.toast('验证失败,请检查验证码')
uni.$u.toast(error?.data?.msg)
} finally {
submitLoading.value = false
}
@ -394,7 +392,7 @@ onUnmounted(() => {
.code-button {
// min-width: 180rpx;
flex: 1;
height: 80rpx;
// height: 80rpx;
font-size: 24rpx;
}
}

View File

@ -2,6 +2,14 @@
<!-- 人员出场资料上传 -->
<view class="data-upload">
<!-- 人员信息 -->
<up-button
size="small"
v-if="projectList.length > 0"
color="linear-gradient(135deg, #4facfe 0%, #00f2fe 100%)"
@click="showProjectSelectPopup = true"
text="选择工程信息"
/>
<view class="person-info">
<view>
<text>姓名</text>
@ -73,23 +81,85 @@
@confirm="onConfirmExit"
@cancel="onCancelConfirmExit"
/>
<!-- 如果工程信息有多个则显示工程信息选择弹框 -->
<up-popup
mode="center"
closeOnClickOverlay
:show="showProjectSelectPopup"
@close="onCloseProjectSelectPopup"
>
<view class="project-select-content">
<view class="project-select-title"> 请选择工程信息 </view>
<view
class="project-select-item"
v-for="item in projectList"
:key="item.id"
@click="onSelectProject(item)"
>
{{ item.proName }}
</view>
</view>
</up-popup>
</view>
</template>
<script setup name="DataUpload">
import { ref } from 'vue'
import { ref, watch } from 'vue'
import { useCommonStore } from '@/stores'
import { onLoad } from '@dcloudio/uni-app'
import { editPersonEntryExitApi } from '@/services/person-entry.js'
import { editPersonEntryExitApi, editPersonEntryExitApiBack } from '@/services/person-entry.js'
import { getEngineeringInfoByPhoneApi } from '@/services/offline-witness.js'
import { decryptWithSM4, encryptWithSM4, hashWithSM3AndSalt } from '@/utils/sm.js'
const commonStore = useCommonStore()
const exitParams = ref({}) //
const exitParams = ref({
name: '', //
idNumber: '', //
proName: '', //
subName: '', //
teamName: '', //
}) //
const showProjectSelectPopup = ref(false) //
const fileList = ref([]) //
const exitContent = ref('') //
const showModalConfirmExit = ref(false) //
const fileIds = ref([]) // ID
const projectList = ref([]) //
const emit = defineEmits(['goBack'])
const props = defineProps({
phone: {
type: [Number, String],
default: '',
},
})
//
const getProjectList = async (phone) => {
const res = await getEngineeringInfoByPhoneApi({
phone,
})
projectList.value = res.data
if (res?.data?.length == 0) {
uni.$u.toast('当前未入场任何工程')
setTimeout(() => {
uni.navigateBack()
}, 1000)
return
} else {
showProjectSelectPopup.value = true
}
}
const onCloseProjectSelectPopup = () => {
showProjectSelectPopup.value = false
}
const onSelectProject = (item) => {
exitParams.value = item
showProjectSelectPopup.value = false
}
//
const deletePic = (e) => {
@ -161,22 +231,44 @@ const onConfirmExit = async () => {
exitWay: 'APP',
}
if (fileIds.value.length > 0) {
params.fileIds = fileIds.value.join(',')
const params2 = {
id: exitParams.value.id,
}
const res = await editPersonEntryExitApi(params)
if (fileIds.value.length > 0) {
params.photoIds = fileIds.value.join(',')
params2.photoIds = fileIds.value.join(',')
}
const API = exitParams.value.type == 1 ? editPersonEntryExitApi : editPersonEntryExitApiBack
const res = await API(exitParams.value.type == 1 ? params : params2)
showModalConfirmExit.value = false
if (res.code === 200) {
uni.$u.toast('出场成功')
exitParams.value = {}
fileList.value = []
fileIds.value = []
setTimeout(() => {
uni.navigateBack()
}, 500)
getProjectList(props.phone)
}, 1000)
} else {
uni.$u.toast(res.msg)
}
}
//
watch(
() => props.phone,
async (newVal) => {
if (newVal) {
try {
getProjectList(newVal)
} catch (error) {}
}
},
{ immediate: true },
)
//
const goBack = () => {
emit('goBack')
@ -187,9 +279,7 @@ const onCancelConfirmExit = () => {
showModalConfirmExit.value = false
}
onLoad((options) => {
exitParams.value = JSON.parse(options?.params)
})
onLoad(() => {})
</script>
<style scoped lang="scss">
@ -260,4 +350,34 @@ onLoad((options) => {
gap: 20rpx;
justify-content: space-between;
}
.project-select-content {
width: 80vw;
height: 80vh;
padding: 30rpx;
background-color: #fff;
border-radius: 10rpx;
box-shadow: 0 0 10rpx 2rpx rgba(0, 0, 0, 0.1);
display: flex;
flex-direction: column;
align-items: center;
overflow-y: auto;
}
.project-select-title {
margin-bottom: 20rpx;
font-size: 32rpx;
font-weight: bold;
}
.project-select-item {
width: 100%;
padding: 20rpx 0;
border-bottom: 1px solid #e5e5e5;
text-align: center;
&:hover {
background-color: #f0f2f5;
}
}
</style>

View File

@ -160,7 +160,7 @@ const onConfirmExit = async () => {
}
if (fileIds.value.length > 0) {
params.fileIds = fileIds.value.join(',')
params.photoIds = fileIds.value.join(',')
}
const res = await editPersonEntryExitApi(params)

View File

@ -0,0 +1,27 @@
import { http } from '@/utils/http'
// 获取短信验证码
export const getSmsCodeApi = (data) => {
return http({
method: 'POST',
url: '/auth/getPhoneCode',
data,
})
}
// 点击下一步登录接口
export const nextLoginApi = (data) => {
return http({
method: 'POST',
url: '/auth/login',
data,
})
}
// 根据手机号码获取工程信息
export const getEngineeringInfoByPhoneApi = (data) => {
return http({
method: 'bmw',
url: `/bmw/workerExit/getWorkerListByPhone`,
data,
})
}

View File

@ -55,6 +55,14 @@ export const editPersonEntryExitApi = (data) => {
data,
})
}
// 已出场未上传附件
export const editPersonEntryExitApiBack = (data) => {
return http({
url: `/bmw/app/appWorkerExitFile`,
method: 'POST',
data,
})
}
// 获取上海工程人员信息
export const getShanghaiProByIdNumberAPI = (data) => {

View File

@ -10,8 +10,8 @@ export default defineConfig({
'/api': {
// target: 'http://112.29.103.165:1616', // 测试环境
// target: 'http://192.168.0.133:58080', // 梁超
target: 'http://192.168.0.14:1999/hd-real-name', // 测试环境
// target: 'http://192.168.0.234:38080', // 方亮
// target: 'http://192.168.0.14:1999/hd-real-name', // 测试环境
target: 'http://192.168.0.234:38080/hd-real-name', // 方亮
changeOrigin: true,
rewrite: (path) => {
return path.replace(/\/api/, '')