uni-Identify-quality/pages/cameraContext/cameraContext.vue

168 lines
4.1 KiB
Vue
Raw Normal View History

2023-09-19 11:18:11 +00:00
<template>
2024-04-01 09:02:13 +00:00
<view class="main" v-if="needPersonSecret">
2023-09-20 07:11:23 +00:00
<view class="logo">
<image src="@/static/image/logo2.png" mode="scaleToFill" class="img" />
</view>
<view class="container">
<view style="color:#626262;font-size:40rpx">人脸识别</view>
<camera
device-position="front"
flash="off"
binderror="error"
mode="normal"
style="width: 600rpx; height: 600rpx"
ref="camera"
>
<cover-image src="@/static/image/camera.png" style="width: 600rpx; height: 600rpx"></cover-image>
</camera>
2023-09-22 05:13:26 +00:00
<view class="time">
2023-09-20 07:11:23 +00:00
<view class="dot"></view>
2023-09-22 05:13:26 +00:00
<u-count-down :time="5 * 1000" format="ss" ref="countDown" v-if="isAnimate"></u-count-down>
2023-09-20 07:11:23 +00:00
</view>
2023-09-26 11:03:35 +00:00
<view style="width:400rpx;">
2023-09-20 07:11:23 +00:00
<u-button
2023-09-26 11:03:35 +00:00
:text="tips"
2023-09-20 07:11:23 +00:00
shape="circle"
color="#76C458"
2023-09-26 11:03:35 +00:00
@click="startRecord"
2023-09-26 11:26:41 +00:00
:disabled="isAnimate"
2023-09-20 07:11:23 +00:00
></u-button>
<view style="margin-top: 20rpx;">
2023-09-27 03:00:50 +00:00
<u-button
text="确认"
shape="circle"
color="#76C458"
@click="back"
:disabled="isEnd||tips !== '⚪录制完成'"
></u-button>
2023-09-20 07:11:23 +00:00
</view>
</view>
</view>
</view>
2023-09-19 11:18:11 +00:00
</template>
<script>
2024-04-01 09:02:13 +00:00
import {configFun} from "../../http/login";
2023-09-20 07:11:23 +00:00
export default {
data() {
return {
2024-04-01 09:02:13 +00:00
needPersonSecret:false,
2023-09-20 07:11:23 +00:00
isAnimate: false,
2023-09-26 11:03:35 +00:00
tempVideoPath: "",
2023-09-26 11:26:41 +00:00
tips: "⚪录制",
isEnd: true
2023-09-20 07:11:23 +00:00
};
},
2024-04-01 09:02:13 +00:00
async onLoad() {
const res= await configFun()
if (res.code===200){
this.needPersonSecret=res.data.needPersonSecret
}
2023-09-20 07:11:23 +00:00
this.ctx = uni.createCameraContext();
2023-09-26 11:03:35 +00:00
this.tips = "⚪录制";
2023-09-20 07:11:23 +00:00
},
methods: {
startRecord() {
this.ctx.startRecord({
success: res => {
this.isAnimate = true;
2023-09-26 11:03:35 +00:00
this.tips = "⚪录制中";
2023-09-20 07:11:23 +00:00
setTimeout(() => {
this.ctx.stopRecord({
success: res => {
2023-09-22 05:13:26 +00:00
console.log("自动停止录像", res);
2023-09-20 07:11:23 +00:00
this.isAnimate = false;
2023-09-26 11:03:35 +00:00
this.$common.msgToast("录制完成");
this.tempVideoPath = res.tempVideoPath;
this.tips = "⚪录制完成";
2023-09-26 11:26:41 +00:00
this.isEnd = false;
2023-09-28 03:18:57 +00:00
uni.setStorageSync("tempVideoPath", res.tempVideoPath);
2023-09-20 07:11:23 +00:00
}
});
}, 5000);
}
});
},
2023-09-26 11:03:35 +00:00
// stopRecord() {
// // 手动停止录制
// this.ctx.stopRecord({
// success: res => {
// console.log("手动停止录像", res);
// this.tempVideoPath = res.tempVideoPath;
// this.isAnimate = false;
// },
// fail: function(error) {
// console.log(error);
// this.isAnimate = false;
// uni.showModal({
// content: "停止录像失败",
// showCancel: false
// });
// }
// });
// },
2023-09-22 05:13:26 +00:00
back() {
2023-09-28 03:18:57 +00:00
uni.navigateBack({
delta: 2
2023-09-22 05:13:26 +00:00
});
2023-09-20 07:11:23 +00:00
}
}
};
2023-09-19 11:18:11 +00:00
</script>
2023-09-20 07:11:23 +00:00
<style lang="scss" scoped>
.main {
box-sizing: border-box;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
.logo {
2023-11-07 06:35:24 +00:00
width: 100%;
2023-09-20 07:11:23 +00:00
height: 200rpx;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
2023-11-07 06:35:24 +00:00
background: url("https://cdns.fontree.cn/fonchain-main/prod/image/1381bd18-2f0c-49f1-84f6-d3eceb94f7a7/artwork/6ef00a09-f663-451d-ae0c-0d00cf4068c5.png");
2023-09-20 07:11:23 +00:00
.img {
2023-11-07 06:35:24 +00:00
width: 142rpx;
height: 60rpx;
2023-09-20 07:11:23 +00:00
}
}
.container {
display: flex;
justify-content: space-between;
align-items: center;
flex-direction: column;
flex: 1;
box-sizing: border-box;
height: calc(100vh - 200upx);
width: 100%;
background: #fff;
border-radius: 40rpx 40rpx 0rpx 0rpx;
padding: 62rpx 32rpx;
.time {
display: flex;
justify-content: center;
align-items: center;
2023-09-26 11:26:41 +00:00
2023-09-20 07:11:23 +00:00
.dot {
width: 30rpx;
height: 30rpx;
background: red;
box-sizing: border-box;
border-radius: 50%;
margin-right: 20rpx;
}
}
}
}
2024-04-01 09:02:13 +00:00
</style>