|
|
@@ -1,6 +1,7 @@
|
|
|
<template>
|
|
|
- <view v-show="!showConfirmBtn" class="sxt-tip-box">{{textMess}}</view>
|
|
|
- <camera v-show="showConfirmBtn" class="zp-camera" device-position="front" flash="off" @initdone="onVideoSuccess"></camera>
|
|
|
+ <view class="video-container">
|
|
|
+ <camera class="zp-camera" device-position="front" flash="off" @initdone="onVideoSuccess"></camera>
|
|
|
+ </view>
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
@@ -22,7 +23,6 @@
|
|
|
let zhuapaiFun = null;
|
|
|
let stopCamera = null;
|
|
|
let errorFunCompleteFn = null;
|
|
|
- const textMess = ref('摄像头正在初始化...')
|
|
|
|
|
|
function startCamera() {
|
|
|
// 请求摄像头权限并获取流
|
|
|
@@ -35,23 +35,16 @@
|
|
|
|
|
|
|
|
|
function onVideoSuccess() {
|
|
|
- showConfirmBtn.value = true;
|
|
|
}
|
|
|
|
|
|
function onVideoError(e) {
|
|
|
- showConfirmBtn.false = true;
|
|
|
- textMess.value = '摄像头初始化失败!'
|
|
|
emits('error')
|
|
|
errorFunCompleteFn && errorFunCompleteFn(e)
|
|
|
}
|
|
|
|
|
|
function showDialog() {
|
|
|
- textMess.value = '摄像头正在初始化...'
|
|
|
setTimeout(() => {
|
|
|
- showConfirmBtn.value = true;
|
|
|
- nextTick(() => {
|
|
|
- startCamera()
|
|
|
- })
|
|
|
+ startCamera()
|
|
|
},1000)
|
|
|
}
|
|
|
|
|
|
@@ -74,3 +67,14 @@
|
|
|
stopCamera && stopCamera();
|
|
|
})
|
|
|
</script>
|
|
|
+
|
|
|
+<style lang="scss">
|
|
|
+ .video-container {
|
|
|
+ position: relative;
|
|
|
+ overflow: hidden;
|
|
|
+
|
|
|
+ .zp-camera {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+</style>
|