Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas_plus
/
business-assistant
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 97b1dcb1
authored
Oct 11, 2022
by
张立顺
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修复storage bug
1 parent
1bfd8d22
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
15 deletions
pages/tab/output/components/merchant/mrechant.wxml
pages/tab/output/output.js
utils/cache/storage.js
utils/cache/storageApi.js
utils/constantData.js
pages/tab/output/components/merchant/mrechant.wxml
View file @
97b1dcb
<!-- pages/tab/output/components/merchant/mrechant.wxml -->
<!-- <text>pages/tab/output/components/merchant/mrechant.wxml</text> -->
<text>商户产值</text>
<!-- -->
<!-- 无门店 -->
<view>
<!-- <img src="" alt=""> -->
...
...
pages/tab/output/output.js
View file @
97b1dcb
// pages/tab/output/output.js
import
{
getSessionId
,
setSessionId
}
from
'~/utils/cache/storageApi'
Page
({
/**
* 页面的初始数据
...
...
@@ -26,7 +27,10 @@ Page({
/**
* 生命周期函数--监听页面加载
*/
onLoad
(
options
)
{},
onLoad
(
options
)
{
setSessionId
(
'xxx'
)
console
.
log
(
getSessionId
())
},
/**
* 生命周期函数--监听页面初次渲染完成
...
...
utils/cache/storage.js
View file @
97b1dcb
...
...
@@ -2,7 +2,7 @@
* 微信小程序标准版:统一封装的 storage 操作类
*/
import
{
DEFAULT_GET_STORAGEKEY
,
GET_
STORAGE_OBJECTkEY
}
from
'~/utils/constantData'
import
{
DEFAULT_GET_STORAGEKEY
,
STORAGE_OBJECTkEY
}
from
'~/utils/constantData'
class
Storage
{
types
=
{
1
:
'get'
,
// get
...
...
@@ -14,7 +14,6 @@ class Storage {
trial
:
'体验版'
,
release
:
'正式版'
}
// getStorageKey = GET_STORAGE_OBJECTkEY
// defaultGetStorageKey = DEFAULT_GET_STORAGEKEY
/** 构造函数 */
constructor
()
{
...
...
@@ -52,15 +51,16 @@ class Storage {
*/
get
=
(
key
,
syncFlag
=
true
)
=>
{
// 有值默认取key值
debugger
if
(
key
)
{
// 判断值是否是指定的对象值
let
tmpKey
=
this
.
checkKeyType
(
key
,
1
)
let
isObjectKey
=
GET_
STORAGE_OBJECTkEY
[
key
]
let
isObjectKey
=
STORAGE_OBJECTkEY
[
key
]
if
(
isObjectKey
)
{
return
this
.
getObjectKeyValue
(
isObjectKey
)
}
else
{
if
(
syncFlag
)
{
tmpKey
=
this
.
addEvnToKey
(
tmpKey
)
let
res
=
wx
.
getStorageSync
(
tmpKey
)
if
(
res
)
{
return
JSON
.
parse
(
res
)
...
...
utils/cache/storageApi.js
View file @
97b1dcb
...
...
@@ -16,14 +16,14 @@ export function setUserInfo(data) {
$Storage
.
set
(
'scrm_shopmall_userInfo'
,
data
)
}
export
function
removeSystemStorage
()
{
$Storage
.
rm
(
'srcm_shopmall_user_info'
)
$Storage
.
rm
(
'scrm_shopmall_sessionId'
)
$Storage
.
rm
(
'guest_no'
)
$Storage
.
rm
(
'equity_info'
)
$Storage
.
rm
(
'packageList'
)
$Storage
.
rm
(
'isVIP'
)
$Storage
.
rm
(
'bizjiaUrl'
)
$Storage
.
rm
(
'vip_card_info'
)
//
$Storage.rm('srcm_shopmall_user_info')
//
$Storage.rm('scrm_shopmall_sessionId')
//
$Storage.rm('guest_no')
//
$Storage.rm('equity_info')
//
$Storage.rm('packageList')
//
$Storage.rm('isVIP')
//
$Storage.rm('bizjiaUrl')
//
$Storage.rm('vip_card_info')
}
export
function
setStorageSync
(
key
,
data
)
{
$Storage
.
set
(
key
,
JSON
.
stringify
(
data
))
...
...
utils/constantData.js
View file @
97b1dcb
...
...
@@ -4,6 +4,9 @@ export const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram-tes
export
const
DEFAULT_GET_STORAGEKEY
=
[
'sessionId'
,
'merchantId'
,
'userInfo'
]
// 缓存get方法key的对应才映射值
export
const
GET_STORAGE_OBJECTkEY
=
{
super
:
[
'sessionId'
,
'merchantId'
,
'userInfo'
]
export
const
STORAGE_OBJECTkEY
=
{
DEFAULT_GET_STORAGEKEY
,
sessionId
:
'sessionId'
,
userInfo
:
'userInfo'
,
systemInfo
:
'systemInfo'
}
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment