entryAuth.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. const app = getApp()
  2. const util = require("../../../utils/util");
  3. const api = require('../../../api/api.js');
  4. const user = require('../../../utils/user.js');
  5. import moment from 'moment'
  6. Page({
  7. data: {
  8. wholeState:{
  9. },
  10. state:'',
  11. contractUrl:'',
  12. signTime:'',
  13. flowId:'',
  14. active:0,
  15. steps:[
  16. {
  17. text: '实名认证',
  18. desc: '',
  19. inactiveIcon: '',
  20. activeIcon: 'success',
  21. },
  22. {
  23. text: '背景认证',
  24. desc: '',
  25. // inactiveIcon: 'like-o',
  26. activeIcon: 'success',
  27. },
  28. {
  29. text: '完成',
  30. desc:'完成',
  31. inactiveIcon: '',
  32. activeIcon: 'success',
  33. },
  34. ],
  35. },
  36. /**
  37. * 生命周期函数--监听页面加载
  38. */
  39. onLoad: function (options) {
  40. // app.globalData.flowId='';
  41. // this.getState();
  42. },
  43. onReachBottom() {
  44. },
  45. /**
  46. * 生命周期函数--监听页面初次渲染完成
  47. */
  48. onReady: function () {
  49. },
  50. /**
  51. * 生命周期函数--监听页面显示
  52. */
  53. onShow(e) {
  54. this.getState();
  55. const options = wx.getEnterOptionsSync()
  56. // options数据在上方
  57. console.log('---options', options);
  58. // wx.showModal({
  59. // title: '警告',
  60. // content: JSON.stringify(options),
  61. // });
  62. // &&options.referrerInfo.extraData.faceResult.ErrorCode === 0
  63. if (options && options.referrerInfo&& options.referrerInfo.extraData && options.referrerInfo.extraData.faceResult&&app.globalData.isFirstFace) {
  64. //这里需要调用e签宝后端【个人实名刷脸结果核对】接口,查询刷脸结果
  65. // 刷脸完成,会跳到贵司自己的小程序,查询刷脸结果完成!
  66. // this.getFaceResult();
  67. }
  68. },
  69. getState(){
  70. let userInfo = wx.getStorageSync('userInfo');
  71. let params={ workerNo:userInfo.workerNo};
  72. if(app.globalData.flowId){
  73. params.flowId=app.globalData.flowId;
  74. }
  75. util.request(api.faceAndInvestigation, params, 'GET').then(res=> {
  76. if (res.errno === 0) {
  77. let faceCheckState=res.data.faceCheckState;
  78. let backInvestigateState=res.data.backInvestigateState;
  79. let signPersonState=res.data.signPersonState;
  80. this.setData({
  81. wholeState:res.data,
  82. 'steps[0].desc':faceCheckState,
  83. 'steps[1].desc':signPersonState+'|'+backInvestigateState
  84. });
  85. if(faceCheckState!='认证成功'){
  86. this.setData({
  87. active:0,
  88. 'steps[0].activeIcon':'arrow',
  89. });
  90. }else if(backInvestigateState!='通过'){
  91. this.setData({
  92. active:1,
  93. 'steps[0].inactiveIcon':'checked',
  94. 'steps[1].activeIcon':'arrow',
  95. });
  96. }else if(backInvestigateState=='通过'){
  97. this.setData({
  98. active:2,
  99. 'steps[0].inactiveIcon':'checked',
  100. 'steps[1].inactiveIcon':'checked',
  101. });
  102. }
  103. }
  104. }).catch(err=>{
  105. });
  106. },
  107. signContract(){
  108. wx.showLoading({
  109. title: '加载中...',
  110. });
  111. let userInfo = wx.getStorageSync('userInfo');
  112. util.request(api.singGerenxinxisouquan, {
  113. workerNo:userInfo.workerNo
  114. }, 'GET').then(res=> {
  115. wx.hideLoading();
  116. if (res.errno === 0) {
  117. this.getSignUrl(res.data);
  118. }else{
  119. wx.showToast({
  120. title: res.errmsg,
  121. icon:'none'
  122. })
  123. }
  124. }).catch(err=>{
  125. });
  126. },
  127. getFaceResult(){
  128. let userInfo = wx.getStorageSync('userInfo');
  129. util.request(api.getFaceResult, {
  130. workerNo:userInfo.workerNo,
  131. flowId:app.globalData.flowId
  132. }, 'GET').then(res=> {
  133. console.log(res);
  134. // wx.showModal({
  135. // title: '警告',
  136. // content: JSON.stringify(res),
  137. // });
  138. if (res.errno === 0) {
  139. this.setData({
  140. state:res.data.faceCheckState,
  141. signTime:res.data.faceCheckTime!=''?moment(res.data.faceCheckTime).format('YYYY-MM-DD HH:mm:ss'):'',
  142. });
  143. }
  144. }).catch(err=>{
  145. });
  146. },
  147. getSignUrl(id){
  148. util.request(api.selectContractSignUrl, {
  149. procedureId:id
  150. }, 'GET').then(res=> {
  151. if (res.errno === 0) {
  152. app.globalData.webViewUrl=res.data;
  153. wx.navigateTo({
  154. url: '/pages/upgrade/webView/webView',
  155. });
  156. }else{
  157. wx.showToast({
  158. title: res.errmsg,
  159. icon:'none'
  160. })
  161. }
  162. }).catch(err=>{
  163. });
  164. },
  165. viewContract(){
  166. app.globalData.webViewUrl=this.data.wholeState.signPersonUrl;
  167. wx.navigateTo({
  168. url: '/pages/upgrade/webView/webView',
  169. })
  170. },
  171. goAuth(){
  172. if(this.data.active==0){
  173. this.faceAuth();
  174. }else if(this.data.active==1&&this.data.wholeState.backInvestigateState=='未背调'&&this.data.wholeState.signPersonState=='未签署'&&this.data.wholeState.signPersonUrl==''){
  175. this.signContract();
  176. }else if(this.data.active==1&&this.data.wholeState.backInvestigateState=='未背调'&&this.data.wholeState.signPersonState=='未签署'&&this.data.wholeState.signPersonUrl!=''){
  177. this.viewContract();
  178. }
  179. },
  180. faceAuth(){
  181. let userInfo = wx.getStorageSync('userInfo');
  182. wx.showLoading({
  183. title: '加载中...',
  184. });
  185. util.request(api.workerIndividualFace, {
  186. workerNo:userInfo.workerNo
  187. }, 'GET').then(res=> {
  188. wx.hideLoading();
  189. if (res.errno === 0) {
  190. // this.getSignUrl(res.data);
  191. let faceToken=res.data.faceToken;
  192. app.globalData.flowId=res.data.flowId;
  193. app.globalData.isFirstFace=true;
  194. wx.navigateToMiniProgram({
  195. appId: 'wx1cf2708c2de46337', // 公证签小程序APPID
  196. path: `/pages/face/index?bizToken=${faceToken}`, // 刷脸页面地址
  197. });
  198. }else{
  199. wx.showToast({
  200. title: res.errmsg,
  201. icon:'none'
  202. })
  203. }
  204. }).catch(err=>{
  205. });
  206. },
  207. onHide: function () {
  208. },
  209. onUnload: function () {
  210. },
  211. /**
  212. * 页面相关事件处理函数--监听用户下拉动作
  213. */
  214. onPullDownRefresh: function () {
  215. },
  216. /**
  217. * 页面上拉触底事件的处理函数
  218. */
  219. onReachBottom: function () {
  220. },
  221. /**
  222. * 用户点击右上角分享
  223. */
  224. onShareAppMessage: function () {
  225. },
  226. })