const formatTime = date => {
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()
  const hour = date.getHours()
  const minute = date.getMinutes()
  const second = date.getSeconds()

  return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}`
}

const formatNumber = n => {
  n = n.toString()
  return n[1] ? n : `0${n}`
}
//获取url参数组成json
const GetQueryJson = e => {
    if (e == 'undefined') {
        return {}
    } else {
        let url = e; //获取url
        let arr = []; //存储参数的数   
        let res = {}; //存储最终JSON结果对象 
        arr = url.split('?')[1].split('&'); //获取浏览器地址栏中的参数
        for (let i = 0; i < arr.length; i++) { //遍历参数
            if (arr[i].indexOf('=') != -1) { //如果参数中有值
                let str = arr[i].split('=');
                res[str[0]] = str[1];
            } else { //如果参数中无值
                res[arr[i]] = '';
            }
        };
        return res;
    }

}
module.exports = {
  formatTime,GetQueryJson
}
