rlxf_index.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  1. // rlxf_index.js
  2. var verify = require('../../../utils/util/util')
  3. const face = require('../../../utils/faceCheck/faceCheck')
  4. const getPhone = require('../../../utils/getPhone/wx_getPhone');
  5. const util = require('../../../utils/func/request')
  6. const {
  7. getContextByAdminId,
  8. realAuthenticationType,
  9. getAdminConfig,
  10. // getUserWhiteByCardIdEx,
  11. getPicture,
  12. getAdminInfoById,
  13. doConfirmFaceNotifyNew,
  14. } = require('../../../utils/api/api');
  15. const {
  16. pro_baseUrl_wxrlxf,
  17. } = require('../../../utils/func/request');
  18. const {
  19. throttle
  20. } = require('../../../utils/throttle/throttle');
  21. const {
  22. weixinTestFuncAdmin,
  23. weixinTestFuncSloveOrgId
  24. } = require('../../../utils/testForWeixin/index');
  25. import {
  26. getWxCode
  27. } from '../../../utils/util'
  28. const app = getApp()
  29. Page({
  30. /**
  31. * 页面的初始数据
  32. */
  33. data: {
  34. checked:false,
  35. // 胶囊位置信息
  36. StatusBar: app.globalData.StatusBar,
  37. CustomBar: app.globalData.CustomBar,
  38. Custom: app.globalData.Custom,
  39. // 基础路径
  40. baseUrl: pro_baseUrl_wxrlxf,
  41. // 输入信息
  42. inputName: '',
  43. inputIdcard: '',
  44. phoneNumber: '',
  45. cardIdEx: '',
  46. warnName: { //姓名校验信息
  47. status: null,
  48. errMsg: null
  49. },
  50. warnIdcard: { //身份证校验信息
  51. status: null,
  52. errMsg: null
  53. },
  54. warnPhone: 1, //手机号校验信息
  55. isShowApplet: null,
  56. isNeedRealAuthentication: true, //是否需要实名认证
  57. disabledSubmit: true,
  58. disabledSubmitScan: false,
  59. xcx_title: 'http://hanghui.oss-cn-gz-ysgzlt-d01-a.ltops.gzdata.com.cn/photo/20221206/ad963f8c73e547fab9a8a8284ef095dc.jpg',
  60. xcx_bg: 'http://hanghui.oss-cn-gz-ysgzlt-d01-a.ltops.gzdata.com.cn/photo/20221206/95ad88c62007442dbe0276b8217ea786.jpg',
  61. mobileAutoInputFlag: 2,
  62. needLoginList: [], //登录参数列表
  63. needPhone: null, //是否输入手机号 0-否 1-需要
  64. needPhoto: null, //是否需要照片 0-否 1-需要
  65. },
  66. //获得姓名
  67. getInputName(e) {
  68. let {
  69. warnName,
  70. inputName
  71. } = this.data;
  72. inputName = e.detail.value
  73. if (e.detail.value) {
  74. warnName.status = true
  75. } else {
  76. warnName.status = false
  77. warnName.errMsg = '您输入的姓名不可以为空!'
  78. };
  79. this.setData({
  80. warnName,
  81. inputName
  82. })
  83. this.disabledSubmitFun()
  84. },
  85. //获得身份证号
  86. getInputIdcard(e) {
  87. let {
  88. warnIdcard,
  89. inputIdcard
  90. } = this.data
  91. inputIdcard = e.detail.value
  92. let res = verify.isCardID(inputIdcard);
  93. if (res.state) {
  94. warnIdcard.status = true;
  95. /**
  96. * 开始
  97. * 测试身份证号,若要修改,请联系负责人
  98. */
  99. var that = this;
  100. weixinTestFuncSloveOrgId.call(that, inputIdcard);
  101. /**
  102. * 结束
  103. */
  104. } else {
  105. warnIdcard.status = false
  106. warnIdcard.errMsg = res.data
  107. };
  108. this.setData({
  109. warnIdcard,
  110. inputIdcard
  111. });
  112. this.disabledSubmitFun()
  113. },
  114. // 获取卡号
  115. getInputCardIdEx(e) {
  116. this.setData({
  117. cardIdEx: e.detail.value
  118. })
  119. this.disabledSubmitFun()
  120. },
  121. // 输入手机号
  122. getInputPhone(e) {
  123. let phoneNumber = e.detail.value
  124. let res = verify.isCornet(phoneNumber);
  125. if (!res.state) {
  126. this.setData({
  127. warnPhone: res.data
  128. })
  129. } else {
  130. this.setData({
  131. warnPhone: 1,
  132. phoneNumber: e.detail.value
  133. })
  134. }
  135. this.disabledSubmitFun()
  136. },
  137. //获取手机号
  138. async getPhoneNumber(e) {
  139. wx.showLoading({
  140. title: '获取中...',
  141. mask: true
  142. });
  143. var result = await getPhone(e);
  144. wx.hideLoading()
  145. this.setData({
  146. phoneNumber: result
  147. })
  148. this.disabledSubmitFun()
  149. },
  150. //查看照片
  151. watch() {
  152. wx.previewImage({
  153. urls: [this.data.baseUrl + '/file/img/instruction.png'],
  154. })
  155. },
  156. //实名认证
  157. submit: throttle(async function () {
  158. /**
  159. * 开始
  160. * 测试身份证号,若要修改,请联系负责人
  161. */
  162. const isAdmin = await weixinTestFuncAdmin(this.data)
  163. if (isAdmin) return;
  164. /**
  165. * 结束
  166. */
  167. // if (this.data.wxLoginType === 2) {
  168. // await this.getUserWhiteByCardIdEx()
  169. // }
  170. let {
  171. inputName,
  172. inputIdcard,
  173. phoneNumber,
  174. // cardIdEx,
  175. orgId,
  176. isShowApplet,
  177. org,
  178. isNeedRealAuthentication,
  179. needPhoto,
  180. } = this.data
  181. // if (!inputIdcard) {
  182. // return
  183. // }
  184. let isAge = 1
  185. if (isNeedRealAuthentication) {
  186. isAge = await this.judgeAge(inputIdcard, orgId)
  187. } else {
  188. isAge = 2
  189. }
  190. // isAge:1人脸认证 2:拍照
  191. if (isAge == 1) {
  192. face.intoFace_wxrlxf(inputName, inputIdcard, phoneNumber, orgId).then(() => {
  193. this.data.flag = 1
  194. }).catch(err => {})
  195. } else if (isAge == 2) {
  196. // 是否需要照片
  197. if (needPhoto) {
  198. wx.navigateTo({
  199. url: '/pages/faceCheck/faceCheck?orgId=' + orgId + '&&inputName=' + inputName + '&&inputIdcard=' + inputIdcard + '&&phoneNumber=' + phoneNumber + '&&isShowApplet=' + isShowApplet + '&&org=' + org
  200. // + '&&cardIdEx=' + cardIdEx
  201. })
  202. } else {
  203. this.doConfirmFaceNotifyNew()
  204. }
  205. } else {
  206. console.log(isAge)
  207. wx.showToast({
  208. title: isAge,
  209. icon: 'none',
  210. })
  211. }
  212. }, 5000),
  213. //验证人脸
  214. async doFaceCheck() {
  215. let taskId = wx.getStorageSync('wx_dateCode');
  216. // taskId = '00-2024052714115242855';
  217. if (!taskId) return;
  218. let res = await face.getFace_wxrlxf('/api/next/doQueryFaceSuccess', 'get', {
  219. taskId: taskId
  220. });
  221. if (res.data.status === true) {
  222. res.data.org = this.data.org;
  223. res.data.orgId = this.data.orgId;
  224. // res.data.cardIdEx = this.data.cardIdEx;
  225. res.data.options = this.data.options;
  226. wx.setStorageSync('userInfo', res.data);
  227. this.changePage(true);
  228. } else {
  229. wx.showModal({
  230. title: '提示',
  231. content: '未查询到认证结果,请重新认证!',
  232. showCancel: false,
  233. })
  234. }
  235. },
  236. doConfirmFaceNotifyNew(img) {
  237. let data = {
  238. avatar: null,
  239. idNumber: this.data.inputIdcard,
  240. // cardIdEx: this.data.cardIdEx,
  241. username: this.data.inputName,
  242. phone: this.data.phoneNumber,
  243. type: 1,
  244. code: wx.getStorageSync('wxCode')
  245. }
  246. console.log(data);
  247. doConfirmFaceNotifyNew(data).then(res => {
  248. if (res.code == 200) {
  249. res.data.org = this.data.org
  250. res.data.orgId = this.data.orgId
  251. // res.data.cardIdEx = this.data.cardIdEx
  252. wx.setStorageSync('userInfo', res.data);
  253. getWxCode()
  254. this.changePage(true)
  255. } else {
  256. wx.showToast({
  257. title: res.msg,
  258. icon: 'none',
  259. })
  260. }
  261. })
  262. },
  263. // 卡号认证-通过卡号获取用户信息
  264. // async getUserWhiteByCardIdEx() {
  265. // let data = {
  266. // cardIdEx: this.data.cardIdEx,
  267. // adminId: this.data.orgId
  268. // }
  269. // await getUserWhiteByCardIdEx(data).then(res => {
  270. // if (res.code === 200) {
  271. // this.setData({
  272. // inputName: res.data.name,
  273. // inputIdcard: res.data.idNumber,
  274. // })
  275. // } else {
  276. // wx.showToast({
  277. // title: res.msg,
  278. // icon: 'none'
  279. // })
  280. // }
  281. // })
  282. // },
  283. // 判断年龄
  284. judgeAge(idNumber, adminId) {
  285. wx.showLoading({
  286. title: '提交中...',
  287. })
  288. return new Promise((resolve, reject) => {
  289. realAuthenticationType({
  290. idNumber,
  291. adminId
  292. }).then(res => {
  293. wx.hideLoading()
  294. if (res.code == 200) {
  295. return resolve(res.data)
  296. } else {
  297. return reject(res.msg)
  298. };
  299. })
  300. })
  301. },
  302. //获取是否有自定义字段
  303. getContextByAdminId(orgId) {
  304. let that = this;
  305. this.data.isShowApplet = null;
  306. wx.showLoading({
  307. title: '检查账号配置中..',
  308. })
  309. return getContextByAdminId(orgId).then(res => {
  310. that.data.isShowApplet = res.data;
  311. }).finally(() => {
  312. wx.hideLoading()
  313. })
  314. },
  315. //跳转页面 (是否缓存进入)
  316. changePage(showModal) {
  317. if (this.data.isShowApplet) {
  318. wx.navigateTo({
  319. url: '/pages/wx_airport/rlxf_userMsg/index?orgId=' + this.data.orgId + '&org=' + this.data.org + '&showModal=' + showModal,
  320. })
  321. } else {
  322. wx.reLaunch({
  323. url: '/pages/wx_airport/rlxf_pass/rlxf_pass?orgId=' + this.data.orgId + '&org=' + this.data.org + '&showModal=' + showModal,
  324. })
  325. }
  326. },
  327. goProblem() {
  328. wx.navigateTo({
  329. url: '/pages/wx_airport/problem_report/index?adminId=' + this.data.orgId,
  330. })
  331. },
  332. goViewPDF(e) {
  333. let type = e.currentTarget.dataset.type
  334. console.log(type)
  335. wx.downloadFile({
  336. url: `https://tx.hz-hanghui.com:8088/yx-fyzd/file/${type}.pdf`,
  337. success: (res) => {
  338. console.log(res)
  339. const filePath = res.tempFilePath;
  340. wx.showLoading({
  341. title: '打开中~',
  342. mask: true
  343. });
  344. console.log(filePath)
  345. wx.openDocument({
  346. filePath: filePath,
  347. // fileType: 'pdf',
  348. success: function(res) {
  349. console.log(res)
  350. wx.hideLoading()
  351. },
  352. fail: (err) => {
  353. wx.hideLoading()
  354. if (err.errMsg == 'openDocument:fail filetype not supported') {
  355. uni.showModal({
  356. title: '不支持预览的文件类型',
  357. content: '指定文件类型,有效值 doc, xls, ppt, pdf, docx, xlsx, pptx',
  358. showCancel: false,
  359. confirmText: '确认',
  360. });
  361. }
  362. }
  363. });
  364. },
  365. fail: function(err) {
  366. uni.hideLoading()
  367. console.log('fail:' + JSON.stringify(err));
  368. }
  369. });
  370. },
  371. onAgreeAgreement(e) {
  372. let checked = e.currentTarget.dataset.checked
  373. this.setData({
  374. checked: checked
  375. })
  376. },
  377. // 获取账号的配置信息
  378. async getAdminConfig(adminId) {
  379. await getAdminConfig(adminId).then(res => {
  380. this.setData({
  381. needPhone: res.data.whitelistAppPhone,
  382. needPhoto: res.data.whitelistAppPhoto,
  383. needLoginList: res.data.whitelistAppLoginList,
  384. isNeedRealAuthentication: res.data.whitelistAppRealname,
  385. })
  386. })
  387. },
  388. // 提交按钮是否禁用
  389. disabledSubmitFun() {
  390. let disabledSubmit = false
  391. let {
  392. needLoginList,
  393. warnName,
  394. warnIdcard,
  395. phoneNumber,
  396. // cardIdEx,
  397. } = this.data
  398. if (needLoginList.indexOf(1) > -1) {
  399. if (warnName.status) {
  400. disabledSubmit = false
  401. } else {
  402. disabledSubmit = true
  403. }
  404. }
  405. if (!disabledSubmit && needLoginList.indexOf(2) > -1) {
  406. if (warnIdcard.status) {
  407. disabledSubmit = false
  408. } else {
  409. disabledSubmit = true
  410. }
  411. }
  412. if (!disabledSubmit && needLoginList.indexOf(3) > -1) {
  413. if (phoneNumber) {
  414. disabledSubmit = false
  415. } else {
  416. disabledSubmit = true
  417. }
  418. }
  419. // if (!disabledSubmit && needLoginList.indexOf(4) > -1) {
  420. // if (cardIdEx) {
  421. // disabledSubmit = false
  422. // } else {
  423. // disabledSubmit = true
  424. // }
  425. // }
  426. this.setData({
  427. disabledSubmit
  428. })
  429. },
  430. // 获取背景,标题
  431. getPicture() {
  432. getPicture().then(res => {
  433. this.setData({
  434. xcx_bg: res.data.xcx_bg,
  435. xcx_title: res.data.xcx_title
  436. })
  437. })
  438. },
  439. // 获取账号信息
  440. getAdminInfoById(orgId) {
  441. getAdminInfoById(orgId).then(res => {
  442. this.setData({
  443. mobileAutoInputFlag: res.data.mobileAutoInputFlag
  444. })
  445. })
  446. },
  447. /**
  448. * 生命周期函数--监听页面加载
  449. */
  450. onLoad: async function (options) {
  451. this.getPicture()
  452. let json = {};
  453. if (!options.isJump) {
  454. var url = decodeURIComponent(options.q);
  455. json = verify.GetQueryJson(url);
  456. } else {
  457. json = options
  458. }
  459. // json = {
  460. // orgId: 106,
  461. // org: '公司测试',
  462. // // orgId: 104,
  463. // // org: '天波测试',
  464. // type: 0, //0通用1常客
  465. // // disinfectAreaId: 5
  466. // };
  467. // json = {
  468. // orgId: 120,
  469. // org: 'Lynn测试',
  470. // type: 0, //0通用1常客
  471. // };
  472. let moduleContent = {
  473. msg: '未检测到区域码,请扫正确的二维码进入小程序哦~',
  474. show: false
  475. }
  476. if (!('orgId' in json)) {
  477. moduleContent.show = true
  478. }
  479. if (json.orgId == '' || String(json.orgId) == 'null' || String(json.orgId) == 'undefined') {
  480. moduleContent.show = true
  481. moduleContent.msg = '区域码数据已失效,请联系管理员更新二维码';
  482. }
  483. if (moduleContent.show) {
  484. wx.showModal({
  485. title: '提示',
  486. content: moduleContent.msg,
  487. showCancel: false
  488. });
  489. this.setData({
  490. disabledSubmitScan: true
  491. })
  492. return
  493. };
  494. //保留二维码的参数
  495. let urlString = ''
  496. for (let i in json) {
  497. urlString += `${i}=${json[i]}&`
  498. }
  499. this.data.options = urlString
  500. this.data.orgId = json.orgId;
  501. this.data.org = json.org;
  502. app.data.type = json.type ? json.type : null
  503. await this.getAdminInfoById(json.orgId)
  504. await this.getContextByAdminId(json.orgId);
  505. await this.getAdminConfig(json.orgId)
  506. this.disabledSubmitFun()
  507. // 判断缓存
  508. var userInfo = wx.getStorageSync('userInfo');
  509. console.log(userInfo);
  510. console.log(json.orgId);
  511. if (userInfo) {
  512. if (userInfo.orgId != json.orgId) {
  513. // userInfo.createTime = ""
  514. wx.removeStorageSync('userInfo')
  515. } else {
  516. this.changePage(false);
  517. }
  518. // userInfo.orgId = json.orgId;
  519. // userInfo.org = json.org;
  520. // userInfo.options = urlString
  521. // wx.setStorageSync('userInfo', userInfo);
  522. }
  523. if ('disinfectAreaId' in json) {
  524. app.data.disinfectAreaId = json.disinfectAreaId
  525. }
  526. },
  527. /**
  528. * 生命周期函数--监听页面初次渲染完成
  529. */
  530. onReady: function () {
  531. },
  532. /**
  533. * 生命周期函数--监听页面显示
  534. */
  535. onShow: function () {
  536. if (this.data.flag === 1) {
  537. this.data.flag = 0;
  538. this.doFaceCheck();
  539. }
  540. },
  541. /**
  542. * 生命周期函数--监听页面隐藏
  543. */
  544. onHide: function () {
  545. },
  546. /**
  547. * 生命周期函数--监听页面卸载
  548. */
  549. onUnload: function () {
  550. },
  551. /**
  552. * 页面相关事件处理函数--监听用户下拉动作
  553. */
  554. onPullDownRefresh: function () {
  555. },
  556. /**
  557. * 页面上拉触底事件的处理函数
  558. */
  559. onReachBottom: function () {
  560. },
  561. /**
  562. * 用户点击右上角分享
  563. */
  564. onShareAppMessage: function () {
  565. }
  566. })