const util = require('../../../utils/util.js'); const api = require('../../../utils/api.js'); const app = getApp(); Page({ /** * 页面的初始数据 */ data: { userIndex: 0, userArray: ['软件学院计算机系刘天仙', '文学院哲学系陈方明'], deviceIndex: 2, deviceArray: [], deviceList: '', startDate: '2019-10-29', endDate: '2019-10-29', list: [] }, bindUserChange: function(e) { this.setData({ userIndex: e.detail.value }) }, bindDeviceChange: function(e) { this.setData({ deviceIndex: e.detail.value }) this.getPassInfo(); }, bindStartDateChange: function(e) { this.setData({ startDate: e.detail.value }) }, bindendDateChange: function(e) { this.setData({ endDate: e.detail.value }) }, getDeviceInfo: function(e) { const that = this; util.httpRequest(api.getDeviceInfo, { }, 'post').then(res => { let deviceArray = []; for (let i = 0; i < res.data.length; i++) { deviceArray.push(res.data[i].name) if (i == res.data.length - 1) { that.setData({ deviceArray: deviceArray, deviceList: res.data }) that.getPassInfo(); } } }) }, getPassInfo: function(e) { const that = this; util.httpRequest(api.getPassInfo, { loginId: 15286831873, start: that.data.startDate, end: that.data.endDate, driviceId: that.data.deviceList[that.data.deviceIndex].id, rows: 20, page: 1 }, 'post').then(res => { that.setData({ list: res.data.data }) }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function(options) { const that = this; that.getDeviceInfo(); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function() { }, /** * 生命周期函数--监听页面显示 */ onShow: function() { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function() { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function() { } })