visitorcheck.js 2.7 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. isregiste: true,
  11. approvalNum: 0,
  12. approvedNum: 0,
  13. list: []
  14. },
  15. checkTab: function(e) {
  16. const that = this;
  17. that.setData({
  18. isregiste: !that.data.isregiste
  19. })
  20. if (that.data.isregiste) {
  21. that.getVisitorCheckInfo(2);
  22. } else {
  23. that.getVisitorCheckInfo(4);
  24. }
  25. },
  26. todetail: function(e) {
  27. let id = e.currentTarget.dataset.id;
  28. let type = e.currentTarget.dataset.type;
  29. wx.navigateTo({
  30. url: '../visitorcheckdetail/visitorcheckdetail?id=' + id + '&type=' + this.data.isregiste,
  31. })
  32. },
  33. getVisitorCheckInfo: function(status) {
  34. const that = this;
  35. util.httpRequest(api.getVisitorCheckInfo, {
  36. status: status,
  37. rows: 20,
  38. page: 1
  39. }, 'post').then(res => {
  40. for (let i = 0; i < res.data.data.data.length; i++) {
  41. res.data.data.data[i].createDate = that.getLocalTime(res.data.data.data[i].createDate)
  42. }
  43. that.setData({
  44. list: res.data.data.data,
  45. approvalNum: res.data.data.approval,
  46. approvedNum: res.data.data.approved
  47. })
  48. })
  49. },
  50. getLocalTime: function(nS) {
  51. let date = new Date(nS);
  52. let year = date.getFullYear();
  53. let month = date.getMonth() + 1;
  54. let day = date.getDate();
  55. let hour = date.getHours();
  56. let minute = date.getMinutes();
  57. let second = date.getSeconds();
  58. month = month < 10 ? "0" + month : month;
  59. day = day < 10 ? "0" + day : day;
  60. hour = hour < 10 ? "0" + hour : hour;
  61. minute = minute < 10 ? "0" + minute : minute;
  62. second = second < 10 ? "0" + second : second;
  63. date = year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second;
  64. return date;
  65. },
  66. /**
  67. * 生命周期函数--监听页面加载
  68. */
  69. onLoad: function(options) {
  70. },
  71. /**
  72. * 生命周期函数--监听页面初次渲染完成
  73. */
  74. onReady: function() {
  75. },
  76. /**
  77. * 生命周期函数--监听页面显示
  78. */
  79. onShow: function() {
  80. const that = this;
  81. that.setData({
  82. apiTotal: api.total.substring(0, api.total.length - 4)
  83. })
  84. console.log(that.data.isregiste)
  85. if (that.data.isregiste) {
  86. that.getVisitorCheckInfo(2);
  87. } else {
  88. that.getVisitorCheckInfo(4);
  89. }
  90. },
  91. /**
  92. * 生命周期函数--监听页面隐藏
  93. */
  94. onHide: function() {
  95. },
  96. /**
  97. * 生命周期函数--监听页面卸载
  98. */
  99. onUnload: function() {
  100. },
  101. /**
  102. * 页面相关事件处理函数--监听用户下拉动作
  103. */
  104. onPullDownRefresh: function() {
  105. },
  106. /**
  107. * 页面上拉触底事件的处理函数
  108. */
  109. onReachBottom: function() {
  110. }
  111. })