Files
FirstUI-hello/store/index.js
2023-08-11 12:42:04 +08:00

43 lines
1.0 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 本文件由FirstUI授权予新疆天衡创新研究院有限公司手机号1 86 140 7 2 5 49身份证尾号5A07X5专用请尊重知识产权勿私下传播违者追究法律责任。
// #ifdef MP
import http from '../common/fui-request'
// #endif
// #ifndef VUE3
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
const store = new Vuex.Store({
// #endif
// #ifdef VUE3
import {
createStore
} from 'vuex'
const store = createStore({
// #endif
state: {
//是否登录
isLogin: uni.getStorageSync("firstui_m_token") ? true : false
},
mutations: {
//登录
login(state, payload) {
if (payload) {
state.token = payload.token
uni.setStorageSync('firstui_m_token',payload.token)
}
state.isLogin = true
},
//退出登录
logout(state) {
state.token = ""
state.isLogin = false
uni.removeStorageSync('firstui_m_token')
}
},
actions: {
}
})
export default store