Skip to content

使用方法

安卓阿里云金融级实人认证UTS原生插件支持金融级实人认证方案,金融级活体人脸验证方案,金融级活体检测方案,金融级多因子意愿认证方案,金融级NFC认证方案,设备助手方案。插件支持自定义UI颜色和icon图标,自定义UI文案。插件支持uniapp和uniapp x

插件使用注意事项

  • 如果您在使用插件的过程中有任何问题,可以联系作者,作者将全力协助您使用插件
  • 本文档同时提供了uniapp的用法示例和uniappx的用法示例,插件市场导入的示例项目仅为uniapp的用法示例,如果您需要uniappx的示例项目可以通过下方的链接下载示例

    https://pan.baidu.com/s/1CTOxnZkYcw2uWxPTYIyHjA?pwd=8w2t

sdk文档地址

https://help.aliyun.com/zh/id-verification/financial-grade-id-verification/product-overview/what-is-id-verification-for-financial-services?spm=a2c4g.11186623.0.i345

联系作者

关注微信公众号可联系作者

插件地址

https://ext.dcloud.net.cn/plugin?id=28218

用法

在需要使用插件的页面加载以下代码

js
import * as module from "@/uni_modules/leven-uts-aliFace"
js
import * as module from "@/uni_modules/leven-uts-aliFace"

页面内容

vue
<template>
  <view>
    <view>
      <uni-easyinput v-model="certifyId" placeholder="请输入认证的certifyId" :disabled="!isInit"></uni-easyinput>
    </view>
    <view>
      <button type="primary" @click="startVerify" :disabled="!isInit">开始认证</button>
    </view>
  </view>
</template>

<script>
  import * as module from "@/uni_modules/leven-uts-aliFace"
  export default {
    data() {
      return {
        //初始化是否成功
        isInit: false,
        //认证信息
        certifyId: ""
      }
    },
    mounted() {
      this.$nextTick(() => {
        this.init();
      })
    },
    methods: {
      //提示消息
      showMessage(message) {
        uni.showToast({
          title: message,
          icon: "none"
        })
      },
      //开始认证
      startVerify() {
        if (this.certifyId == "") {
          this.showMessage("请输入certifyId")
          return
        }
        module.verify({
          params: {
            /**
             * 从服务端初始化认证接口(InitFaceVerify)获取的CertifyId
             * 每个CertifyId只能调用一次verify函数,每次调用verify函数之前务必重新获取CertifyId
             */
            certifyId: this.certifyId,
            /**
             * 当刷脸认证过程中出现异常情况,是否使用SDK内部的弹框提示。取值:
             * true:SDK先弹框提示,确定之后,返回错误code
             * false:不弹提示框,直接返回错误code,客户业务应用App自行决定如何提示
             */
            useMsgBox: false,
            //用户自定义参数,一般直接传NULL即可。目前支持的自定义字段,具体取值信息可参考插件文档
            // extParams:{},
            //自定义ui样式
            // customUIConfig: {
            //   //配置自定义入参的类型,具体类型可参考插件文档
            //   paramType: "assets",
            //   //与paramType配套调用
            //   param: "DTFConsumUIConfig.json"
            // },
            //自定义ui文案
            // customTxtConfig: {
            //   //配置自定义入参的类型,具体类型可参考插件文档
            //   paramType: "assets",
            //   //与paramType配套调用
            //   param: "DTFConsumTxtConfig.json"
            // }
          },
          complete: (res) => {
            if (res.code != 0) {
              this.showMessage("认证失败")
              return
            }
            let data = res.data || {};
            let code = data.code
            if (code == 1000) {
              this.showMessage("认证成功");
            } else {
              let retMessageSub = data.retMessageSub
              this.showMessage(retMessageSub)
            }
          }
        })
      },
      //初始化
      init() {
        module.initSdk({
          params: {
            //是否使用IPv6初始化
            isInstallIPv6: false
          },
          complete: (res) => {
            if (res.code == 0) {
              this.isInit = true
              this.showMessage("初始化成功")
            } else {
              this.showMessage("初始化失败:" + res.message)
            }
          }
        })
      }
    }
  }
</script>

<style>

</style>
vue
<template>
  <!-- #ifdef APP -->
  <scroll-view style="flex:1">
  <!-- #endif -->
    <view>
      <rice-input v-model="certifyId" placeholder="请输入认证的certifyId" :disabled="!isInit"></rice-input>
    </view>
    <view>
      <rice-button type="primary" text="开始认证" @click="startVerify" :disabled="!isInit"></rice-button>
    </view>
  <!-- #ifdef APP -->
  </scroll-view>
  <!-- #endif -->
</template>

<script setup>
  import * as module from "@/uni_modules/leven-uts-aliFace"
  import { LevenResult, LevenOptions } from "@/uni_modules/leven-uts-aliFace"
  //初始化是否成功
  const isInit = ref(false)
  //认证信息
  const certifyId = ref("")

  function showMessage(message : string) {
    uni.showToast({
      title: message,
      icon: "none"
    })
  }

  //开始认证
  function startVerify() {
    if (certifyId.value == "") {
      showMessage("请输入certifyId")
      return
    }
    module.verify({
      params: {
        /**
         * 从服务端初始化认证接口(InitFaceVerify)获取的CertifyId
         * 每个CertifyId只能调用一次verify函数,每次调用verify函数之前务必重新获取CertifyId
         */
        certifyId: this.certifyId,
        /**
         * 当刷脸认证过程中出现异常情况,是否使用SDK内部的弹框提示。取值:
         * true:SDK先弹框提示,确定之后,返回错误code
         * false:不弹提示框,直接返回错误code,客户业务应用App自行决定如何提示
         */
        useMsgBox: true,
        //用户自定义参数,一般直接传NULL即可。目前支持的自定义字段,具体取值信息可参考插件文档
        // extParams:{},
        //自定义ui样式
        // customUIConfig: {
        //   //配置自定义入参的类型,具体类型可参考插件文档
        //   paramType: "assets",
        //   //与paramType配套调用
        //   param: "DTFConsumUIConfig.json"
        // },
        //自定义ui文案
        // customTxtConfig: {
        //   //配置自定义入参的类型,具体类型可参考插件文档
        //   paramType: "assets",
        //   //与paramType配套调用
        //   param: "DTFConsumTxtConfig.json"
        // }
      },
      complete: (res : LevenResult) => {
        if (res.code != 0) {
          showMessage("认证失败")
          return
        }
        let data = res.data || {};
        let code = data.getNumber("code")!
        if (code == 1000) {
          showMessage("认证成功")
        } else {
          let retMessageSub = data.getString("retMessageSub")!
          showMessage(retMessageSub)
        }
      }
    } as LevenOptions)
  }

  //初始化
  function init() {
    module.initSdk({
      params: {
        //是否使用IPv6初始化
        isInstallIPv6: false
      },
      complete: (res : LevenResult) => {
        if (res.code == 0) {
          isInit.value = true
          showMessage("初始化成功")
        } else {
          showMessage("初始化失败:" + res.message)
        }
      }
    } as LevenOptions)
  }

  onMounted(() => {

  })
</script>

<style>

</style>

注意

其他页面内容请导入示例项目查看