|
|
|
@ -104,9 +104,9 @@
|
|
|
|
|
<script>
|
|
|
|
|
// import { validUsername } from '@/utils/validate'
|
|
|
|
|
import stringify from '@/utils/stringify'
|
|
|
|
|
import { faceRecognition, faceStart, faceStop, login } from '@/api/user/user'
|
|
|
|
|
import { faceStart, faceStop, login } from '@/api/user/user'
|
|
|
|
|
import { client_list } from '@/api/common'
|
|
|
|
|
import { throttle, web_stream as webStream } from '@/utils'
|
|
|
|
|
import { throttle } from '@/utils'
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
name: 'Login',
|
|
|
|
@ -155,6 +155,9 @@ export default {
|
|
|
|
|
immediate: true
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
beforeDestroy() {
|
|
|
|
|
this.sockets.unsubscribe('reco')
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
handleClose: throttle(function() {
|
|
|
|
|
faceStop().then(
|
|
|
|
@ -162,7 +165,6 @@ export default {
|
|
|
|
|
console.log(res)
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
this.web_stream.destroy()
|
|
|
|
|
this.play = null
|
|
|
|
|
this.rflag = false
|
|
|
|
|
}, 1000),
|
|
|
|
@ -171,25 +173,22 @@ export default {
|
|
|
|
|
faceStart().then(res => {
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.play = process.env.VUE_APP_FACE_API + '/face/play/'
|
|
|
|
|
this.web_stream = webStream.get(process.env.VUE_APP_FACE_API + '/face/play/', (data) => {
|
|
|
|
|
if (data.length > 41) {
|
|
|
|
|
const buffer = Buffer.allocUnsafe(data.byteLength - 41)
|
|
|
|
|
data.copy(buffer, 0, 37)
|
|
|
|
|
this.img_src = buffer.toString('base64')
|
|
|
|
|
const count = Math.floor(Math.random() * 10 + 1)
|
|
|
|
|
// 随机抽样
|
|
|
|
|
if (count < 2) {
|
|
|
|
|
this.img_list.push('data:image/png;base64,' + this.img_src)
|
|
|
|
|
}
|
|
|
|
|
if (this.img_list.length > 10 && this.rflag) {
|
|
|
|
|
const data = {
|
|
|
|
|
'images': this.img_list
|
|
|
|
|
}
|
|
|
|
|
faceRecognition(data).then((res) => {
|
|
|
|
|
this.rflag = false
|
|
|
|
|
})
|
|
|
|
|
this.img_list = []
|
|
|
|
|
this.sockets.subscribe('reco', (res) => {
|
|
|
|
|
if (res.status === 0) {
|
|
|
|
|
// 人脸识别成功
|
|
|
|
|
this.$message.success(res.msg)
|
|
|
|
|
this.$store.commit('user/SET_TOKEN', res.data.token)
|
|
|
|
|
this.$store.dispatch('permission/generateRoutes')
|
|
|
|
|
this.$router.replace('/home')
|
|
|
|
|
// 登录后立刻获取client数据供后续使用
|
|
|
|
|
client_list().then(
|
|
|
|
|
res => {
|
|
|
|
|
this.$store.commit('app/SET_COPTS', res.data.data_list)
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
} else {
|
|
|
|
|
// 人脸识别失败
|
|
|
|
|
this.$message.warning(res.msg)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
this.rflag = true
|
|
|
|
@ -452,6 +451,7 @@ $light_gray: #eee;
|
|
|
|
|
text-align: center;
|
|
|
|
|
margin-top: 2rem;
|
|
|
|
|
margin-bottom: 2rem;
|
|
|
|
|
|
|
|
|
|
img {
|
|
|
|
|
height: 23.4375rem;
|
|
|
|
|
width: 23.4375rem;
|
|
|
|
@ -482,7 +482,8 @@ $light_gray: #eee;
|
|
|
|
|
font-weight: 400;
|
|
|
|
|
color: #C0C4CC;
|
|
|
|
|
}
|
|
|
|
|
.dia-back{
|
|
|
|
|
|
|
|
|
|
.dia-back {
|
|
|
|
|
margin-top: 0.5rem;
|
|
|
|
|
text-align: center;
|
|
|
|
|
}
|
|
|
|
|