rlxf_pass.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. const _my = require("../../../__antmove/api/index.js")(my);
  2. const wx = _my;
  3. const {
  4. throttle
  5. } = require("../../../utils/throttle/throttle");
  6. const face = require("../../../utils/faceCheck/faceCheck");
  7. const {
  8. updateVisitDeviceUser
  9. } = require("../../../utils/api/api");
  10. import QRCode from "../../../utils/util/weapp-qrcode";
  11. const app = getApp();
  12. Page({
  13. /**
  14. * 页面的初始数据
  15. */
  16. data: {
  17. userInfo: {},
  18. machineInfo_FKJ: wx.getStorageSync("machineInfo_FKJ"),
  19. timeCount: 0,
  20. dateTime: "",
  21. //时间戳
  22. qrCode: "",
  23. //二维码
  24. timer: null
  25. },
  26. //切换用户
  27. back() {
  28. wx.showModal({
  29. title: "提示",
  30. content: `确定要切换用户吗?`,
  31. success(res) {
  32. if (res.confirm) {
  33. wx.removeStorageSync("machineInfo_FKJ");
  34. // wx.removeStorageSync('dateCode')
  35. wx.reLaunch({
  36. url: "/pages/temporary_prove_FKJ/index/index"
  37. });
  38. }
  39. }
  40. });
  41. },
  42. //查看头像
  43. preview() {
  44. wx.previewImage({
  45. current: this.data.machineInfo_FKJ.avatar,
  46. urls: [this.data.machineInfo_FKJ.avatar]
  47. });
  48. },
  49. updateTime() {
  50. this.setData({
  51. dateTime: new Date().getTime()
  52. });
  53. console.log(this.data.dateTime);
  54. this.creatQrCode();
  55. },
  56. creatQrCode() {
  57. // wx.showLoading({
  58. // title: '加载中...',
  59. // })
  60. let that = this;
  61. new QRCode("myQrcode", {
  62. text: `HHFKJ?userId=${this.data.machineInfo_FKJ.userId}&timestamp=${this.data.dateTime}`,
  63. width: 141,
  64. //canvas 画布的宽
  65. height: 141,
  66. //canvas 画布的高
  67. padding: 0,
  68. // 生成二维码四周自动留边宽度,不传入默认为0
  69. correctLevel: QRCode.CorrectLevel.L,
  70. // 二维码可辨识度
  71. callback: res => {
  72. console.log(res);
  73. //工具回调数据
  74. // 接下来就可以直接调用微信小程序的api保存到本地或者将这张二维码直接画在海报上面去,看各自需求
  75. // wx.hideLoading()
  76. //将图片路劲放入data中,显示在wxml的image标签上
  77. that.setData({
  78. qrCode: res.path
  79. });
  80. }
  81. });
  82. },
  83. // 更新访客机用户
  84. updateVisitDeviceUser() {
  85. let {
  86. machineInfo_FKJ
  87. } = this.data;
  88. let data = {
  89. workPlace: app.data.workPlace,
  90. carNumber: app.data.carNumber,
  91. userId: machineInfo_FKJ.userId
  92. };
  93. updateVisitDeviceUser(data).then(res => {
  94. if (res.code === 200) {
  95. machineInfo_FKJ.workPlace = app.data.workPlace;
  96. machineInfo_FKJ.carNumber = app.data.carNumber;
  97. wx.setStorageSync("machineInfo_FKJ", machineInfo_FKJ);
  98. this.setData({
  99. machineInfo_FKJ
  100. });
  101. } else {
  102. wx.showToast({
  103. title: res.msg,
  104. icon: "none"
  105. });
  106. }
  107. });
  108. },
  109. /**
  110. * 生命周期函数--监听页面加载
  111. */
  112. onLoad: function () {
  113. this.setData({
  114. machineInfo_FKJ: wx.getStorageSync("machineInfo_FKJ")
  115. });
  116. if (app.data.workPlace) {
  117. my.alert({
  118. title: "提示",
  119. content: "恭喜认证成功,可刷码快速登记!"
  120. });
  121. this.updateVisitDeviceUser();
  122. }
  123. },
  124. /**
  125. * 生命周期函数--监听页面初次渲染完成
  126. */
  127. onReady: function () {},
  128. /**
  129. * 生命周期函数--监听页面显示
  130. */
  131. onShow: function () {
  132. wx.hideHomeButton();
  133. this.updateTime();
  134. let _this = this;
  135. this.setData({
  136. timer: setInterval(function () {
  137. _this.updateTime();
  138. }, 1000 * 30)
  139. });
  140. // setInterval(function () {
  141. // this.updateTime()
  142. // }.bind(this), 1000 * 30);
  143. },
  144. /**
  145. * 生命周期函数--监听页面隐藏
  146. */
  147. onHide: function () {
  148. clearInterval(this.data.timer);
  149. this.setData({
  150. timer: null
  151. });
  152. },
  153. /**
  154. * 生命周期函数--监听页面卸载
  155. */
  156. onUnload: function () {
  157. clearInterval(this.data.timer);
  158. this.setData({
  159. timer: null
  160. });
  161. },
  162. /**
  163. * 页面相关事件处理函数--监听用户下拉动作
  164. */
  165. onPullDownRefresh: function () {},
  166. /**
  167. * 页面上拉触底事件的处理函数
  168. */
  169. onReachBottom: function () {},
  170. /**
  171. * 用户点击右上角分享
  172. */
  173. onShareAppMessage: function () {},
  174. antmoveAction: function () {
  175. //执行时动态赋值,请勿删除
  176. }
  177. });