123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- import Vue from "vue"
- import Vuex from "vuex"
- import getters from './getters'
- Vue.use(Vuex)
- const store = new Vuex.Store({
- state: {
- Token: uni.getStorageSync('xj-storage_token'),
- users:uni.getStorageSync('xj-storage_users'),
- auths:uni.getStorageSync('xj-storage_auth') || [],
- dataArray:[],
- doneBack:false
- },
- actions: {
- setToken({
- commit,
- state
- }, token) {
- commit("SETTOKEN", token)
- },
- setUsers({
- commit,
- state
- }, users) {
- commit("SETUSERS", users)
- },
- setAuths({
- commit,
- state
- }, auths) {
- commit("SETAUTHS", auths)
- },
- setObj({
- commit,
- state
- }, dataArray) {
- commit("SETOBJ", dataArray)
- },
- setDoneBack({
- commit,
- state
- }, doneBack) {
- commit("SETBACK", doneBack)
- },
- },
- mutations: {
- SETBACK: (state, doneBack) => {
- state.doneBack = doneBack
- },
- SETOBJ: (state, dataArray) => {
- state.dataArray = dataArray
- },
- SETTOKEN: (state, token) => {
- state.Token = token
- uni.setStorageSync("xj-storage_token", token)
- },
- SETUSERS:(state,users) =>{
- state.users = users
- uni.setStorageSync("xj-storage_users", users)
- },
- SETAUTHS:(state,auths) =>{
- state.auths = auths
- uni.setStorageSync("xj-storage_auth", auths)
- }
- },
- getters
- })
- export default store
|