first commit
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
import {MAIN_API} from "@/config";
|
||||
|
||||
export const setLocation = ({latitude, longitude, province_str, city_str, area_str, area_id, city_id, province_id}) => {
|
||||
if (latitude) uni.setStorageSync("latitude", latitude)
|
||||
if (longitude) uni.setStorageSync("longitude", longitude)
|
||||
uni.setStorageSync("province_str", province_str)
|
||||
uni.setStorageSync("city_str", city_str)
|
||||
uni.setStorageSync("area_str", area_str)
|
||||
uni.setStorageSync("area_id", area_id)
|
||||
uni.setStorageSync("city_id", city_id)
|
||||
uni.setStorageSync("province_id", province_id)
|
||||
}
|
||||
|
||||
export const getLocation = () => {
|
||||
return {
|
||||
latitude: uni.getStorageSync("latitude"),
|
||||
longitude: uni.getStorageSync("longitude"),
|
||||
province_str: uni.getStorageSync("province_str"),
|
||||
city_str: uni.getStorageSync("city_str"),
|
||||
area_str: uni.getStorageSync("area_str"),
|
||||
area_id: uni.getStorageSync("area_id"),
|
||||
city_id: uni.getStorageSync("city_id"),
|
||||
province_id: uni.getStorageSync("province_id")
|
||||
}
|
||||
}
|
||||
|
||||
export const setUserInfo = (user) => {
|
||||
if (user.uid) uni.setStorageSync("uid", user.uid)
|
||||
if (user.username) uni.setStorageSync("username", user.username)
|
||||
if (user.token) uni.setStorageSync("token", user.token)
|
||||
if (user.header) uni.setStorageSync("header", `${MAIN_API}${user.header}`)
|
||||
if (user.phone) uni.setStorageSync("phone", user.phone)
|
||||
}
|
||||
|
||||
export const getUserInfo = () => {
|
||||
return {
|
||||
uid: uni.getStorageSync("uid"),
|
||||
username: uni.getStorageSync("username"),
|
||||
token: uni.getStorageSync("token"),
|
||||
header: uni.getStorageSync("header"),
|
||||
phone: uni.getStorageSync("phone"),
|
||||
}
|
||||
}
|
||||
|
||||
export const clearUserInfo = () => {
|
||||
uni.removeStorageSync("uid");
|
||||
uni.removeStorageSync("username");
|
||||
uni.removeStorageSync("token");
|
||||
uni.removeStorageSync("header");
|
||||
uni.removeStorageSync("phone");
|
||||
}
|
||||
Reference in New Issue
Block a user