rlxf_pass.js 7.6 KB

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