Browse Source

修复h5登陆异常的问题

master
Gaoxs 3 years ago
parent
commit
10dfffbd82
  1. 5
      main.js
  2. 26
      utils/store/cookie.js

5
main.js

@ -67,11 +67,10 @@ deviceType = 'routine'
import { wechat, clearAuthStatus, oAuth, auth, toAuth, pay, openAddress, openShareAll, openShareAppMessage, openShareTimeline, wechatEvevt, ready, wxShowLocation } from '@/libs/wechat' import { wechat, clearAuthStatus, oAuth, auth, toAuth, pay, openAddress, openShareAll, openShareAppMessage, openShareTimeline, wechatEvevt, ready, wxShowLocation } from '@/libs/wechat'
import { isWeixin } from '@/utils' import { isWeixin } from '@/utils'
const CACHE_KEY = 'clear_0.0.1'
if (!cookie.has(CACHE_KEY)) { if (!cookie.has(cookie.CACHE_KEY)) {
cookie.clearAll() cookie.clearAll()
cookie.set(CACHE_KEY, 1) cookie.set(cookie.CACHE_KEY, 1)
} }
var urlSpread = parseQuery()['spread'] var urlSpread = parseQuery()['spread']

26
utils/store/cookie.js

@ -1,12 +1,10 @@
import { trim, isType } from "@/utils"; import { trim, isType } from '@/utils'
const doc = null; const doc = null
const CACHE_KEY = 'clear_0.0.1'
// const doc = window.document; // const doc = window.document;
function get(key) { function get(key) {
if (!key || !_has(key)) {
return '';
}
return uni.getStorageSync(key) return uni.getStorageSync(key)
} }
@ -16,29 +14,26 @@ function all() {
function set(key, data, time) { function set(key, data, time) {
if (!key) { if (!key) {
return; return
} }
uni.setStorageSync(key, data) uni.setStorageSync(key, data)
} }
function remove(key) { function remove(key) {
if (!key || !_has(key)) { if (!key || !_has(key)) {
return; return
} }
uni.removeStorageSync(key) uni.removeStorageSync(key)
} }
function clearAll() { function clearAll() {
const res = uni.getStorageInfoSync(); const res = uni.getStorageInfoSync()
res.keys.map((item) => { res.keys.map(item => {
if (item == 'redirect' || item == 'spread') { if (item == 'redirect' || item == 'spread' || item == CACHE_KEY) {
return return
} }
remove(item) remove(item)
}) })
console.log(res)
// debugger
// uni.clearStorageSync()
} }
function _has(key) { function _has(key) {
@ -58,5 +53,6 @@ export default {
set, set,
remove, remove,
clearAll, clearAll,
has: _has has: _has,
}; CACHE_KEY,
}

Loading…
Cancel
Save