/*
 * @Description: cookie封装
 * @Author: Napier
 * @LastEditors: Napier
 * @LastEditorTime:
 */

export default {
  /**
   * @description:设置cookie
   * @param {*} value：值
   * @param {number} saveDays ：保存的时间
   * @param {string} cookieName ：键名
   */
  setCookie: function (value, saveDays, cookieName) {
    let date = new Date()
    date.setTime(date.getTime() + saveDays * 24 * 60 * 60 * 1000)
    document.cookie = cookieName + '=' + escape(value) + ';expires=' + date.toGMTString()
  },

  /**
   * @description:获取cookie
   * @param {} name :键名
   * @returns {*}
   */
  getCookie: function (name) {
    var v = window.document.cookie.match('(^|;) ?' + name + '=([^;]*)(;|$)')
    return v ? v[2] : null
  }
}
