以下是基本代码:
<template>
<view style="background-color: #fff;">
<view class="myNavigationBar" :style="{ height: cHeight + textHight + 'rpx' }">
<view class="navigationBar" :style="{ height: cHeight + 'rpx', backgroundColor: '#0055ff' }"></view>
<view class="navigationBarText" :style="{ top: cHeight + 'rpx', backgroundColor: '#fff', color: '#333' }">
<image src="https://sxhcxfyy-1305280360.cos.ap-beijing.myqcloud.com/sxhcxfyy/cecf*fanhui@3x%20(2).png"
class="backImg"></image>
<text class="barBack" @click="BackPage">返回</text>
<text class="barTitle">{
{type == 'login' ? '人脸登录' : '人脸新增' }}</text>
</view>
</view>
<div>
<text
style="text-align: center;font-size: 60rpx;color: #333;margin-top: 40rpx;">{
{type == 'login' ? '人脸登录服务' : '人脸新增服务' }}</text>
</div>
<div class="tixing_text">
<text v-if="text == '验证成功!' || text == '新增成功!'" style="font-size: 30rpx;color: #18B566;">{
{ text }}</text>
<text v-else style="font-size: 30rpx;color: #F29100;">{
{ text }}</text>
</div>
<div class="livefater">
<div style="width: 350rpx;height: 350rpx;border-radius: 350rpx;overflow: hidden;background-color: #CCCCCC;">
<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"></live-pusher>
</div>
<cover-image
src="https://sxhcxfyy-1305280360.cos.ap-beijing.myqcloud.com/sxhcxfyy/d26d*微信图片_20210411170242.png"
class="gaiimg"></cover-image>
<cover-image src="https://sxhcxfyy-1305280360.cos.ap-beijing.myqcloud.com/app/icon/faceBottom.png"
class="gaiimg2"></cover-image>
</div>
</view>
</template>
<script>
import axios from '../../plugins/pocky-request/index.js';
export default {
data: {
statusBar: '',
CustomBar: 0,
uid: '',
type: '',
addFlag: false,
err_num: 0,
// post: null
timer: null,
snapshTimeout: null,
text: '请正对屏幕进行人脸识别',
textHight: '',
cHeight: ''
},
onLoad(e) {
this.type = e.type;
this.uid = e.uid;
},
onReady() {
var that = this;
// 注意:需要在onReady中 或 onLoad 延时
this.context = uni.createLivePusherContext('livePusher', this);
setTimeout(function() {
that.context.startPreview({
success: a => {
that.snapshot();
}
});
}, 200);
uni.getSystemInfo({
success: function(res) {
if (res.platform == 'android') {
that.cHeight = res.statusBarHeight + 50;
} else {
that.cHeight = res.statusBarHeight + 45;
}
}
});
this.textHight = 87;
},
methods: {
async post(obj = {
url: '',