pass.js 2.3 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. userIndex: 0,
  10. userArray: ['软件学院计算机系刘天仙', '文学院哲学系陈方明'],
  11. deviceIndex: 2,
  12. deviceArray: [],
  13. deviceList: '',
  14. startDate: '2019-10-29',
  15. endDate: '2019-10-29',
  16. list: []
  17. },
  18. bindUserChange: function(e) {
  19. this.setData({
  20. userIndex: e.detail.value
  21. })
  22. },
  23. bindDeviceChange: function(e) {
  24. this.setData({
  25. deviceIndex: e.detail.value
  26. })
  27. this.getPassInfo();
  28. },
  29. bindStartDateChange: function(e) {
  30. this.setData({
  31. startDate: e.detail.value
  32. })
  33. },
  34. bindendDateChange: function(e) {
  35. this.setData({
  36. endDate: e.detail.value
  37. })
  38. },
  39. getDeviceInfo: function(e) {
  40. const that = this;
  41. util.httpRequest(api.getDeviceInfo, {
  42. }, 'post').then(res => {
  43. let deviceArray = [];
  44. for (let i = 0; i < res.data.length; i++) {
  45. deviceArray.push(res.data[i].name)
  46. if (i == res.data.length - 1) {
  47. that.setData({
  48. deviceArray: deviceArray,
  49. deviceList: res.data
  50. })
  51. that.getPassInfo();
  52. }
  53. }
  54. })
  55. },
  56. getPassInfo: function(e) {
  57. const that = this;
  58. util.httpRequest(api.getPassInfo, {
  59. loginId: 15286831873,
  60. start: that.data.startDate,
  61. end: that.data.endDate,
  62. driviceId: that.data.deviceList[that.data.deviceIndex].id,
  63. rows: 20,
  64. page: 1
  65. }, 'post').then(res => {
  66. that.setData({
  67. list: res.data.data
  68. })
  69. })
  70. },
  71. /**
  72. * 生命周期函数--监听页面加载
  73. */
  74. onLoad: function(options) {
  75. const that = this;
  76. that.getDeviceInfo();
  77. },
  78. /**
  79. * 生命周期函数--监听页面初次渲染完成
  80. */
  81. onReady: function() {
  82. },
  83. /**
  84. * 生命周期函数--监听页面显示
  85. */
  86. onShow: function() {
  87. },
  88. /**
  89. * 生命周期函数--监听页面隐藏
  90. */
  91. onHide: function() {
  92. },
  93. /**
  94. * 生命周期函数--监听页面卸载
  95. */
  96. onUnload: function() {
  97. },
  98. /**
  99. * 页面相关事件处理函数--监听用户下拉动作
  100. */
  101. onPullDownRefresh: function() {
  102. },
  103. /**
  104. * 页面上拉触底事件的处理函数
  105. */
  106. onReachBottom: function() {
  107. }
  108. })