123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- import Vue from 'vue'
- import Vuex from 'vuex'
- Vue.use(Vuex)
- const store = new Vuex.Store({
- state: {
- hasLogin: false,
- token:'',
- userInfo: {},
- },
- mutations: {
- setLogin(state, userInfo) {
- // console.log('userInfo',userInfo);
- // state.userInfo = userInfo.wechatUserInfo || {}
- state.token = userInfo.access_token
- state.hasLogin = Boolean(state.token)
- console.log(state)
- // uni.setStorage({
- // key: "userInfo",
- // data: userInfo.wechatUserInfo
- // })
- uni.setStorage({
- key: "hasLogin",
- data: true
- })
- uni.setStorage({
- key: "token",
- data: userInfo.access_token
- })
- },
- logout(state) {
- userInfo = {}
- hasLogin: false,
- uni.removeStorage({
- key: "userInfo"
- })
- uni.removeStorage({
- key: "token"
- })
- }
- },
- actions: {
- }
- })
- export default store
|