123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- const util = require('../../../utils/util.js');
- const api = require('../../../utils/api.js');
- const app = getApp()
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- apiTotal: '',
- isregiste: true,
- approvalNum: 0,
- approvedNum: 0,
- list: []
- },
- checkTab: function(e) {
- const that = this;
- that.setData({
- isregiste: !that.data.isregiste
- })
- if (that.data.isregiste) {
- that.getVisitorCheckInfo(2);
- } else {
- that.getVisitorCheckInfo(4);
- }
- },
- todetail: function(e) {
- let id = e.currentTarget.dataset.id;
- let type = e.currentTarget.dataset.type;
- wx.navigateTo({
- url: '../visitorcheckdetail/visitorcheckdetail?id=' + id + '&type=' + this.data.isregiste,
- })
- },
- getVisitorCheckInfo: function(status) {
- const that = this;
- util.httpRequest(api.getVisitorCheckInfo, {
- status: status,
- rows: 20,
- page: 1
- }, 'post').then(res => {
- for (let i = 0; i < res.data.data.data.length; i++) {
- res.data.data.data[i].createDate = that.getLocalTime(res.data.data.data[i].createDate)
- }
- that.setData({
- list: res.data.data.data,
- approvalNum: res.data.data.approval,
- approvedNum: res.data.data.approved
- })
- })
- },
- getLocalTime: function(nS) {
- let date = new Date(nS);
- let year = date.getFullYear();
- let month = date.getMonth() + 1;
- let day = date.getDate();
- let hour = date.getHours();
- let minute = date.getMinutes();
- let second = date.getSeconds();
- month = month < 10 ? "0" + month : month;
- day = day < 10 ? "0" + day : day;
- hour = hour < 10 ? "0" + hour : hour;
- minute = minute < 10 ? "0" + minute : minute;
- second = second < 10 ? "0" + second : second;
- date = year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second;
- return date;
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function(options) {
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function() {
- const that = this;
- that.setData({
- apiTotal: api.total.substring(0, api.total.length - 4)
- })
- console.log(that.data.isregiste)
- if (that.data.isregiste) {
- that.getVisitorCheckInfo(2);
- } else {
- that.getVisitorCheckInfo(4);
- }
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function() {
- }
- })
|