index.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. const app = getApp();
  2. const api = app.api;
  3. let QRCode = require('../../../utils/weapp.qrcode.min.js')
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. signTime: '',
  10. dataForm: {
  11. id: '',
  12. status: '0',
  13. statusOther: '',
  14. realName: '',
  15. idType: '0',
  16. idNumber: '',
  17. country: '0',
  18. liveCity: ['北京市', '北京市', '东城区'],
  19. liveCityNotChina: '',
  20. gender: '0',
  21. emailAddress: '',
  22. company: '',
  23. position: ''
  24. }
  25. },
  26. /**
  27. * 生命周期函数--监听页面加载
  28. */
  29. onLoad: function (options) {
  30. // 查询核验二维码
  31. const self = this
  32. self.getGuestQRCode()
  33. // 设置页面标题
  34. wx.setNavigationBarTitle({
  35. title: '入场凭证',
  36. })
  37. },
  38. /**
  39. * 查询客人核验二维码
  40. */
  41. getGuestQRCode() {
  42. const self = this;
  43. app.post(api.InvitationGet, {}).then(response => {
  44. if(response.success) {
  45. self.setData({
  46. ['dataForm.id']: response.data.id,
  47. ['dataForm.status']: response.data.roles + '',
  48. ['dataForm.statusOther']: response.data.roleOther,
  49. ['dataForm.realName']: response.data.name,
  50. ['dataForm.idType']: response.data.types + '',
  51. ['dataForm.idNumber']: response.data.nums,
  52. ['dataForm.country']: response.data.country + '',
  53. ['dataForm.liveCity']: response.data.country === 0 ? [response.data.province, response.data.city, response.data.district] : [],
  54. ['dataForm.liveCityNotChina']: response.data.country === 1 ? response.data.states : '',
  55. ['dataForm.gender']: response.data.gender + '',
  56. ['dataForm.emailAddress']: response.data.mail,
  57. ['dataForm.company']: response.data.company,
  58. ['dataForm.position']: response.data.position,
  59. });
  60. // 生成核销二维码
  61. const systemInfo = wx.getSystemInfoSync()
  62. const width = 107*systemInfo.windowWidth/375
  63. const height = width
  64. new QRCode({
  65. text: self.data.dataForm.id + '',
  66. width: width,
  67. height: height,
  68. canvasId: 'myQrcode'
  69. });
  70. }
  71. }).catch(() => {
  72. wx.showModal({
  73. content: '没有查询到您的入场凭证',
  74. cancelText: '返回',
  75. confirmText: '获取凭证',
  76. success: function(response) {
  77. if(response.confirm) {
  78. wx.redirectTo({
  79. url: '../index/index',
  80. })
  81. } else {
  82. wx.navigateBack({
  83. delta: 0,
  84. })
  85. }
  86. }
  87. })
  88. })
  89. }
  90. })