rlxf_pass.js 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. const {
  2. userInfoInsert,
  3. getAdminConfig
  4. } = require("../../../utils/api/api");
  5. const {
  6. getAuthFlagByAdminId,
  7. adminShowCheck
  8. } = require("../../../utils/api/xiaosha");
  9. const {
  10. weixinTestMakeUserInfo
  11. } = require("../../../utils/testForWeixin/index");
  12. const {
  13. throttle
  14. } = require("../../../utils/throttle/throttle");
  15. const face = require('../../../utils/faceCheck/faceCheck')
  16. const app = getApp()
  17. // pages/wx_airport/rlxf_pass/rlxf_pass.js
  18. Page({
  19. /**
  20. * 页面的初始数据
  21. */
  22. data: {
  23. userInfo: {},
  24. machineInfo: {},
  25. timeCount: 0,
  26. functionList: [{
  27. img: '../../../static/function-bar/one.png',
  28. tit: '问题上报',
  29. url: '/pages/wx_airport/problem_report/index',
  30. isShow: false,
  31. },
  32. {
  33. img: '../../../static/function-bar/two.png',
  34. tit: '上报记录',
  35. url: '/pages/wx_airport/Reported_list/index',
  36. isShow: false,
  37. },
  38. {
  39. img: '../../../static/function-bar/three.png',
  40. tit: '消杀登记',
  41. url: '/pages/wx_airport/Xiaosha_registration/scan_code/index',
  42. isShow: false,
  43. },
  44. {
  45. img: '../../../static/function-bar/four.png',
  46. tit: '消杀记录',
  47. url: '/pages/wx_airport/Xiaosha_record/index?checkAuth=',
  48. isShow: false,
  49. },
  50. ],
  51. authFlag: null, //获取导航栏权限
  52. wxLoginType: 1, //微信小程序登录方式1-身份证 2-卡号认证
  53. },
  54. // 功能栏跳转
  55. clickFun(e) {
  56. let item = e.currentTarget.dataset.item
  57. if (item.url === '/pages/wx_airport/Xiaosha_registration/scan_code/index') {
  58. wx.requestSubscribeMessage({
  59. tmplIds: ['3fRN-XG2-dTYH0AwCUQK3x8xL_IrXTf5H1u_u0k1tFs'],
  60. success: (res) => {
  61. if (app.data.disinfectAreaId) {
  62. wx.navigateTo({
  63. url: '/pages/wx_airport/Xiaosha_registration/index?disinfectAreaId=' + app.data.disinfectAreaId
  64. })
  65. } else {
  66. wx.navigateTo({
  67. url: item.url
  68. })
  69. }
  70. }
  71. })
  72. } else {
  73. if (item.url === '/pages/wx_airport/Xiaosha_record/index?checkAuth=') {
  74. item.url = '/pages/wx_airport/Xiaosha_record/index?checkAuth=' + this.data.authFlag.checkAuth
  75. }
  76. wx.navigateTo({
  77. url: item.url
  78. })
  79. }
  80. },
  81. //切换用户
  82. back() {
  83. let isMachine = this.data.isMachine
  84. wx.showModal({
  85. title: '提示',
  86. content: `确定要${isMachine?'切换用户':'重新认证'}吗?`,
  87. success(res) {
  88. if (res.confirm) {
  89. if (isMachine) {
  90. wx.removeStorageSync('machineInfo')
  91. wx.reLaunch({
  92. url: '/pages/temporary_prove/index/index'
  93. })
  94. } else {
  95. let options = wx.getStorageSync('userInfo').options
  96. wx.removeStorageSync('userInfo')
  97. wx.reLaunch({
  98. url: '/pages/wx_airport/rlxf_index/rlxf_index?'+options+'isJump=1'
  99. })
  100. }
  101. }
  102. }
  103. })
  104. },
  105. //查看头像
  106. preview() {
  107. wx.previewImage({
  108. current: this.data.userInfo.avatar,
  109. urls: [this.data.userInfo.avatar],
  110. })
  111. },
  112. //人脸下发
  113. doPass: throttle(function () {
  114. var data = {
  115. userId: this.data.userInfo.userId,
  116. adminId: this.data.userInfo.orgId,
  117. type: app.data.type,
  118. action: 2, //1-自定义字段更新 2-下发
  119. };
  120. /**
  121. * 开始
  122. * 测试身份证号,若要修改,请联系负责人
  123. */
  124. if (this.data.userInfo.idNumber == '330821********0212') {
  125. wx.showLoading({
  126. title: '申报中..',
  127. });
  128. setTimeout(() => {
  129. this.data.timeCount = 30
  130. this.countDown();
  131. wx.hideLoading()
  132. wx.showModal({
  133. content: '恭喜申报成功,您已获得闸机快速通行权限,如有疑问,请就近联系管理人员',
  134. showCancel: false,
  135. });
  136. }, 600)
  137. return
  138. }
  139. /**
  140. * 结束
  141. */
  142. wx.showLoading({
  143. title: '申报中..',
  144. });
  145. userInfoInsert(data).then((res) => {
  146. if (res.code == 200 && res.data.status) {
  147. this.data.timeCount = 30
  148. this.countDown()
  149. this.data.userInfo.createTime = res.data.date;
  150. wx.showModal({
  151. content:'门禁-'+ this.data.userInfo.org + '恭喜申报成功,您已获得闸机快速通行权限,如有疑问,请就近联系管理人员',
  152. showCancel: false,
  153. })
  154. } else {
  155. this.data.userInfo.createTime = '';
  156. wx.showModal({
  157. content: res.msg,
  158. showCancel: false,
  159. })
  160. };
  161. wx.setStorageSync('userInfo', this.data.userInfo);
  162. this.getUserInfo();
  163. })
  164. .catch(err => {})
  165. .finally(() => {
  166. wx.hideLoading()
  167. })
  168. }, 30000),
  169. //申报倒计时
  170. countDown() {
  171. let {
  172. timeCount
  173. } = this.data;
  174. if (timeCount > 0) {
  175. setTimeout(() => {
  176. timeCount--
  177. this.setData({
  178. timeCount
  179. })
  180. this.countDown();
  181. }, 1000)
  182. }
  183. },
  184. //获取基本信息
  185. getUserInfo(userInfoTest = null) {
  186. var userInfo = userInfoTest || wx.getStorageSync('userInfo');
  187. userInfo.idNumber = userInfo.idNumber.replace(/(\w)/g, function (a, b, c, d) {
  188. return ((c > 5 && c < 14)) ? '*' : a
  189. });
  190. userInfo.phone = userInfo.phone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2');
  191. userInfo.avatar = userInfo.avatar
  192. this.setData({
  193. userInfo: userInfo
  194. })
  195. },
  196. // 判断消杀
  197. adminShowCheck() {
  198. let {
  199. userInfo,
  200. functionList
  201. } = this.data
  202. let data = {
  203. adminId: userInfo.orgId,
  204. userId: userInfo.userId
  205. }
  206. adminShowCheck(data).then(res => {
  207. // 是否显示开启问题上报 1:显示 0:不显示
  208. if (res.data.showProblemReport) {
  209. functionList[0].isShow = true
  210. functionList[1].isShow = true
  211. }
  212. // 是否显示消杀 1-显示 0-不显示
  213. if (res.data.showDisinfect) {
  214. functionList[2].isShow = true
  215. functionList[3].isShow = true
  216. }
  217. this.setData({
  218. functionList,
  219. authFlag: res.data,
  220. })
  221. })
  222. },
  223. // 获取账号的配置信息
  224. getAdminConfig(adminId) {
  225. getAdminConfig(adminId).then(res => {
  226. this.setData({
  227. wxLoginType: res.data.wxLoginType,
  228. // isNeedRealAuthentication: res.data.isNeedRealAuthentication,
  229. })
  230. })
  231. },
  232. /**
  233. * 生命周期函数--监听页面加载
  234. */
  235. onLoad: function ({
  236. orgId = null,
  237. org,
  238. name,
  239. idNumber,
  240. phone,
  241. showModal,
  242. isMachine
  243. }) {
  244. if (orgId != null) {
  245. this.orgId = orgId
  246. this.getUserInfo();
  247. this.getAdminConfig(orgId)
  248. } else {
  249. /**
  250. * 开始
  251. * 测试身份证号,若要修改,请联系负责人
  252. */
  253. this.getUserInfo(weixinTestMakeUserInfo(name, phone, idNumber));
  254. /**
  255. * 结束
  256. */
  257. }
  258. if (showModal === 'true') {
  259. this.doPass()
  260. }
  261. this.adminShowCheck()
  262. },
  263. /**
  264. * 生命周期函数--监听页面初次渲染完成
  265. */
  266. onReady: function () {
  267. },
  268. /**
  269. * 生命周期函数--监听页面显示
  270. */
  271. onShow: function () {
  272. wx.hideHomeButton()
  273. this.adminShowCheck()
  274. },
  275. /**
  276. * 生命周期函数--监听页面隐藏
  277. */
  278. onHide: function () {
  279. },
  280. /**
  281. * 生命周期函数--监听页面卸载
  282. */
  283. onUnload: function () {
  284. },
  285. /**
  286. * 页面相关事件处理函数--监听用户下拉动作
  287. */
  288. onPullDownRefresh: function () {
  289. },
  290. /**
  291. * 页面上拉触底事件的处理函数
  292. */
  293. onReachBottom: function () {
  294. },
  295. /**
  296. * 用户点击右上角分享
  297. */
  298. onShareAppMessage: function () {
  299. }
  300. })