faceCheck.js 5.8 KB

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