2025/07/24 APP端人脸
parent
246f61f975
commit
9dc6aad85e
|
@ -1,4 +1,4 @@
|
||||||
import {post, upload, uploads,videoApiGet} from "@/utils/request";
|
import {post, upload, uploads,videoApiGet,loginRequest} from "@/utils/request";
|
||||||
|
|
||||||
export const submitLogin = (params) => post("/sys/login", params) // 登录
|
export const submitLogin = (params) => post("/sys/login", params) // 登录
|
||||||
export const getUserInfo = (params) => post("/sys/user/info/app", params); // 获取用户信息
|
export const getUserInfo = (params) => post("/sys/user/info/app", params); // 获取用户信息
|
||||||
|
|
|
@ -821,6 +821,12 @@
|
||||||
"navigationBarTitleText" : "股份公司车辆管理"
|
"navigationBarTitleText" : "股份公司车辆管理"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/mine/face/face_authentication",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "人脸认证"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"path" : "pages/door_access_control/share_office_vehicle_info/add",
|
"path" : "pages/door_access_control/share_office_vehicle_info/add",
|
||||||
"style" : {
|
"style" : {
|
||||||
|
|
|
@ -0,0 +1,138 @@
|
||||||
|
<template>
|
||||||
|
<view class="container">
|
||||||
|
<view class="fat">
|
||||||
|
<text class="fatt">请将人脸置于圆圈内</text>
|
||||||
|
</view>
|
||||||
|
<view class="livefater">
|
||||||
|
<view style="width: 700upx; height: 700upx; border-radius: 700upx; overflow: hidden">
|
||||||
|
<live-pusher id="livePusher" ref="livePusher" class="livePusher" url="" mode="SD" :muted="true"
|
||||||
|
:enable-camera="true" :auto-focus="true" :beauty="1" whiteness="2" aspect="1:1" />
|
||||||
|
</view>
|
||||||
|
<cover-image src="/static/images/gaiz.png" class="gaiimg"></cover-image>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view style="margin: 0 100upx">
|
||||||
|
<u-button :text="btnTextStr" type="primary" @click="snapshot" />
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {
|
||||||
|
submitEditUserFace,
|
||||||
|
compareUserFaceCertify,
|
||||||
|
compareUserExamFaceCertify
|
||||||
|
} from '@/api';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
startPreviewTimer: null, // 开始预览计时器实例
|
||||||
|
btnTextStr: '拍照'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onReady() {
|
||||||
|
this.context = uni.createLivePusherContext('livePusher', this)
|
||||||
|
this.startPreviewTimer = setInterval(() => {
|
||||||
|
this.startPreview()
|
||||||
|
}, 1000)
|
||||||
|
},
|
||||||
|
onUnload() {
|
||||||
|
this.startPreviewTimer && clearInterval(this.startPreviewTimer)
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
snapshot() {
|
||||||
|
uni.showLoading({
|
||||||
|
title: '加载中'
|
||||||
|
})
|
||||||
|
this.context.snapshot({
|
||||||
|
success: (e) => {
|
||||||
|
this.getMinImage(e.message.tempImagePath)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
startPreview() {
|
||||||
|
this.context.stopPreview()
|
||||||
|
this.context.startPreview({
|
||||||
|
success: () => {
|
||||||
|
this.startPreviewTimer && clearInterval(this.startPreviewTimer)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
getMinImage(imgPath) {
|
||||||
|
plus.zip.compressImage({
|
||||||
|
src: imgPath,
|
||||||
|
dst: imgPath,
|
||||||
|
overwrite: true,
|
||||||
|
quality: 40
|
||||||
|
},
|
||||||
|
(zipRes) => {
|
||||||
|
setTimeout(() => {
|
||||||
|
const reader = new plus.io.FileReader()
|
||||||
|
reader.onloadend = async (res) => {
|
||||||
|
const speech = res.target.result
|
||||||
|
// 获取 base 64 图片编码的前缀
|
||||||
|
const USERAVATARPREFIX = speech.substring(0, speech.indexOf(
|
||||||
|
'base64,') + 7)
|
||||||
|
// 获取 base 64 图片的二进制到文本
|
||||||
|
const USERAVATARURL = speech.substring(speech.indexOf('base64,') + 7)
|
||||||
|
try {
|
||||||
|
// TODO USERAVATARPREFIX USERAVATARURL
|
||||||
|
// 调用 API 提交人脸图片
|
||||||
|
const fullBase64 = USERAVATARPREFIX + USERAVATARURL;
|
||||||
|
console.log(fullBase64)
|
||||||
|
console.log(this.$store.getters.getUserInfo.USER_ID)
|
||||||
|
const res = await submitEditUserFace({ faceData: fullBase64, userId: this.$store.getters.getUserInfo.USER_ID });
|
||||||
|
uni.hideLoading();
|
||||||
|
uni.$u.toast('上传成功');
|
||||||
|
uni.navigateBack({ delta: 1 });
|
||||||
|
} catch (e) {
|
||||||
|
if (e && e.msg) {
|
||||||
|
uni.$u.toast(e.msg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
reader.readAsDataURL(plus.io.convertLocalFileSystemURL(zipRes.target))
|
||||||
|
}, 4000)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.container {
|
||||||
|
background-color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.livePusher {
|
||||||
|
width: 700upx;
|
||||||
|
height: 700upx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.livefater {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
margin-bottom: 100upx;
|
||||||
|
height: 700upx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fat {
|
||||||
|
margin: 100upx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fatt {
|
||||||
|
text-align: center;
|
||||||
|
font-size: 36upx;
|
||||||
|
font-weight: 800;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gaiimg {
|
||||||
|
width: 700upx;
|
||||||
|
height: 700upx;
|
||||||
|
margin-top: -700upx;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -61,6 +61,10 @@ export default {
|
||||||
img: require('../../../static/images/my_ico1.png'),
|
img: require('../../../static/images/my_ico1.png'),
|
||||||
name:'个人信息',
|
name:'个人信息',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
img: require('../../../static/images/my_ico2.png'),
|
||||||
|
name: '人脸认证',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
img: require('../../../static/images/my_ico3.png'),
|
img: require('../../../static/images/my_ico3.png'),
|
||||||
name:'问题反馈',
|
name:'问题反馈',
|
||||||
|
@ -137,11 +141,17 @@ export default {
|
||||||
url: '/pages/mine/promise/promise'
|
url: '/pages/mine/promise/promise'
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
faceAuthentication() {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '/pages/mine/face/face_authentication'
|
||||||
|
})
|
||||||
|
},
|
||||||
clickItem(name){
|
clickItem(name){
|
||||||
if(name === '个人信息') this.goabout()
|
if(name === '个人信息') this.goabout()
|
||||||
if(name === '问题反馈') this.feedbackclick()
|
if(name === '问题反馈') this.feedbackclick()
|
||||||
if(name === '安全承诺') this.promiseclick()
|
if(name === '安全承诺') this.promiseclick()
|
||||||
if(name === '修改密码') this.pwdclick()
|
if(name === '修改密码') this.pwdclick()
|
||||||
|
if(name === '人脸认证') this.faceAuthentication()
|
||||||
// #ifdef APP-PLUS
|
// #ifdef APP-PLUS
|
||||||
if(name === '版本更新') this.fnUpdateVersion()
|
if(name === '版本更新') this.fnUpdateVersion()
|
||||||
// #endif
|
// #endif
|
||||||
|
|
|
@ -226,6 +226,51 @@ function videoApiGet(url, data) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function loginRequest(url, data = {}) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
if (data && data.loading !== false) {
|
||||||
|
uni.showLoading({
|
||||||
|
title: "加载中",
|
||||||
|
mask: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
uni.request({
|
||||||
|
url: requestPath + url,
|
||||||
|
data: {
|
||||||
|
...data,
|
||||||
|
},
|
||||||
|
header: {
|
||||||
|
"Content-type": data?.postMethod || "application/json",
|
||||||
|
},
|
||||||
|
method: "POST",
|
||||||
|
success: (res) => {
|
||||||
|
if (data && data.loading !== false) {
|
||||||
|
uni.hideLoading();
|
||||||
|
}
|
||||||
|
if (res.data.result === "success") {
|
||||||
|
resolve(res.data);
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: res.data || "系统开小差了",
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
reject(res.data);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail: (err) => {
|
||||||
|
if (data && data.loading !== false) {
|
||||||
|
uni.hideLoading();
|
||||||
|
}
|
||||||
|
uni.showToast({
|
||||||
|
title: "网络错误请重试",
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
reject(err);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
setInterval(async () => {
|
setInterval(async () => {
|
||||||
if (uni.getStorageSync('tokenTime') == null) return;
|
if (uni.getStorageSync('tokenTime') == null) return;
|
||||||
if (dayjs().diff(dayjs(uni.getStorageSync('tokenTime')), "minute") >= 5) {
|
if (dayjs().diff(dayjs(uni.getStorageSync('tokenTime')), "minute") >= 5) {
|
||||||
|
@ -234,4 +279,4 @@ setInterval(async () => {
|
||||||
}
|
}
|
||||||
}, 1000 * 60);
|
}, 1000 * 60);
|
||||||
|
|
||||||
export {post, upload, uploads,setBasePath,videoApiGet}
|
export {post, upload, uploads,setBasePath,videoApiGet,loginRequest}
|
||||||
|
|
Loading…
Reference in New Issue