faceCheck.js 3.5 KB

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