智慧教务系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

73 lines
1.7 KiB

import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
//为了方便测试,此处用vuex做全局数据
const store = new Vuex.Store({
state: {
userInfo: {},
isLogin: false,
orderType: 'takein',
addresses: [{
"id": 1,
"user_id": 1,
"name": "梁先生",
"phone": "18666610100",
"gender": 0,
"address": "有间大厦",
"complete_address": "广东省深圳市宝安区福海大道118号",
"description": "ABC1234",
"latitude": "",
"longitude": "",
"is_default": 1
}],
address: {},
remark: '不打包',
// 家长端状态管理
userRole: 'parent', // 用户角色: parent-家长, student-学生
childrenList: [], // 孩子列表
selectedChild: null, // 当前选中的孩子
},
mutations: {
SET_ORDER_TYPE(state, orderType) {
state.orderType = orderType
},
SET_ADDRESS(state, address) {
state.address = address
},
SET_REMARK(state, remark) {
state.remark = remark
},
SET_USERINFO(state, userInfo) {
state.userInfo = userInfo
},
SET_ISLOGIN(state, isLogin) {
state.isLogin = isLogin
},
setCarbarData(state, data) {
state.carbarData = data
},
// 家长端状态管理mutations
SET_USER_ROLE(state, userRole) {
state.userRole = userRole
},
SET_CHILDREN_LIST(state, childrenList) {
state.childrenList = childrenList
},
SET_SELECTED_CHILD(state, selectedChild) {
state.selectedChild = selectedChild
},
// 添加或更新孩子信息
UPDATE_CHILD_INFO(state, childInfo) {
const index = state.childrenList.findIndex(child => child.id === childInfo.id)
if (index !== -1) {
state.childrenList.splice(index, 1, childInfo)
} else {
state.childrenList.push(childInfo)
}
},
},
})
export default store