index.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. // pages/temporary_prove/index.js
  2. // index.js
  3. var verify = require('../../../utils/util/util')
  4. const face = require('../../../utils/faceCheck/faceCheck')
  5. const { pro_baseUrl_wxrlxf } = require('../../../utils/func/request');
  6. const app = getApp()
  7. Page({
  8. /**
  9. * 页面的初始数据
  10. */
  11. data: {
  12. // 胶囊位置信息
  13. StatusBar: app.globalData.StatusBar,
  14. CustomBar: app.globalData.CustomBar,
  15. Custom: app.globalData.Custom,
  16. // 基础路径
  17. baseUrl: pro_baseUrl_wxrlxf,
  18. inputName: '',
  19. inputIdcard: '',
  20. warnName: 1, //姓名校验信息
  21. warnIdcard: 1, //身份证校验信息
  22. disableSubmit: true
  23. },
  24. //获得姓名
  25. getInputName (e) {
  26. this.setData({
  27. warnName: 1,
  28. inputName: e.detail.value
  29. });
  30. if (!e.detail.value) {
  31. this.setData({
  32. warnName: '您输入的姓名不可以为空!'
  33. })
  34. } else {
  35. this.setData({
  36. warnName: 2
  37. })
  38. }
  39. },
  40. //获得身份证号
  41. getInputIdcard (e) {
  42. var result = verify.isCardID(e.detail.value);
  43. if (!result.state) {
  44. this.setData({
  45. warnIdcard: result.data
  46. })
  47. } else {
  48. this.setData({
  49. warnIdcard: 2,
  50. inputIdcard: e.detail.value
  51. })
  52. }
  53. },
  54. //实名认证
  55. submit() {
  56. var a = this.data.inputName;
  57. var b = this.data.inputIdcard;
  58. var taskId = this.taskId;
  59. face.intoFace(a,b,taskId).then((suc) => {
  60. this.data.flag = 1
  61. }, (err) => {
  62. console.log(err)
  63. })
  64. },
  65. //验证人脸
  66. async doFaceCheck () {
  67. var taskId = this.taskId
  68. var res = await face.getFace('/nsapi/is_idc_ok','post',{ taskId: taskId });
  69. //todo--人脸结果
  70. if (res && res.success === 1) {
  71. wx.redirectTo({
  72. url: '/pages/wx_airport/rlxf_pass/rlxf_pass',
  73. })
  74. } else {
  75. wx.showModal({
  76. title: '提示',
  77. content: '认证失败请重新认证!',
  78. showCancel: false,
  79. })
  80. }
  81. },
  82. //查看照片
  83. watch () {
  84. wx.previewImage({
  85. urls: [this.data.baseUrl+'/file/img/instruction.png'],
  86. })
  87. },
  88. /**
  89. * 生命周期函数--监听页面加载
  90. */
  91. onLoad: async function (options) {
  92. // this.taskId = "9000000020210602100757"
  93. var that = this
  94. var url = decodeURIComponent(options.q);
  95. var json = verify.GetQueryJson(url);
  96. if('machineCode' in json){
  97. this.taskId = json.machineCode
  98. var result = await face.checkNotice(this.taskId)
  99. if (result.scan === 1) {
  100. wx.showModal({
  101. title: '提示',
  102. content: '该二维码已被占用,请耐心等待其他用户完成认证哦~',
  103. showCancel: false
  104. });
  105. that.setData({
  106. disableSubmit: false
  107. })
  108. } else {
  109. face.notice(this.taskId)
  110. }
  111. } else {
  112. wx.showModal({
  113. title: '提示',
  114. content: '未检测到设备码,请扫正确的二维码进入小程序哦~',
  115. showCancel: false
  116. });
  117. that.setData({
  118. disableSubmit: false
  119. })
  120. return
  121. }
  122. },
  123. /**
  124. * 生命周期函数--监听页面初次渲染完成
  125. */
  126. onReady: function () {
  127. },
  128. /**
  129. * 生命周期函数--监听页面显示
  130. */
  131. onShow: function () {
  132. if (this.data.flag === 1) {
  133. this.doFaceCheck();
  134. }
  135. },
  136. /**
  137. * 生命周期函数--监听页面隐藏
  138. */
  139. onHide: function () {
  140. },
  141. /**
  142. * 生命周期函数--监听页面卸载
  143. */
  144. onUnload: function () {
  145. },
  146. /**
  147. * 页面相关事件处理函数--监听用户下拉动作
  148. */
  149. onPullDownRefresh: function () {
  150. },
  151. /**
  152. * 页面上拉触底事件的处理函数
  153. */
  154. onReachBottom: function () {
  155. },
  156. /**
  157. * 用户点击右上角分享
  158. */
  159. onShareAppMessage: function () {
  160. }
  161. })