WeChat applet ocr ID card identification and mobile phone number acquisition

insert image description here
Open community personal WeChat account purchase https://fuwu.weixin.qq.com/service/detail/000ce4cec24ca026d37900ed551415

page code

<template>
	<view>
		<button style="margin-top:200px;" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">获取手机号</button>
		<ocr-navigator @onSuccess="success" certificateType="idCard" :opposite="false">
		  <button type="primary">身份证正面识别</button>
		</ocr-navigator>
		<ocr-navigator @onSuccess="success" certificateType="idCard" :opposite="true">
		  <button type="primary">身份证反面识别</button>
		</ocr-navigator>
	</view>
</template>

<script>
export default {
    
    
  data() {
    
    
    return {
    
    
    }
  },
  computed: {
    
    
	  
  },
  onload() {
    
    
  },
  methods: {
    
    
	async getPhoneNumber(e) {
    
    
		console.log(e.detail.code)
		// 这里请求后端接口传e.detail.code参数获取手机号
	},
	success(res) {
    
    
	    console.log(res)
	}
  }
}
</script>

<style>
</style>

Configuration (fill in the latest ocr version, otherwise the press conference will prompt that the plug-in can be updated)
insert image description here

"ocr-plugin": {
    
    
				"version": "3.0.2",
				"provider": "wx4418e3e031e551be"
			}

insert image description here

"usingComponents": {
    
    
	    "ocr-navigator": "plugin://ocr-plugin/ocr-navigator"
	}

Guess you like

Origin blog.csdn.net/qq_29184685/article/details/127278788