拷贝铜箔手持
This commit is contained in:
77
vuex/modules/user.js
Normal file
77
vuex/modules/user.js
Normal file
@@ -0,0 +1,77 @@
|
||||
import * as types from '../types'
|
||||
|
||||
const baseUrl = process.env.NODE_ENV === 'development' ? 'http://10.1.3.90:8010' : 'http://10.1.3.90:8010'
|
||||
const state = {
|
||||
baseUrl: uni.getStorageSync('baseUrl') || baseUrl,
|
||||
setTime: uni.getStorageSync('setTime') || 5000,
|
||||
setPrintName: uni.getStorageSync('setPrintName') || '',
|
||||
loginName: uni.getStorageSync('loginName') ? uni.getStorageSync('loginName') : '',
|
||||
userInfo: uni.getStorageSync('userInfo') ? uni.getStorageSync('userInfo') : '',
|
||||
saveToken: uni.getStorageSync('saveToken') || ''
|
||||
}
|
||||
const getters = {
|
||||
baseUrl: state => state.baseUrl,
|
||||
setTime: state => state.setTime,
|
||||
setPrintName: state => state.setPrintName,
|
||||
loginName: state => state.loginName,
|
||||
userInfo: state => state.userInfo,
|
||||
saveToken: state => state.saveToken
|
||||
}
|
||||
const actions = {
|
||||
setConfig ({commit}, res) {
|
||||
uni.setStorageSync('baseUrl', res.baseUrl)
|
||||
uni.setStorageSync('setTime', res.setTime)
|
||||
uni.setStorageSync('setPrintName', res.setPrintName)
|
||||
commit(types.COM_CONFIG, res)
|
||||
},
|
||||
saveLoginName({commit}, res) {
|
||||
uni.setStorageSync('loginName', res)
|
||||
commit(types.SAVE_LOGIN_NAME, res)
|
||||
},
|
||||
delLoginName({commit}, res) {
|
||||
uni.clearStorageSync('loginName')
|
||||
commit(types.DEL_LOGIN_NAME, res)
|
||||
},
|
||||
saveUserInfo({commit}, res) {
|
||||
uni.setStorageSync('userInfo', res)
|
||||
commit(types.SAVE_USER_INFO, res)
|
||||
},
|
||||
delUserInfo({commit}, res) {
|
||||
uni.removeStorageSync('userInfo')
|
||||
uni.removeStorageSync('saveToken')
|
||||
commit(types.DEL_USER_INFO, res)
|
||||
},
|
||||
saveToken({commit}, res) {
|
||||
uni.setStorageSync('saveToken', res)
|
||||
commit(types.SAVE_TOKEN, res)
|
||||
}
|
||||
}
|
||||
const mutations = {
|
||||
[types.COM_CONFIG] (state, res) {
|
||||
state.baseUrl = res.baseUrl
|
||||
state.setTime = res.setTime
|
||||
state.setPrintName = res.setPrintName
|
||||
},
|
||||
[types.SAVE_LOGIN_NAME] (state, res) {
|
||||
state.loginName = res
|
||||
},
|
||||
[types.DEL_LOGIN_NAME] (state, res) {
|
||||
state.loginName = res
|
||||
},
|
||||
[types.SAVE_USER_INFO] (state, res) {
|
||||
state.userInfo = res
|
||||
},
|
||||
[types.DEL_USER_INFO] (state, res) {
|
||||
state.userInfo = res
|
||||
},
|
||||
[types.SAVE_TOKEN] (state, res) {
|
||||
state.saveToken = res
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
state,
|
||||
getters,
|
||||
actions,
|
||||
mutations
|
||||
}
|
||||
12
vuex/store.js
Normal file
12
vuex/store.js
Normal file
@@ -0,0 +1,12 @@
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
|
||||
import user from './modules/user'
|
||||
|
||||
Vue.use(Vuex)
|
||||
|
||||
export default new Vuex.Store({
|
||||
modules: {
|
||||
user
|
||||
}
|
||||
})
|
||||
9
vuex/types.js
Normal file
9
vuex/types.js
Normal file
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* user
|
||||
*/
|
||||
export const SAVE_LOGIN_NAME = 'SAVE_LOGIN_NAME'
|
||||
export const DEL_LOGIN_NAME = 'DEL_LOGIN_NAME'
|
||||
export const COM_CONFIG = 'COM_CONFIG'
|
||||
export const SAVE_USER_INFO = 'SAVE_USER_INFO'
|
||||
export const DEL_USER_INFO = 'DEL_USER_INFO'
|
||||
export const SAVE_TOKEN = 'SAVE_TOKEN'
|
||||
Reference in New Issue
Block a user