method.js 1.5 KB
const axios = require('axios');

const methods = {
  YesterdayTime() {
    let YesterdayTime = (new Date).getTime() - 24 * 60 * 60 * 1000
    let YesterdayTimeDate = new Date(YesterdayTime)
    let year = YesterdayTimeDate.getFullYear()
    year = year.toString()
    let month = YesterdayTimeDate.getMonth() + 1
    let date = YesterdayTimeDate.getDate()
    let startTime = new Date(year + "-" + month + "-" + date + " 5:30:00").getTime()
    let endTime = new Date(year + "-" + month + "-" + date + " 23:59:00").getTime()
    if (month < 10) {
      month = '0' + month
    }else{
      month = month.toString()
    }

    if (date < 10) {
      date = '0' + date
    }else{
      date = date.toString()
    }
    return {
      startTime,
      endTime,
      ymd: year + month + date
    }
  },
  dayTimeYMD() {
    let dayTimeDate = new Date()
    let year = dayTimeDate.getFullYear()
    year = year.toString()
    let month = dayTimeDate.getMonth() + 1
    let date = dayTimeDate.getDate()
    if (month < 10) {
      month = '0' + month
    }else{
      month = month.toString()
    }
    if (date < 10) {
      date = '0' + date
    }else{
      date = date.toString()
    }
    return {
      ymd: year + month + date
    }
  },
  async getRequestClassIds(url, siteId, key, startTime, endTime, page) {
    let axiosUrl = `${url}?siteId=${siteId}&key=${key}&from=${startTime}&to=${endTime}&page=${page}`
    console.log('axiosUrl', axiosUrl)
    let result = await axios.get(axiosUrl)
    return result
  },
}

module.exports = methods