faceCheck.js 3.5 KB

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