bug 修复
This commit is contained in:
parent
8020780cdc
commit
ea522a9c9f
|
|
@ -1,4 +1,4 @@
|
|||
# VITE_API_BASE_URL = http://112.29.103.165:1616
|
||||
VITE_API_BASE_URL = /api
|
||||
# VITE_API_BASE_URL = http://192.168.0.14:1999/hd-realname/prod-api
|
||||
# VITE_API_BASE_URL = /api
|
||||
VITE_API_BASE_URL = http://192.168.0.14:1999/hd-realname/prod-api
|
||||
# VITE_API_BASE_URL = http://192.168.0.234:38080
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
"lodash-es": "^4.17.21",
|
||||
"pinia": "^2.3.0",
|
||||
"pinia-plugin-persistedstate": "^4.2.0",
|
||||
"sm-crypto": "^0.3.13",
|
||||
"uview-plus": "^3.4.65",
|
||||
"vue": "3.5.13",
|
||||
"vue-i18n": "9.14.3"
|
||||
|
|
@ -8812,6 +8813,12 @@
|
|||
"js-yaml": "bin/js-yaml.js"
|
||||
}
|
||||
},
|
||||
"node_modules/jsbn": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://repo.huaweicloud.com/repository/npm/jsbn/-/jsbn-1.1.0.tgz",
|
||||
"integrity": "sha512-4bYVV3aAMtDTTu4+xsDYa6sy9GyJ69/amsu9sYF2zqjiEoZA5xJi3BrfX3uY+/IekIu7MwdObdbDWpoZdBv3/A==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/jsdom": {
|
||||
"version": "16.7.0",
|
||||
"resolved": "https://repo.huaweicloud.com/repository/npm/jsdom/-/jsdom-16.7.0.tgz",
|
||||
|
|
@ -11138,6 +11145,15 @@
|
|||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/sm-crypto": {
|
||||
"version": "0.3.13",
|
||||
"resolved": "https://repo.huaweicloud.com/repository/npm/sm-crypto/-/sm-crypto-0.3.13.tgz",
|
||||
"integrity": "sha512-ztNF+pZq6viCPMA1A6KKu3bgpkmYti5avykRHbcFIdSipFdkVmfUw2CnpM2kBJyppIalqvczLNM3wR8OQ0pT5w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"jsbn": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/source-map": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://repo.huaweicloud.com/repository/npm/source-map/-/source-map-0.6.1.tgz",
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@
|
|||
"lodash-es": "^4.17.21",
|
||||
"pinia": "^2.3.0",
|
||||
"pinia-plugin-persistedstate": "^4.2.0",
|
||||
"sm-crypto": "^0.3.13",
|
||||
"uview-plus": "^3.4.65",
|
||||
"vue": "3.5.13",
|
||||
"vue-i18n": "9.14.3"
|
||||
|
|
|
|||
|
|
@ -16,9 +16,7 @@ const props = defineProps({
|
|||
|
||||
// 返回按钮
|
||||
const onHandleBack = () => {
|
||||
uni.navigateBack({
|
||||
delta: 1,
|
||||
})
|
||||
uni.navigateBack()
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -291,7 +291,7 @@ const onHandleRecognizeBankCard = () => {
|
|||
}
|
||||
// 上传后台接口
|
||||
uni.request({
|
||||
url: '/bmw/appRecognition/bankCardRecognition',
|
||||
url: import.meta.env.VITE_API_BASE_URL + '/bmw/appRecognition/bankCardRecognition',
|
||||
method: 'POST',
|
||||
data: param,
|
||||
header: {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
<view class="attendance-content">
|
||||
<view class="today-attendance">
|
||||
<view>今日考勤:32</view>
|
||||
<view>今日考勤:{{ total }}</view>
|
||||
<view>
|
||||
<up-button
|
||||
icon="calendar"
|
||||
|
|
@ -46,10 +46,14 @@
|
|||
</template>
|
||||
|
||||
<script setup name="Attendance">
|
||||
import { pathToBase64 } from 'image-tools'
|
||||
import { ref, onMounted, onBeforeUnmount } from 'vue'
|
||||
import { useCommonStore, useMemberStore } from '@/stores'
|
||||
import { pathToBase64 } from 'image-tools'
|
||||
import { getAttendanceRecordAPI } from '@/services/attendance'
|
||||
import { decryptWithSM4, encryptWithSM4, hashWithSM3AndSalt } from '@/utils/sm'
|
||||
|
||||
import dayjs from 'dayjs'
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
|
||||
const commonStore = useCommonStore()
|
||||
const memberStore = useMemberStore()
|
||||
|
|
@ -57,6 +61,7 @@ const currentTime = ref('') //获取当前的时分秒时间
|
|||
const timeInterval = ref(null) //定时器
|
||||
const activeProjectName = ref('') // 当前选择的工程名称
|
||||
const showLoading = ref(false) // 是否显示加载中
|
||||
const total = ref(0) // 总条数
|
||||
|
||||
// 打卡记录
|
||||
const onAttendanceRecord = () => {
|
||||
|
|
@ -84,37 +89,57 @@ const onAttendanceHandle = () => {
|
|||
sizeType: ['original', 'compressed'],
|
||||
sourceType: ['camera', 'album'], // 选择图片的来源
|
||||
success: (res) => {
|
||||
console.log(res, '选择的文件')
|
||||
showLoading.value = true
|
||||
const files = [
|
||||
{
|
||||
file: res.tempFiles[0],
|
||||
file: res.tempFilePaths[0],
|
||||
name: 'file',
|
||||
uri: res.tempFilePaths[0],
|
||||
},
|
||||
]
|
||||
|
||||
const { encryptRequest, encryptResponse, checkIntegrity } = commonStore?.requestConfig
|
||||
|
||||
// 先调人脸识别接口检查人脸是否合规
|
||||
uni.uploadFile({
|
||||
url: '/api/bmw/appRecognition/getFaceRecognition',
|
||||
url: '/bmw/appRecognition/getFaceRecognition',
|
||||
files: files,
|
||||
name: 'file',
|
||||
formData: {},
|
||||
isUploadFile: true,
|
||||
success: (res) => {
|
||||
console.log('res人脸识别结果--', res)
|
||||
showLoading.value = false
|
||||
const data = JSON.parse(res.data)
|
||||
|
||||
if (data.code === 200) {
|
||||
uni.$u.toast('人脸识别成功')
|
||||
|
||||
const params = {
|
||||
idNumber: data.data.idNumber,
|
||||
}
|
||||
// 人脸识别成功后调用打卡接口
|
||||
uni.uploadFile({
|
||||
url: '/api/bmw/appRecognition/appPlayCard',
|
||||
url: '/bmw/appRecognition/appPlayCard',
|
||||
files: files,
|
||||
name: 'file',
|
||||
formData: {
|
||||
params: JSON.stringify({
|
||||
idNumber: data.data.idNumber,
|
||||
}),
|
||||
params: !encryptRequest
|
||||
? JSON.stringify(params)
|
||||
: encryptWithSM4(JSON.stringify(params)),
|
||||
},
|
||||
header: {
|
||||
encryptRequest,
|
||||
encryptResponse,
|
||||
checkIntegrity,
|
||||
},
|
||||
success: (res) => {
|
||||
const result = JSON.parse(res.data)
|
||||
let result = null
|
||||
if (encryptResponse) {
|
||||
result = JSON.parse(decryptWithSM4(res.data))
|
||||
} else {
|
||||
result = JSON.parse(res.data)
|
||||
}
|
||||
if (result.code === 200) {
|
||||
uni.$u.toast('打卡成功')
|
||||
} else {
|
||||
|
|
@ -157,15 +182,33 @@ const imgToBase64Fun = async (data) => {
|
|||
})
|
||||
}
|
||||
|
||||
// 获取打卡记录
|
||||
const getAttendanceRecord = async () => {
|
||||
const res = await getAttendanceRecordAPI({
|
||||
pageNum: 1,
|
||||
pageSize: 20,
|
||||
isAtt: '1', // 是否考勤 1:已考勤 0:未考勤
|
||||
proName: activeProjectName.value,
|
||||
})
|
||||
|
||||
total.value = res?.total
|
||||
}
|
||||
|
||||
// onMounted生命周期 组件挂载时
|
||||
onMounted(() => {
|
||||
timeInterval.value = setInterval(() => {
|
||||
// currentTime.value = new Date().toLocaleTimeString()
|
||||
|
||||
// 设置时分秒
|
||||
currentTime.value = dayjs().format('HH:mm:ss')
|
||||
}, 1000)
|
||||
|
||||
activeProjectName.value = commonStore?.activeProjectName
|
||||
getAttendanceRecord()
|
||||
})
|
||||
|
||||
onShow(() => {
|
||||
activeProjectName.value = commonStore?.activeProjectName
|
||||
getAttendanceRecord()
|
||||
})
|
||||
|
||||
// onBeforeUnmount生命周期 组件卸载时
|
||||
|
|
|
|||
|
|
@ -92,20 +92,7 @@ const queryParams = ref({
|
|||
proName: '',
|
||||
workerName: '',
|
||||
})
|
||||
const attList = ref([
|
||||
{
|
||||
id: 1,
|
||||
name: '张三',
|
||||
status: '已考勤',
|
||||
time: '10:00:00',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: '李四',
|
||||
status: '未考勤',
|
||||
time: '10:00:00',
|
||||
},
|
||||
])
|
||||
|
||||
const statusList = ref([
|
||||
{
|
||||
name: '已考勤',
|
||||
|
|
|
|||
|
|
@ -116,13 +116,15 @@
|
|||
<script setup>
|
||||
import { onMounted, ref, nextTick } from 'vue'
|
||||
import { debounce } from 'lodash-es' // 引入防抖函数
|
||||
import { useMemberStore } from '@/stores'
|
||||
import { useMemberStore, useCommonStore } from '@/stores'
|
||||
import { loginApi, getUserInfoApi, getCodeImgApi } from '@/services/login.js'
|
||||
import { getRequestConfigAPI } from '@/services/common'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
|
||||
const showPassword = ref(false) // 密码是否可见
|
||||
const sendLoading = ref(false) // 加载中
|
||||
const memberStore = useMemberStore() // 用户信息
|
||||
const commonStore = useCommonStore() // 请求配置
|
||||
const imgWidth = ref(0)
|
||||
const imgHeight = ref(0)
|
||||
const codeUrl = ref('')
|
||||
|
|
@ -229,6 +231,13 @@ const getUserInfo = () => {
|
|||
})
|
||||
}
|
||||
|
||||
// 获取请求配置
|
||||
const getRequestConfig = async () => {
|
||||
const { data: res } = await getRequestConfigAPI()
|
||||
commonStore.setRequestConfig(res?.requestConfig)
|
||||
console.log(res, '请求配置')
|
||||
}
|
||||
|
||||
onLoad(() => {
|
||||
const userInfo = uni.getStorageSync('userInfo')
|
||||
if (userInfo) {
|
||||
|
|
@ -236,6 +245,8 @@ onLoad(() => {
|
|||
opinionModel.value.password = atob(userInfo.password)
|
||||
remember.value = true
|
||||
}
|
||||
|
||||
getRequestConfig()
|
||||
})
|
||||
onHandleCodeImg()
|
||||
|
||||
|
|
|
|||
|
|
@ -130,6 +130,7 @@ const onConfirmLogout = () => {
|
|||
memberStore.clearUserInfo() // 清除用户信息
|
||||
memberStore.clearToken() // 清除token
|
||||
commonStore.clearActiveProjectIdAndName() // 清除工程信息
|
||||
commonStore.clearRequestConfig() // 清除请求配置
|
||||
uni.$u.toast('退出成功')
|
||||
setTimeout(() => {
|
||||
uni.reLaunch({
|
||||
|
|
|
|||
|
|
@ -40,14 +40,16 @@ const onFaceRecognition = () => {
|
|||
showLoading.value = true
|
||||
const files = [
|
||||
{
|
||||
file: res.tempFiles[0],
|
||||
file: res.tempFilePaths[0],
|
||||
name: 'file',
|
||||
uri: res.tempFilePaths[0],
|
||||
},
|
||||
]
|
||||
uni.uploadFile({
|
||||
url: '/api/bmw/appRecognition/getFaceRecognition',
|
||||
url: '/bmw/appRecognition/getFaceRecognition',
|
||||
files: files,
|
||||
name: 'file',
|
||||
isUploadFile: true,
|
||||
success: (res) => {
|
||||
showLoading.value = false
|
||||
const data = JSON.parse(res.data)
|
||||
|
|
|
|||
|
|
@ -61,16 +61,19 @@
|
|||
</template>
|
||||
|
||||
<script setup name="addAndEditPerson">
|
||||
import { useCommonStore } from '@/stores'
|
||||
import { ref, onMounted, nextTick } from 'vue'
|
||||
import { decryptWithSM4, encryptWithSM4, hashWithSM3AndSalt } from '@/utils/sm'
|
||||
import { getPersonInfoByIdAPI, updatePersonLightStatusApi } from '@/services/person-entry'
|
||||
|
||||
import PersonIdCardForm from '@/components/PersonIdCardForm/index.vue'
|
||||
import KeyInfoForm from '@/components/KeyInfoForm/index.vue'
|
||||
import ContractForm from '@/components/ContractForm/index.vue'
|
||||
import WageCardForm from '@/components/WageCardForm/index.vue'
|
||||
import NavBarModal from '@/components/NavBarModal/index.vue'
|
||||
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
const { safeAreaInsets } = uni.getSystemInfoSync()
|
||||
const commonStore = useCommonStore()
|
||||
const navBarTitle = ref('新增人员信息')
|
||||
const currentStep = ref(0) // 当前步骤
|
||||
const nextBtnRef = ref(null) // 下一步按钮ref
|
||||
|
|
@ -83,6 +86,7 @@ const personWageCardFormRef = ref(null) // 工资卡见证表单ref
|
|||
const editUploadFileList = ref([]) // 编辑时已上传文件列表
|
||||
const formType = ref(1) // 表单类型
|
||||
const personId = ref('') // 人员id
|
||||
const einStatus = ref('') // 人员状态
|
||||
|
||||
const props = defineProps({
|
||||
type: {
|
||||
|
|
@ -247,6 +251,11 @@ const onHandleNext = async () => {
|
|||
...keyInfo.value,
|
||||
}
|
||||
|
||||
if (formType.value == 2) {
|
||||
params.id = personId.value
|
||||
params.einStatus = einStatus.value
|
||||
}
|
||||
|
||||
// 处理人脸
|
||||
if (keyInfo.value.faceImg) {
|
||||
keyInfo.value.faceImg.forEach((e) => {
|
||||
|
|
@ -316,34 +325,97 @@ const onHandleNext = async () => {
|
|||
|
||||
delete params.faceImg // 删除无关数据
|
||||
const requestUrl = formType.value == 2 ? '/bmw/worker/edit' : '/bmw/worker/insert'
|
||||
uni.uploadFile({
|
||||
url: requestUrl,
|
||||
files: files,
|
||||
name: 'files',
|
||||
formData: {
|
||||
params: JSON.stringify(params),
|
||||
fileMsg: JSON.stringify(fileMsg),
|
||||
},
|
||||
success: async (res) => {
|
||||
const data = JSON.parse(res.data)
|
||||
if (data.code === 200) {
|
||||
uni.$u.toast(formType.value == 2 ? '修改成功' : '新增成功')
|
||||
setTimeout(() => {
|
||||
uni.navigateBack({
|
||||
delta: 1,
|
||||
})
|
||||
}, 500)
|
||||
|
||||
const id = formType.value == 2 ? personId.value : data.data
|
||||
await updatePersonLightStatusApi(id) // 更新红绿灯状态
|
||||
} else {
|
||||
uni.$u.toast(data.msg)
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
sendLoading.value = false
|
||||
},
|
||||
})
|
||||
console.log('files---***---', files)
|
||||
|
||||
const { encryptRequest, encryptResponse, checkIntegrity } =
|
||||
commonStore?.requestConfig
|
||||
|
||||
if (files.length > 0) {
|
||||
uni.uploadFile({
|
||||
url: requestUrl,
|
||||
files: files,
|
||||
name: 'files',
|
||||
formData: {
|
||||
params: !encryptRequest
|
||||
? JSON.stringify(params)
|
||||
: encryptWithSM4(JSON.stringify(params)),
|
||||
fileMsg: !encryptRequest
|
||||
? JSON.stringify(fileMsg)
|
||||
: encryptWithSM4(JSON.stringify(fileMsg)),
|
||||
},
|
||||
header: {
|
||||
encryptRequest,
|
||||
encryptResponse,
|
||||
checkIntegrity,
|
||||
},
|
||||
success: async (res) => {
|
||||
console.log('res提交结果', res)
|
||||
|
||||
let data = null
|
||||
if (encryptResponse) {
|
||||
data = JSON.parse(decryptWithSM4(res.data))
|
||||
} else {
|
||||
data = JSON.parse(res.data)
|
||||
}
|
||||
if (data.code === 200) {
|
||||
uni.$u.toast(data.msg)
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 500)
|
||||
|
||||
const id = formType.value == 2 ? personId.value : data.data
|
||||
await updatePersonLightStatusApi(id) // 更新红绿灯状态
|
||||
} else {
|
||||
uni.$u.toast(data.msg)
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
sendLoading.value = false
|
||||
},
|
||||
})
|
||||
} else {
|
||||
uni.uploadFile({
|
||||
url: requestUrl,
|
||||
formData: {
|
||||
params: !encryptRequest
|
||||
? JSON.stringify(params)
|
||||
: encryptWithSM4(JSON.stringify(params)),
|
||||
fileMsg: !encryptRequest
|
||||
? JSON.stringify(fileMsg)
|
||||
: encryptWithSM4(JSON.stringify(fileMsg)),
|
||||
},
|
||||
header: {
|
||||
encryptRequest,
|
||||
encryptResponse,
|
||||
checkIntegrity,
|
||||
},
|
||||
success: async (res) => {
|
||||
console.log('res提交结果', res)
|
||||
|
||||
let data = null
|
||||
if (encryptResponse) {
|
||||
data = JSON.parse(decryptWithSM4(res.data))
|
||||
} else {
|
||||
data = JSON.parse(res.data)
|
||||
}
|
||||
if (data.code === 200) {
|
||||
uni.$u.toast(data.msg)
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 500)
|
||||
|
||||
const id = formType.value == 2 ? personId.value : data.data
|
||||
await updatePersonLightStatusApi(id) // 更新红绿灯状态
|
||||
} else {
|
||||
uni.$u.toast(data.msg)
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
sendLoading.value = false
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
|
|
@ -397,7 +469,7 @@ const getPersonInfoByIdFun = async (id) => {
|
|||
teamName, // 入场班组名称
|
||||
postName, // 工种名称
|
||||
|
||||
files, // 工资卡图片
|
||||
files, // 人脸图片
|
||||
bmWorkerContract, // 合同状态
|
||||
bmWorkerWageCard, // 工资卡状态
|
||||
} = res.data
|
||||
|
|
@ -513,8 +585,10 @@ onMounted(() => {
|
|||
|
||||
onLoad((options) => {
|
||||
options?.type == 1 ? (navBarTitle.value = '新增人员信息') : (navBarTitle.value = '人员信息修改')
|
||||
einStatus.value = options?.einStatus
|
||||
formType.value = options?.type
|
||||
personId.value = options?.id
|
||||
|
||||
if (options?.id) {
|
||||
getPersonInfoByIdFun(options?.id)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ const queryParams = ref({
|
|||
// 修改人员信息
|
||||
const onEditPerson = (item) => {
|
||||
uni.navigateTo({
|
||||
url: `/pages/person-entry/child-pages/addAndEditPerson?id=${item.id}&type=${2}`,
|
||||
url: `/pages/person-entry/child-pages/addAndEditPerson?id=${item.id}&type=${2}&einStatus=${item.einStatus}`,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -69,19 +69,23 @@ const handleTapPersonEntry = (item) => {
|
|||
count: 1, // 最多选择1张图片
|
||||
sizeType: ['original', 'compressed'],
|
||||
sourceType: ['camera', 'album'], // 选择图片的来源
|
||||
isUploadFile: true,
|
||||
success: (res) => {
|
||||
showLoading.value = true
|
||||
const files = [
|
||||
{
|
||||
file: res.tempFiles[0],
|
||||
file: res.tempFiles[0].path,
|
||||
name: 'file',
|
||||
uri: res.tempFiles[0].path,
|
||||
},
|
||||
]
|
||||
uni.uploadFile({
|
||||
url: '/api/bmw/appRecognition/getFaceRecognition',
|
||||
url: '/bmw/appRecognition/getFaceRecognition',
|
||||
files: files,
|
||||
name: 'file',
|
||||
isUploadFile: true,
|
||||
success: (res) => {
|
||||
console.log(res, 'res人脸识别结果')
|
||||
showLoading.value = false
|
||||
const data = JSON.parse(res.data)
|
||||
if (data.code === 200) {
|
||||
|
|
@ -97,6 +101,7 @@ const handleTapPersonEntry = (item) => {
|
|||
},
|
||||
fail: (err) => {
|
||||
showLoading.value = false
|
||||
console.log(err, 'err人脸识别失败')
|
||||
uni.$u.toast('人脸识别失败:' + err.msg)
|
||||
},
|
||||
})
|
||||
|
|
|
|||
|
|
@ -77,7 +77,11 @@
|
|||
|
||||
<script setup name="DataUpload">
|
||||
import { ref } from 'vue'
|
||||
import { useCommonStore } from '@/stores'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { decryptWithSM4, encryptWithSM4, hashWithSM3AndSalt } from '@/utils/sm'
|
||||
|
||||
const commonStore = useCommonStore()
|
||||
const exitParams = ref({}) // 出场参数
|
||||
const fileList = ref([]) // 离场工资结算确认单
|
||||
const exitContent = ref('') // 离场工资结算确认单内容
|
||||
|
|
@ -133,18 +137,33 @@ const onConfirmExit = () => {
|
|||
})
|
||||
}
|
||||
|
||||
const { encryptRequest, encryptResponse, checkIntegrity } = commonStore?.requestConfig
|
||||
|
||||
uni.uploadFile({
|
||||
url: '/bmw/workerExit/exit',
|
||||
files: files,
|
||||
name: 'files',
|
||||
formData: {
|
||||
params: JSON.stringify(params),
|
||||
fileMsg: JSON.stringify(fileMsg),
|
||||
params: !encryptRequest
|
||||
? JSON.stringify(params)
|
||||
: encryptWithSM4(JSON.stringify(params)),
|
||||
fileMsg: !encryptRequest
|
||||
? JSON.stringify(fileMsg)
|
||||
: encryptWithSM4(JSON.stringify(fileMsg)),
|
||||
},
|
||||
header: {
|
||||
encryptRequest,
|
||||
encryptResponse,
|
||||
checkIntegrity,
|
||||
},
|
||||
success: async (res) => {
|
||||
console.log('res出场结果', res)
|
||||
|
||||
const data = JSON.parse(res.data)
|
||||
success: async (res) => {
|
||||
let data = null
|
||||
if (encryptResponse) {
|
||||
data = JSON.parse(decryptWithSM4(res.data))
|
||||
} else {
|
||||
data = JSON.parse(res.data)
|
||||
}
|
||||
|
||||
if (data.code === 200) {
|
||||
uni.$u.toast('出场成功')
|
||||
|
|
|
|||
|
|
@ -142,12 +142,18 @@ const onSearchName = () => {
|
|||
switch (searchType.value) {
|
||||
case 1:
|
||||
queryParams.value.name = searchValue.value
|
||||
queryParams.value.subName = ''
|
||||
queryParams.value.proName = ''
|
||||
break
|
||||
case 2:
|
||||
queryParams.value.subName = searchValue.value
|
||||
queryParams.value.name = ''
|
||||
queryParams.value.proName = ''
|
||||
break
|
||||
case 3:
|
||||
queryParams.value.proName = searchValue.value
|
||||
queryParams.value.name = ''
|
||||
queryParams.value.subName = ''
|
||||
break
|
||||
}
|
||||
getPersonExitListFun()
|
||||
|
|
|
|||
|
|
@ -42,3 +42,11 @@ export const getProjectSelectListByConditionAPI = () => {
|
|||
method: 'GET',
|
||||
})
|
||||
}
|
||||
|
||||
// 获取请求配置
|
||||
export const getRequestConfigAPI = () => {
|
||||
return http({
|
||||
url: '/auth/getConfig',
|
||||
method: 'GET',
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,26 +1,66 @@
|
|||
import { defineStore } from 'pinia'
|
||||
import { ref } from 'vue'
|
||||
|
||||
export const useCommonStore = defineStore('common', () => {
|
||||
// 定义当前选择的工程ID和工程名称
|
||||
const activeProjectId = ref('')
|
||||
const activeProjectName = ref('')
|
||||
export const useCommonStore = defineStore(
|
||||
'common',
|
||||
() => {
|
||||
// 定义当前选择的工程ID和工程名称
|
||||
const activeProjectId = ref('')
|
||||
const activeProjectName = ref('')
|
||||
const requestConfig = ref({
|
||||
encryptRequest: false,
|
||||
checkIntegrity: false,
|
||||
encryptResponse: false,
|
||||
})
|
||||
|
||||
// 存储当前选择的工程ID和工程名称
|
||||
const setActiveProjectIdAndName = (id, name) => {
|
||||
activeProjectId.value = id
|
||||
activeProjectName.value = name
|
||||
}
|
||||
// 存储当前选择的工程ID和工程名称
|
||||
const setActiveProjectIdAndName = (id, name) => {
|
||||
activeProjectId.value = id
|
||||
activeProjectName.value = name
|
||||
}
|
||||
|
||||
// 清除当前选择的工程ID和工程名称
|
||||
const clearActiveProjectIdAndName = () => {
|
||||
activeProjectId.value = ''
|
||||
activeProjectName.value = ''
|
||||
}
|
||||
return {
|
||||
activeProjectId,
|
||||
activeProjectName,
|
||||
setActiveProjectIdAndName,
|
||||
clearActiveProjectIdAndName,
|
||||
}
|
||||
})
|
||||
// 清除当前选择的工程ID和工程名称
|
||||
const clearActiveProjectIdAndName = () => {
|
||||
activeProjectId.value = ''
|
||||
activeProjectName.value = ''
|
||||
}
|
||||
|
||||
// 设置请求配置
|
||||
const setRequestConfig = (config) => {
|
||||
requestConfig.value = config
|
||||
}
|
||||
|
||||
// 清除请求配置
|
||||
const clearRequestConfig = () => {
|
||||
requestConfig.value = {
|
||||
encryptRequest: false,
|
||||
checkIntegrity: false,
|
||||
encryptResponse: false,
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
activeProjectId,
|
||||
activeProjectName,
|
||||
requestConfig,
|
||||
setActiveProjectIdAndName,
|
||||
clearActiveProjectIdAndName,
|
||||
setRequestConfig,
|
||||
clearRequestConfig,
|
||||
}
|
||||
},
|
||||
|
||||
// 用户信息持久化处理
|
||||
{
|
||||
persist: {
|
||||
storage: {
|
||||
getItem(key) {
|
||||
return uni.getStorageSync(key)
|
||||
},
|
||||
setItem(key, value) {
|
||||
uni.setStorageSync(key, value)
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
// SM 配置
|
||||
export const SM_CONFIG = {
|
||||
SALT: '2cc0c5f9f1749f1632efa9f63e902323', // SM3 盐值(16 字节)
|
||||
SM4_KEY: '78d1295afa99449b99d6f83820e6965c', // SM4 对称加密密钥
|
||||
SM4_SALT: 'f555adf6c01d0ab0761e626a2dae34a2',
|
||||
SM2_PUBLIC_KEY: 'your-public-key', // SM2 公钥
|
||||
SM2_PRIVATE_KEY: 'your-private-key', // SM2 私钥
|
||||
}
|
||||
// AES 配置
|
||||
export const AES_CONFIG = {
|
||||
AES_KEY: 'zhgd@bonus@zhgd@bonus@1234567890', // AES key值
|
||||
AES_IV: '1234567812345678', // AES 偏移量
|
||||
}
|
||||
|
||||
export function generateUUID() {
|
||||
// 使用当前时间戳和随机数生成一个 UUID
|
||||
return 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
||||
const r = (Math.random() * 16) | 0 // 生成随机数
|
||||
const v = c === 'x' ? r : (r & 0x3) | 0x8 // 根据 UUID 规范生成相应的值
|
||||
return v.toString(16) // 转换为十六进制
|
||||
})
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
import { useMemberStore } from '@/stores'
|
||||
import { useMemberStore, useCommonStore } from '@/stores'
|
||||
import { encrypt, decrypt } from './encrypt' // 引入加解密方法
|
||||
import { cloneDeep } from 'lodash-es' // 引入深拷贝函数
|
||||
import { decryptWithSM4, encryptWithSM4, hashWithSM3AndSalt, tansParams } from '@/utils/sm'
|
||||
|
||||
/**
|
||||
* 添加拦截器
|
||||
|
|
@ -9,6 +10,7 @@ import { cloneDeep } from 'lodash-es' // 引入深拷贝函数
|
|||
*/
|
||||
|
||||
const baseURL = import.meta.env.VITE_API_BASE_URL
|
||||
|
||||
/**
|
||||
* httpInterceptor 分别拦截 request 和 uploadFile 请求
|
||||
*/
|
||||
|
|
@ -16,26 +18,86 @@ const baseURL = import.meta.env.VITE_API_BASE_URL
|
|||
// 添加请求拦截
|
||||
const httpInterceptor = {
|
||||
invoke(options) {
|
||||
// 1. 先判断请求 url 是否为完整的 http 请求路径 如果不是则拼接 baseURL
|
||||
if (!options.url.startsWith('http')) {
|
||||
options.url = baseURL + options.url
|
||||
}
|
||||
// console.log(options, 'options')
|
||||
|
||||
// 2. 设置请求超时时间,默认为60s,设置为 10s
|
||||
options.timeout = 10000
|
||||
if (options.isUploadFile) {
|
||||
if (!options.url.startsWith('http')) {
|
||||
options.url = baseURL + options.url
|
||||
}
|
||||
|
||||
// 3. 增加小程序端请求头标识
|
||||
options.header = {
|
||||
// 'source-client': 'mini',
|
||||
...options.header,
|
||||
}
|
||||
console.log(options.url, '文件上传')
|
||||
|
||||
// 4. 增加 token 请求头标识
|
||||
const memberStore = useMemberStore()
|
||||
const token = memberStore.token
|
||||
if (token) {
|
||||
options.header.Authorization = token
|
||||
options.header.Token = token
|
||||
// 2. 设置请求超时时间,默认为60s,设置为 10s
|
||||
options.timeout = 10000
|
||||
|
||||
// 3. 增加小程序端请求头标识
|
||||
options.header = {
|
||||
// 'source-client': 'mini',
|
||||
...options.header,
|
||||
}
|
||||
|
||||
// 4. 增加 token 请求头标识
|
||||
const memberStore = useMemberStore()
|
||||
const token = memberStore.token
|
||||
if (token) {
|
||||
options.header.Authorization = token
|
||||
}
|
||||
|
||||
console.log(options, 'options--**----')
|
||||
} else {
|
||||
// 1. 先判断请求 url 是否为完整的 http 请求路径 如果不是则拼接 baseURL
|
||||
if (!options.url.startsWith('http')) {
|
||||
options.url = baseURL + options.url
|
||||
}
|
||||
|
||||
// 2. 设置请求超时时间,默认为60s,设置为 10s
|
||||
options.timeout = 10000
|
||||
|
||||
// 3. 增加小程序端请求头标识
|
||||
options.header = {
|
||||
// 'source-client': 'mini',
|
||||
...options.header,
|
||||
}
|
||||
|
||||
// 4. 增加 token 请求头标识
|
||||
const memberStore = useMemberStore()
|
||||
const token = memberStore.token
|
||||
if (token) {
|
||||
options.header.Authorization = token
|
||||
options.header.Token = token
|
||||
}
|
||||
|
||||
const commonStore = useCommonStore() // 请求配置
|
||||
const requestConfig = commonStore.requestConfig // 请求配置
|
||||
|
||||
// 5. 增加请求配置
|
||||
// 入参加密
|
||||
options.header['encryptRequest'] = requestConfig.encryptRequest
|
||||
// 数据完整性校验
|
||||
options.header['checkIntegrity'] = requestConfig.checkIntegrity
|
||||
//回参是否加密
|
||||
options.header['encryptResponse'] = requestConfig.encryptResponse
|
||||
|
||||
const queryData =
|
||||
options.data instanceof Object ? JSON.stringify(options.data) : options.data
|
||||
|
||||
if (typeof queryData !== 'undefined' && options.method.toUpperCase() === 'POST') {
|
||||
// 加密数据
|
||||
if (requestConfig.encryptRequest) {
|
||||
options.data = encryptWithSM4(queryData + '|' + hashWithSM3AndSalt(queryData))
|
||||
}
|
||||
}
|
||||
|
||||
if (options.data instanceof Object && options.method.toUpperCase() === 'GET') {
|
||||
// 加密数据
|
||||
if (requestConfig.encryptRequest) {
|
||||
const url =
|
||||
options.url + '?' + tansParams(options.data, requestConfig.encryptRequest)
|
||||
|
||||
options.data = {}
|
||||
options.url = url
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
@ -48,8 +110,17 @@ export const http = (options) => {
|
|||
return new Promise((resolve, reject) => {
|
||||
uni.request({
|
||||
...options,
|
||||
|
||||
success(res) {
|
||||
console.log(res, '请求拦截器处的返回值')
|
||||
console.log(res, '请求拦截器处解密后的返回值')
|
||||
|
||||
if (res.header.encryptResponse) {
|
||||
console.log(JSON.parse(decryptWithSM4(res.data)), '解密后')
|
||||
|
||||
res.data = JSON.parse(decryptWithSM4(res.data))
|
||||
}
|
||||
|
||||
// console.log(res.data, '请求拦截器处解密后的返回值')
|
||||
// 1. 判断是否请求成功
|
||||
if (res.statusCode >= 200 && res.statusCode < 300) {
|
||||
if (res.data) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,90 @@
|
|||
// src/utils/encryption.js
|
||||
import { sm2, sm3, sm4 } from 'sm-crypto'
|
||||
// 配置项,例如盐值、SM2 公私钥、SM4 密钥
|
||||
import { SM_CONFIG } from './configure'
|
||||
import SM4 from 'sm-crypto/src/sm4'
|
||||
|
||||
// SM3 哈希
|
||||
export function hashSM3(text) {
|
||||
// 对数据进行哈希计算
|
||||
return sm3(text)
|
||||
}
|
||||
|
||||
// 使用 SM3 进行哈希并加入盐值
|
||||
export function hashWithSM3AndSalt(text) {
|
||||
// 将文本和盐值拼接在一起
|
||||
const textWithSalt = SM_CONFIG.SALT + text
|
||||
// 使用 SM3 进行哈希
|
||||
return hashSM3(textWithSalt)
|
||||
}
|
||||
|
||||
// SM2 加密
|
||||
export function encryptWithSM2(text) {
|
||||
// SM2 公钥加密
|
||||
return sm2.doEncrypt(text, SM_CONFIG.SM2_PUBLIC_KEY)
|
||||
}
|
||||
|
||||
// SM2 解密
|
||||
export function decryptWithSM2(encryptedText) {
|
||||
// SM2 私钥解密
|
||||
return sm2.doDecrypt(encryptedText, SM_CONFIG.SM2_PRIVATE_KEY)
|
||||
}
|
||||
/**
|
||||
* 加密函数
|
||||
* @param {string} plainText
|
||||
* @returns {string} 加密后的密文(Hex 编码格式)
|
||||
*/
|
||||
export function encryptWithSM4(plainText) {
|
||||
return sm4.encrypt(plainText, SM_CONFIG.SM4_KEY, {
|
||||
mode: 'cbc',
|
||||
padding: 'pkcs#5',
|
||||
iv: SM_CONFIG.SM4_SALT,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 解密函数
|
||||
* @param {string} cipherText
|
||||
* @returns {string} 解密后的明文
|
||||
*/
|
||||
export function decryptWithSM4(cipherText) {
|
||||
return SM4.decrypt(cipherText, SM_CONFIG.SM4_KEY, {
|
||||
mode: 'cbc',
|
||||
padding: 'pkcs#5',
|
||||
iv: SM_CONFIG.SM4_SALT,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数处理
|
||||
* @param {*} params 参数
|
||||
*/
|
||||
export function tansParams(params, isEncrypt = false) {
|
||||
let result = ''
|
||||
for (const propName of Object.keys(params)) {
|
||||
const value = params[propName]
|
||||
var part = encodeURIComponent(propName) + '='
|
||||
if (value !== null && value !== '' && typeof value !== 'undefined') {
|
||||
if (typeof value === 'object') {
|
||||
for (const key of Object.keys(value)) {
|
||||
if (
|
||||
value[key] !== null &&
|
||||
value[key] !== '' &&
|
||||
typeof value[key] !== 'undefined'
|
||||
) {
|
||||
let params = propName + '[' + key + ']'
|
||||
var subPart = encodeURIComponent(params) + '='
|
||||
result += subPart + encodeURIComponent(value[key]) + '&'
|
||||
}
|
||||
}
|
||||
} else {
|
||||
result += part + encodeURIComponent(value) + '&'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isEncrypt) {
|
||||
result = encryptWithSM4(result)
|
||||
}
|
||||
return result
|
||||
}
|
||||
Loading…
Reference in New Issue