‘首次‘

This commit is contained in:
fz
2023-08-30 09:44:26 +08:00
parent c119608fb2
commit cfd272743d
236 changed files with 33203 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
import Vue from "vue"
import Vuex from 'vuex'
import createPersistedState from 'vuex-persistedstate'
// 导入仓库模块
import login from './modules/login.js'
import devList from './modules/devList.js'
import area from './modules/area.js'
import auth from './modules/auth.js'
import search from './modules/search.js'
import message from './modules/message.js'
import loginUserInfo from './modules/userInfoApp.js'
// 数据持久化
const vuexPersisted = new createPersistedState({
storage: {
getItem: key => uni.getStorageSync(key),
setItem: (key, value) => uni.setStorageSync(key, value),
removeItem: key => uni.clearStorageSync(key)
}
})
// 使用 vuex
Vue.use(Vuex)
export default new Vuex.Store({
plugins:[vuexPersisted],
modules:{
login,
devList,
area,
auth,
search,
message,
loginUserInfo
}
})
+41
View File
@@ -0,0 +1,41 @@
// 地区信息仓库
export default {
state: {
area:{},
},
getters: {
// 获取国家id
getCountry(state){
return state.area.countryid
},
// 获取地区id
getAreaId(state){
return state.area.areaid
}
},
mutations: {
// 设置area信息
'SETAREA':function(state, payload){
state.area = payload
},
// 设置国家id
'SETCOUNTRYID':function(state, payload){
state.countryid = payload
},
// 清除area信息
'CLEARAREA':function(state){
state.area = {}
},
},
actions: {
setArea({ commit },payload){
commit('SETAREA',payload)
},
setCountryid({ commit },payload){
commit('SETCOUNTRYID',payload)
},
clearArea({ commit }){
commit('CLEARAREA')
},
}
}
+71
View File
@@ -0,0 +1,71 @@
// 权限信息仓库
export default {
state: {
authList:[],
menuArr:[] //菜单
},
getters: {
// 检查菜单是否存在
getAuth:(state) => {
return function (key) {
let arr = state.authList.filter(item => item.name == key)
return arr.length == 0 ? false : true
}
},
// 返回菜单名
getAuthName:(state) => {
return function (key) {
let arr = state.authList.filter(item => item.name == key)
return arr.length == 0 ? '' : arr[0].label
}
},
// 返回用户是否拥有该按钮权限
getOperation(state){
return function(key){
let curRoute = '/' + this.$mp.page.route;
let arr = state.authList.filter(item => (curRoute.indexOf(item.name) != -1 || item.name.indexOf(curRoute) != -1))
let operation = arr[0] ? arr[0].operation : []
return operation.indexOf(key) > -1 ? true : false
}
},
// 获取菜单
getMenu(state){
return function(key){
let arr = state.menuArr.filter(item => item.url == key)
return arr.length ? arr[0].children : []
}
}
},
mutations: {
// 设置权限信息
'SETAUTH':function(state, payload){
state.authList = payload
},
// 清除权限信息
'CLEARAUTH':function(state){
state.authList = []
},
// 设置菜单信息
'SETMENU':function(state, payload){
state.menuArr = payload
},
// 清除菜单信息
'CLEARMENU':function(state){
state.menuArr = []
},
},
actions: {
setAuth({ commit },payload){
commit('SETAUTH',payload)
},
clearAuth({ commit }){
commit('CLEARAUTH')
},
setMenu({ commit },payload){
commit('SETMENU',payload)
},
clearMenu({ commit }){
commit('CLEARMENU')
}
}
}
+31
View File
@@ -0,0 +1,31 @@
// 设备信息仓库
export default {
state: {
devList:[]
},
mutations: {
// 添加多个设备
'SETLISTALL':function(state, payload){
state.devList = [...payload]
},
// 添加单个设备
'SETLIST':function(state, payload){
state.devList.push(payload)
},
// 删除单个
'DELLIST':function(state, payload){
state.devList.splice(payload,1)
}
},
actions: {
setListAll({ commit },payload){
commit('SETLISTALL',payload)
},
setList({ commit },payload){
commit('SETLIST',payload)
},
delList({ commit },payload){
commit('DELLIST',payload)
}
}
}
+40
View File
@@ -0,0 +1,40 @@
// 登录信息仓库
export default {
state: {
token:'',
userInfo:{
userName:'测试',
}
},
getters: {
// 是否存在token
isLogin(state){
return !!state.token
}
},
mutations: {
// 设置token信息
'SETTOKEN':function(state, payload){
state.token = payload
},
// 清除token信息
'CLEARTOKEN':function(state){
state.token = null
},
// 设置userinfoi信息
'SETUSERINFO':function(state,payload){
state.userInfo = { ...payload }
}
},
actions: {
setToken({ commit },payload){
commit('SETTOKEN',payload)
},
clearToken({ commit }){
commit('CLEARTOKEN')
},
setUserInfo({ commit },payload){
commit('SETUSERINFO',payload)
}
}
}
+40
View File
@@ -0,0 +1,40 @@
// 地区信息仓库
export default {
state: {
message:{
allcount:0,
notecount:0,
taskcount:0,
warncount:0
},
},
getters: {
// 获取消息数量
getCount(state){
return state.message
},
},
mutations: {
// 设置message数量
'SETMESSAGE':function(state, payload){
state.message = { ...state.message,...payload }
},
// 清除message数量
'CLEARMESSAGE':function(state){
state.message = {
allcount:0,
notecount:0,
taskcount:0,
warncount:0
}
},
},
actions: {
setMessage({ commit },payload){
commit('SETMESSAGE',payload)
},
clearMessage({ commit }){
commit('CLEARMESSAGE')
},
}
}
+34
View File
@@ -0,0 +1,34 @@
// 搜索条件
export default {
state: {
searchObj:{}
},
getters: {
},
mutations: {
// 设置搜索信息
'SETSEARCH':function(state, payload){
state.searchObj = payload
},
// 清除搜索信息
'CLEARSEARCH':function(state){
state.searchObj = {}
},
},
actions: {
setSearch({ commit },payload){
// 过滤存储条件,只存,城市,线路,车辆,车厢,车门,时间
let obj = JSON.parse(JSON.stringify(payload))
let searchKey = ['areaid','lineid','metroid','carriageid','doorno','doorid','starttime','endtime']
for(let key in obj){
if(searchKey.indexOf(key) == -1){
delete obj[key]
}
}
commit('SETSEARCH',obj)
},
clearSearch({ commit }){
commit('CLEARSEARCH')
},
}
}
+30
View File
@@ -0,0 +1,30 @@
// 登陆过的用户信息
export default {
state: {
userInfoApp:[],
},
getters: {
// 获取消息数量
getUserInfoApp(state){
return state.userInfoApp
},
},
mutations: {
// 设置用户信息
'SETUSERINFOAPP':function(state, payload){
state.userInfoApp = payload
},
// 清除用户登录信息
'CLEARUSERINFOAPP':function(state){
state.userInfoApp = []
},
},
actions: {
setUserInfoApp({ commit },payload){
commit('SETUSERINFOAPP',payload)
},
clearUserInfoApp({ commit }){
commit('CLEARUSERINFOAPP')
},
}
}