faceCheck.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. const _my = require("../../__antmove/api/index.js")(my);
  2. const wx = _my;
  3. // pages/make_appointment/faceCheck/faceCheck.js
  4. const { BaiDuFaceComparison } = require("../../utils/api/make_appointment");
  5. const upload_image = require("../../utils/upload/upload_image");
  6. const app = getApp();
  7. Page({
  8. /**
  9. * 页面的初始数据
  10. */
  11. data: {
  12. cardAvatarUrl: null,
  13. // (过审专用,禁止删除)- start
  14. fake: null
  15. // (过审专用,禁止删除)- start
  16. },
  17. getPhotoPath(e) {
  18. upload_image({
  19. url: e.detail
  20. }).then(img => {
  21. this.BaiDuFaceComparison(img.url);
  22. });
  23. },
  24. BaiDuFaceComparison(faceImageUrl) {
  25. let data = {
  26. cardImage: app.data.temporary_userInfo.avatar,
  27. faceImage: faceImageUrl
  28. // cardImage: 'https://noise.hz-hanghui.com:8088/yx-fyzd/file/upload/imagesnew/20220517/16527562131689445.jpg',
  29. // faceImage: 'https://noise.hz-hanghui.com:8088/yx-fyzd/file/upload/imagesnew/20220517/16527562131689445.jpg'
  30. };
  31. BaiDuFaceComparison(data).then(res => {
  32. if (res.data) {
  33. app.data.temporary_userInfo.avatar = data.faceImage;
  34. wx.setStorageSync("language", "en");
  35. wx.showModal({
  36. title: "prompt",
  37. content: "Certification successful!",
  38. showCancel: false,
  39. //是否显示取消按钮
  40. success: function () {
  41. wx.navigateBack({
  42. delta: 2
  43. });
  44. }
  45. });
  46. } else {
  47. app.data.temporary_userInfo = null;
  48. wx.showModal({
  49. title: "prompt",
  50. content: "The witness match failed. Please try again!",
  51. showCancel: false,
  52. //是否显示取消按钮
  53. success: function (res) {
  54. wx.navigateBack({
  55. delta: 1
  56. });
  57. }
  58. });
  59. }
  60. });
  61. },
  62. /**
  63. * 生命周期函数--监听页面加载
  64. */
  65. onLoad: function (options) {
  66. // this.BaiDuFaceComparison()
  67. // (过审专用,禁止删除)- start
  68. this.setData({
  69. fake:
  70. app.data.fake === false || app.data.fake == null ? false : true
  71. });
  72. // (过审专用,禁止删除)- end
  73. },
  74. /**
  75. * 生命周期函数--监听页面初次渲染完成
  76. */
  77. onReady: function () { },
  78. /**
  79. * 生命周期函数--监听页面显示
  80. */
  81. onShow: function () { },
  82. /**
  83. * 生命周期函数--监听页面隐藏
  84. */
  85. onHide: function () { },
  86. /**
  87. * 生命周期函数--监听页面卸载
  88. */
  89. onUnload: function () { },
  90. /**
  91. * 页面相关事件处理函数--监听用户下拉动作
  92. */
  93. onPullDownRefresh: function () { },
  94. /**
  95. * 页面上拉触底事件的处理函数
  96. */
  97. onReachBottom: function () { },
  98. /**
  99. * 用户点击右上角分享
  100. */
  101. onShareAppMessage: function () { }
  102. });