zrg
14 小时以前 359befaa90ca7037153f77ee38f03c6b41306e9a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// 该文件用来存储localStorage 本地缓存的方法
/**
 * 操作登录信息
 */
 
export function setLoginData(value) {
  try {
    let newValue = JSON.stringify(value);
    uni.setStorageSync('loginData', newValue);
    console.log('存储登录信息成功');
  } catch (e) {
    return;
  }
}
export function getLoginData() {
  let loginData = uni.getStorageSync('loginData');
  return JSON.parse(loginData);
}
export function removeLoginData(){
    uni.removeStorageSync('loginData');
}
/**
 * 操作用户code
 */
export function setCode(value) {
  uni.setStorageSync('code', value);
  console.log('存储用户code成功');
}
export function getCode() {
  let code = uni.getStorageSync('code');
  return code;
}
/**
 * 操作用户openId
 */
export function setOpenId(value) {
  uni.setStorageSync('openId', value);
  console.log('存储用户openId成功');
}
export function getOpenId() {
  let openId = uni.getStorageSync('openId');
  return openId;
}
export function removeOpenId() {
  uni.removeStorageSync('openId');
}
 
/**
 * 操作用户token
 */
export function setToken(value) {
  uni.setStorageSync('token', value);
  console.log('存储用户信息成功');
}
export function getToken() {
  let token = uni.getStorageSync('token');
  return token;
}
export function removeToken() {
  uni.removeStorageSync('token');
}
/**
 * 操作用户信息
 */
 
export function setUserInfo(value) {
  try {
    let newValue = JSON.stringify(value);
    uni.setStorageSync('userinfo', newValue);
    console.log('存储用户信息成功');
  } catch (e) {
    return;
  }
}
export function getUserInfo() {
  let userinfo = uni.getStorageSync('userinfo');
  //console.log('userinfo', userinfo)
  if (userinfo) {
    return JSON.parse(userinfo);
  }
}
export function removeUserInfo(){
    uni.removeStorageSync('userinfo');
}
 
// 存储用户地址
export function setAddress(value) {
  try {
    let newValue = JSON.stringify(value);
    uni.setStorageSync('address', newValue);
    console.log('存储地址信息成功', newValue);
  } catch (e) {
    return;
  }
}
export function getAddress() {
  let address = uni.getStorageSync('address');
 
  if (address) {
    return JSON.parse(address);
  }
}
export function removeAddress() {
  uni.removeStorageSync('address');
}
export function setlocation(value){ //存储位置信息
    try {
      let newValue = JSON.stringify(value);
      uni.setStorageSync('location', newValue);
      console.log('存储地址信息成功', newValue);
    } catch (e) {
      return;
    }
}
export function getlocation() { //获取位置信息
  let location = uni.getStorageSync('location');
  if (location) {
    return JSON.parse(location);
  }
}