index.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. import {
  2. snConfig,
  3. getWXScanQRCodeValue,
  4. createWXScanQRCode
  5. } from '../../utils/api/api'
  6. import {
  7. getQRCodeUrl,
  8. getWaterDrop,
  9. throttle,guid
  10. } from '../../utils/index/index'
  11. import { closeSecondaryScreen, openSecondaryScreen } from "../../utils/index/callAmpe";
  12. const app = getApp()
  13. Page({
  14. data: {
  15. snDisposition: {},
  16. tabList: [{
  17. img: 'https://tx.hz-hanghui.com:8088/yx-fyzd/file/upload/imagesnew/static/home/tab-one.png',
  18. tit: '设置',
  19. path: '/pages/settings/login/index'
  20. },
  21. {
  22. img: 'https://tx.hz-hanghui.com:8088/yx-fyzd/file/upload/imagesnew/static/home/tab-two.png',
  23. tit: '通讯录',
  24. path: '/pages/settings/interviewee/index?formPath="通讯录"'
  25. },
  26. {
  27. img: '../../image/fkjl-icon.png',
  28. tit: '访客记录',
  29. path: '/pages/settings/visitorLog/index?formPath="访客记录"'
  30. },
  31. ],
  32. centerList: [{
  33. img: 'https://tx.hz-hanghui.com:8088/yx-fyzd/file/upload/imagesnew/static/home/center-one.png',
  34. tit: '刷脸登记',
  35. path: '/pages/resultPage/index?result=刷脸登记',
  36. isShow: true,
  37. id: 1,
  38. },
  39. {
  40. img: 'https://tx.hz-hanghui.com:8088/yx-fyzd/file/upload/imagesnew/static/home/center-two.png',
  41. tit: '持证登记',
  42. path: '/pages/resultPage/index?result=刷身份证',
  43. isShow: true,
  44. id: 2,
  45. },
  46. {
  47. img: 'https://tx.hz-hanghui.com:8088/yx-fyzd/file/upload/imagesnew/static/home/center-three.png',
  48. tit: '输身份证登记',
  49. path: '/pages/inputIDCard/index',
  50. isShow: true,
  51. id: 3,
  52. },
  53. {
  54. img: 'https://tx.hz-hanghui.com:8088/yx-fyzd/file/upload/imagesnew/static/home/center-four.png',
  55. tit: '签离',
  56. path: '/pages/resultPage/index?result=扫码签离',
  57. isShow: true,
  58. id: 4,
  59. },
  60. ],
  61. centerListCope: [],
  62. qrCodeImg: '', // 微信二维码图片地址
  63. qrCodeUrl: '', // 微信二维码 码值
  64. intervalId: null, //定时器
  65. intervalId1: null, //定时器
  66. },
  67. onLoad() {
  68. app.data.cycleIntervalSwitch = true
  69. let url = app.globalData.snDisposition.secondaryPageImages[app.data.secondaryPageImagesIndex] || ''
  70. if (url) {
  71. openSecondaryScreen(url)
  72. }
  73. this.data.centerListCope = JSON.parse(JSON.stringify(this.data.centerList))
  74. this.snConfig()
  75. },
  76. async onShow() {
  77. my.hideBackHome();
  78. app.data.userInfo.xm = ''
  79. app.data.userInfo.sfzh = ''
  80. app.data.userInfo.phone = ''
  81. app.data.userInfo.avatar = ''
  82. app.data.userInfo.idCardPhoto = ''
  83. app.data.userInfo.workPlace = ''
  84. app.data.userInfo.carNumber = ''
  85. app.data.userInfo.verifyType = 1;
  86. app.data.userInfo.certContent = '';
  87. app.globalData.signOffQrcodeUrl = ''
  88. app.globalData.ethQrcodeUrl = ''
  89. app.globalData.gateGrcodeUrl = ''
  90. app.data.inputPhone = ''
  91. app.globalData.brushingCardUserIInfo = {}
  92. app.globalData.visitoMsgData = {}
  93. app.data.isOkBrushingCard = false
  94. app.data.isOkQrCodeSignIn = false
  95. app.data.isokFaceScan = false
  96. app.globalData.riskResult = 1
  97. app.data.isNetworkQueryError = true
  98. app.data.clickRetryNum = 0
  99. console.log('clickRetryNum', app.data.clickRetryNum)
  100. },
  101. clickAudio() {
  102. getWaterDrop()
  103. },
  104. // 获取设备配置
  105. snConfig() {
  106. let that = this
  107. that.assignData()
  108. if (!app.globalData.snDisposition.id) {
  109. that.data.intervalId = setInterval(function () {
  110. if (app.globalData.snDisposition.id) {
  111. that.assignData()
  112. clearInterval(that.data.intervalId);
  113. }
  114. }, 1000);
  115. }
  116. },
  117. // 赋值
  118. async assignData() {
  119. this.data.centerList = JSON.parse(JSON.stringify(this.data.centerListCope))
  120. let centerList = this.data.centerList
  121. centerList[0].isShow = app.globalData.snDisposition.useAlipayFace
  122. centerList[1].isShow = app.globalData.snDisposition.useIdcard
  123. centerList[2].isShow = app.globalData.snDisposition.noIdcardRegister
  124. centerList[3].isShow = app.globalData.snDisposition.signOut
  125. this.setData({
  126. snDisposition: app.globalData.snDisposition,
  127. centerList
  128. })
  129. // 生成二维码
  130. if (app.globalData.snDisposition.wxQrcodeUrl) {
  131. let qrImgWX = await getQRCodeUrl(app.globalData.snDisposition.wxQrcodeUrl)
  132. this.setData({
  133. qrImgWX
  134. })
  135. }
  136. if (app.globalData.snDisposition.wxScanRegister) {
  137. let info = {
  138. connectionId: `${guid()}`,
  139. extInfo: [{
  140. keyName: "carnum",
  141. keyboardType: "carNumber",
  142. placeholder: "请选择车牌",
  143. title: "车牌",
  144. type: "",
  145. value: ""
  146. }, {
  147. keyName: "visitorUnit",
  148. keyboardType: "text",
  149. placeholder: "请输入单位",
  150. title: "单位",
  151. type: "",
  152. value: ""
  153. }], // 额外填写信息
  154. mode: 'http', // websocket(长链接)/http(三要素换特殊码)
  155. needCertName: true, // 姓名
  156. needCertNo: true, // 证件号
  157. needPhone: false, // 手机号
  158. needPhotoBase64: false, // 照片
  159. needReal: false, // 是否需要实名比对
  160. sn: app.globalData.sn, // 设备sn
  161. }
  162. let res = await getWXScanQRCodeValue(info);
  163. let qrCodeUrl = `https://tx.hz-hanghui.com:8088?connectionId=${res.data.connectionId || ''}&encryptId=${res.data.encryptId || ''}&sn=${app.globalData.sn || ''}&mode=http`
  164. // let qrCodeUrl = `https://test.hz-hanghui.com:18890?connectionId=${res.data.connectionId || ''}&encryptId=${res.data.encryptId || ''}&sn=${app.globalData.sn || ''}&mode=http`;
  165. let qrRes = await createWXScanQRCode({ qrcodeContent: qrCodeUrl, width: 300, height: 300 });
  166. let qrCodeImg = qrRes.data.qrcodeUrl || '';
  167. // let qrCodeImg = await getQRCodeUrl(qrCodeUrl)
  168. this.setData({
  169. qrCodeUrl,
  170. qrCodeImg
  171. })
  172. }
  173. },
  174. // 跳转
  175. goto: throttle(function (e) {
  176. let item = e.currentTarget.dataset.item;
  177. switch (item.id) {
  178. case 1:
  179. console.log(app.data.isFaceScanInitialize);
  180. if (!app.data.isFaceScanInitialize) {
  181. my.showToast({
  182. content: '刷脸初始化失败,请重试',
  183. duration: 2000
  184. });
  185. return
  186. }
  187. app.data.isokFaceScan = true
  188. break;
  189. case 2:
  190. item.path = item.path + `&&timer=${app.globalData.snDisposition.readIdcardTimeout}`
  191. break;
  192. case 4:
  193. item.path = item.path + `&&timer=${app.globalData.snDisposition.singOutTimeout}`
  194. break;
  195. default:
  196. break;
  197. }
  198. if (item.id) {
  199. setTimeout(() => {
  200. closeSecondaryScreen()
  201. app.data.cycleIntervalSwitch = false
  202. }, 1000)
  203. }
  204. if (item.path) {
  205. my.reLaunch({
  206. url: item.path,
  207. })
  208. }
  209. }, 5000),
  210. isMoreThan15Days(date) {
  211. var fifteenDaysAgo = new Date();
  212. fifteenDaysAgo.setDate(fifteenDaysAgo.getDate() - 15);
  213. return date < fifteenDaysAgo;
  214. },
  215. sure() {},
  216. });