W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
查看本文檔前,建議先閱讀《小程序插件文檔》 體驗工具小程序 —— 該插件完全使用此插件實現(xiàn)。該插件支持身份證識別,行駛證識別和銀行卡識別。 小程序碼
app.json中增加聲明引入插件 version選擇最新的
"pages": [],
"plugins": {
"ocr-plugin": {
"version": "3.0.2",
"provider": "wx4418e3e031e551be"
}
}
}
頁面的json也要增加聲明
{
"usingComponents": {
"ocr-navigator": "plugin://ocr-plugin/ocr-navigator"
}
}
對外暴露自定義組件,UI載體為button(可樣式自定義) 封裝了
屬性名 | 類型 | 默認值 | 是否必填 | 說明 |
---|---|---|---|---|
onSuccess | HandleEvent | 是 | 接口調(diào)用成功的回調(diào)函數(shù) | |
certificateType | String | idCard | 否 | 證書類型包含四種 身份證:idCard、駕駛證:drivingLicense、銀行卡:bankCard、營業(yè)執(zhí)照:businessLicense |
返回結果中image_path 是用戶證件照片的臨時地址,開發(fā)者可以通過image_path拿到用戶的證件照片
以下具體說明四種證件類型的使用方法
certificateType='idCard' 或 無certificateType這個參數(shù)
屬性名 | 類型 | 默認值 | 是否必填 | 說明 |
---|---|---|---|---|
onSuccess | HandleEvent | 是 | 接口調(diào)用成功的回調(diào)函數(shù) | |
certificateType | String | idCard | 否 | 證書類型包含四種 身份證:idCard、駕駛證:drivingLicense、銀行卡:bankCard、營業(yè)執(zhí)照:businessLicense |
opposite | Boolean | true | 否 | 是否顯示身份證的反面,默認為 true顯示反面 |
參數(shù) e.detail
參考身份證返回結果實例
<ocr-navigator bind:onSuccess="success" certificateType="idCard" opposite="{{false}}">
<button type="primary">身份證正面識別</button>
</ocr-navigator>
<ocr-navigator bind:onSuccess="success" certificateType="idCard" opposite="{{true}}">
<button type="primary">身份證反面識別</button>
</ocr-navigator>
/** wxss **/
/*自定義按鈕樣式*/
.ocr-wrapper {
margin: 40rpx auto;
width: 375rpx;
}
.intro {
margin: 40rpx;
}
{"type":0,"name":{"text":"張三","pos":{"left_top":{"x":98.7780914307,"y":40.9823074341},"right_top":{"x":172.311325073,"y":41.2864379883},"right_bottom":{"x":172.190856934,"y":64.9047088623},"left_bottom":{"x":98.6072158813,"y":64.5630187988}},"label":[]},"gender":{"text":"男","pos":{"left_top":{"x":101.035919189,"y":80.7537384033},"right_top":{"x":121.421043396,"y":80.7818603516},"right_bottom":{"x":121.264938354,"y":101.272567749},"left_bottom":{"x":100.882026672,"y":101.244766235}},"label":[]},"nationality":{"text":"漢","pos":{"left_top":{"x":201.881393433,"y":81.7225189209},"right_top":{"x":222.004470825,"y":81.6959762573},"right_bottom":{"x":221.899169922,"y":101.255821228},"left_bottom":{"x":201.765304565,"y":101.291915894}},"label":[]},"address":{"text":"廣州市天河區(qū)五山路483號xxxxxxxxx","pos":{"left_top":{"x":95.5787811279,"y":150.794250488},"right_top":{"x":310.358947754,"y":151.617507935},"right_bottom":{"x":310.004699707,"y":220.222885132},"left_bottom":{"x":95.1295013428,"y":219.552230835}},"label":[]},"id":{"text":"4452xxxxxxxxxxxx","pos":{"left_top":{"x":176.158676147,"y":244.072860718},"right_top":{"x":453.888336182,"y":244.978515625},"right_bottom":{"x":453.874603271,"y":266.313659668},"left_bottom":{"x":176.066543579,"y":265.342407227}},"label":[]},"card_position":{"pos":{"left_top":{"x":1085.625,"y":621.75},"right_top":{"x":338.125,"y":594.75},"right_bottom":{"x":303.625,"y":99.75},"left_bottom":{"x":1189.125,"y":126.75}},"label":[]},"image_width":1280,"image_height":960,"image_path":"http://tmp/wx4418e3e031e551be.o6zAJs-yC5ByIjnyyy09jKDZquXk.dlrc7P7WlhnGb4aca86b078fc2acb5b08e7a0f438943.jpg"}
certificateType='bankCard'
屬性名 | 類型 | 默認值 | 是否必填 | 說明 |
---|---|---|---|---|
onSuccess | HandleEvent | 是 | 接口調(diào)用成功的回調(diào)函數(shù) | |
certificateType | String | bankCard | 是 | 證書類型包含四種 身份證:idCard、駕駛證:drivingLicense、銀行卡:bankCard、營業(yè)執(zhí)照:businessLicense |
參數(shù) e.detail
參考銀行卡返回結果實例
<ocr-navigator bind:onSuccess="blankSuccess" certificateType="bankCard">
<button type="primary">銀行卡識別</button>
</ocr-navigator>
/** wxss **/
/*自定義按鈕樣式*/
.ocr-wrapper {
margin: 40rpx auto;
width: 375rpx;
}
.intro {
margin: 40rpx;
}
{"number":{"text":"6225xxxxxxxxxxxx","label":[]},"card_position":{"pos":{"left_top":{"x":2.19140625,"y":227.6171875},"right_top":{"x":729.50390625,"y":206.0546875},"right_bottom":{"x":769.91015625,"y":658.8671875},"left_bottom":{"x":-11.27734375,"y":680.4296875}},"label":[]},"image_width":762,"image_height":1280,"image_path":"http://tmp/wx4418e3e031e551be.o6zAJs-yC5ByIjnyyy09jKDZquXk.dlrc7P7WlhnGb4aca86b078fc2acb5b08e7a0f438943.jpg"}
銀行卡只支持橫版儲蓄卡,信用卡,并且只能識別出銀行卡號,如果需要銀行卡名稱、過期時間需要用戶手動輸入
certificateType='drivingLicense'
屬性名 | 類型 | 默認值 | 是否必填 | 說明 |
---|---|---|---|---|
onSuccess | HandleEvent | 是 | 接口調(diào)用成功的回調(diào)函數(shù) | |
certificateType | String | drivingLicense | 是 | 證書類型包含四種 身份證:idCard、駕駛證:drivingLicense、銀行卡:bankCard、營業(yè)執(zhí)照:businessLicense |
參數(shù) e.detail
參考行駛證返回結果實例
<ocr-navigator bind:onSuccess="driverSuccess" certificateType="drivingLicense" selectedOptions="{{['plateNum','vehicleType','owner']}}">
<button type="primary">行駛證識別</button>
</ocr-navigator>
/** wxss **/
/*自定義按鈕樣式*/
.ocr-wrapper {
margin: 40rpx auto;
width: 375rpx;
}
.intro {
margin: 40rpx;
}
{"plate_num":{"text":"粵KDxxxx","label":[]},"vehicle_type":{"text":"小型轎車","label":[]},"owner":{"text":"周xx","label":[]},"addr":{"text":"廣東省xxxxxxxx","label":[]},"use_character":{"text":"非營運","label":[]},"model":{"text":"東風日產(chǎn)牌xxxxxx","label":[]},"vin":{"text":"LGBH52Exxxxxx","label":[]},"engine_num":{"text":"873073Y","label":[]},"register_date":{"text":"2017-11-13","label":[]},"issue_date":{"text":"2017-11-13","label":[]},"plate_num_b":{"text":"粵R82xxxx","label":[]},"record":{"text":"4418005xxxx","label":[]},"passengers_num":{"text":"26人","label":[]},"total_quality":{"text":"6900kg","label":[]},"prepare_quality":{"text":"4480kg","label":[]},"load_quality":{"text":"","label":[]},"lead_quality":{"text":"","label":[]},"overall_size":{"text":"7725x205xxxx","label":[]},"type":2,"card_position":[{"pos":{"left_top":{"x":454.0625,"y":17.34375},"right_top":{"x":987.8125,"y":11.71875},"right_bottom":{"x":987.8125,"y":562.96875},"left_bottom":{"x":471.5625,"y":546.09375}},"label":[]},{"pos":{"left_top":{"x":-0.9375,"y":28.59375},"right_top":{"x":445.3125,"y":22.96875},"right_bottom":{"x":445.3125,"y":551.71875},"left_bottom":{"x":-0.9375,"y":546.09375}},"label":[]}],"card_position_front":{"pos":{"left_top":{"x":454.0625,"y":17.34375},"right_top":{"x":987.8125,"y":11.71875},"right_bottom":{"x":987.8125,"y":562.96875},"left_bottom":{"x":471.5625,"y":546.09375}},"label":[]},"card_position_back":{"pos":{"left_top":{"x":-0.9375,"y":28.59375},"right_top":{"x":445.3125,"y":22.96875},"right_bottom":{"x":445.3125,"y":551.71875},"left_bottom":{"x":-0.9375,"y":546.09375}},"label":[]},"image_width":1000,"image_height":600,"img_size":{"w":1000,"h":600},"image_path":"http://tmp/wx4418e3e031e551be.o6zAJs-yC5ByIjnyyy09jKDZquXk.dlrc7P7WlhnGb4aca86b078fc2acb5b08e7a0f438943.jpg"}
行駛證支持正副頁面在一張圖片中
certificateType='businessLicense'
屬性名 | 類型 | 默認值 | 是否必填 | 說明 |
---|---|---|---|---|
onSuccess | HandleEvent | 是 | 接口調(diào)用成功的回調(diào)函數(shù) | |
certificateType | String | businessLicense | 是 | 證書類型包含四種 身份證:idCard、駕駛證:drivingLicense、銀行卡:bankCard、營業(yè)執(zhí)照:businessLicense |
參數(shù) e.detail
參考營業(yè)執(zhí)照返回結果實例
<ocr-navigator bind:onSuccess="businessSuccess" certificateType="businessLicense">
<button type="primary">營業(yè)執(zhí)照識別</button>
</ocr-navigator>
/** wxss **/
/*自定義按鈕樣式*/
.ocr-wrapper {
margin: 40rpx auto;
width: 375rpx;
}
.intro {
margin: 40rpx;
}
{"reg_num":{"text":"371400228016303","label":[]},"legal_representative":{"text":"xxxx","label":[]},"enterprise_name":{"text":"xxxxx有限公司","label":[]},"address":{"text":"xxx省xxx市xxx","label":[]},"type_of_enterprise":{"text":"有限責任公司(自然人投資或控股)","label":[]},"business_scope":{"text":"xxxxxxxxxxxx","label":[]},"registered_capital":{"text":"叁佰萬元整","label":[]},"valid_period":{"text":"2008年04月12日至年月日","label":[]},"registered_date":{"text":"2008年04月12日","label":[]},"cert_position":{"pos":{"left_top":{"x":65.4609375,"y":115.640625},"right_top":{"x":567.4921875,"y":123.828125},"right_bottom":{"x":567.4921875,"y":811.578125},"left_bottom":{"x":65.4609375,"y":819.765625}},"label":[]},"img_size":{"w":630,"h":874},"image_path":"http://tmp/wx4418e3e031e551be.o6zAJs-yC5ByIjnyyy09jKDZquXk.dlrc7P7WlhnGb4aca86b078fc2acb5b08e7a0f438943.jpg"}
本文檔配合3.0.2以及以上的插件使用,并且調(diào)試基礎庫在2.4.0以及以上才能使用
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: