visitorcheck.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. isregiste: true,
  10. approvalNum: 0,
  11. approvedNum: 0,
  12. list: []
  13. },
  14. checkTab: function(e) {
  15. const that = this;
  16. that.setData({
  17. isregiste: !that.data.isregiste
  18. })
  19. if (that.data.isregiste) {
  20. that.getVisitorCheckInfo(2);
  21. } else {
  22. that.getVisitorCheckInfo(4);
  23. }
  24. },
  25. todetail: function(e) {
  26. let id = e.currentTarget.dataset.id;
  27. let type = e.currentTarget.dataset.type;
  28. wx.navigateTo({
  29. url: '../visitorcheckdetail/visitorcheckdetail?id=' + id + '&type=' + this.data.isregiste,
  30. })
  31. },
  32. getVisitorCheckInfo: function(status) {
  33. const that = this;
  34. util.httpRequest(api.getVisitorCheckInfo, {
  35. status: status,
  36. rows: 20,
  37. page: 1
  38. }, 'post').then(res => {
  39. for (let i = 0; i < res.data.data.data.length; i++) {
  40. res.data.data.data[i].createDate = that.getLocalTime(res.data.data.data[i].createDate)
  41. // res.data.data.data[i].headImage =
  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. console.log(date);
  65. return date;
  66. },
  67. /**
  68. * 生命周期函数--监听页面加载
  69. */
  70. onLoad: function(options) {
  71. const that = this;
  72. that.getVisitorCheckInfo(2);
  73. },
  74. /**
  75. * 生命周期函数--监听页面初次渲染完成
  76. */
  77. onReady: function() {
  78. },
  79. /**
  80. * 生命周期函数--监听页面显示
  81. */
  82. onShow: function() {
  83. },
  84. /**
  85. * 生命周期函数--监听页面隐藏
  86. */
  87. onHide: function() {
  88. },
  89. /**
  90. * 生命周期函数--监听页面卸载
  91. */
  92. onUnload: function() {
  93. },
  94. /**
  95. * 页面相关事件处理函数--监听用户下拉动作
  96. */
  97. onPullDownRefresh: function() {
  98. },
  99. /**
  100. * 页面上拉触底事件的处理函数
  101. */
  102. onReachBottom: function() {
  103. }
  104. })