吉光研途前端代码仓库
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.

50 lines
1.1 KiB

3 days ago
3 days ago
  1. import Vue from 'vue'
  2. import Vuex from 'vuex'
  3. Vue.use(Vuex); //vue的插件机制
  4. import api from '@/api/api.js'
  5. //Vuex.Store 构造器选项
  6. const store = new Vuex.Store({
  7. state: {
  8. configList: {}, //配置列表
  9. shop : false,//身份判断如果不需要,可以删除
  10. userInfo : {}, //用户信息
  11. },
  12. getters: {
  13. // 角色 true为水洗店 false为酒店 : 身份判断如果不需要,可以删除
  14. userShop(state){
  15. return state.shop
  16. }
  17. },
  18. mutations: {
  19. // 初始化配置
  20. initConfig(state){
  21. api('getConfig', res => {
  22. const configList = {
  23. ...state.configList,
  24. }
  25. if (res.code == 200) {
  26. res.result?.records?.forEach(n => {
  27. configList[n.keyName] = n.keyContent;
  28. configList[n.keyName + '_keyValue'] = n.keyValue;
  29. });
  30. }
  31. state.configList = configList
  32. uni.$emit('initConfig', state.configList)
  33. })
  34. // let config = ['getPrivacyPolicy', 'getUserAgreement']
  35. // config.forEach(k => {
  36. // api(k, res => {
  37. // if (res.code == 200) {
  38. // state.configList[k] = res.result
  39. // }
  40. // })
  41. // })
  42. },
  43. },
  44. actions: {},
  45. })
  46. export default store