//读取用户信息
var cookieVal = oCookie.read('cookieId');
if(cookieVal){
storage.setItem("cookieId",cookieVal);
}else{
//oCookie.write("cookieId",cookieVal);
}
/*设置与获取Cookie*/
export var oCookie = {};
oCookie.write = function(key, value) {
var date = new Date();
date.setTime(date.getTime() + 1000 * 60 * 60 * 24 * 30);
document.cookie = key + "=" + encodeURI(value) + "; expires=" + date.toUTCString();
};
oCookie.read = function(key) {
var arr = document.cookie.match(new RegExp("(^| )" + key + "=([^;]*)(;|$)"));
if (arr != null) return decodeURIComponent(arr[2]);
return "";
};
//定义本地存储对象
export var storage = {
getItem: function(key) {
return window.localStorage ? localStorage.getItem(key) : oCookie.read(key);
},
setItem: function(key, val) {
if (window.localStorage) {
localStorage.setItem(key, val);
} else {
oCookie.write(key, val);
}
}
};