let fns = {
  // 设置cookie
  setCookie: function (cName, value, expiremMinutes = 24 * 60) {
    let exdate = new Date()
    exdate.setTime(exdate.getTime() + expiremMinutes * 60 * 1000)
    document.cookie = cName + '=' + escape(value) + ((expiremMinutes === null) ? '' : 'expires=' + exdate.toGMTString())
  },

  // 读取cookie
  getCookie: function (cName) {
    let value = ''
    let str = document.cookie
    let start = str.indexOf(cName + '=')
    if (~start) {
      str = str.substr(start)
      let end = str.indexOf('expires')

      if (~end) {
        value = str.substring(cName.length + 1, end)
      } else {
        value = str.substr(cName.length + 1)
      }
    }

    return value
  }
}

export default fns
