import Cookies from 'js-cookie'
import Lockr from 'lockr'
import md5 from 'js-md5'

const TokenKey = 'Admin-Token'
const md5key = "3Jr8S1K18rcC1wAfv8";

export function getToken() {
  //// console.log("getToken ================"+Lockr.get(TokenKey))
  //return Cookies.get(TokenKey)
  return Lockr.get(TokenKey)
}

export function setToken(token) {
  //// console.log("setToken ================")
  //// console.log("setToken token = "+token)
  Lockr.set(TokenKey, token)
  var vl = Lockr.get(TokenKey)
  //// console.log("刚刚存的 token = "+vl)
  return Lockr.set(TokenKey, token)
  // return Cookies.set(TokenKey, token)
}

export function removeToken() {
  //// console.log("removeToken ================")
  return Lockr.rm(TokenKey)
 // return Cookies.remove(TokenKey)
}

export function getSign(params, timestamp) {
   //// console.log("getSign ================")
   let signStr = JSON.stringify(params) + "nonce" + timestamp + "" + md5key;
   var sign = md5(signStr);
  return sign
}
