uniapp 小程序 身份证 和人脸视频拍摄
使用前提:
已经在微信公众平台的用户隐私协议,已经选择配置“摄像头,录像”等权限
开发背景:客户需要使用带有拍摄边框的摄像头 ,微信小程序的方法无法支持,使用camera修改
身份证正反面:
<template><view :style="{ height: windowHeight + 'px' }"><cameramode="normal":device-position="devicePosition"flash="off":style="{ height: cameraHeight + 'px' }"><cover-view class="controls" style="width: 100%;height: 100%;"><!-- 国徽面 --><cover-imagev-show="!idcardFrontSide"class="w569-h828"src="/static/images/index/camera_module_side.png"/></cover-view><!-- 国徽面 --><cover-imagev-show="!idcardFrontSide"class="w569-h828"src="/static/images/index/camera_module_side.png"/></cover-view></camera><view class="bottom font-36-fff"><view class="wrap"><view class="back" @click="switchBtn">切换</view><view @click="takePhoto"><image class="w131-h131" src="/static/images/index/take_camera_btn_icon.png"></image></view><view @click="chooseImage">相册</view></view></view></view>
</template><script>export default {data() {return {cameraContext: {},windowHeight: '',cameraHeight: '',idcardFrontSide: true,devicePosition: 'front',};},onLoad(options) {if(uni.createCameraContext) {this.cameraContext = uni.createCameraContext()}else {// 如果希望用户在最新版本的客户端上体验您的小程序,可以这样子提示uni.showModal({title: '提示',content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'})}},onShow() {const systemInfo = uni.getSystemInfoSync()this.windowHeight = systemInfo.windowHeightthis.cameraHeight = systemInfo.windowHeight - 80},methods: {// 拍照takePhoto() {uni.showLoading({title:'拍摄中'})this.cameraContext.takePhoto({quality: 'high',success: (res) => {uni.showToast({title:'拍照成功',icon: 'none',duration: 1200})},fail: (err) => {uni.showToast({title:'拍照失败,请检查系统是否授权',icon: 'none',duration: 1200})}})},// 从相册选取chooseImage() {uni.chooseImage({count: 1,sizeType: ['original', 'compressed'],sourceType: ['album'],success: (res) => {},fail: (err) => {}});},},// 切换摄像头switchBtn() {if(this.devicePosition === 'back') {this.devicePosition = 'front'} else {this.devicePosition = 'back'}},}
</script><style lang="less" scoped>.icon-w569-h828 {width: 569rpx;height: 828rpx;}.controls {position: relative;display: flex;align-items: center;justify-content: center;}.bottom {width: 100%;background-color: #000;.wrap {display: flex;align-items: center;justify-content: space-between;height: 80px;padding: 0 73rpx;}}.w569-h828 {width: 569rpx;height: 828rpx;}.w131-h131 {width: 131rpx;height: 131rpx;}.font-36-fff {font-size: 36rpx;color: #fff;}
</style>
人脸视频:
<template><!-- 第三步上传视频 --><view class="container background-color-474747" :style="{height: windowHeight + 'px'}"><view class="video-wrap wpercent-100 text-align" :style="{height: takeVideoHeight + 'px'}" v-if="tipShow"><view class="content-wrap"><view class="font-36-fff font-weight">请保持声音清晰,话术完整,露出五官</view><view class="padding-top-20 font-36-fff font-weight">不符合以上要求,需重新拍摄</view><view class="padding-top-35 padding-bottom-30 font-24-FF2323 font-weight">点击下方按钮开始拍摄</view><image class="tips-icon" src="/static/images/index/take_video_tips.png"></image><text class="know" @click="startCenterCountDown">知道了</text></view></view><view class="video-wrap wpercent-100" v-if="cameraShow" ><view v-if="!centerCountDownShow" class="number">{{ second }}s</view><camera mode="normal"class="wpercent-100":device-position="devicePosition" :style="{height: takeVideoHeight + 'px'}"><!-- 中间3,2,1倒计时 --><cover-view class="center-count-down-wrap" v-if="centerCountDownShow && centerCountDownValue != 4"><cover-view :class="centerCountDownValue === '开始' ? 'center-count-down-start' : 'center-count-down'">{{ centerCountDownValue }}</cover-view></cover-view><!-- 正式拍照人面框 --><cover-image v-if="!centerCountDownShow" class="controls" src="/static/images/index/take_video_back.png"/><cover-view class="font-36-fff font-weight absolute-one-font" v-if="!centerCountDownShow">正视镜头录制一段匀速朗读下方数字的视频</cover-view><cover-view class="font-36-fff font-weight absolute-two-font" v-if="!centerCountDownShow">1234</cover-view></camera></view><transition name="fade" :duration="{ enter: 500, leave: 800 }"><view class="bottom" v-if="showBottom"><view class="wrap"><view class="back" @click="backTwoStep"><image class="w55-h49" src="/static/images/index/back_before_icon.png"></image></view><!-- 开始倒计时 --><view class="take" @click="startCenterCountDown" v-if="tipShow"> <image class="w100-h100" src="/static/images/index/take_btn_icon.png"></image></view><!-- 点击就暂停 --><view class="take" @click="stopRecord" v-if="cameraShow && !centerCountDownShow"><image class="w100-h100" src="/static/images/index/take_btn_icon.png"></image></view><view class="switch" @click="switchCamera"><image class="w69-h56" src="/static/images/index/switch_camera_icon.png"></image></view></view></view></transition></view>
</template><script>export default {data() {return {windowHeight: '',takeVideoHeight: '',tipShow: true,showBottom: true,centerCountDownShow: false,cameraShow: false,centerCountDownValue: 4,cameraContext: {},devicePosition: 'front',second: 9,setTimer: '',};},onLoad() {if(uni.createCameraContext) {setTimeout(() => {this.cameraContext = uni.createCameraContext();},200)}else {// 如果希望用户在最新版本的客户端上体验您的小程序,可以这样子提示uni.showModal({title: '提示',content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'})}},created() {const systemInfo = uni.getSystemInfoSync()this.windowHeight = systemInfo.windowHeightthis.computedHeight(80)},methods: {// 计算heightcomputedHeight (number) {const systemInfo = uni.getSystemInfoSync()this.takeVideoHeight = systemInfo.windowHeight - number},// 开始倒计时 3,2,1,开始startCenterCountDown () {this.computedHeight(0)this.setBoolean(false)this.centerCountDown()},// 中间倒计时centerCountDown() {let promise = new Promise((resolve, reject) => {let setTimer = setInterval(() => {if(this.centerCountDownValue === 1) {this.centerCountDownValue = '开始'resolve(setTimer)} else {this.centerCountDownValue = this.centerCountDownValue - 1}if(this.centerCountDownValue === 2) { // this.cameraContext.startRecord 有延迟执行的问题,所以需要提前半秒执行setTimeout(() => {this.startRecord()}, 1200)}}, 1000)})promise.then((setTimer) => {clearInterval(setTimer)this.computedHeight(80)this.showBottom = truethis.centerCountDownShow = false})},// 开始录像startRecord() {this.cameraContext.startRecord({success: (res) => {this.rightTopCountDown()},fail: (err) => {uni.showToast({title: '录像失败,请重试',icon: 'none',duration: 1200})}})},// 右上角倒计时rightTopCountDown() {let promise = new Promise((resolve, reject) => {this.setTimer = setInterval(() => {this.second = this.second - 1if (this.second <= 0) {this.stopRecord()resolve(this.setTimer)}}, 1000)})promise.then((setTimer) => {clearInterval(setTimer)this.second = 9})},// 结束录像stopRecord() {uni.showToast({title: '结束录像,正在处理视频',icon: 'none',duration: 10000})clearInterval(this.setTimer)this.second = 9this.showBottom = falsethis.computedHeight(0)this.cameraContext.stopRecord({compressed: true,success: (res) => {uni.setStorageSync('taxCollectVideoPath',res.tempVideoPath)setTimeout(() => {this.stopRecordInitData()}, 500)},fail: (err) => {this.showBottom = truethis.computedHeight(80)uni.showToast({title: '操作失败,请重试',icon: 'none',duration: 1200})}})},// 切换摄像头switchCamera() {if(this.devicePosition === 'back') {this.devicePosition = 'front'} else {this.devicePosition = 'back'}},// 结束录像之后 初始数据stopRecordInitData () {this.computedHeight(80)this.setBoolean(true)this.centerCountDownValue = 4this.second = 9},// 设置 booleansetBoolean(boolean) {this.tipShow = booleanthis.showBottom = booleanthis.cameraShow = !booleanthis.centerCountDownShow = !boolean},}}
</script><style lang="less" scoped>.container {position: relative;.video-wrap {position: relative;.content-wrap {position: absolute;bottom: 150px;width: 100%;}.padding-bottom-40 {padding-bottom: 40rpx;}.tips-icon {position: absolute;left: 242rpx;width: 96rpx;height: 327rpx;}.know {position: relative;top: 210rpx;left: 155rpx;display: inline-block;width: 199rpx;height: 92rpx;line-height: 92rpx;text-align: center;border: 3rpx dashed #fff;border-radius: 5rpx;font-size: 48rpx;color: #fff;}.number {position: absolute;top: 15px;right: 20px;z-index: 11;color: #fff;width: 30px;height: 30px;background-color: #7a7a7a;border-radius: 50%;text-align: center;line-height: 30px;}.center-count-down-wrap {display: flex;justify-content: center;align-items: center;width: 100%;height: 100%;}.center-count-down {font-size: 330rpx;color: #fff;font-weight: bold;}.center-count-down-start {font-size: 220rpx;color: #fff;font-weight: bold;}}.controls {position: absolute;bottom: 200rpx;width: 100%;height: 753rpx;}.absolute-one-font {position: absolute;left: 4.5%;bottom: 130rpx;}.absolute-two-font {position: absolute;bottom: 30rpx;left: 44%;}.bottom {// position: fixed;// bottom: 0;width: 100%;background-color: #000;.wrap {display: flex;align-items: center;justify-content: space-between;height: 80px;padding: 0 73rpx;}}.fade-enter-active, .fade-leave-active {transition: opacity .5s;}.fade-enter, .fade-leave-to /* .fade-leave-active below version 2.1.8 */ {opacity: 0;}.background-color-474747 {background-color: #474747;}.wpercent-100 {width: 100%;}.text-align {text-align: center;}.font-36-fff {font-size: 36rpx;color: #fff;}.font-weight {font-weight: bold;}.w55-h49 {width: 55rpx;height: 49rpx;}.w100-h100 {width: 100rpx;height: 100rpx;}.w69-h56 {width: 69rpx;height: 56rpx;}}
</style>
效果图:
借鉴的是uniapp-components,记录一下如何使用
相关文章:

uniapp 小程序 身份证 和人脸视频拍摄
使用前提: 已经在微信公众平台的用户隐私协议,已经选择配置“摄像头,录像”等权限 开发背景:客户需要使用带有拍摄边框的摄像头 ,微信小程序的方法无法支持,使用camera修改 身份证正反面: <…...
飞腾ARM UOS编译Qt 5.15.2源码及Qt Creator
背景 在 ARM 架构下,UOS 系统,需要使用 Qt 5.15.2 版本环境,所以只能通过源码编译的形式进行 Qt 环境的部署。 软硬件相关信息: 处理器: 飞腾 FT-2000 4 核制造商: Phytium架构: aarch 64家族: ARMv 8系统:UOS V 20…...

Oracle(2-2)Oracle Net Architecture
文章目录 一、基础知识1、Oracle Net Connections Oracle网络连接2、C/S Application Connection C/S应用程序连接3、OSI Communication Layers OSI通信层4、Oracle Protocol Support Oracle协议支持5、B/S Application Connections B/S应用程序连接6、TwoTypes JDBC Drivers 两…...

高速高精运动控制,富唯智能AI边缘控制器助力自动化行业变革
随着工业大数据时代的到来,传统控制与决策方式无法满足现代数字化工厂对工业大数据分析与决策的需求,AI边缘控制器赋能现代化智慧工厂,实现工业智造与行业变革。 富唯智能AI边缘控制器,基于x86架构的IPC形态产品,通过…...

GPTS应用怎么创建?GPTS无法创建应用很卡怎么办
在首届开发者大会上,OpenAI宣布推出了GPTs功能,也就是GPT Store,类似App Store的应用商店,任何用户都可以去参与创建应用。那么GPTS应用该如何创建?碰到应用无法创建很卡怎么办呢?下面就为大家带来GPTS应用创建图文教程…...
目标检测YOLO实战应用案例100讲-基于无人机的运动目标检测
目录 前言 国内外研究现状 2运动目标检测相关理论基础 2.1 运动目标检测算法...

东莞松山湖数据中心|莞服务器托管的优势
东莞位于珠江三角洲经济圈,交通便利,与广州、深圳等大城市相邻,而且东莞是中国重要的制造业基地,有众多的制造业和科技企业集聚于此,随着互联网和数字化时代的到来,企业都向数字化转型,对于信息…...

时间序列预测实战(十五)PyTorch实现GRU模型长期预测并可视化结果
往期回顾:时间序列预测专栏——包含上百种时间序列模型带你从入门到精通时间序列预测 一、本文介绍 本文讲解的实战内容是GRU(门控循环单元),本文的实战内容通过时间序列领域最经典的数据集——电力负荷数据集为例,深入的了解GRU的基本原理和…...

探索STM32系列微控制器的特性和性能
STM32系列微控制器是意法半导体(STMicroelectronics)公司开发的一款强大的嵌入式微控制器系列。该系列微控制器以其丰富的特性和卓越的性能,成为了嵌入式系统开发领域的首选。本文将深入探索STM32系列微控制器的特性和性能,并结合…...

数据结构(超详细讲解!!)第二十三节 树型结构
1.定义 树型结构是一类重要的非线性数据结构,是以分支关系定义的层次结构。是一种一对多的逻辑关系。 树型结构是结点之间有分支,并且具有层次关系的结构,它非常类似于自然界中的树。树结构在客观世界中是大量存在的,例如家谱、…...

Python 日志记录器logging 百科全书 之 日志回滚
Python 日志记录器logging 百科全书 之 日志回滚 前言 在之前的文章中,我们学习了关于Python日志记录的基础配置。 本文将深入探讨Python中的日志回滚机制,这是一种高效管理日志文件的方法,特别适用于长时间运行或高流量的应用。 知识点&…...

线圈寿命预测 数据集讲解
来自-郭师兄 1.这个是线圈数据的阻抗、电抗等数据,我想根据这个个数据进行线圈寿命预测也就是RUL预测,请问有什么思路吗。 最简单的思路: 数据通过某种方法进行压缩表征到一维再通过 同时需要标签。 确定一个特征 使用降维方法如同PCA来构…...
Flutter.源码分析.flutter/packages/flutter/lib/src/widgets/scroll_view.dart/GridView
Flutter.源码分析 GridView flutter/packages/flutter/lib/src/widgets/scroll_view.dart/GridView 李俊才 的个人博客:https://blog.csdn.net/qq_28550263 本文地址:https://blog.csdn.net/qq_28550263/article/details/134375048 本文提供 Flutter 框…...

IDEA 2022创建Spring Boot项目
首先点击New Project 接下来: (1). 我们点击Spring Initializr来创建。 (2). 填写项目名称 (3). 选择路径 (4). 选择JDK------这里笔者选用jdk17。 (5). java选择对应版本即可。 (6). 其余选项如无特殊需求保持默认即可。 然后点击Next。 稍等一会,…...

Python 框架学习 Django篇 (十) Redis 缓存
开发服务器系统的时候,程序的性能是至关重要的。经过我们前面框架的学习,得知一个请求的处理基本分为接受http请求、数据库处理、返回json数据,而这3个部分中就属链接数据库请求的响应速度最慢,因为数据库操作涉及到数据库服务处理…...
考研数学笔记:线性代数中抽象矩阵性质汇总
在考研线性代数这门课中,对抽象矩阵(矩阵 A A A 和矩阵 B B B 这样的矩阵)的考察几乎贯穿始终,涉及了很多性质、运算规律等内容,在这篇考研数学笔记中,我们汇总了几乎所有考研数学要用到的抽象矩阵的性质…...

C语言--假设共有鸡、兔30只,脚90只,求鸡、兔各有多少只
一.题目描述 假设共有鸡、兔30只,脚90只,求鸡、兔各有多少只? 二.思路分析 本题是一个典型的穷举法例题,而穷举法,最重要的就是条件判断。⭐⭐ 本题中的条件很容易发现: 假设鸡有x只,兔有y只…...

nacos适配达梦数据库
一、下载源码 源码我直接下载gitee上nacos2.2.3的,具体链接:https://gitee.com/mirrors/Nacos/tree/2.2.3,具体如下图: 二、集成达梦数据库驱动 解压源码包,用idea打开源码,等idea和maven编译完成ÿ…...

CTFhub-RCE-读取源代码
源代码: <?php error_reporting(E_ALL); if (isset($_GET[file])) { if ( substr($_GET["file"], 0, 6) "php://" ) { include($_GET["file"]); } else { echo "Hacker!!!"; } } else {…...

Ansible playbook详解
playbook是ansible用于配置,部署,和被管理被控节点的剧本 playbook常用的YMAL格式:(文件名称以 .yml结尾) 1、文件的第一行应该以 "---" (三个连字符)开始,表明YMAL文件的开始。 2、在同一…...

第19节 Node.js Express 框架
Express 是一个为Node.js设计的web开发框架,它基于nodejs平台。 Express 简介 Express是一个简洁而灵活的node.js Web应用框架, 提供了一系列强大特性帮助你创建各种Web应用,和丰富的HTTP工具。 使用Express可以快速地搭建一个完整功能的网站。 Expre…...
SkyWalking 10.2.0 SWCK 配置过程
SkyWalking 10.2.0 & SWCK 配置过程 skywalking oap-server & ui 使用Docker安装在K8S集群以外,K8S集群中的微服务使用initContainer按命名空间将skywalking-java-agent注入到业务容器中。 SWCK有整套的解决方案,全安装在K8S群集中。 具体可参…...

解决Ubuntu22.04 VMware失败的问题 ubuntu入门之二十八
现象1 打开VMware失败 Ubuntu升级之后打开VMware上报需要安装vmmon和vmnet,点击确认后如下提示 最终上报fail 解决方法 内核升级导致,需要在新内核下重新下载编译安装 查看版本 $ vmware -v VMware Workstation 17.5.1 build-23298084$ lsb_release…...
基于服务器使用 apt 安装、配置 Nginx
🧾 一、查看可安装的 Nginx 版本 首先,你可以运行以下命令查看可用版本: apt-cache madison nginx-core输出示例: nginx-core | 1.18.0-6ubuntu14.6 | http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages ng…...

ardupilot 开发环境eclipse 中import 缺少C++
目录 文章目录 目录摘要1.修复过程摘要 本节主要解决ardupilot 开发环境eclipse 中import 缺少C++,无法导入ardupilot代码,会引起查看不方便的问题。如下图所示 1.修复过程 0.安装ubuntu 软件中自带的eclipse 1.打开eclipse—Help—install new software 2.在 Work with中…...
爬虫基础学习day2
# 爬虫设计领域 工商:企查查、天眼查短视频:抖音、快手、西瓜 ---> 飞瓜电商:京东、淘宝、聚美优品、亚马逊 ---> 分析店铺经营决策标题、排名航空:抓取所有航空公司价格 ---> 去哪儿自媒体:采集自媒体数据进…...
浅谈不同二分算法的查找情况
二分算法原理比较简单,但是实际的算法模板却有很多,这一切都源于二分查找问题中的复杂情况和二分算法的边界处理,以下是博主对一些二分算法查找的情况分析。 需要说明的是,以下二分算法都是基于有序序列为升序有序的情况…...

第 86 场周赛:矩阵中的幻方、钥匙和房间、将数组拆分成斐波那契序列、猜猜这个单词
Q1、[中等] 矩阵中的幻方 1、题目描述 3 x 3 的幻方是一个填充有 从 1 到 9 的不同数字的 3 x 3 矩阵,其中每行,每列以及两条对角线上的各数之和都相等。 给定一个由整数组成的row x col 的 grid,其中有多少个 3 3 的 “幻方” 子矩阵&am…...

【Oracle】分区表
个人主页:Guiat 归属专栏:Oracle 文章目录 1. 分区表基础概述1.1 分区表的概念与优势1.2 分区类型概览1.3 分区表的工作原理 2. 范围分区 (RANGE Partitioning)2.1 基础范围分区2.1.1 按日期范围分区2.1.2 按数值范围分区 2.2 间隔分区 (INTERVAL Partit…...

算法笔记2
1.字符串拼接最好用StringBuilder,不用String 2.创建List<>类型的数组并创建内存 List arr[] new ArrayList[26]; Arrays.setAll(arr, i -> new ArrayList<>()); 3.去掉首尾空格...