index.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. // pages/invitation/verify/index.js
  2. const app = getApp();
  3. const api = app.api;
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. statusOptions: [
  10. {id: '0', value: '藏家 Collector'},
  11. {id: '1', value: '艺术行业 Art Professional'},
  12. {id: '2', value: '院校师生 Academic'},
  13. {id: '3', value: '媒体 Media'},
  14. {id: '4', value: '合作方 Partner'},
  15. {id: '5', value: '其他 Other '}
  16. ],
  17. idTypeOptions: [
  18. {id: '0', value: '身份证 ID Card'},
  19. {id: '1', value: '护照 Passport'},
  20. {id: '2', value: '回乡证 Home Return Certificate'},
  21. {id: '3', value: '台胞证 MTP'}
  22. ],
  23. countryOptions: [
  24. {id: '0', value: '中国 China'},
  25. {id: '1', value: '外籍 Foreigners'}
  26. ],
  27. genderOptions: [
  28. {id: '0', value: '男 Male'},
  29. {id: '1', value: '女 Female'},
  30. {id: '2', value: '其他 Other'}
  31. ],
  32. dataForm: {
  33. id: '',
  34. status: '0',
  35. statusOther: '',
  36. realName: '',
  37. idType: '0',
  38. idNumber: '',
  39. country: '0',
  40. liveCity: ['', '', ''],
  41. liveCityNotChina: '',
  42. gender: '0',
  43. emailAddress: '',
  44. company: '',
  45. position: ''
  46. }
  47. },
  48. /**
  49. * 查询客人信息
  50. */
  51. getGuest(id) {
  52. const self = this;
  53. app.post(api.InvitationGetId, {id: id}).then(response => {
  54. if(response.success) {
  55. self.setData({
  56. ['dataForm.id']: response.data.id,
  57. ['dataForm.status']: response.data.roles,
  58. ['dataForm.statusOther']: response.data.roleOther,
  59. ['dataForm.realName']: response.data.name,
  60. ['dataForm.idType']: response.data.types,
  61. ['dataForm.idNumber']: response.data.nums,
  62. ['dataForm.country']: response.data.country,
  63. ['dataForm.liveCity']: response.data.country === 0 ? [response.data.province, response.data.city, response.data.district] : [],
  64. ['dataForm.liveCityNotChina']: response.data.country === 1 ? response.data.states : '',
  65. ['dataForm.gender']: response.data.gender + '',
  66. ['dataForm.emailAddress']: response.data.mail,
  67. ['dataForm.company']: response.data.company,
  68. ['dataForm.position']: response.data.position,
  69. ['dataForm.signTime']: response.data.signTime
  70. })
  71. }
  72. }).catch(() => {
  73. wx.showToast({
  74. title: '未查询到登记信息',
  75. complete: function() {
  76. setTimeout(() => {
  77. wx.navigateBack({
  78. delta: 0,
  79. })
  80. }, 1500)
  81. }
  82. })
  83. })
  84. },
  85. /**
  86. * 核销
  87. */
  88. guestSign: function() {
  89. const self = this
  90. app.post(api.InvitationVerification, {id: self.data.dataForm.id}).then(response => {
  91. if (response.success) {
  92. wx.showToast({
  93. title: '核验成功',
  94. mask: true,
  95. complete: function() {
  96. setTimeout(() => {
  97. wx.navigateBack({
  98. delta: 0,
  99. })
  100. }, 1500)
  101. }
  102. })
  103. }
  104. }).catch(() => {
  105. wx.showModal({
  106. title: '核验失败',
  107. showCancel: false,
  108. content: '未查询到登记信息',
  109. success: function(res) {
  110. if(res.confirm) {
  111. wx.navigateBack({
  112. delta: 0,
  113. })
  114. }
  115. }
  116. });
  117. })
  118. },
  119. /**
  120. * 生命周期函数--监听页面加载
  121. */
  122. onLoad: function (options) {
  123. const id = options.id;
  124. const self = this
  125. self.getGuest(id)
  126. wx.setNavigationBarTitle({
  127. title: '邀请码核验',
  128. })
  129. },
  130. /**
  131. * 生命周期函数--监听页面显示
  132. */
  133. onShow: function () {
  134. },
  135. })