tiefen_space_h5/utils/storeInfo.js

29 lines
707 B
JavaScript
Raw Normal View History

2024-07-03 19:59:39 +08:00
export function save(key,value){
localStorage.setItem(key,value)
}
export function get(key){
2024-07-10 00:48:37 +08:00
let data = localStorage.getItem("account");
2024-07-12 22:52:48 +08:00
// console.log(key,data)
2024-07-10 00:48:37 +08:00
2024-07-06 11:05:19 +08:00
return data ? JSON.parse(data) : {};
2024-07-03 19:59:39 +08:00
}
export function remove(key){
localStorage.removeItem(key)
}
export function clear(){
localStorage.clear()
2024-07-06 11:05:19 +08:00
}
export function saveUserInfo (data, mobilePhone, regionCode){
save("token", data.data.token);
save("account", JSON.stringify(data.data.account));
save("mobile_phone", mobilePhone);
save("region_code", regionCode);
}
export function removeUserInfo (){
remove("token");
remove("account");
remove("mobile_phone");
remove("region_code");
}