faceCheck.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. const util = require('../../utils/func/request');
  2. const date = require('../../utils/util/util')
  3. const app = getApp()
  4. /*** 自助通行_云上贵州_2021/08/23 ***/
  5. //进入人脸识别--人脸下发
  6. const intoFace_wxrlxf = (name, idcard, phone, orgId) => {
  7. return new Promise ((reslove, reject) => {
  8. let taskId = `${orgId}-${date.formatTime(Date.now(), 'YYYYMMDDHHNNSS')}${(parseInt((Math.random()*9+1)*10000))}`
  9. // taskId = '00-993306131355291200';
  10. app.data.faceTaskId = taskId;
  11. wx.navigateToMiniProgram({
  12. appId: 'wx331fa6d546331cc0',
  13. path: 'pages/index/index?idNumber='+idcard+'&name='+name+'&phone='+phone+'&notify='+(util.wx_rlxf?util.pro_baseUrl_wxrlxf:util.dev_baseUrl_wxrlxf)+'/api/next/doConfirmFaceNotify&unit=简约通&token=73b81e3eb2ff11eb877300163e0a5d80&taskId='+taskId,
  14. envVersion: 'release',
  15. success(res) {
  16. reslove(true)
  17. },
  18. fail(err) {
  19. reject(err)
  20. wx.showToast({
  21. title:'您取消了实名认证',
  22. icon: 'none'
  23. })
  24. }
  25. })
  26. })
  27. .catch(err => {})
  28. .finally(() => {
  29. })
  30. }
  31. //验证人脸信息--人脸下发
  32. const getFace_wxrlxf = (api, method, data) => {
  33. wx.showLoading({
  34. title: '验证中...',
  35. })
  36. return util.request_wxrlxf({
  37. url: api,
  38. data: data,
  39. method: method,
  40. type: 'application/json'
  41. }).then((suc)=>{
  42. return suc
  43. }).catch((err) => {
  44. wx.showToast({
  45. title: err,
  46. icon: 'none'
  47. })
  48. }).finally(() => {
  49. app.data.faceTaskId = null;
  50. wx.hideLoading()
  51. })
  52. }
  53. /***自助通行_安卓_李工_20211-01-17***/
  54. //进入人脸识别
  55. const intoFace = (name, idcard, taskId) => {
  56. wx.setStorageSync('dateCode', taskId)
  57. return new Promise ((reslove, reject) => {
  58. wx.navigateToMiniProgram({
  59. appId: 'wx331fa6d546331cc0',
  60. path: 'pages/index/index?idNumber='+idcard+'&name='+name+'&notify=http://idc.hz-hanghui.com:8901/nsapi/mpidc&unit=简约通&token=73b81e3eb2ff11eb877300163e0a5d80&taskId='+taskId,
  61. envVersion: 'release',
  62. success(res) {
  63. reslove(true)
  64. },
  65. fail(err) {
  66. reject(err)
  67. util.showToast(err.errMsg)
  68. }
  69. })
  70. })
  71. }
  72. //验证人脸信息
  73. const getFace = (api, method, data) => {
  74. wx.showLoading({
  75. title: '验证中...',
  76. })
  77. return (
  78. util.request({
  79. url: api,
  80. data: data,
  81. method: method,
  82. type: 'application/json'
  83. }).then((suc)=>{
  84. wx.hideLoading()
  85. return suc
  86. }).catch((err) => {
  87. wx.hideLoading()
  88. util.showToast(err)
  89. })
  90. )
  91. }
  92. //告知二维码已被扫描
  93. const notice = (taskId) => {
  94. return (
  95. util.request({
  96. url: '/nsapi/mpidc_scan',
  97. data: {
  98. taskId: taskId
  99. },
  100. method: 'post',
  101. type: 'applycation/json'
  102. })
  103. .then((suc) => {
  104. return(suc)
  105. })
  106. .catch((err) => {
  107. console.log(err)
  108. })
  109. )
  110. }
  111. //查询是否已扫码
  112. const checkNotice = (taskId) => {
  113. return (
  114. util.request({
  115. url: '/nsapi/is_idc_scan',
  116. data: {
  117. taskId: taskId
  118. },
  119. method: 'post',
  120. type: 'applycation/json'
  121. })
  122. .then((suc) => {
  123. return(suc)
  124. })
  125. .catch((err) => {
  126. console.log(err)
  127. })
  128. )
  129. }
  130. module.exports = {
  131. intoFace_wxrlxf: intoFace_wxrlxf,
  132. getFace_wxrlxf: getFace_wxrlxf,
  133. intoFace: intoFace,
  134. getFace: getFace,
  135. notice: notice,
  136. checkNotice: checkNotice,
  137. }