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.

51 lines
1.1 KiB

3 months ago
3 months ago
3 months ago
  1. import Vue from 'vue'
  2. import Vuex from 'vuex'
  3. import user from '@/store/modules/user'
  4. import getters from './getters'
  5. import { getConfigList } from '@/api/system/configList'
  6. Vue.use(Vuex)
  7. const store = new Vuex.Store({
  8. state : {
  9. price_config : {},
  10. configList : {},
  11. position : {},//用户选择的定位信息
  12. buyInfo : {
  13. teacher : null,//用户选择的购买老师
  14. },//用户选择的购买信息
  15. },
  16. mutations : {
  17. // 初始化配置
  18. initConfig(state) {
  19. getConfigList({
  20. paramCode : 'price_config'
  21. }).then(res => {
  22. const configList = {
  23. ...state.configList,
  24. }
  25. if (res.code == 200) {
  26. res.result.forEach(n => {
  27. configList[n.paramCode] = n.paramValueText;
  28. configList[n.paramCode + '_keyValue'] = n.keyValue;
  29. if(n.paramCode == 'price_config'){
  30. state.price_config = JSON.parse(n.paramValueText)
  31. }
  32. });
  33. }
  34. state.configList = configList
  35. uni.$emit('initConfig', state.configList)
  36. })
  37. },
  38. setPosition(state, position){
  39. state.position = position;
  40. },
  41. },
  42. modules: {
  43. user
  44. },
  45. getters
  46. })
  47. export default store