更新记录

0.0.2(2026-02-02) 下载此版本

通过自定义高亮.png 实现各种自定义模版(与其难为自己,不如为难ui对吧

0.0.1(2026-01-30) 下载此版本

init-project


平台兼容性

uni-app(4.87)

Vue2 Vue3 Chrome Safari app-vue app-nvue app-nvue插件版本 Android Android插件版本 iOS iOS插件版本 鸿蒙
- - × × × 0.0.2 4.4 0.0.2 12 0.0.2 ×
微信小程序 支付宝小程序 抖音小程序 百度小程序 快手小程序 京东小程序 鸿蒙元服务 QQ小程序 飞书小程序 小红书小程序 快应用-华为 快应用-联盟
× × × × × × × × × - × ×

uni-app x(4.87)

Chrome Safari Android iOS 鸿蒙 微信小程序
- - - - - -

自定义相机,身份证相机

简介

lhs-camera 是一个自定义相机组件,用于实现身份证相机的功能, 目前仅限于APP使用,后续会迭代小程序版本 已实现:

  • 支持打开闪光灯(ios不支持)
  • 支持打开相册
  • 支持切换摄像头
  • 通过自定义高亮.png 实现各种自定模版(与其难为自己,不如为难ui对吧😂)

待实现:

  • 微信版本

参数

参数名 类型 默认值 说明
mode String SD 推流视频模式,可选:SD(标清)、HD(高清)、FHD(超清)
aspect String 16:9 视频宽高比例
enable-camera Boolean true 是否开启摄像头
auto-focus Boolean true 是否开启自动对焦
beauty Number 1 美颜级别,范围 0-9(iOS 最低为 1),0 表示关闭
whiteness Number 2 美白级别,范围 0-9(iOS 最低为 1),0 表示关闭
orientation String vertical 画面方向,可选:verticalhorizontal
device-position String back 摄像头位置,可选:back(后置)、front(前置)

使用方法

在pages.json 中添加

    "easycom": {
        "autoscan": true,
        "custom": {
            "^lhs-camera-(.*)": "@/uni_modules/lhs-camera/components/lhs-camera-$1/lhs-camera-$1.nvue",
            "^lhs-camera": "@/uni_modules/lhs-camera/components/lhs-camera/lhs-camera.nvue",
        }
    }

template

<template>
  <view class="page">
    <lhs-camera-id ref="cameraRef" @onSnapshot="onSnapshot" />
  </view>
</template>

script

export default {
  data() {
     return {
      cameraRef: null,
      cameraInstance: null,
      opt: {}
    }
  },
  onReady() {
    // 注意:需要在onReady中 或 onLoad 延时
     nextTick(() => {
      this.cameraInstance = this.$refs.cameraRef.onReady(this, {
        hl: {
          width: '710rpx',
          height: '450rpx',
          top: '200rpx',
          left: '20rpx',
          radius: '12px',
          url: this.opt.png
        }
      })
    })
  },
  methods: {
    onSnapshot(tempImagePath) {
      console.log('onSnapshot:' + tempImagePath)
    }
  }
}

隐私、权限声明

1. 本插件需要申请的系统权限列表:

android.permission.CAMERA

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

插件不采集任何数据

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

许可协议

MIT协议

暂无用户评论。