faceCheck.js 5.1 KB

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