123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- const app = require('../../utils/util.js');
- var util = require('../../utils/md5.js')
- Page({
- data: {
- postindex: null,
- incomeindex: null,
- educationindex: null,
- posttext: '请选择',
- incometext: '请选择',
- educationtext: '请选择',
- postList: [{
- name: '群众'
- },
- {
- name: '团员'
- },
- {
- name: '党员'
- },
- ],
- incomeList: [{
- name: '1000'
- },
- {
- name: '2000'
- },
- {
- name: '3000'
- },
- ],
- educationList: [{
- name: '小学'
- },
- {
- name: '初中'
- },
- {
- name: '高中'
- },
- ],
- },
- goOcr() {
- wx.showLoading({
- title: '加载中',
- })
- var _this = this;
- wx.chooseImage({
- count: 1, // 默认9
- sizeType: ['compressed'], // 可以指定是原图还是压缩图,默认二者都有
- sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
- success: function (res) {
- // console.log('拍照获取图片路径',res);
- // 读取本地文件内容
- wx.showLoading({
- title: '加载中',
- })
- wx.getFileSystemManager().readFile({
- filePath: res.tempFilePaths[0],
- encoding: 'base64',
- success: res => {
- //返回临时文件路径
- // console.log('读取本地文件basema ',res.data)
- let img = 'data:image/png;base64,' + res.data
- const bodys = {
- "base64Str": img
- };
- const AppCode = '4638ef02c8e248e1b12d55b1170e4feb';
- // console.log('读取本地文件basema ',res.data)
- // console.log(JSON.stringify( {base64Str:res.data}))
- wx.request({
- url: 'https://zid.market.alicloudapi.com/thirdnode/ImageAI/idcardfrontrecongnition',
- method: 'POST',
- header: {
- Authorization: 'APPCODE ' + AppCode,
- 'content-type': 'application/x-www-form-urlencoded'
- },
- data: {
- base64Str: img
- },
- dataType: 'json',
- success: (e) => {
- // console.log('身份证ocr识别返回数据',e.data)
- if (e.data.error_code == 0) {
- if (e.data.result) {
- const idcardno = e.data.result.idcardno
- const name = e.data.result.name
- }
- } else {
- wx.hideLoading();
- _this.setData({
- show: false,
- buttonShow: false,
- idButtonShow: true
- });
- wx.showModal({
- title: '提示',
- content: '身份证OCR识别失败',
- })
- }
- },
- })
- },
- // 错误信息
- fail: console.error
- })
- },
- fail: function () {
- wx.hideLoading();
- }
- })
- },
- postListChange: function (e) {
- this.setData({
- postindex: e.detail.value,
- posttext: '',
- })
- },
- incomeListChange: function (e) {
- this.setData({
- incomeindex: e.detail.value,
- incometext: '',
- })
- },
- educationListChange: function (e) {
- this.setData({
- educationindex: e.detail.value,
- educationtext: '',
- })
- },
-
- formSubmit(e) {
- console.log(e.detail, "daying");
- // wx.request({
- // url: app.globalData.publicUrl + '/applet/bing',
- // method: "GET",
- // data: {
- // name: e.detail.value.name,
- // pwd: util.hexMD5(password),
- // appletsId: wx.getStorageSync('openId')
- // },
- // success: (res) => {
- // }
- // })
- // wx.switchTab({
- // url: '/pages/index/index',
- // })
- },
- onLoad: function () {},
- })
|