finishInfo.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. const app = require('../../utils/util.js');
  2. var util = require('../../utils/md5.js')
  3. Page({
  4. data: {
  5. postindex: null,
  6. incomeindex: null,
  7. educationindex: null,
  8. posttext: '请选择',
  9. incometext: '请选择',
  10. educationtext: '请选择',
  11. postList: [{
  12. name: '群众'
  13. },
  14. {
  15. name: '团员'
  16. },
  17. {
  18. name: '党员'
  19. },
  20. ],
  21. incomeList: [{
  22. name: '1000'
  23. },
  24. {
  25. name: '2000'
  26. },
  27. {
  28. name: '3000'
  29. },
  30. ],
  31. educationList: [{
  32. name: '小学'
  33. },
  34. {
  35. name: '初中'
  36. },
  37. {
  38. name: '高中'
  39. },
  40. ],
  41. },
  42. goOcr() {
  43. wx.showLoading({
  44. title: '加载中',
  45. })
  46. var _this = this;
  47. wx.chooseImage({
  48. count: 1, // 默认9
  49. sizeType: ['compressed'], // 可以指定是原图还是压缩图,默认二者都有
  50. sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
  51. success: function (res) {
  52. // console.log('拍照获取图片路径',res);
  53. // 读取本地文件内容
  54. wx.showLoading({
  55. title: '加载中',
  56. })
  57. wx.getFileSystemManager().readFile({
  58. filePath: res.tempFilePaths[0],
  59. encoding: 'base64',
  60. success: res => {
  61. //返回临时文件路径
  62. // console.log('读取本地文件basema ',res.data)
  63. let img = 'data:image/png;base64,' + res.data
  64. const bodys = {
  65. "base64Str": img
  66. };
  67. const AppCode = '4638ef02c8e248e1b12d55b1170e4feb';
  68. // console.log('读取本地文件basema ',res.data)
  69. // console.log(JSON.stringify( {base64Str:res.data}))
  70. wx.request({
  71. url: 'https://zid.market.alicloudapi.com/thirdnode/ImageAI/idcardfrontrecongnition',
  72. method: 'POST',
  73. header: {
  74. Authorization: 'APPCODE ' + AppCode,
  75. 'content-type': 'application/x-www-form-urlencoded'
  76. },
  77. data: {
  78. base64Str: img
  79. },
  80. dataType: 'json',
  81. success: (e) => {
  82. // console.log('身份证ocr识别返回数据',e.data)
  83. if (e.data.error_code == 0) {
  84. if (e.data.result) {
  85. const idcardno = e.data.result.idcardno
  86. const name = e.data.result.name
  87. }
  88. } else {
  89. wx.hideLoading();
  90. _this.setData({
  91. show: false,
  92. buttonShow: false,
  93. idButtonShow: true
  94. });
  95. wx.showModal({
  96. title: '提示',
  97. content: '身份证OCR识别失败',
  98. })
  99. }
  100. },
  101. })
  102. },
  103. // 错误信息
  104. fail: console.error
  105. })
  106. },
  107. fail: function () {
  108. wx.hideLoading();
  109. }
  110. })
  111. },
  112. postListChange: function (e) {
  113. this.setData({
  114. postindex: e.detail.value,
  115. posttext: '',
  116. })
  117. },
  118. incomeListChange: function (e) {
  119. this.setData({
  120. incomeindex: e.detail.value,
  121. incometext: '',
  122. })
  123. },
  124. educationListChange: function (e) {
  125. this.setData({
  126. educationindex: e.detail.value,
  127. educationtext: '',
  128. })
  129. },
  130. formSubmit(e) {
  131. console.log(e.detail, "daying");
  132. // wx.request({
  133. // url: app.globalData.publicUrl + '/applet/bing',
  134. // method: "GET",
  135. // data: {
  136. // name: e.detail.value.name,
  137. // pwd: util.hexMD5(password),
  138. // appletsId: wx.getStorageSync('openId')
  139. // },
  140. // success: (res) => {
  141. // }
  142. // })
  143. // wx.switchTab({
  144. // url: '/pages/index/index',
  145. // })
  146. },
  147. onLoad: function () {},
  148. })