yujingsearch.js 3.5 KB
// pages/yujing/yujingsearch/yujingsearch.js
const app=getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    datechu:false,
    currentdate:false,
    startdate:'',
    enddate:'',
    datePickerValue: ['', '', ''],
    timesel:1,
    chaxun:true,
    reset:true,
    // 显示企业信息搜索还是查询列表
    qiyexinxi:false
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      startdate: app.nowDate(),
      enddate: app.qiendate()
    })
  },

  //输入企业姓名
  enterqiyename(e){
    this.setData({
      qiyename:e.detail.value
    })

    if(this.data.qiyename.length>0){
      this.setData({
        chaxun: false,
        reset: false
      })
    }
  },
  // 显示时间弹出层
  begintime(){
    this.setData({
      datechu: true,
      currentdate: true,
    })

    this.datexianshi()
  },

  //开始时间和结束时间切换
  xuanshijan(e) {
    this.setData({
      timesel:e.currentTarget.dataset.time,
      currentdate: true
    })

    this.datexianshi()
  },
  // 显示日期
  datexianshi() {
    this.setData({
      datechu: true,
      currentdate: true
    })

    //获取年
    var date = new Date();
    var obj = {}
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    if (month < 10) {
      month = '0' + month
    }

    var day = date.getDate();
    if (day < 10) {
      day = "0" + day
    }
    console.log()
    if (typeof (day) == 'number') {
      day = day.toString()
    }
    console.log(typeof (day))
    this.setData({
      datePickerValue: [year, month, day],
    })

  },


//确定选择时间
  datePickerOnSureClick: function (e) {
    console.log('datePickerOnSureClick');

    if (this.data.timesel == 1) {
      console.log(e);
      this.setData({
        date: `${e.detail.value[0]}${e.detail.value[1]}${e.detail.value[2]}日`,
        datePickerValue: e.detail.value,
        datePickerIsShow: false,
        currentdate: false,
        state: 2,
        startdate: e.detail.value[0] + '年' + e.detail.value[1] + "月" + e.detail.value[2]+'日'
      });
    } else {
      console.log(e);
      this.setData({
        date: `${e.detail.value[0]}${e.detail.value[1]}${e.detail.value[2]}日`,
        datePickerValue: e.detail.value,
        datePickerIsShow: false,
        currentdate: false,
        state: 2,
        enddate: e.detail.value[0] + '年' + e.detail.value[1] + "月" + e.detail.value[2]+'日'
      });
    }

  },
// 取消选择时间
  datePickerOnCancelClick: function (event) {
    console.log('datePickerOnCancelClick');
    console.log(event);
    this.setData({
      datePickerIsShow: false,

      currentdate: false,
      state: 2
    });
  },

  //确定选择开始日期和结束日期
  qudingxuandate() {
    this.setData({
      datechu: false,
      watertime: this.data.startdate + '-' + this.data.enddate
    })
  },


  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})