recognition.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <!-- @format -->
  2. <template>
  3. <view style="padding: 20rpx">
  4. <view style="color: #3c9cff" class="informationTitle"
  5. >人脸识别/实名认证</view
  6. >
  7. <view class="pass" v-if="formdData.isPass">
  8. <u-icon name="checkbox-mark" color="#19be6b" size="90"></u-icon>
  9. <text class="passText">认证成功</text>
  10. </view>
  11. <view style="padding: 100rpx">
  12. <u-button v-if="!formdData.isPass" type="primary" @click="handleFinish"
  13. >开始认证</u-button
  14. >
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. export default {
  20. data() {
  21. return {
  22. url: this.$baseUrl,
  23. };
  24. },
  25. props: {
  26. formdData: {
  27. type: Object,
  28. default: () => ({}),
  29. },
  30. },
  31. methods: {
  32. //完成认证
  33. async handleFinish() {
  34. this.$emit(
  35. "update:formdData",
  36. Object.assign({
  37. ...this.formdData,
  38. isPass: true,
  39. })
  40. );
  41. },
  42. handleAuthentication() {
  43. var that = this;
  44. wx.checkIsSupportFacialRecognition({
  45. checkAliveType: 2,
  46. success: function (res) {
  47. if (
  48. res.errCode === 0 ||
  49. res.errMsg === "checkIsSupportFacialRecognition:ok"
  50. ) {
  51. //调用人脸识别
  52. that.startface(
  53. that.formdData.personCardOrcResult.name,
  54. that.formdData.personCardOrcResult.idNum
  55. ); //身份证名称,身份证号码
  56. return;
  57. }
  58. uni.showToast({
  59. title: "微信版本过低,暂时无法使用此功能,请升级微信最新版本",
  60. icon: "none",
  61. duration: 4000,
  62. });
  63. },
  64. fail: function (res) {
  65. console.log(res);
  66. uni.showToast({
  67. title: "微信版本过低,暂时无法使用此功能,请升级微信最新版本",
  68. icon: "none",
  69. duration: 4000,
  70. });
  71. },
  72. });
  73. },
  74. startface(name, idcard) {
  75. var that = this;
  76. wx.startFacialRecognitionVerify({
  77. name: name, //身份证名称
  78. idCardNumber: idcard, //身份证号码
  79. success: (res) => {
  80. this.$emit(
  81. "update:formdData",
  82. Object.assign({
  83. ...this.formdData,
  84. isPass: true,
  85. })
  86. );
  87. },
  88. checkAliveType: 2, //屏幕闪烁(人脸核验的交互方式,默认0,读数字)
  89. fail: (err) => {
  90. uni.showToast({
  91. title: "请本人持手机,确保光线充足,面部正对手机,且无遮挡",
  92. icon: "none",
  93. duration: 4000,
  94. });
  95. },
  96. });
  97. },
  98. },
  99. };
  100. </script>
  101. <style lang="scss">
  102. .pass {
  103. display: flex;
  104. justify-content: center;
  105. flex-direction: column;
  106. align-items: center;
  107. }
  108. .informationTitle {
  109. margin-bottom: 30rpx;
  110. font-size: 30;
  111. }
  112. .passText {
  113. margin-top: 30rpx;
  114. font-size: 34rpx;
  115. color: #909399;
  116. }
  117. </style>