You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
shop-app/common/store/index.js

62 lines
1.3 KiB

3 years ago
/*
* @Author: ch
* @Date: 2022-03-22 18:28:52
* @LastEditors: ch
3 years ago
* @LastEditTime: 2022-04-29 14:13:05
3 years ago
* @Description: file content
*/
import Vue from 'vue'
import Vuex from 'vuex';
Vue.use(Vuex);
const
// token
TOKEN = 'tk',
// 用户信息
USER_INFO = 'ui',
// 地址列表
3 years ago
ADDRESS = 'ads',
// oppenId
OPPED_ID = 'oi';
3 years ago
export default new Vuex.Store({
state : {
token : uni.getStorageSync(TOKEN) || '',
userInfo : JSON.parse(uni.getStorageSync(USER_INFO) || '{}'),
3 years ago
address : JSON.parse(uni.getStorageSync(ADDRESS) || '[]'),
sessionData : [],
3 years ago
sessionMsgCount : 0,
3 years ago
sessionMsgId : '',
3 years ago
openId : uni.getStorageSync(OPPED_ID) || ''
3 years ago
},
mutations:{
SET_TOKEN (state, token = ''){
state.token = token;
uni.setStorageSync(TOKEN, token);
},
SET_USER_INFO (state, userInfo = {}){
state.userInfo = userInfo;
uni.setStorageSync(USER_INFO, JSON.stringify(userInfo));
3 years ago
},
SET_ADDRESS (state, address = []){
state.address = address;
uni.setStorageSync(ADDRESS, JSON.stringify(address));
3 years ago
},
SET_SESSION_DATA (state, data){
state.sessionData = data ;
},
SET_SESSION_MSG_COUNT (state, data){
state.sessionMsgCount = data;
3 years ago
},
SET_OPEN_ID (state, data){
state.openId = data;
3 years ago
uni.setStorageSync(OPPED_ID, data);
3 years ago
},
3 years ago
SET_SESSION_MSG_ID (state, data){
state.sessionMsgId = data;
}
3 years ago
},
actions : {
3 years ago
}
})