// import JSEncrypt from 'jsencrypt/bin/jsencrypt'
export default{
    /**
     * 获取当前日期
     * @param {string} formatType 格式化方式
     * @returns {string} backDate 格式完成后的日期
     */
    getFormatDate: function (formatType = 'yyyymmdd', dateObj = new Date()) {
      let date = dateObj
      let yyyy = date.getFullYear() + ''
      let mm = (date.getMonth() + 1) > 9 ? (date.getMonth() + 1) : '0' + (date.getMonth() + 1)
      let dd = date.getDate() > 9 ? date.getDate() : '0' + date.getDate()
      let hh = date.getHours() > 9 ? date.getHours() : '0' + date.getHours()
      let min = date.getMinutes() > 9 ? date.getMinutes() : '0' + date.getMinutes()
      let sec = date.getSeconds() > 9 ? date.getSeconds() : '0' + date.getSeconds()
      let backDate = ''
      switch (formatType) {
        case 'yyyymmdd':
          backDate = yyyy + mm + dd
          break
        case 'yyyy-mm-dd':
          backDate = `${yyyy}-${mm}-${dd}`
          break
        case 'yyyymmddhhmmss':
          backDate = yyyy + mm + dd + hh + min + sec
          break
        case 'yyyy-mm-dd hh:mm:ss':
          backDate = `${yyyy}-${mm}-${dd} ${hh}:${min}:${sec}`
          break
        default:
          break
      }
      return backDate
    },

    getDay:function(num, str) {
        var today = new Date();
        var nowTime = today.getTime();
        var ms = 24 * 3600 * 1000 * num;
        today.setTime(parseInt(nowTime + ms));
        var oYear = today.getFullYear();
        var oMoth = (today.getMonth() + 1).toString();
        if (oMoth.length <= 1) oMoth = '0' + oMoth;
        var oDay = today.getDate().toString();
        if (oDay.length <= 1) oDay = '0' + oDay;
        return oYear + str + oMoth + str + oDay;
    },
    
    formatDate: function (value) {
      let date = new Date(value);
      let y = date.getFullYear();
      let MM = date.getMonth() + 1;
      MM = MM < 10 ? ('0' + MM) : MM;
      let d = date.getDate();
      d = d < 10 ? ('0' + d) : d;
      let h = date.getHours();
      h = h < 10 ? ('0' + h) : h;
      let m = date.getMinutes();
      m = m < 10 ? ('0' + m) : m;
      let s = date.getSeconds();
      s = s < 10 ? ('0' + s) : s;
      return y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s;
    },
  }
  