|
@@ -5,20 +5,14 @@ import store from '@/store';
|
|
|
|
|
|
// 获取当前用户详情
|
|
|
export function getUserData() {
|
|
|
- let data='';
|
|
|
- if(window.plus){
|
|
|
- if(plus.storage.getItem('user_info')){
|
|
|
- data=JSON.parse(plus.storage.getItem('user_info')).data
|
|
|
- }
|
|
|
- }else{
|
|
|
- if(localStorage.getItem('user_info')){
|
|
|
- data=JSON.parse(localStorage.getItem('user_info')).data
|
|
|
- }
|
|
|
+ let data=localStorage.getItem('user_info');
|
|
|
+ if(data){
|
|
|
+ data=JSON.parse(data).data
|
|
|
}
|
|
|
if(!data){
|
|
|
data=store.getters.user_info;
|
|
|
}
|
|
|
- return data
|
|
|
+ return data
|
|
|
}
|
|
|
|
|
|
// 获取积分类型
|
|
@@ -34,88 +28,36 @@ export function getTypes(id) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-export function getToken() {
|
|
|
- if (window.plus) {
|
|
|
- return plus.storage.getItem(TokenKey)
|
|
|
- } else {
|
|
|
- return localStorage.getItem(TokenKey)
|
|
|
+export const checkPlatform = function() {
|
|
|
+ if (/android/i.test(navigator.userAgent)) {
|
|
|
+ return '1'
|
|
|
}
|
|
|
-}
|
|
|
-export function cookGetToken() {
|
|
|
- // return Cookies.get(TokenKey)|| getToken(TokenKey)
|
|
|
- return Cookies.get(TokenKey)|| 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOm51bGwsImlhdCI6MTY3NTczNzEzOSwiZXhwIjoxNjc2MzM3MTM5LCJuYmYiOjE2NzU3MzcxMzksImp0aSI6InZZbmtIUHpFZ3JzS2lkWWkiLCJzdWIiOjc0LCJwcnYiOiJjYTY0ODlkNTBmMjQwN2E2NzgzMGU4MDkwZDAxNDg4MzU2ODU5NjJiIiwicm9sZSI6ImVtcGxveWVlIn0.Omz7v07Iox44cuTAPgflBjA-4GtT9aN8uf4619DoGzw'
|
|
|
-}
|
|
|
-
|
|
|
-export function getUserId() {
|
|
|
- if (window.plus) {
|
|
|
- return plus.storage.getItem(UserIdKey)
|
|
|
- } else {
|
|
|
- return localStorage.getItem(UserIdKey)
|
|
|
+ if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
|
|
|
+ return '2'
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function setToken(token) {
|
|
|
- if (window.plus) {
|
|
|
- var timestamp = parseInt((new Date()).valueOf() / 1000)
|
|
|
- plus.storage.setItem('token-expire', timestamp + 7200)
|
|
|
- return plus.storage.setItem(TokenKey, token)
|
|
|
- } else {
|
|
|
- var timestamp = parseInt((new Date()).valueOf() / 1000)
|
|
|
- localStorage.setItem('token-expire', timestamp + 7200)
|
|
|
- return localStorage.setItem(TokenKey, token)
|
|
|
- }
|
|
|
+ setCache(TokenKey,token)
|
|
|
+ Cookies.set(TokenKey, token)
|
|
|
}
|
|
|
-
|
|
|
-export function setUserId(token) {
|
|
|
- if (window.plus) {
|
|
|
- return plus.storage.setItem(UserIdKey, token)
|
|
|
- } else {
|
|
|
- return localStorage.setItem(UserIdKey, token)
|
|
|
- }
|
|
|
+export function getToken() {
|
|
|
+ return Cookies.get(TokenKey)|| getCache(TokenKey)
|
|
|
}
|
|
|
|
|
|
-export function removeToken() {
|
|
|
- if (window.plus) {
|
|
|
- plus.storage.removeItem('user_info')
|
|
|
- return plus.storage.removeItem(TokenKey)
|
|
|
- } else {
|
|
|
- localStorage.removeItem('user_info')
|
|
|
- return localStorage.removeItem(TokenKey)
|
|
|
- }
|
|
|
+// 获取缓存
|
|
|
+export function getCache(key) {
|
|
|
+
|
|
|
+ let tas="eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOm51bGwsImlhdCI6MTY4MTk1OTcxMSwiZXhwIjoxNjgyNTU5NzExLCJuYmYiOjE2ODE5NTk3MTEsImp0aSI6Ijg3TEliV0NDOE1DSFlyQWQiLCJzdWIiOjc0LCJwcnYiOiJjYTY0ODlkNTBmMjQwN2E2NzgzMGU4MDkwZDAxNDg4MzU2ODU5NjJiIiwicm9sZSI6ImVtcGxveWVlIn0.2iALty8DawnjA-ImsapozVxHHu5e3Rc6ArAkydGRl1c"
|
|
|
+ return JSON.parse(localStorage.getItem(key))
|
|
|
}
|
|
|
-
|
|
|
-export function removeUserId() {
|
|
|
- if (window.plus) {
|
|
|
- return plus.storage.removeItem(UserIdKey)
|
|
|
- } else {
|
|
|
- return localStorage.removeItem(UserIdKey)
|
|
|
- }
|
|
|
+// 设置缓存
|
|
|
+export function setCache(key,data) {
|
|
|
+ localStorage.setItem(key, JSON.stringify(data))
|
|
|
}
|
|
|
|
|
|
-export const checkPlatform = function() {
|
|
|
- if (/android/i.test(navigator.userAgent)) {
|
|
|
- return '1'
|
|
|
- }
|
|
|
- if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
|
|
|
- return '2'
|
|
|
- }
|
|
|
-}
|
|
|
|
|
|
-// cache
|
|
|
-export function set_cache(key, data) {
|
|
|
- if (window.plus) {
|
|
|
- return plus.storage.getItem(key, data)
|
|
|
- } else {
|
|
|
- return localStorage.getItem(key, JSON.stringify(data))
|
|
|
- }
|
|
|
-}
|
|
|
-export function get_cache(key) {
|
|
|
- if (window.plus) {
|
|
|
- return plus.storage.getItem(key)
|
|
|
- } else {
|
|
|
- return JSON.parse(localStorage.getItem(key))
|
|
|
- }
|
|
|
-}
|
|
|
+
|
|
|
// 创始人:creator
|
|
|
// 公司管理员:admin
|
|
|
// 积分管理员:point_manager
|
|
@@ -212,6 +154,7 @@ export function _throttle(fn, interval=500) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
export function isPt_id(item){
|
|
|
switch (item){
|
|
|
case 1:
|
|
@@ -225,11 +168,3 @@ export function isPt_id(item){
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
-// 获取缓存
|
|
|
-export function getCache(key) {
|
|
|
- return JSON.parse(localStorage.getItem(key))
|
|
|
-}
|
|
|
-// 设置缓存
|
|
|
-export function setCache(key,data) {
|
|
|
- localStorage.setItem(key, JSON.stringify(data))
|
|
|
-}
|