Commit 36dd8d58 authored by lizhan's avatar lizhan

📝 【TASK-20240808-04】TASK:增加user个人信息节点

parent 0aa317a6
import storage from '../../utils/storage'
const user = {
state: {
id: storage.get('vuex_id'),
areaCode: storage.get('vuex_areaCode')
},
mutations: {
SET_ID(state, id) {
state.id = id
storage.set('vuex_id', id)
},
SET_AREACODE(state, areaCode) {
state.areaCode = areaCode
storage.set('vuex_areaCode', areaCode)
}
}
}
export default user
// 存储变量名
let storageKey = 'storage_data'
// 存储节点变量名
let storageNodeKeys = ['vuex_id', 'vuex_areaCode']
const storage = {
set: function (key, value) {
if (storageNodeKeys.indexOf(key) != -1) {
let tmp = uni.getStorageSync(storageKey)
tmp = tmp ? tmp : {}
tmp[key] = value
uni.setStorageSync(storageKey, tmp)
}
},
get: function (key) {
let storageData = uni.getStorageSync(storageKey) || {}
return storageData[key] || ''
},
remove: function (key) {
let storageData = uni.getStorageSync(storageKey) || {}
delete storageData[key]
uni.setStorageSync(storageKey, storageData)
},
clean: function () {
uni.removeStorageSync(storageKey)
}
}
export default storage
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment