复制斗山
This commit is contained in:
31
vuex/modules/data.js
Normal file
31
vuex/modules/data.js
Normal file
@@ -0,0 +1,31 @@
|
||||
import * as types from '../types'
|
||||
const state = {
|
||||
publicObj: '',
|
||||
publicArr: ''
|
||||
}
|
||||
const getters = {
|
||||
publicObj: state => state.publicObj,
|
||||
publicArr: state => state.publicArr
|
||||
}
|
||||
const actions = {
|
||||
setPublicObj ({commit}, res) {
|
||||
commit(types.PUBLIC_OBJ, res)
|
||||
},
|
||||
setPublicArr ({commit}, res) {
|
||||
commit(types.PUBLIC_ARR, res)
|
||||
}
|
||||
}
|
||||
const mutations = {
|
||||
[types.PUBLIC_OBJ] (state, res) {
|
||||
state.publicObj = res
|
||||
},
|
||||
[types.PUBLIC_ARR] (state, res) {
|
||||
state.publicArr = res
|
||||
}
|
||||
}
|
||||
export default {
|
||||
state,
|
||||
getters,
|
||||
actions,
|
||||
mutations
|
||||
}
|
||||
84
vuex/modules/user.js
Normal file
84
vuex/modules/user.js
Normal file
@@ -0,0 +1,84 @@
|
||||
import * as types from '../types'
|
||||
|
||||
const baseUrl = process.env.NODE_ENV === 'development' ? 'http://192.168.81.120:8011' : 'http://192.168.81.120:8011'
|
||||
const acsUrl = process.env.NODE_ENV === 'development' ? 'http://192.168.81.120:8010' : 'http://192.168.81.120:8010'
|
||||
const printUrl = process.env.NODE_ENV === 'development' ? 'http://192.168.81.120:8010' : 'http://192.168.81.120:8010'
|
||||
const state = {
|
||||
baseUrl: uni.getStorageSync('baseUrl') || baseUrl,
|
||||
acsUrl: uni.getStorageSync('acsUrl') || acsUrl,
|
||||
printUrl: uni.getStorageSync('printUrl') || printUrl,
|
||||
setTime: uni.getStorageSync('setTime') || 50000,
|
||||
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,
|
||||
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)
|
||||
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
|
||||
},
|
||||
[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
|
||||
}
|
||||
14
vuex/store.js
Normal file
14
vuex/store.js
Normal file
@@ -0,0 +1,14 @@
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
|
||||
import user from './modules/user'
|
||||
import data from './modules/data'
|
||||
|
||||
Vue.use(Vuex)
|
||||
|
||||
export default new Vuex.Store({
|
||||
modules: {
|
||||
user,
|
||||
data
|
||||
}
|
||||
})
|
||||
15
vuex/types.js
Normal file
15
vuex/types.js
Normal file
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* 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'
|
||||
|
||||
/**
|
||||
* data
|
||||
*/
|
||||
export const PUBLIC_OBJ = 'PUBLIC_OBJ'
|
||||
export const PUBLIC_ARR = 'PUBLIC_ARR'
|
||||
Reference in New Issue
Block a user