visitorcheckdetail.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. const util = require('../../../utils/util.js');
  2. const api = require('../../../utils/api.js');
  3. const app = getApp();
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. apiTotal: '',
  10. id: '',
  11. type: false,
  12. userInfo: '',
  13. list: []
  14. },
  15. getUserInfoArray: function(e) {
  16. const that = this;
  17. util.httpRequest(api.getVisitorInfo, {
  18. visitorId: that.data.id
  19. }, 'post').then(res => {
  20. let userInfo = [];
  21. userInfo.push({
  22. key: '访客姓名:',
  23. value: res.data.data.visitor.visitorName
  24. }, {
  25. key: '身份证号:',
  26. value: res.data.data.visitor.idnumber
  27. }, {
  28. key: '手机号:',
  29. value: res.data.data.visitor.visitorPhone
  30. }, {
  31. key: '被访人:',
  32. value: res.data.data.visitor.inviteName
  33. }, {
  34. key: '身份类型:',
  35. value: res.data.data.visitor.identity
  36. }, {
  37. key: '访问楼栋:',
  38. value: res.data.data.visitor.storey
  39. }, {
  40. key: '访问宿舍:',
  41. value: res.data.data.visitor.room
  42. }, {
  43. key: '访问原因:',
  44. value: res.data.data.visitor.visitorReason
  45. })
  46. that.setData({
  47. list: userInfo,
  48. userInfo: res.data.data.visitor
  49. })
  50. })
  51. },
  52. check: function(e) {
  53. const that = this;
  54. let reject = e.currentTarget.dataset.reject;
  55. let id = e.currentTarget.dataset.id;
  56. util.httpRequest(api.getVisitorCheck, {
  57. id: that.data.id,
  58. audit: reject == 'approve' ? true : false
  59. }, 'post').then(res => {
  60. wx.showToast({
  61. title: res.data.errmsg,
  62. })
  63. setTimeout(function() {
  64. wx.navigateBack({
  65. })
  66. }, 500)
  67. })
  68. },
  69. /**
  70. * 生命周期函数--监听页面加载
  71. */
  72. onLoad: function(options) {
  73. const that = this;
  74. console.log(options.type)
  75. that.setData({
  76. id: options.id,
  77. type: options.type,
  78. apiTotal: api.total.substring(0, api.total.length - 4)
  79. })
  80. that.getUserInfoArray();
  81. },
  82. /**
  83. * 生命周期函数--监听页面初次渲染完成
  84. */
  85. onReady: function() {
  86. },
  87. /**
  88. * 生命周期函数--监听页面显示
  89. */
  90. onShow: function() {
  91. },
  92. /**
  93. * 生命周期函数--监听页面隐藏
  94. */
  95. onHide: function() {
  96. },
  97. /**
  98. * 生命周期函数--监听页面卸载
  99. */
  100. onUnload: function() {
  101. },
  102. /**
  103. * 页面相关事件处理函数--监听用户下拉动作
  104. */
  105. onPullDownRefresh: function() {
  106. },
  107. /**
  108. * 页面上拉触底事件的处理函数
  109. */
  110. onReachBottom: function() {
  111. }
  112. })