init
This commit is contained in:
88
vuex/modules/user.js
Normal file
88
vuex/modules/user.js
Normal file
@@ -0,0 +1,88 @@
|
||||
import * as types from '../types'
|
||||
|
||||
const baseUrl = process.env.NODE_ENV === 'development' ? 'http://192.168.18.218:8012' : 'http://192.168.18.218:8012'
|
||||
const acsUrl = process.env.NODE_ENV === 'development' ? 'http://192.168.18.250:8012' : 'http://192.168.18.250:8012'
|
||||
const printUrl = process.env.NODE_ENV === 'development' ? 'http://192.168.18.4:8000' : 'http://192.168.18.4:8000'
|
||||
const state = {
|
||||
baseUrl: uni.getStorageSync('baseUrl') || baseUrl,
|
||||
acsUrl: uni.getStorageSync('acsUrl') || acsUrl,
|
||||
printUrl: uni.getStorageSync('printUrl') || printUrl,
|
||||
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,
|
||||
acsUrl: state => state.acsUrl,
|
||||
printUrl: state => state.printUrl,
|
||||
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('acsUrl', res.acsUrl)
|
||||
uni.setStorageSync('printUrl', res.printUrl)
|
||||
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.acsUrl = res.acsUrl
|
||||
state.printUrl = res.printUrl
|
||||
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
|
||||
state.saveToken = res
|
||||
},
|
||||
[types.SAVE_TOKEN] (state, res) {
|
||||
state.saveToken = res
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
state,
|
||||
getters,
|
||||
actions,
|
||||
mutations
|
||||
}
|
||||
Reference in New Issue
Block a user