- import Vue from 'vue'
- import Vuex from 'vuex'
- import user from '@/store/modules/user'
- import getters from './getters'
-
- import { getConfigList } from '@/api/system/configList'
-
- Vue.use(Vuex)
-
- const store = new Vuex.Store({
- state : {
- configList : {},
- position : {},//用户选择的定位信息
- buyInfo : {
- teacher : null,//用户选择的购买老师
- },//用户选择的购买信息
- },
- mutations : {
- // 初始化配置
- initConfig(state) {
- getConfigList().then(res => {
- const configList = {
- ...state.configList,
- }
- if (res.code == 200) {
- res.result.forEach(n => {
- configList[n.keyName] = n.keyContent;
- configList[n.keyName + '_keyValue'] = n.keyValue;
- });
- }
- state.configList = configList
- uni.$emit('initConfig', state.configList)
- })
- },
- setPosition(state, position){
- state.position = position;
- },
- },
- modules: {
- user
- },
- getters
- })
-
- export default store
|