This commit is contained in:
2023-04-03 11:14:32 +08:00
commit e423452dfd
70 changed files with 14097 additions and 0 deletions

99
src/vuex/modules/com.js Normal file
View File

@@ -0,0 +1,99 @@
import * as types from '../types'
import { getStore, setStore } from '@config/utils.js'
const baseUrl = process.env.NODE_ENV === 'development' ? 'http://192.168.81.107:8080/hlapp' : 'http://192.168.81.100:8081/hl_nlapp'
const imgBaseUrl = process.env.NODE_ENV === 'development' ? 'http://192.168.81.100/' : 'http://192.168.81.107/'
const state = {
baseUrl: getStore('baseUrl') || baseUrl,
imgBaseUrl: getStore('imgBaseUrl') || imgBaseUrl,
lockTime: getStore('lockTime') || 0,
loading: false,
showToast: false,
showAlert: false,
showSuccess: true,
showFail: false,
toastMsg: '',
alertMsg: ''
}
const getters = {
baseUrl: state => state.baseUrl,
imgBaseUrl: state => state.imgBaseUrl,
lockTime: state => state.lockTime,
loading: state => state.loading,
showToast: state => state.showToast,
showAlert: state => state.showAlert
}
const actions = {
setConfig ({commit}, res) {
setStore('baseUrl', res.baseUrl)
setStore('imgBaseUrl', res.imgBaseUrl)
setStore('lockTime', res.lockTime)
commit(types.COM_CONFIG, res)
},
setLoadingState ({ commit }, status) {
commit(types.COM_LOADING_STATUS, status)
},
showToast ({ commit }, status) {
commit(types.COM_SHOW_TOAST, status)
},
showAlert ({ commit }, status) {
commit(types.COM_SHOW_ALERT, status)
},
showSuccess ({ commit }, status) {
commit(types.COM_SHOW_SUCCESS, status)
},
showFail ({ commit }, status) {
commit(types.COM_SHOW_FAIL, status)
},
toastMsg ({ commit }, str) {
commit(types.COM_TOAST_MSG, str)
},
alertMsg ({ commit }, str) {
commit(types.COM_ALERT_MSG, str)
}
}
const mutations = {
[types.COM_CONFIG] (state, res) {
state.baseUrl = res.baseUrl
state.imgBaseUrl = res.imgBaseUrl
state.lockTime = res.lockTime
},
[types.COM_LOADING_STATUS] (state, status) {
state.loading = status
},
[types.COM_SHOW_TOAST] (state, status) {
state.showToast = status
},
[types.COM_SHOW_ALERT] (state, status) {
state.showAlert = status
},
[types.COM_SHOW_SUCCESS] (state, status) {
state.showSuccess = status
},
[types.COM_SHOW_FAIL] (state, status) {
state.showFail = status
},
[types.COM_TOAST_MSG] (state, str) {
state.toastMsg = str
},
[types.COM_ALERT_MSG] (state, str) {
state.alertMsg = str
}
}
export default {
state,
actions,
getters,
mutations
}

43
src/vuex/modules/data.js Normal file
View File

@@ -0,0 +1,43 @@
import * as types from '../types'
import { getStore, setStore } from '@config/utils.js'
const state = {
deviceUuid: getStore('deviceUuid') || '',
deviceCode: getStore('deviceCode') || '',
isProductonplan: getStore('isProductonplan') || ''
}
const getters = {
deviceUuid: state => state.deviceUuid,
deviceCode: state => state.deviceCode,
isProductonplan: state => state.isProductonplan
}
const actions = {
setDevice ({commit}, res) {
setStore('deviceUuid', res.deviceUuid)
setStore('deviceCode', res.deviceCode)
commit(types.DATA_DEVICE, res)
},
getIsProplan ({ commit }, res) {
setStore('isProductonplan', res)
commit(types.DATA_IS_PROPLAN, res)
}
}
const mutations = {
[types.DATA_DEVICE] (state, res) {
state.deviceUuid = res.deviceUuid
state.deviceCode = res.deviceCode
},
[types.DATA_IS_PROPLAN] (state, res) {
state.isProductonplan = res
}
}
export default {
state,
getters,
actions,
mutations
}

55
src/vuex/modules/user.js Normal file
View File

@@ -0,0 +1,55 @@
import * as types from '../types'
import { getStore, setStore } from '@config/utils.js'
const state = {
accountId: getStore('accountId') || '',
accountName: getStore('accountName') || '',
userName: getStore('userName') || '',
deptName: getStore('deptName') || ''
}
const getters = {
accountId: state => state.accountId,
accountName: state => state.accountName,
userName: state => state.userName,
deptName: state => state.deptName
}
const actions = {
setUserInfo ({ commit }, res) {
setStore('accountId', res.account_id)
setStore('accountName', res.account_name)
setStore('userName', res.user_name)
setStore('deptName', res.dept_name)
commit(types.SET_USER_INFO, res)
},
setSignOut ({ commit }) {
localStorage.removeItem('accountId')
localStorage.removeItem('accountName')
localStorage.removeItem('userName')
localStorage.removeItem('deptName')
commit(types.SET_SIGN_OUT)
}
}
const mutations = {
[types.SET_USER_INFO] (state, res) {
state.accountId = res.account_id
state.accountName = res.account_name
state.userName = res.user_name
state.deptName = res.dept_name
},
[types.SET_SIGN_OUT] (state) {
state.accountId = ''
state.accountName = ''
state.userName = ''
state.deptName = ''
}
}
export default {
state,
getters,
actions,
mutations
}

16
src/vuex/store.js Normal file
View File

@@ -0,0 +1,16 @@
import Vue from 'vue'
import Vuex from 'vuex'
import com from './modules/com'
import user from './modules/user'
import data from './modules/data'
Vue.use(Vuex)
export default new Vuex.Store({
modules: {
com,
user,
data
}
})

17
src/vuex/types.js Normal file
View File

@@ -0,0 +1,17 @@
// 公共配置
export const COM_CONFIG = 'COM_CONFIG'
export const COM_LOADING_STATUS = 'COM_LOADING_STATUS'
export const COM_SHOW_TOAST = 'COM_SHOW_TOAST' // 显示toast
export const COM_SHOW_SUCCESS = 'COM_SHOW_SUCCESS' // 显示成功toast
export const COM_SHOW_FAIL = 'COM_SHOW_FAIL' // 显示失败toast
export const COM_TOAST_MSG = 'COM_TOAST_MSG' // 显示toast文字
export const COM_SHOW_ALERT = 'COM_SHOW_ALERT'
export const COM_ALERT_MSG = 'COM_ALERT_MSG'
// 用户
export const SET_USER_INFO = 'SET_USER_INFO'
export const SET_SIGN_OUT = 'SET_SIGN_OUT'
// 数据
export const DATA_DEVICE = 'DATA_DEVICE'
export const DATA_IS_PROPLAN = 'DATA_IS_PROPLAN'