This commit is contained in:
蔡玲
2024-12-19 19:09:39 +08:00
commit 3bd1795234
133 changed files with 23044 additions and 0 deletions

47
vuex/modules/data.js Normal file
View File

@@ -0,0 +1,47 @@
import * as types from '../types'
const state = {
publicObj: '',
publicArr: '',
routeStatus: uni.getStorageSync('routeStatus') || false
}
const getters = {
publicObj: state => state.publicObj,
publicArr: state => state.publicArr,
routeStatus: state => state.routeStatus
}
const actions = {
setPublicObj ({commit}, res) {
commit(types.PUBLIC_OBJ, res)
},
setPublicArr ({commit}, res) {
commit(types.PUBLIC_ARR, res)
},
setRouteStatus ({commit}, res) {
uni.setStorageSync('routeStatus', res)
commit(types.SET_ROUTE_STATUS, res)
},
delRouteStatus ({commit}, res) {
uni.removeStorageSync('routeStatus', res)
commit(types.DEL_ROUTE_STATUS, res)
},
}
const mutations = {
[types.PUBLIC_OBJ] (state, res) {
state.publicObj = res
},
[types.PUBLIC_ARR] (state, res) {
state.publicArr = res
},
[types.SET_ROUTE_STATUS] (state, res) {
state.routeStatus = res
},
[types.DEL_ROUTE_STATUS] (state, res) {
state.routeStatus = res
}
}
export default {
state,
getters,
actions,
mutations
}

84
vuex/modules/user.js Normal file
View File

@@ -0,0 +1,84 @@
import * as types from '../types'
const baseUrl = process.env.NODE_ENV === 'development' ? 'http://192.168.81.162:8011' : 'http://192.168.81.162:8011'
const acsUrl = process.env.NODE_ENV === 'development' ? 'http://192.168.81.162:8010' : 'http://192.168.81.162:8010'
const printUrl = process.env.NODE_ENV === 'development' ? 'http://192.168.81.162:8010' : 'http://192.168.81.162:8010'
const state = {
baseUrl: uni.getStorageSync('baseUrl') || baseUrl,
acsUrl: uni.getStorageSync('acsUrl') || acsUrl,
printUrl: uni.getStorageSync('printUrl') || printUrl,
setTime: uni.getStorageSync('setTime') || 5000,
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
View 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
}
})

17
vuex/types.js Normal file
View File

@@ -0,0 +1,17 @@
/**
* 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'
export const SET_ROUTE_STATUS = 'SET_ROUTE_STATUS'
export const DEL_ROUTE_STATUS = 'DEL_ROUTE_STATUS'