Compare commits

...

2 Commits
master ... h5

Author SHA1 Message Date
BianLzhaoMin 11d9d02597 完善 2025-10-23 17:49:28 +08:00
BianLzhaoMin 69f14e5186 H5扫码功能页面搭建 2025-10-22 13:54:05 +08:00
10 changed files with 1031 additions and 5 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

@ -9,6 +9,22 @@
}
},
"pages": [
//
{
"path": "pages/sel-business/index",
"style": {
"navigationBarTitleText": "请选择操作业务",
"navigationBarBackgroundColor": "#fff"
}
},
// -线
{
"path": "pages/offline-witness/index",
"style": {
"navigationBarTitleText": "custom",
"navigationStyle": "custom"
}
},
//
{
"path": "pages/login/index",

View File

@ -0,0 +1,478 @@
<template>
<!-- 离场见证-线下页面 -->
<view class="offline-witness-container">
<!-- 导航栏 -->
<view class="nav-bar">
<view class="nav-left" @tap="goBack">
<up-icon name="arrow-left" size="20" color="#333" />
<text class="nav-text">返回</text>
</view>
<view class="nav-title">离场见证-线下</view>
<view class="nav-right"></view>
</view>
<!-- 进度指示器 -->
<view>
<up-steps :current="currentStep">
<up-steps-item
:key="item.title"
:title="item.title"
:error="item.isError"
v-for="item in stepList"
/>
</up-steps>
</view>
<!-- 表单内容 -->
<template v-if="currentStep === 0">
<view class="form-container">
<up-form ref="formRef" :model="formData" :rules="formRules" labelWidth="auto">
<!-- 手机号码输入 -->
<up-form-item prop="phone">
<up-input
v-model="formData.phone"
placeholder="请输入手机号码"
prefixIcon="phone"
clearable
class="custom-input"
/>
</up-form-item>
<!-- 验证码输入 -->
<up-form-item prop="code" class="code-form-item">
<view style="width: 63%">
<up-input
v-model="formData.code"
placeholder="请输入验证码"
prefixIcon="email"
clearable
/>
</view>
<up-button
:text="codeButtonText"
:disabled="codeButtonDisabled"
:loading="codeLoading"
type="primary"
class="code-button"
color="linear-gradient(135deg, #4facfe 0%, #00f2fe 100%)"
@tap="getVerificationCode"
/>
</up-form-item>
</up-form>
</view>
<!-- 下一步按钮 -->
<view class="button-container">
<up-button
text="下一步"
type="primary"
:loading="submitLoading"
class="next-button"
@tap="handleNext"
color="linear-gradient(135deg, #4facfe 0%, #00f2fe 100%)"
/>
</view>
</template>
<template v-if="currentStep === 1">
<Upload @goBack="onGoBack" :phone="formData.phone" />
</template>
<!-- 加载页面 -->
<up-loading-page
color="#fff"
fontSize="16"
loadingColor="#2979ff"
:loading="submitLoading"
bg-color="rgba(0,0,0,0.7)"
loading-text="正在验证..."
/>
</view>
</template>
<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)
const submitLoading = ref(false)
const codeLoading = ref(false)
const countdown = ref(0)
const countdownTimer = ref(null)
const currentStep = ref(0)
const stepList = ref([
{
title: '短信验证',
isError: false,
},
{
title: '见证上传',
isError: false,
},
])
//
const formData = ref({
phone: '',
code: '',
})
//
const formRules = ref({
phone: [
{
type: 'string',
required: true,
message: '请输入手机号码',
trigger: ['blur', 'change'],
},
{
pattern: /^1[3-9]\d{9}$/,
message: '请输入正确的手机号码',
trigger: ['blur', 'change'],
},
],
code: [
{
type: 'string',
required: true,
message: '请输入验证码',
trigger: ['blur', 'change'],
},
{
pattern: /^\d{6}$/,
message: '请输入6位数字验证码',
trigger: ['blur', 'change'],
},
],
})
//
const codeButtonText = computed(() => {
return countdown.value > 0 ? `${countdown.value}s后重新获取` : '获取验证码'
})
const codeButtonDisabled = computed(() => {
return (
countdown.value > 0 || !formData.value.phone || !/^1[3-9]\d{9}$/.test(formData.value.phone)
)
})
const submitDisabled = computed(() => {
return (
!formData.value.phone ||
!formData.value.code ||
!/^1[3-9]\d{9}$/.test(formData.value.phone) ||
!/^\d{6}$/.test(formData.value.code)
)
})
//
const goBack = () => {
uni.navigateBack()
}
//
const onGoBack = () => {
currentStep.value = 0
}
//
const getVerificationCode = debounce(async () => {
if (codeButtonDisabled.value) return
try {
codeLoading.value = true
// API
const res = await getSmsCodeApi({
username: formData.value.phone,
verificationCodeType: 'WORKER_LOGIN',
})
// console.log(res, '')
// API
uni.$u.toast('验证码已发送')
//
startCountdown()
} catch (error) {
uni.$u.toast(error?.data?.msg)
} finally {
codeLoading.value = false
}
}, 500)
//
const startCountdown = () => {
countdown.value = 60
countdownTimer.value = setInterval(() => {
countdown.value--
if (countdown.value <= 0) {
clearInterval(countdownTimer.value)
countdownTimer.value = null
}
}, 1000)
}
//
const handleNext = debounce(() => {
if (submitDisabled.value) return
formRef.value
.validate()
.then(async (valid) => {
if (valid) {
try {
submitLoading.value = true
// API
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('验证成功')
//
currentStep.value = 1
} catch (error) {
uni.$u.toast(error?.data?.msg)
} finally {
submitLoading.value = false
}
}
})
.catch(() => {
submitLoading.value = false
})
}, 500)
//
onUnmounted(() => {
if (countdownTimer.value) {
clearInterval(countdownTimer.value)
}
})
</script>
<style lang="scss" scoped>
.offline-witness-container {
min-height: 100vh;
background-color: #fff;
display: flex;
flex-direction: column;
}
//
.nav-bar {
display: flex;
align-items: center;
justify-content: space-between;
padding: 20rpx 30rpx;
background-color: #fff;
border-bottom: 1rpx solid #f0f0f0;
margin-bottom: 20rpx;
.nav-left {
display: flex;
align-items: center;
cursor: pointer;
.nav-text {
margin-left: 10rpx;
font-size: 28rpx;
color: #333;
}
}
.nav-title {
font-size: 32rpx;
font-weight: 600;
color: #333;
}
.nav-right {
width: 80rpx; //
}
}
//
.progress-container {
padding: 60rpx 30rpx 40rpx;
background-color: #fff;
.progress-line {
display: flex;
align-items: center;
justify-content: center;
position: relative;
.progress-step {
display: flex;
flex-direction: column;
align-items: center;
z-index: 2;
.step-circle {
width: 40rpx;
height: 40rpx;
border-radius: 50%;
background-color: #e0e0e0;
border: 4rpx solid #e0e0e0;
transition: all 0.3s ease;
&.active {
background-color: #2979ff;
border-color: #2979ff;
}
}
.step-text {
margin-top: 20rpx;
font-size: 24rpx;
color: #999;
transition: color 0.3s ease;
}
&.active .step-text {
color: #2979ff;
}
}
.progress-connector {
position: absolute;
top: 20rpx;
left: 50%;
transform: translateX(-50%);
width: 200rpx;
height: 4rpx;
background-color: #e0e0e0;
z-index: 1;
transition: background-color 0.3s ease;
&.active {
background-color: #2979ff;
}
}
}
}
//
.form-container {
flex: 1;
padding: 40rpx 30rpx;
background-color: #fff;
.code-form-item {
:deep(.up-form-item__body) {
display: flex;
align-items: center;
gap: 20rpx;
}
.code-input {
width: 70%;
}
.code-button {
// min-width: 180rpx;
flex: 1;
// height: 80rpx;
font-size: 24rpx;
}
}
}
//
.button-container {
padding: 40rpx 30rpx 60rpx;
background-color: #fff;
.next-button {
width: 100%;
height: 88rpx;
font-size: 32rpx;
font-weight: 600;
border-radius: 44rpx;
// background: linear-gradient(135deg, #2979ff, #5e35b1);
// box-shadow: 0 8rpx 20rpx rgba(41, 121, 255, 0.3);
transition: all 0.3s ease;
&:active {
transform: translateY(2rpx);
box-shadow: 0 4rpx 10rpx rgba(41, 121, 255, 0.3);
}
&:disabled {
background: #e0e0e0;
box-shadow: none;
transform: none;
}
}
}
//
:deep(.custom-input) {
.up-input__content {
height: 88rpx;
border-radius: 12rpx;
border: 2rpx solid #e0e0e0;
background-color: #fff;
transition: border-color 0.3s ease;
&:focus-within {
border-color: #2979ff;
}
}
.up-input__content__field-wrapper__field {
font-size: 28rpx;
color: #333;
&::placeholder {
color: #999;
}
}
.up-input__content__prefix-icon {
color: #999;
margin-right: 20rpx;
}
}
//
@media (max-width: 480px) {
.progress-container {
padding: 40rpx 20rpx 30rpx;
.progress-line {
.progress-connector {
width: 150rpx;
}
}
}
.form-container {
padding: 30rpx 20rpx;
}
.button-container {
padding: 30rpx 20rpx 40rpx;
}
}
</style>

View File

@ -0,0 +1,383 @@
<template>
<!-- 人员出场资料上传 -->
<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>
<text>
{{ exitParams?.name }}
</text>
</view>
<view>
<text>身份证号</text>
<text>
{{ exitParams?.idNumber }}
</text>
</view>
<view>
<text>工程名称</text>
<text>
{{ exitParams?.proName }}
</text>
</view>
<view>
<text>分包商名称</text>
<text>
{{ exitParams?.subName }}
</text>
</view>
<view>
<text>班组名称</text>
<text>
{{ exitParams?.teamName }}
</text>
</view>
</view>
<view class="red-text exit-title"> 离场工资结算确认单 </view>
<view class="upload-content">
<text>离场工资结算确认单</text>
<up-upload
multiple
:maxCount="3"
accept="image"
@delete="deletePic"
:fileList="fileList"
@afterRead="afterRead"
:capture="['camera']"
/>
</view>
<view class="confirm-btn">
<up-button
color="linear-gradient(135deg, #bdc3c7 0%, #2c3e50 100%)"
@click="goBack"
text="上一步"
/>
<up-button
color="linear-gradient(135deg, #4facfe 0%, #00f2fe 100%)"
@click="openConfirmExitModal"
text="提交"
/>
</view>
<!-- 确认出场提示弹框 -->
<up-modal
title="出场确认"
:showCancelButton="true"
content="是否确认将人员出场?"
:show="showModalConfirmExit"
@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, watch } from 'vue'
import { useCommonStore } from '@/stores'
import { onLoad } from '@dcloudio/uni-app'
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({
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) => {
fileList.value = fileList.value.filter((item) => item.id !== e.file.id)
}
//
const afterRead = (e) => {
const type = e.file[0].type
if (!type.includes('image')) {
uni.$u.toast('请上传图片格式')
return
}
// fileList.value.push(e.file[0])
const files = [
{
file: e.file[0].url,
name: 'file',
uri: e.file[0].url,
},
]
uni.uploadFile({
url: '/bmw/app/uploadFile',
files: files,
name: 'file',
isUploadFile: true,
formData: {
type: 1,
},
success: (res) => {
const data = JSON.parse(res.data)
if (data.code === 200) {
fileIds.value.push(data.data)
fileList.value.push({ ...e.file[0], id: data.data })
} else {
uni.$u.toast('上传失败:' + data.msg)
}
},
fail: (err) => {
uni.$u.toast('上传失败,请重新上传')
},
})
}
//
const openConfirmExitModal = () => {
if (fileList.value.length === 0 && exitParams.value.isShanghai == 0) {
uni.$u.toast('请上传离场工资结算确认单')
return
// exitContent.value = ` <${exitParams.value.name}> `
} else {
exitContent.value = `是否确认将人员 ${exitParams.value.name} 出场?`
}
showModalConfirmExit.value = true
}
//
const onConfirmExit = async () => {
const params = {
id: exitParams.value.id,
proId: exitParams.value.proId,
workerId: exitParams.value.workerId,
subId: exitParams.value.subId,
teamId: exitParams.value.teamId,
exitWay: 'APP',
}
const params2 = {
id: exitParams.value.id,
}
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(() => {
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')
}
//
const onCancelConfirmExit = () => {
showModalConfirmExit.value = false
}
onLoad(() => {})
</script>
<style scoped lang="scss">
.data-upload {
height: 100%;
padding: 20rpx;
box-sizing: border-box;
background-color: #fff;
}
.exit-tip {
padding: 30rpx 15rpx;
background-color: #f0f2f5;
border-radius: 10rpx;
}
.exit-tip-item {
padding: 4rpx 0;
}
.person-info {
margin-top: 20rpx;
padding: 30rpx;
background-color: #f5f5f5;
view {
padding: 20rpx 0;
border-bottom: 1px solid #e5e5e5;
& text:first-child {
display: inline-block;
width: 200rpx;
color: #909399;
}
& text:last-child {
margin-left: 20rpx;
}
}
}
.exit-title {
padding: 18rpx 0;
border-bottom: 1px solid #e5e5e5;
}
.upload-content {
padding: 30rpx 0;
display: flex;
align-items: center;
& text:first-child {
display: inline-block;
width: 200rpx;
color: #909399;
margin-right: 50rpx;
}
}
.confirm-btn {
position: fixed;
bottom: 0;
left: 0;
right: 0;
padding: 20rpx;
background-color: #fff;
display: flex;
align-items: center;
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,109 @@
<template>
<!-- 离场见证选择页面 -->
<view class="sel-business-container">
<!-- 选择卡片 -->
<view class="business-card">
<!-- 线下选项 -->
<view class="business-option" @tap="handleSelect('offline')">
<view class="option-icon offline-icon">
<up-icon name="account" size="40" color="#ff4757" />
</view>
<text class="option-text">离场见证-线下</text>
</view>
<!-- 线上选项 -->
<!-- <view class="business-option" @tap="handleSelect('online')">
<view class="option-icon online-icon">
<up-icon name="account" size="40" color="#ff4757" />
<view class="upload-indicator">
<up-icon name="arrow-up" size="16" color="#ff4757" />
</view>
</view>
<text class="option-text">离场见证-线上</text>
</view> -->
</view>
</view>
</template>
<script setup>
//
const handleSelect = (type) => {
if (type === 'offline') {
// 线
uni.navigateTo({
url: '/pages/offline-witness/index',
})
} else if (type === 'online') {
// 线
uni.navigateTo({
url: '/pages/person-exit/index?type=online',
})
}
}
</script>
<style lang="scss" scoped>
.sel-business-container {
min-height: 100vh;
background-color: #f0f2f5;
padding: 40rpx 30rpx;
box-sizing: border-box;
}
.business-card {
width: 100%;
background-color: #fff;
border-radius: 20rpx;
padding: 60rpx 40rpx;
display: flex;
align-items: center;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
}
.business-option {
display: flex;
flex-direction: column;
align-items: center;
cursor: pointer;
transition: all 0.3s ease;
&:active {
transform: scale(0.95);
}
}
.option-icon {
width: 120rpx;
height: 120rpx;
background-color: #ffe6e6;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
position: relative;
margin-bottom: 20rpx;
}
.online-icon {
.upload-indicator {
position: absolute;
top: -8rpx;
right: -8rpx;
width: 32rpx;
height: 32rpx;
background-color: #ffe6e6;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
border: 2rpx solid #fff;
}
}
.option-text {
font-size: 28rpx;
color: #333;
font-weight: 500;
text-align: center;
}
</style>

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/, '')