visitorcheck.js 2.2 KB

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