index.js 892 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import Vue from 'vue'
  2. import Vuex from 'vuex'
  3. Vue.use(Vuex)
  4. const store = () => new Vuex.Store({
  5. state: {
  6. isPC: -1,
  7. isWeixin: false,
  8. userinfo: {},
  9. wxConfig: {},
  10. regPhone: /^(0|86|17951)?(13[0-9]|15[012356789]|166|17[35678]|18[0-9]|14[57])[0-9]{8}$/,
  11. regEmail: /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/,
  12. regSpecialChar: /[&¥%\/\*]+/
  13. },
  14. getters: {
  15. isLogin(state) {
  16. return state.userinfo && !!state.userinfo.nickname
  17. }
  18. },
  19. mutations: {
  20. updateUserinfo(state, payload) {
  21. state.userinfo = payload.userinfo
  22. },
  23. updateIsPC(state, payload) {
  24. state.isPC = payload.isPC
  25. },
  26. updateIsWeixin(state, payload) {
  27. state.isWeixin = payload.isWeixin
  28. },
  29. updateWxConfig(state, payload) {
  30. state.wxConfig = {
  31. ...state.wxConfig,
  32. ...payload.wxConfig,
  33. }
  34. }
  35. }
  36. })
  37. export default store