You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

158 lines
3.7 KiB
Vue

1 year ago
<template>
1 year ago
<view class="main">
<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>
1 year ago
<view class="time">
1 year ago
<view class="dot"></view>
1 year ago
<u-count-down :time="5 * 1000" format="ss" ref="countDown" v-if="isAnimate"></u-count-down>
1 year ago
</view>
1 year ago
<view style="width:400rpx;">
1 year ago
<u-button
1 year ago
:text="tips"
1 year ago
shape="circle"
color="#76C458"
1 year ago
@click="startRecord"
1 year ago
:disabled="isAnimate"
1 year ago
></u-button>
<view style="margin-top: 20rpx;">
1 year ago
<u-button
text="确认"
shape="circle"
color="#76C458"
@click="back"
:disabled="isEnd||tips !== '⚪录制完成'"
></u-button>
1 year ago
</view>
</view>
</view>
</view>
1 year ago
</template>
<script>
1 year ago
export default {
data() {
return {
isAnimate: false,
1 year ago
tempVideoPath: "",
1 year ago
tips: "⚪录制",
isEnd: true
1 year ago
};
},
onLoad() {
this.ctx = uni.createCameraContext();
1 year ago
this.tips = "⚪录制";
1 year ago
},
methods: {
startRecord() {
this.ctx.startRecord({
success: res => {
this.isAnimate = true;
1 year ago
this.tips = "⚪录制中";
1 year ago
setTimeout(() => {
this.ctx.stopRecord({
success: res => {
1 year ago
console.log("自动停止录像", res);
1 year ago
this.isAnimate = false;
1 year ago
this.$common.msgToast("录制完成");
this.tempVideoPath = res.tempVideoPath;
this.tips = "⚪录制完成";
1 year ago
this.isEnd = false;
1 year ago
}
});
}, 5000);
}
});
},
1 year ago
// 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
// });
// }
// });
// },
1 year ago
back() {
uni.navigateTo({
1 year ago
url: "/pages/realName/realName?tempVideoPath=" + this.tempVideoPath
1 year ago
});
1 year ago
}
}
};
1 year ago
</script>
1 year ago
<style lang="scss" scoped>
.main {
box-sizing: border-box;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
.logo {
height: 200rpx;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
.img {
width: 124rpx;
height: 72rpx;
}
}
.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;
1 year ago
1 year ago
.dot {
width: 30rpx;
height: 30rpx;
background: red;
box-sizing: border-box;
border-radius: 50%;
margin-right: 20rpx;
}
}
}
}
1 year ago
</style>