faceCheck.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import {
  2. wx_rlxf,
  3. dev_baseUrl_wxrlxf,
  4. pro_baseUrl_wxrlxf,
  5. request_wxrlxf
  6. } from '@/utils/request.js'
  7. import {
  8. formatTime
  9. } from '@/utils/util/util.js'
  10. let app = getApp();
  11. /*** 自助通行_云上贵州_2021/08/23 ***/
  12. //进入人脸识别--人脸下发
  13. const intoFace_wxrlxf = (name, idcard) => {
  14. console.log(name, idcard)
  15. return new Promise((reslove, reject) => {
  16. let taskId =
  17. `01-${formatTime(Date.now(), 'YYYYMMDDHHNNSS')}${(parseInt((Math.random()*9+1)*10000))}`
  18. // taskId = '00-98765411111111121'
  19. wx.setStorageSync('wx_dateCode', taskId);
  20. wx.navigateToMiniProgram({
  21. appId: 'wx331fa6d546331cc0',
  22. path: 'pages/index/index?idNumber=' + idcard + '&name=' + name +
  23. '&notify=' + (wx_rlxf ? pro_baseUrl_wxrlxf : dev_baseUrl_wxrlxf) +
  24. '/api/next/doConfirmFaceNotify&unit=易行巡逻打卡&token=73b81e3eb2ff11eb877300163e0a5d80&taskId=' +
  25. taskId,
  26. envVersion: 'release',
  27. success(res) {
  28. // app.globalData.faceCheckTit = 'res:' + res
  29. reslove(true)
  30. },
  31. fail(err) {
  32. // app.globalData.faceCheckTit = 'error:' + err
  33. reject(err)
  34. wx.showToast({
  35. title: '您取消了实名认证',
  36. icon: 'none'
  37. })
  38. }
  39. })
  40. })
  41. .catch(err => {
  42. console.log(err);
  43. })
  44. .finally(() => {})
  45. }
  46. //验证人脸信息--人脸下发
  47. const getFace_wxrlxf = (api, method, data) => {
  48. wx.showLoading({
  49. title: '验证中...',
  50. })
  51. return request_wxrlxf({
  52. url: api,
  53. data: data,
  54. method: method,
  55. type: 'application/json'
  56. }).then((suc) => {
  57. // app.globalData.faceCheckTit = 'suc:' + JSON.stringify(suc) + 'data:' + JSON
  58. // .stringify(data)
  59. return suc
  60. }).catch((err) => {
  61. // app.globalData.faceCheckTit = 'error:' + JSON.stringify(err) + 'data:' + JSON
  62. // .stringify(data)
  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. export {
  75. intoFace_wxrlxf,
  76. getFace_wxrlxf
  77. };